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 8.8.8.8, 8.8.4.4;

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

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU]
"RebootRelaunchTimeoutEnabled"=dword:00000000
"NoAutoRebootWithLoggedOnUsers"=dword:00000001

Wednesday, March 10, 2010

Full path of file in ruby


File.expand_path(__FILE__)

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'