Updates


3
Apr 10

An Easter Birdy

Well it was time.

After about 2000 miles on the Dahon Vitesse D7, it was time to get a new bike. The Dahon had it’s fair share of problems. The frame split where the seat post frame tube met the cross tube – luckily within warranty, so a new frame was fitted. The wheels on the Dahon where very poor.  On average a spoke broke on the rear wheel every three to four weeks.  Eventually I had the rear wheel rebuilt with new spokes.

Of course there was all the usual stuff with chains wearing and the like… but that is normal for a bike that does 8 miles a day four day’s a week. So the Dahon is being retired to ‘second bike’ for use in emergencies.

So, what about the new bike?

I am now a proud owner of a Birdy Touring bike.

This bike has 24 gears, nicely distributed from very low (hill climbing will be so much easier!) to pretty high. One of the things that I found with the Dahon was that there was not enough high end in the gears, and I was quickly at top speed, with a feeling that I could have gone further. The new bike has by contrast a massive high end in the gears. I topped 42 mph on the flat – with a tail wind!

It has full suspension using a combination of elastomer (rear) and spring/elastomer (front). And on a canal tow-path trip which varied from very uneven brick to muddy pools, it coped well.

It is fully kitted out with mudguards and Pannier racks (front and back).

And of course it folds.


11
Mar 10

Outlook to Skype SMS

I wanted to know when a process on a customer’s server had failed. In fact I wanted it to wake me up in the middle of the night so that I could fix it.

About the only usable outbound communication supported by the server is email, but my phone is not email capable (well it is, but not for work emails!).

So a colleague mentioned using MSN chat or Skype chat to send comments, and that set me wondering…

Skype has a COM library which can be used to interface with the Skype application. (A reinstall of Skype with the Extras Manager option ticked was needed to get the library installed.) The Skype4COM library allows you to send SMS. Outlook of course allows you to apply rules to incoming mail messages, and one of these allows you to run some code in a VBA module (the run a script option).

So put it all together and we have:

  1. A script on the customer’s server will monitor another script’s progress. If it detects a particular condition it will generate an email sent to my work email account.
  2. Outlook has a rule to look for specific text in the email subject (for example “ERROR”).  If it detects a suitable email, it will run a piece of VBA.
  3. The VBA will call skype and send the SMS message

Installation of outlook VBA code

  1. Add the code below to an outlook module
  2. Add a reference to the Skype4COM object in the module.
  3. Create a button in outlook that is linked to the macro SendTestSMS
  4. Create a rule in outlook that searches your incoming mail and will ‘run a script’ if it finds something. the script to run is the SendSMSRule VBA macro.

Running the solution

  1. Have outlook running and make sure that macros are enabled.
  2. Click the button you created in step 4 above and enter your phone number. The VBA app will remember your phone number, but you will want to send a test SMS, because you will probably have to ‘allow’ outlook to access Skype the first time after starting outlook.  Skype will ask you for confirmation.
  3. If Skype is not running, it will be started for you by the VBA code.
  4. Have some credit in Skype for sending sms!
  5. Wait for email’s to arrive.

The VBA Code

Public Sub SendTestSMS()
    Dim strMsg As String
    Dim strContact As String
    Dim strPhoneNumber As String

    strPhoneNumber = GetSetting("SendSkypeSMS", "PhoneNumber", "Data", "")

    strContact = InputBox("Make sure you allow Outlook to use Skype when prompted in Skype." & vbCrLf & _
                            "You will probably have to do this for every session" & vbCrLf & _
                            "Enter your mobile number (+44123456789)", "Enter Phone Number", strPhoneNumber)

    SaveSetting "SendSkypeSMS", "PhoneNumber", "Data", strContact

    If Len(strContact) = 0 Then
        Exit Sub
    End If

    strMsg = "A test message from Outlook"
    subSendSMS strContact, strMsg

    strPhoneNumber = GetSetting("SendSkypeSMS", "PhoneNumber", "Data", "")
    MsgBox "Sent a text to: " & strPhoneNumber
    SaveSetting "SendSkypeSMS", "PhoneNumber", "Data", strPhoneNumber

End Sub

Public Sub SendSMSRule(Item As Outlook.MailItem) 'Outlook will give us the mail item that matched the rule
    Dim strPhoneNumber As String

    strPhoneNumber = GetSetting("SendSkypeSMS", "PhoneNumber", "Data")

    If strPhoneNumber = "" Then
        MsgBox "You have to send a test SMS message so that I know what your phone number is!", vbCritical
        Exit Sub
    End If

    subSendSMS strPhoneNumber, Item.Subject

End Sub

