Wednesday, 31 December 2008

BASH arithmetic

How to add using bash

type something as an int
typeset -i VARIABLE

Add something
VAR=$((${VARIABLE} + 1 ))

It is just that easy! Here's the quick reference for more useful bash stuff

And finally a sample script so I never have to write this again

[bm@nerdbox dir]$ cat test.sh
#!/bin/bash

TODAY=$(date +%Y%m%d)

BACKUP_FILE_MASK=/var/app/archive/services/services_${TODAY}
BACKUP_FILE=${BACKUP_FILE_MASK}.tar

typeset -i COUNTER=0

JAVA=/usr/java/jdk1.5.0_12/bin/java
UPDATER_JAR=~/service_updater/service_updater.jar
CONFIG_FILE=~/service_updater/service-updater-config-11_3.xml

[[ -e ${CONFIG_FILE} ]] || die "cannot find config file: ${CONFIG_FILE}"

while true ; do

if [[ -e ${BACKUP_FILE} ]] ; then
COUNTER=$(($COUNTER + 1))
BACKUP_FILE=${BACKUP_FILE_MASK}.${COUNTER}.tar
else
break
fi
done

echo BACKUP_FILE = ${BACKUP_FILE}

Sunday, 7 September 2008

How to customise cool Picasa tools

I have a heap of picasa web albums which I like to have slideshows of on my personal blog, which is very nice, but, I want a bit more functionality from my slideshow applet, so here I go.

What I would like to do is have a small combo box that lists the various albums I have available and the user selects one of them. After that the slideshow kicks off with the selected album and everyone is happy.

Sounds easy enough, right?

Lets see.

Well I finally got around to doing this and here's what I came up with..

The slideshow is a flash swf file that sits in an <embed> tag. The tricky part of it is the feedurl parameter that tells picasa which feed to serve to the slideshow player. In my url it has a id for the album which is the only thing that changes between the albums, like this

host=picasaweb.google.com&RGB=0x000000&feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2Fbrockwmills
%2Falbumid%2F5228351820043835105%3Fkind%3Dphoto%26alt%3Drss

so I set up a select form with the various album Id's as the values and the name as the selection text, then wrote some javascript to remove the embed element and replace it with a new one, with the new id value from the drop down list.

Easy!

Is it sensible, that's my question.... Also is there a way to access the Picasa data (feed URL, Album names, etc) dynamically instead of hard coding them into the blog widget.