Thursday, April 24, 2008

Temporarily Share Internet Connection on Ubunty Gutsy (Linux)

On host machine:

(this machine has wireless internet connection over wlan0 and wants to share it over eth0)

sudo ifconfig eth0 192.168.10.1 netmask 255.255.255.0
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo su
echo 1 > /proc/sys/net/ipv4/ip_forward

On client machine:
(this machine wants to connect to host over eth0)

sudo ifconfig eth0 192.168.10.2
sudo route add default gw 192.168.10.1 eth0

Source: http://wiki.steenbe.nl/?p=29#more-29

Wednesday, April 09, 2008

Save interactive python history to file

import readline
readline.write_history_file('lds_calendar.py')

Tuesday, April 01, 2008

Batch croping images in Linux

I used this blog post: http://www.kriyayoga.com/love_blog/post.php/853

I was having a hard time with the for loop because of spaces in my file names. I tried this alternative and it worked. I'm not sure that I couldn't have gotten the for loop to work though, had I added the proper quotes.


find ./ -name '* *' | while read FILE; do convert "$FILE" -crop 487x370+386+281 "$FILE-cropped.jpg"; done

487x370 are the new image sizes. 386 and 281 are the offsets from the left and top borders.

Pyjamas