Daily Tweet Dump

08:22 Gearing up for the weekend. Saturday is Velociraptor Awareness Day. Must rehearse my ‘raptor invasion plan.

Virtual Weather Station and Twitter

Last night, I coded up a handy script for uploading weather station data to Twitter. You can see the end result here. The procedure is: Have Virtual Weather Station (VWS) create a comma delimited file with the weather data. The script then reads this file, parses out the stuff I want, then “posts” it to Twitter.

To get VWS to create the data file:
1) From the top VWS menu select Settings>CSV Export

2) A dialogue box will come up. Ensure that “Create csv output file” is ticked. Enter the path for where you wish to store the file (i.e. “c:\htdocs\weather”) and the file update time frequency (in seconds). A value of “300” would update the file every five minutes. Click “Close”. The data.csv file will now be updated at the rate entered above.

Now the script. I used VB script for this. The web server is on a Windows XP box, so it seemed appropriate. I did the google thing for the code needed to post to Twitter. Don’t know who the original author of that snippet of code is. I will assume public domain. So here is the script…

Set objFSO = CreateObject("Scripting.FileSystemObject")
'change the path below to where your data.csv file is
Set objFile = objFSO.OpenTextFile("C:\htdocs\weather\data.csv", ForReading)

Const ForReading = 1

Dim wxData, wxArray, temp, intemp, baro, trend, dewp, sUsername, sPassword, sMessage
' data.csv is just one line, so this is all that is needed to read the data into a string.
wxData = objFile.ReadLine
objFile.Close

' This code takes the line read, breaks it up, and puts it into an array.
wxArray = Split(wxData,",")

temp  = wxArray(13)
intemp = wxArray(12)
baro = wxArray(14)
trend = wxArray(35)
dewp = wxArray(31)

' The commented code below is for posting via command line arguments.  Here in case you need it.
' Usage: cscript twitter.vbs [username] [password] "[message]"
' eg: cscript twitter.vbs ip1 password "This is a test message" 
'    if not wscript.arguments.count > 1 then
'       wscript.echo "Not enough options provided"
'       wscript.quit
'    end if

'    sUsername = wscript.arguments(0)
'    sPassword = wscript.arguments(1)
'    sMessage = wscript.arguments(2)

    sUrl = "http://twitter.com/statuses/update.xml"
    sUsername = "Type in Twitter username"
    sPassword = "Type in Password"
' plain text password exposure  ... EEEK!!!
    sMessage = "OutTemp= " & temp & "°  InTemp= " & intemp & "°  Dewp= " & dewp & "°  Baro= " & baro & "in  Trend= " & trend & "in"

'Line below is for debugging purposes.
'    wscript.echo sUsername & ", " & sPassword & ", " & sMessage
    sMessage = "status=" & sMessage

    HTTPPost sUrl, sMessage, sUsername, sPassword

    Function HTTPPost(sUrl, sRequest, sUsername, sPassword)
      set oHTTP = CreateObject("Microsoft.XMLHTTP")
    oHTTP.open "POST", sUrl,false,sUsername,sPassword
      oHTTP.send sMessage
      HTTPPost = oHTTP.responseText
'Line below is for debugging purposes.
'      WScript.Echo HTTPPost
    End Function  

Then use the task scheduler to run this script every so often. I set it up for every 20 minutes.

Daily Tweet Dump

20:14 Installing Windows 7 Starter edition on the netbook. Curious to see how nerfed that edition is.

22:02 Completed a fun scripting project – uploading wx station data to a spare twitter account – twitter.com/k_fred.

Daily Tweet Dump

05:52 {sigh} New travel mug isn’t microwavable.

11:36 Suffering from a bit of “peeps revenge”.

21:20 Won a Goodwill auction. Didn’t really mean to. I guess Goodwill can use the money. A Sears Tele-games heavy sixer. is.gd/sh4A

Daily Tweet Dump

10:37 Lessoned learned: When crossing the Blatnik bridge in Duluth, always tie-down your stuffed gorilla.

10:57 Latest WiiWare game is a winner. Move a marble around with remote or balance board. Fun, simple puzzle game. is.gd/rVQW

Daily Tweet Dump

09:37 @commandertim Just great. Kickstart my heart by Motley Crue is a better driving song. Best is Jesus Built my Hot Rod by Ministry.

09:54 It was Good Friday 1978, I got hit in the face with a golf club. Such fond memories…

12:00 5k run – connect.garmin.com/activity/3255033 Pushed hard the last mile. Got the heart rate above 180 bpm.

15:36 Lily Allen is going to be at 1st Ave tomorrow night. Anyone have spare tix?

Daily Tweet Dump

08:54 There is a “men wearing bunny ears” group on Flickr. For once in my life, I feel like I belong.

23:28 Bought the latest mp3 albums from Lily Allen and Neko Case. I’m caught up for now.