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

Thursday, 3 September 2009

BeautifulSoup + savannah

At work, we use savanne to power http://savannah.cern.ch where we keep track of all the glite-middleware (amongst other things)

However, one of the problems with savanne/savannah is that it doesn't have a nice machine readable API, but requires the user to click with a browser.

Cue Beautiful Soup and lo, the python SavannahCLI was born.

Well, in its early years it was unloved and handed round from developer to developer, until it arrived as a pedantic teenager to yours truly who decided to get rid of the horrible 'operation, item, name, value" syntax and replace with something more, um, fluid instead. (--patch 1234 --set foo=bar). It also had a huge set of hard coded lookup tables for converting select items to names and vice versa -- WHY?

thanks to some googling, I came across this which, with a little refinement gave me:


def enum_forms():
# we search within the table tag so that we lose the LHS searchbox
selects = soup.find('table').findAll('select')
for sel in selects:
sel_name = sel['name']
print "SELECT NAME=%s" % sel_name
for o in sel.findAll('option'):
print " %s, %s" % (o['value'],o.renderContents())

hey, it's not finished yet, but sure saves a whole pile of hard-coded badness.

Sunday, 9 August 2009

SPA3102 and Swisscom

I've had a Linksys (nee sipura) spa3102 for a while (worked fine in the UK with sipgate) but havent got round to configuring it for switzerland yet.

Idiots guide seeing as I had trouble finding this on the net:

1) factory reset: ****, 73738#, 1#, hangup
2) make sure you have a computer in the NAT socket ('Ethernet') - I use mine bridged or into a main switch
3) http://192.168.0.1 and reset Router > WAN Setup > Enable WAN Web Server > YES
4) Router > LAN Setup > Networking Service > BRIDGE

http://www.3amsystems.com/wireline/daa-search.htm?country=Switzerland
helps a little
as does http://switzernet.com/public/070723-config_UA/spa-3102.php

Things I've changed are
Voice > Regional > TimeZone > "GMT +1"
Voice > Regional > FXS Port Impedance > "270+750||150nF"
Voice > Regional > Caller ID Method > ETSI FSK
Voice > Line 1 > Dialplan > (<#:>xx.<:@gw1>|xx.<:@gw0>)

This dialplan is because I wish to use swisscom pstn most of the time, but prefix with # if I want the call to go over the VOIP service

Friday, 3 July 2009

Gimmie, Gimmie, Gimmie (a patch after midnight)

...won't somebody help me chase those bad docs away.

As I recently mumbled on twitter (sorry, but 'tweet' is even naffer than the bad title of this post) I've started poking at Yum around the edges. Partially as I'm trying to find a 'Better Way' than the groupinstall we have to do for 64/32 bit package co-existence on the current middleware, but also as I'm narked off at the complete lack of manpages (on SL5) for yum-utils.

actually, thats a bit harsh - as of 1.1.16 (el5) there are minimal docs, including yaim-utils.1 but nothing for each individual utility (see also http://yum.baseurl.org/wiki/YumUtils/RepoDiff). So, once again I'd ideally like something that can parse wiki markup and give me the output without having to keep pasting into a test page and hitting preview.

wikilint anyone?

Anyway, 1st patch sent off for approval, but my home server has dropped off the net so no more updates for the day.

[obligatory swiss status report]
Hot. :-) Sunflowers are blooming. nice n fresh in the evenings with thunderstorms. Sadly not had a chance to see if my shiny new camera can catch lightning, but I'm reasonably impressed with the highspeed capture. see sample

Friday, 19 June 2009

SVN Stats munging


As an aside I recently looked at a piece of GPL'd software and analysed the subversion stats for it.
Each datapoint represents a checkin to the tree and I assigned a numerical ID to each ssh account. shows which developes 'stick' with a package and which abandon their updates.

Bonus points for working out what the code is :-)