Skip to content

Instantly share code, notes, and snippets.

@vijaydev
vijaydev / gist:713678
Created November 24, 2010 13:53
Unix/Linux
Use ssh-copy-id to install your public key in a remote machine's authorized_keys. Also takes care of the permissions of the remote user's .ssh and .ssh/authorized_keys.
ssh -t reachable_host ssh unreachable_host. Enables to connect to a host unreachable from current network but reachable from reachable_host's network.
To navigate to a directory, run a command and get back: (cd /to/dir && cmd_to_run)
To rip audio out of a video file: mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile <out_file> <in_file>
Rsync: rsync --recursive -avz -e "ssh -p 2020" user@machine:/path dest
@vijaydev
vijaydev / Rails
Created November 21, 2010 18:41
Rails
Rails 3 no longer auto loads the lib folder. We can make it auto load the lib folder by putting it in config/application.rb like thus: config.autoload_paths += %W(#{config.root}/lib)
All strings are HTML escaped by default in Rails 3. Need to call html_safe on strings which we know are sure to be safe to display the HTML properly.
Reserved words: "config", "process"
Specifying RailsEnv in Apache configuration (vhost/httpd.conf etc) for Passenger 3.0.0 does not work in Rails 3. Changing that to RakeEnv does the trick. This was fixed in Passenger 3.0.1.
To add the default integer primary key to a table which was created with :id => false setting, we can do add_column :table_name, :id, :primary_key