Private Sub subSendSMS(strRecipients As String, strMessage As String)
    Dim objSkype        As SKYPE4COMLib.Skype
    Dim objSMS          As SKYPE4COMLib.SmsMessage

    Set objSkype = New SKYPE4COMLib.Skype

    If Not objSkype.Client.IsRunning Then
        objSkype.Client.Start
    End If

    objSkype.Attach , True

    Set objSMS = objSkype.CreateSms(smsMessageTypeOutgoing, strRecipients)

    With objSMS
        .Body = strMessage
        .Send
    End With

    objSkype.Convert.SmsMessageStatusToText (objaStatus)

KillObjects:
    Set objSMS = Nothing
    Set objSkype = Nothing
End Sub

22
Feb 10

Command line twitter

I had half a thought that I might want to have a wee utility to alert me that other wee utilities had finished whatever it was they were doing. So seeing as I usually have at least one terminal window open at a time, a minimal command line tool for twittering follows. called ‘twit’.

It has a dependency on your having cURL installed.

$cat `which twit`
#!/bin/bash
# script to post to twitter

USER=username
PASS=password
UPDATE=$1
LEN=${#UPDATE}
SILENT=$2

if [ "$SILENT" == "" ]; then
	SILENT="1>/dev/null 2>&1"
fi

if [ $LEN -lt 140 ] ; then

	eval curl --basic --user $USER:$PASS --user-agent "twit/1.0" --data status=\"$UPDATE\" http://api.twitter.com/1/statuses/update.xml $SILENT

	if [ $? == 0 ]; then
		echo -e "Tweet Sent"
	fi
else
	echo -e "ERROR: tweet too long ($LEN)\a"
fi

#ends

Update: Since June 2010 when twitter dropped Basic Authentication, this no longer works. 🙁


6
Feb 10

A little bash deployment assistant

I wanted to copy some files from one directory to another while I am working on my wordpress blog-in-blog plugin.  Basically I needed to copy the files checked out from svn, from the working directory, to the root of the web directory on my local machine.

Feature requirements:

  • Should only move a file if it has been edited. (we assume that the filesize will have changed by at least 1 byte!)
  • Should not just sit there copying all the time.
  • Should find out about all files in the specified directory.
  • Should report when it updated the file and which file was updated
  • First run should copy all files to the destination directory. (assumes I have updated my working copy from svn)

So after several attempts, here is a more polished version which stores the filename and the last size of the file in a ‘bash hash’. OK bash doesn’t have hashes (mores the pity) but reading around on the web I found this post with a comment from Scott Mcdermott which does the job nicely (once I had stripped offending characters from the file names).

So here is the full code of the deployment assistant:

#!/bin/bash
# script to deploy code from SOURCEDIR to DELIVERDIR 

PROJECTNAME="blog-in-blog"
SOURCEDIR=blog-in-blog/trunk
DELIVERDIR=/var/www/wordpress/wp-content/plugins/blog-in-blog/
FILENAMES=blog-in-blog/trunk/*
LASTFILESIZE=0
COUNTER=1

echo "======================================================"
echo -e "delivering changes \n\tin \033[1m$SOURCEDIR\033[0m \n\tto \033[1m$DELIVERDIR\033[0m"
echo "======================================================"		

if [ -z $1 ]
then
	echo "usage$  $0 "
	exit 1
fi

hash_insert ()
{
	local name=$1 key=$2 val=$3
	eval __hash_${name}_${key}=$val
}

hash_find ()
{
	local name=$1 key=$2
	local var=__hash_${name}_${key}
	echo -n ${!var}
}

while true
do
	for FILE in $FILENAMES
	do
		FILESIZE=$(stat -c%s "$FILE")

		#tidy up file to avoid problems in variable name
		FILE=`basename $FILE`
		FILEORIG=$FILE
		FILE=`echo "$FILE" | sed 's/[\.\_-]//g'`

		LASTFILESIZE=`hash_find fileHash $FILE`
		#echo "filesize:"$FILESIZE
		#echo "lastfilesize:"$LASTFILESIZE
		if [ "$FILESIZE" != "$LASTFILESIZE" ]
		then
			echo "--- $COUNTER ---------------------------------------"
			date
			echo -e "deploying \033[1m$FILEORIG\033[0m from project $PROJECTNAME"
			echo "Size was $LASTFILESIZE bytes, now $FILESIZE bytes."
			cp $SOURCEDIR/$FILEORIG $DELIVERDIR
			hash_insert fileHash $FILE $FILESIZE
			UPDATE=1
		elif [ "$UPDATE" -ne "1" ]
		then
			UPDATE=0
		fi
	done

	if [ "$UPDATE" = 1 ]
	then
		echo "======================================================"
		let COUNTER+=1
		UPDATE=0
	fi

	sleep $1
done
#ends

30
Jan 10

Stop motion animation

This animation is a test using a DV camera and a little script I wrote to control it.

Basically I wanted to be able to use my DV camera to take single frames, which could then be rolled into a finished video.

A little shell script follows, which does just what I need, using dvgrab and ffplay.

#!/bin/bash
# script to take a shot with DV camera

count=1
calldir=`pwd`
wrapdir='wraps'

function help_me
{
echo -e "HELP!"
echo -e "h - shows this help!"
echo -e "s - takes a shot"
echo -e "p - shows a preview of all the shots so far"
echo -e "w - writes the shots to a wrap file in ./$wrapdir"
echo -e "q - quits\n"
}

help_me

if [ ! -d $calldir/$wrapdir ] ; then
mkdir $calldir/$wrapdir || exit
fi

while [ "$ans" != "q" ]
do

echo -e "I'm waiting for instructions:(h|s|p|w|q)"
read -sn1 ans

if [ "$ans" = "h" ] ; then

help_me

elif [ "$ans" = "s" ] ; then

echo -e "grabbing a frame"
dvgrab --every 25 --duration 1 2>/dev/null
echo -e "grabbed $count\n\a"

count=$(($count+1))

elif [ "$ans" = "p" ] ; then

echo -e "Preview"
cat $calldir/*.dv | ffplay -
echo -e "Preview ended"

elif [ "$ans" = "w" ] ; then

echo -e "Wrapping up"
echo -e "Creating in in $calldir/$wrapdir"
echo -e "Enter filename for wrap:"

read filename

cd $calldir/$wrapdir || exit

cat $calldir/*.dv | dvgrab -stdin --format dv2 $filename 2>/dev/null

clear

# reset count after wrapping file
count=1

echo -e "Tidying up last wrap: deleting $calldir/*.dv"
rm $calldir/*.dv

echo -e "Preview wrap"
ffplay $calldir/$wrapdir/$filename*
echo -e "Preview wrap ended"

cd $calldir || exit

elif [ "$ans" = "q" ] ; then

echo -e "Quitting...\n"
exit

fi

done

30
Jan 10

A Day in the life…

A Day In The Life. 🙂


30
Dec 09

Do you remember those plastic floppy records?

Do you remember those plastic floppy records? The ones that were sent with your new Hornby Train set?  Well I found this one the other day in a 1979 Hornby Railways Catalogue. So I have recorded it for your delectation.

New Hornby train set – Bernard Cribbins


27
Nov 09

E-mu 1820 update

I have finally managed to get some use out of my E-mu card!  For months this was lying dormant because it was installed on an old 1ghz 512MB ram Windows box which was retired in favour of a 2.5ghz Quad Core with 4GB Ram.

When I moved to the new PC, I decided to go with Ubuntu as main (and only) operating system. I wanted to see just how far I could get with free software. I also love a challenge…

Finally I have documented my struggles with E-mu 1820 and linux.


18
Nov 09

Playing with Audio

I have spent quite some time recently playing with audio on my ubuntu desktop.

Last time I tried Audio on linux I found it to be a sorely disappointing affair. That was some 6 to 12 months ago.

On my old Windows box I had an E-mu 1820, but when I bought it I didn’t know that Creative didn’t like to help out by open sourcing their drivers. (How many people have bought M-Audio cards now, knowing that they can get Open Source drivers for it!) On my old Windows box I thought that card was going to stay, until week before last…

I had had some recent successes with getting jack and pulseaudio playing nicely. I had had a play with Ardour and loved it. So I bit the bullet and gave it a go.

I now have glorious multi channel playback and recording via my E-mu audiodock, so I have taken the opportunity to throw together a few recordings of my poetry. The first couple were straight recordings with a bit of reverberation added for ambience.

Virility

The Tree I Wish I’d Been

The most recent is a full on four and a half minutes of sequenced sound and samples 🙂

A Rude Awakening

If you are viewing this on the site you’ll see the above links as little embedded mp3 players, courtesy of the very smart wpaudio plugin.


9
Nov 09

Fireworks – At The Hell’s Angel’s Club House

We keep meaning to go the Wolverhampton Hell’s Angel’s Club House Fireworks.  Every year we say we must go, it’s only a five minute walk away, but there always seem to be a reason why we don’t. This year it was someone writing an essay…

Anyway, the view from the bedroom window was still fairly spectacular for the high mortars, so I couldn’t resist a few firework shots. Here is one to wet your appetite.

[flickr size=”medium”]http://www.flickr.com/photos/informationtakesover/4090592734/[/flickr]

View the full set