Tuesday, December 23, 2008

Useful Commands

For network troubles getting files:
wget -c -t 0 -T 1
-> continue download with infinite re-tries and a 1 second timeout.

To allow ssh users to launch apps into the logged in users X sessoion:
netcat -l -s 127.0.0.1 -p 2020
-> start net cat in listen mode on the lo interface on port 2020
Ensure this is called in the gdm PreSession config script

Wednesday, December 10, 2008

Putty authorized keys

  1. Install Putty
  2. Generate the key
  3. Enter a pass phrase
  4. Select the generated public key and copy to the clipboard
  5. Save the private and public keys somehwere sensible
  6. ssh into the server that will hold the public key
  7. Make a .ssh directory in ~: mkdir .ssh
  8. Set access to .ssh : chmod 700 .ssh
  9. Enter the command: cat > .ssh/authorized_keys
  10. Paste the test from the clipboard
  11. Hit CTRL-D to exit
  12. Set the access on the authorized_keys file: chmod 644 .ssh/authorized_keys
  13. Start Pagent and add the new private key (passphrase entered above will be required)
Check that it worked by using putty to ssh in to the server.

How to install Ruby on Rails

For Ubuntu:
sudo apt-get install ruby ruby-dev postgres libpq-dev libopenssl-ruby
sudo gem install rake rails postgres ruby-debug-ide

To allow users to install gems:
chmod -R 777 /var/lib/gems/1.8

For Windows:
install ruby (using the one click installer!)
install postgres
gem install rake rails postgres-pr ruby-debug-ide

Points to note:
NetBeans 6.1 cvs doesn't work on windows - use 6.5 instead
Also, let NetBeans install the fast debugger (ruby-debug-ide)

Drag and drop in a text box

I have an application that needs to fire an onchange javascript event when data in one of 21 to 119 text boxes changes (yes, it sounds like a problem, but the UI works!). Sounds easy...

But it is possible to drag and drop text from one text box into any of the others.

This is the one situation where MS IE actually does a decent job - IE fires all the drag events (ondrop, ondragstart, ondragend, etc) where as all the other browsers (firefox, chrome, konqueror, opera, safari) do not!

So IE first...
ondrop set variable window.dragged to be the destination text box, and ondragend (fired on the source text box) calls the onchange function on both source and destination - see, easy!

Now the hard bit....
This is only an approximation, but seems to work well. (We'll see what the testers do with it!)
When onmousedown is fired, and there is text selected in the textbox make a note of the id of the text box (window.dragged) - this indicates that we may have a drag event,
Subsequently, when the onmouseout event is fired (that doesn't originate from the text box that was source for the onmousedown event), and window.dragged is set, call the onchange function on both source and destination.

Yes, its a hack, but it seems to work.

To summarise:
onmousedown fired at start of text selection
onmouseup fired at end of text selection
onmousedown fired at start of drag - there is text selected, so we set window.dragged to this.id
** user drags text to another field, and drops
onmouseout fired at source text box
** user moves mouse out of destination text box
onmouseout event fired on destination text box - signal to call onchange function on the source (window.dragged) and destination (this)

Possible improvements:
1. Maybe the onmouseout code should be in document.onmousedown (update: not required)
2. Save needs to re-check each - just to be sure.... (update: yes, to force update before form is submitted using enter key after drop)