I can see an end.
I see it in your face.
I see it in your eyes;
the things you don’t say.The things you don’t say.
I see pain in your eyes,
I see pain in your face.
I can’t say sorry.He can’t say sorry.
Sorry is meaningless,
confronted with nothing.
It’s not his to say sorry.
it’s my own diagnosis.
25
Jun 10
Diagnosis – A dialogue.
03
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:
- 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.
- 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.
- The VBA will call skype and send the SMS message
Installation of outlook VBA code
- Add the code below to an outlook module
- Add a reference to the Skype4COM object in the module.
- Create a button in outlook that is linked to the macro SendTestSMS
- 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
- Have outlook running and make sure that macros are enabled.
- 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.
- If Skype is not running, it will be started for you by the VBA code.
- Have some credit in Skype for sending sms!
- 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. 🙁
15
Feb 10
Taking the plunge
Ever been really indecisive?
Yes?
No?
[gview file=”http://timhodson.com/wp-content/uploads/2010/02/taking-the-plunge.pdf” ]
Taking the plunge by Tim Hodson is licensed under a Creative Commons Attribution-Non-Commercial-No Derivative Works 2.0 UK: England & Wales License.
Based on a work at timhodson.com.
15
Feb 10
Shepherd cries wolf
Shepherd cries wolf was written for a crib service at St Paul’s in Hereford. The madder and the more like compo (last of the summer wine) the shepherd appears, the better. 🙂
[gview file=http://timhodson.com/wp-content/uploads/2010/02/shepherdcrieswolf.pdf]
Released under the following license:
Shepherd Cries Wolf by Tim Hodson is licensed under a Creative Commons Attribution-Non-Commercial-No Derivative Works 2.0 UK: England & Wales License.
Based on a work at timhodson.com.
13
Feb 10
Clive’s Funny Valentine
Written for a children’s talk at Lakeside Community Church Perton, this sketch was written with a view to being a screen play.
Hence the video.
Clive is waiting for a valentine day card from someone. anyone…
[gview file=http://timhodson.com/wp-content/uploads/2010/02/The-Apostle-Clive-on-Valentines-day.pdf]
Clive’s Funny Valentine by Tim Hodson is licensed under a Creative Commons Attribution-Non-Commercial-No Derivative Works 2.0 UK: England & Wales License.
Based on a work at timhodson.com.
06
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