Monday, 9 September 2013

Recreating Google Docs automatic "Saving..." status display

Developing a new Warcraft guild website gave me a handful of good opportunities to construct and recreate/imitate some edge features used in modern apps today. One of them is a "Saving" status display when you are editing a Google document. So here are the steps I wanted to mirror in my own app:

  1. when the app is constantly saving what the user inputs
  2. when it is just done saving every piece of data
  3. when some time passed and it wants to inform the user about real time status information

These are the steps for the frontend side. On the server side, well just look at this network traffic below, this absolutely has to be custom tailored to everyones infrastructure

Let's look at my original code that was born to recreate this action


The above code looks like this in the browser (sorry, it's the Hungarian version)


Now let me sum up the crucial points in the above code. Javascript is good in using callbacks, async calls. This behaviour could lead to tricky "bugs" or some hours of search on Google. When using setTimeout() with AJAX hand-in-hand then we have to think about AJAX's async nature, where calls are not finished one-by-one in a numbered row. They will finish independently on different timeframes, some fired later but finishes earlier. To overcome this I use an array to store the timeout ids and clear all of them out when the user sends more input. Now there will be no race to clear all living timeouts in time :)

I hope this little code gives some of you more ideas. Please bare with this code as it is premature and not yet ready for production (I believe).

Thursday, 28 March 2013

Ubuntu: add personal path to the global path

My best choice when I want to extend the system path is to create a profile shell script in the /etc/profile.d/ directory with and extension of .sh. The content is something like this:
export PATH=$PATH:/home/ikon/bin
This way my ~/bin directory is added to the system path.  Check it with
$ echo $PATH

Saturday, 9 February 2013

Problem installing debugger on 1.9.3 and RVM

This is a recent problem now, so if you are reading it years later try to adopt your numbers on these lines.

Version ruby 1.9.3-p327 using RVM, debugger and debugger-linecache restisted the bundle install command.
Workaround:
gem install debugger-linecache -v '1.1.2' -- --with-ruby-include=\$rvm_path/src/ruby-1.9.3-p374

gem install debugger -v '1.2.3' -- --with-ruby-include=\$rvm_path/src/ruby-1.9.3-p374

Wednesday, 6 February 2013

Vboxheadless and bridge nic trouble

I wanted to have my VM built on Windows to be hosted on an Ubuntu linux Virtualbox headless. The VM had a bridged interface and when I tried to fire it up after a plain import I got this:
Error: failed to start machine. Error message: Configuration error: Failed to get the "Trunk" value (VERR_CFGM_NOT_ENOUGH_SPACE).
Failed to attach the network LUN (VERR_CFGM_NOT_ENOUGH_SPACE)
The solution is simple:
  1. check the host's main network interface name (or the one you want to bridge to), e.g. eth1
  2. modify the VM's bridge interface to that with:
vboxmanage modifyvm vm_name --bridgeadapter1 eth1
After this adjustment is done and the bridge interface knows where to point to the VM will surely fire up.