Saturday, March 20, 2010

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

To find PID or process name

tasklist.exe
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.

https://wiki.ubuntu.com/HardwareSupportComponentsPrinters

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!

http://hplipopensource.com/hplip-web/downloads.html

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@192.168.1.60 "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 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'

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

Old:

/etc/syslog.conf
New:

/etc/rsyslog.d/50-default

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

JQuery:

Grab the jQuery driver at http://github.com/rails/jquery-ujs and put it in your javascripts directory. Include the file in the layout.

http://joshhuckabee.com/jquery-rails-3

Forms:

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.

csrf_meta_tag
Routing:

Old

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

# 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