Category: Software

Scanning and posting photos

I scanned in a bunch of family photos, fixed them up, added captions, and posted them on Google’s Picasa Web Album.

I used a flatbed scanner and filled it with photos each scan. This necessitated splitting and cropping each scan into separate images. To speed this along I wrote an AppleScript to call Photoshop’s “Crop and Straighten Photos” function and then save the images.

split_img Applescript

The script worked pretty well for about half the images. I went through and cropped/straightened each image. Then I automatically ran Auto Levels and Auto Contrast or Auto Colors on each image using a second Applescript.

adjust_img Applescript

I wanted to add captions and tags to each image using a list of captions I made when I scanned the photos. Jpg images can store this meta data in the file using the IPTC standard. Unfortunately, Google’s Picasa uploading applications terribly buggy and don’t work well with IPTC tags added by other programs like iPhoto or EXIFutils. So I couldn’t use Google’s Picasa software or plugins to upload the photos.

Google makes an API for interacting with their web sites available, and there is a Perl module, Net::Google::PicasaWeb, available that allows adding captions and tags when uploading pictures. Testing showed that it worked so I wrote a small Perl program to take a tab-delimited text file of images, the target album, the caption, and any tags and load the photos onto the Picasa Web Album site. I needed to use the most up to date version of Net::Google::PicasaWeb and make a one line change.

picasa_upload Perl program

My Picasa Web Album:

Old family photos (Jan. 2009)

Word cloud program

I saw the Wordle site for making word clouds and was really impressed. I had a few ideas for doing things differently–showing phrases instead of individual words for example. So I wrote my own version.

Origin of the Species word cloud

It displays phrases, words, or combinations of words and phrases. Text size indicates the relative frequency of different words. The output is a PDF file.

Uplift word cloud

The algorithm used to arrange the words places them randomly on open spaces in the image. Horizontal and vertical placements alternate. There is a bias toward placements towards the center of the image. This helps keep the cloud together. Words difficult to place are shrunk up to 10%. The Postscript font metrics are used to find the exact size of each letter. The allows close word placement.


Here it is:
System requirements: OS X or Linux.

RAID1 recovery

One of the MA database systems went down. It wouldn’t boot, so we put in the install disk, ‘linux rescue’ at the prompt, and it booted into rescue mode. The system is set up with the system files on a pair of RAID1 SATA drives. Drive /dev/sda was gone–fdisk found no partition. /dev/sdb was fine. I looked around for hacking traces but found nothing. /var/log/messages indicated the system had shutdown for reboot two days before. We hadn’t done it, so how/why?

First, I re-partitioned /dev/sda to look like /dev/sdb using the same ‘fd’ RAID partition type.

To bring it back up, I shut down, switched the sda and sdb cables so we could boot off the good drive and then have RAID restore the second drive. The original /dev/sdb didn’t have grub installed on the MBR, so I had to reboot with the rescue disk and reinstall grub.

grub>root (hd0,0)
grub>setup (hd0)

I had to use grub because grub-install wasn’t available from the rescue environment and /mnt/sysimage/sbin/grub-install couldn’t find /sbin/grub.

Then reboot, grub comes up, the system boots. The root /dev/md1 RAID1 is degraded as this shows, so add /dev/sdb back:

mdadm --query --detail /dev/md1

mdadm --add /dev/md1 /dev/sdb

And 20 minutes later the array is clean!

vnc to linux vncserver

Figured out how to VNC from my laptop to my linux server. Forwarded X conections were too slow so I gave VNC a try. It was harder to set up than I expected. I googled around and after many tries found a post online that worked.

Here’s the stiuation. I need to connect to my lab computer from my laptop at home. The lab computer is behind UK’s firewall. Run vncserver on the lab computer–that’s the easy part. It runs on display :1 by default:> vncserver

Turns out I need to enable port forwarding on the lab computer’s sshd:
As root add this line to /etc/ssh/sshd_config

AllowTcpForwarding yes

then restart sshd:
/etc/rc.d/init.d/sshd restart

Then forward the ssh connection. On my laptop I run this command from a terminal:

ssh -L 5901:localhost:5901

And run the VNC client. My laptop runs OS X, so I downloaded “Chicken of the VNC. By default it uses port 5900, enter display 1 (so it goes to 5900+1 = 5901) and the host is localhost. Starts up and runs fast!

Messing with css

I’ve messed with the site’s css style sheets. If it looked OK before, there’s no change. If the layout used to suck, it should be fine now. Css is such a tar baby, I won’t tell you how long it took me.

And I went and downloaded 400+ new mammal pics, should be enough to keep the site in mammals all year!

Install new hard drives with Software RAID 1

This turned out to be pretty straightforward once I got the order of steps right. Don’t make the filesystems before the mkraid, you will end up with “bad superblock” errors later.

I added two 400Gb SATA hard drives in RAID1 to an existing system. I already had one pair of drives in RAID 1, the new drives form a new RAID array.

1) Phyiscally add the drives.

2) Run fdisk, make one partition on each drive.
fdisk /dev/hdc
fdisk /dev/hdd

3) Edit /etc/raidtab, add section for /dev/md1:
raiddev /dev/md1
raid-level 1
nr-raid-disks 2
chunk-size 256
persistent-superblock 1
nr-spare-disks 0
device /dev/sdc1
raid-disk 0
device /dev/sdd1
raid-disk 1

4) Make RAID, needed ‘force’ flag:
mkraid -f /dev/md1
mkraid -R /dev/md1

5) Make filesystems:
mke2fs -j /dev/sdc1
mke2fs -j /dev/sdd1

This takes 10 min or so.

6) Add new filesystem to /etc/fstab for automounting:
/dev/md1 /home ext3 defaults 1 2

And now the keychain drive gets pushed from sdc to sde:
/udev/sde1 /mnt/key vfat owner,kudzu 0 0

7) Mount new RAID:
mkdir /data
mount /data

Useful RAID commands:
more /proc/mdstat
mdadm -D /dev/md1

Useful guide:

Kernel upgrade

Upgraded the kernel on my linux server and it was the easiest thing ever:

yum upgrade kernel-smp

It updated grub and everything! Color me surprised. Linux is getting *so* easy to use.