Saturday, March 20, 2010

Finding and killing application processes in the command prompt on Windows XP

To find PID or process name

Note: Not available in Windows XP Home edition by default. Google and download it.

To kill the PID or process name, look for tskill.exe under c:\windows\system32\

tskill.exe PID | PROCESS NAME

Friday, March 19, 2010

HP F2410 printer on Ubuntu

Wanted a printer that works on Ubuntu. Did some research and realized HP printers are the most well supported.

Acquired a cheap SGD99.00 HP F2410 printer off local store. Installing it isn't as easy as plug and play but it's close enough. Essentially CUPS doesn't have the right PPD so it's off to HP website to download the the driver. They even provide a neat installation run file that does dependency checks!

Printing well and scanning works with Xsane. At such a low price I can't be happier. I owe HP one!

Monday, March 15, 2010

Play remote media files over ssh using mplayer

ssh username@ "cat ~/Video/apprentice.avi" | mplayer -

Sunday, March 14, 2010

Set Ubuntu to use Google DNS for internet

Sometimes my 2Wire router doesn't seem to route to the DNS properly. As such I can ping IP addresses but not domain names. To fix that just tell Ubuntu to use Google DNS (or any other free DNS service) directly.

# In /etc/dhcp3/dhclient.conf

prepend domain-name-servers,;

Friday, March 12, 2010

Sync music/podcasts to mobile phone

Essentially use rsync to sync folders between multiple machines which in this case the host machine with the music files and the mobile phone storage.

rsync ~/Music /media/disk/Music -rP
For podcasts it'll be a good idea to use cronjob to download new podcasts. I'm using a remote server to download them.

# On my remote server

sudo apt-get install podget

# crontab -e on server
0 * * * * /usr/bin/podget -s

# On my local host machine with mobile phone plugged in

rsync username@remote-server:./Music/Podcasts /media/disk/Podcasts -rP

Thursday, March 11, 2010

Stop restart popup after automatic updates in Windows XP

Absolutely annoying feature of windows is a popup that keeps asking you to restart the system after a Windows update. Disable that!

# Disable current popup from the command prompt

net stop "automatic updates"

# Disable future auto restarting of system. 
# I'm using Windows XP Home so can't access gpedit.msc. 
# Need to use a registry script instead --> stop_update_restart.reg
# P.S. note the first line.

Windows Registry Editor Version 5.00


Wednesday, March 10, 2010

Full path of file in ruby


Monday, March 8, 2010

cp with progress indicator by using rsync instead

# Instead of

cp -r folder destination_folder

# Use rsync instead

rsync folder destination_folder -P

Sunday, March 7, 2010

Comparing 2 files using diff

diff -uN app/models/common_test.rb app/models/major_test.rb  | vi -

Running ruby scripts as cron jobs in rvm environment

# This will fail to run properly

*/5 * * * * /usr/bin/env ruby /home/username/twitter.rb

# Need to run the script in full bash environment

*/5 * * * * bash -c 'source /home/username/.rvm/scripts/rvm && /usr/bin/env ruby /home/username/twitter.rb'

Cron log in Ubuntu

* Edit /etc/syslog.conf and uncomment the line starting with cron.*
* touch /var/log/cron.log
* Run /etc/init.d/rsyslog restart
* Run /etc/init.d/cron restart

Changing of syslog.conf location in Ubuntu Karmic




Saturday, March 6, 2010

Changing timezone in terminal

sudo dpkg-reconfigure tzdata

Friday, March 5, 2010

Rvm notes

Getting prepared

sudo apt-get update
sudo apt-get -y install build-essential zlib1g zlib1g-dev libxml2 libxml2-dev libxslt-dev sqlite3 libsqlite3-dev locate git-core libssl-dev openssl autoconf subversion bison
sudo apt-get -y install curl wget

For Ubuntu, use rvm package to download and complie zlib

rvm package install zlib
rvm remove 1.8.7
rvm install 1.8.7 -C --with-zlib-dir=$rvm_path/usr

Before installing any versions of ruby using rvm

sudo apt-get install libssl-dev
Installing Ruby Enterprise Edition

Error running './installer -a /home/username/.rvm/rubies/ree-1.8.7-2010.01  --dont-install-useful-gems ', please check /home/username/.rvm/log/ree-1.8.7-2010.01/install*.log
There has been an error while trying to run the ree installer. Aborting the installation.

# Need to install the following library first
sudo apt-get install libreadline5-dev
rvm install ree

Thursday, March 4, 2010

Rails 3 notes


Grab the jQuery driver at and put it in your javascripts directory. Include the file in the layout.


Rails requires an authenticity token to do form posts back to the server. This helps protect your site against CSRF attacks. In order to handle this requirement the driver looks for two meta tags that must be defined in your page's head.



link_to :controller => 'user_sessions', :action => 'destroy'

# Route
match '/log' => "user_sessions#destroy", :as => :logout

# View
link_to 'Logout', '/logout'

Vim can't make backup file

Ensure that the backup directory in .vimrc exists.

# in .vimrc

set backup
set backupdir=~/.vim/backups

mkdir -p .vim/backups

Vim unable to open swap file

If you see the following message when opening a vim file

Unable to open swap file for "{filename}", recovery impossible

The directory specified in your vim for swap files is missing. In my case it's ~/.vim/tmp.

# in .vimrc
set directory=~/.vim/tmp

mkdir -p ~/.vim/tmp

Blog Archive