Tuesday, 2 March 2010

concerto + twitter

During the trials of concerto at CERN, I wanted to make the text fields a bit more dynamic like say following a specific twitter feed.

This would (ideally) simply consist of a DB entry with type=twitter, value=name of person. In the Real World however I got round this by hacking up a simple python script that connects to the DB and does a simple UPDATE of an existing text/plain entry via cron.

posted below incase others find it useful:

#!/usr/bin/python

# Script to pull twitter feeds for cern / lhcstatus
import twitter
import MySQLdb


conn = MySQLdb.connect (host = "...", user = "...", passwd = "...", db = "...")
api = twitter.Api()
feeds = { 'cern': 25, 'lhcstatus': 28 }
for f in feeds:
tweets = api.GetUserTimeline(f,count=1)
for tweet in tweets:
sql = 'UPDATE content SET CONTENT = "%s" WHERE id = %s' % (tweet.GetText(),feeds[f])
cursor = conn.cursor ()
try:
cursor.execute(sql)
conn.commit()
except:
conn.rollback()
cursor.close ()
conn.close ()


yes its hacky, but hey, called from cron regularly it works :-)

Monday, 1 March 2010

They're following me!


As you know, I've been 'tweeting' the Status of the LHC from the 'Page1 comments' field. Decided to knock up a quick script to plot the number of followers over time, and lo:

Thursday, 11 February 2010

Design vs Reality

Decided to check that savannah was behaving as it should be. As with any good process we have a nice flowchart that depicts the allowed transition states.

ie:

however, thanks to a quick 'copy n paste' into graphviz it appears the reality is a little more complicated. Ho hum, cleanup time....




update: Just tidied up savannah and lo:

Wednesday, 20 January 2010

transmission

Snippet to see how many chunks of a bittorrent file are still to be downloaded (ie, what does '84% complete *really* mean):

transmission-remote -t 2 -i | egrep "^ (0|1)"| grep -o 0 | wc -l

where -t 2 is the number of the torrent.

Monday, 23 November 2009

Twittering OCR


'things that go bump in the tunnel'

As I've beem following the LHC restart I've written a parser for the vistar status feed to send it to twitter. The basic method is:

Grab URL (see image) then do some imagemagick hackery to cut out the corner. Resize larger (helps with the OCR) and save as tiff. Run the image through OCR software, compare the output to the last run, if different then upload to twitter.

ie

curl -o $IMG $SRC
convert $IMG +repage -crop 509x205+1+533 -resize 1000x -threshold 39000 $IMG
convert -monochrome $IMG $TIFF
mv $OUT.txt $OUT.old # make a backup of old
tesseract $TIFF $OUT

# Strip out ready for Twitter
DATE=`date +%d-%m-%Y`
sed -i "s/Comments $DATE /#LHC Status /" $OUT.txt

diff -q $OUT.txt $OUT.old
if [ $? -eq 1 ] ; then
# Post to Twitter.
curl --basic --user lhcstatus:password --data status="`cat $OUT.txt`" http://twitter.com/statuses/update.json
fi

and lo: http://twitter.com/lhcstatus

Monday, 5 October 2009

swisscom VDSL & dyndns

Those of you who follow my twitter stream will have noticed that I managed to 'lose' my home machine today. It was online and active, I just didn't have its IP address (somwhere in the swisscom pool)

I thought I'd set up the embedded dynamic-dns client on my router, a Swisscom provided (motorola) netopia VDSL modem:

Terminal shell v1.0
Copyright ©2008 Motorola, Inc. All rights reserved.
Netopia Model 7347-84 AnnexA VDSL Wireless Ethernet Switch, PBC
Running Netopia SOC OS version 7.8.2 (build r3)
VDSL Capable

Turns out that you have to save your username not your email address in the client, even though both are valid in the dyndns.com web login.

so the correct settings for those googling is:

Netopia-7000/XXXXXX> conf

Config Mode v1.3
Netopia-7000/XXXXXX (top)>>
set dynamic-dns option dyndns.org
set dynamic-dns ddns-host-name "DYNHOSTNAME"
set dynamic-dns ddns-user-name "USERNAME"
set dynamic-dns ddns-user-password "PASSWORD"

subsitituting the things in caps for your own
then do a validate, save, restart and lo:

later on in 'view log' I see:

10/5/09 08:01:05 PM L3 DDNS: initializing service
10/5/09 08:01:23 PM L3 DDNS: Hostname updated. good

tada!

Monday, 21 September 2009

Studies on a hashtag

I'm at the EGEE09 conference this week, and they're also plugging use of tagging in social networking such as the #egee hashtag in twitter and the 'egee09' tag in flickr. As a small experiment I created an IRC channel on freenode (#EGEE09) and announced it with a hashtag on twitter. Within 3 minutes there were an additional 3 users, only one of whom was in my normal twitter cloud, ie the other 2 came in purely from the hashtag (and one of those was under a minute later)

so, twitter is certainly becoming a respectable way of broadcasting announcements to an interested group of people who are subscribing to a hashtag.

oh and as an aside, the IRC channel paid off -- I discovered that GridPP had some nice laptop bags via it and secured one for myself during coffee.

Anyway, back to more important work -- listening to how the EU proposes to carve up the funding for call7