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 netmask
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
sudo route add default gw eth0


Wednesday, April 09, 2008

Save interactive python history to file

import readline

Tuesday, April 01, 2008

Batch croping images in Linux

I used this blog post:

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.