Wednesday, December 30, 2009

Print documents to pdf on the commandline


sudo apt-get install cups-pdf

# Find out pdf printer name under "System > Administration > Printing"
# In my case it's named "PDF"

openoffice.org -norestore -nofirststartwizard -nologo -headless -pt PDF test.odt

Thursday, November 26, 2009

[Solved] No sound on external speaker for eeePc running Ubuntu

My Ubuntu netbook suddenly stopped having sound from its external speakers. No such problem if using headphone jack.

The solution is simple --> I have accidentally switched "iSpeaker" off in "Volume Control > Preferences"

Tuesday, November 24, 2009

Joining 2 videos in Ubuntu


sudo apt-get install mencoder

cat video1.mpg video2.mpg > video12.mpg

Friday, November 20, 2009

Delete remote tracking branch in git


# Show remote branches tracked
git branch -r

# Delete one by one
git branch -d -r origin/branch

# Delete with one swoop
git remote prune origin

Tuesday, November 17, 2009

Authlogic login in rails functional tests


# Place this at the top of test/test_helper.rb
require "authlogic/test_case"

# Activating authlogic in before each test
def setup
activate_authlogic
UserSession.create(Factory(:teacher))
end

Monday, November 16, 2009

Manually mount USB hard disk

Ref: https://help.ubuntu.com/community/Mount/USB

# Find details of the hard disk
fdisk -l

# Create directory in /media
sudo mkdir /media/external

# Mount drive
# FAT16 or FAT32
sudo mount -t vfat /dev/sdb1 /media/external -o uid=1000,gid=100,utf8,dmask=027,fmask=137

# NTFS
sudo mount -t ntfs-3g /dev/sdb1 /media/external

# Unmount before plugging out
sudo umount /media/external

Sunday, November 15, 2009

ignore files that are already tracked in git

Scenario:

"log/test.log" has already been "git added" but I wanna ignore any further modifications made to the file.

Solution: Update .gitignore and run "git update-index"

# .gitignore

log/**/*

# run git update-index

git update-index --assume-unchanged log/test.log