Updated: acronymmer.py for ecto

I’ve improved acronymmer.py, my script for adding acronym tags to posts in ecto. It will work with any file, however, that is passed as an argument to the script. There is one issue with ecto, and that is that abbr tags are not recognised by the Rich Text parser, so I’ve just set it to convert tags to acronym only for the time being. (Note to Adriaan: You should fix this!) Don’t run this script over the same text twice: it will re-tag them, resulting in messy (but still legal) code. Also, this needs a little fixing: the dictionary of items needs to return keys in size order, rather than just randomly.

 1     #! /usr/bin/env python
 2         
 3     'A script for ecto that adds abbr and acronym tags to the text'
 4     
 5     import sys, re
 6         
 7     acronyms={'WYSIWYG':'What You See Is What You Get', 
 8               'DOM':'Document Object Model',
 9               'XHTML':'eXtensible HyperText Markup Language',
10               'NSLU2':'[Linksys] Network Storage Link (USB) 2.0'
11              }
12         
13     # get input data - depends on implementation.  For ecto:
14     data = open(sys.argv[1]).read()
15         
16     # replace only the first instance of each acronym/abbreviation
17     for each in acronyms:
18         d = re.search(r'\b%s\b' % each, data)
19         if d:
20             data = data[:d.start()] + '<acronym title="' + \
21                    acronyms[each] + '">' + \
22                    each + '</acronym>' + data[d.end():]
23         
24     #return data to ecto
25     open(sys.argv[1],'w').write(data)

Theme Conversion (Benevolence)

I’ve converted another WordPress theme to work with Blogsome: check it out on legendtest.blogsome.com for the time being, until it goes live on the site it will belong on.

Boys & Their Toys.

There’s three guys on the train behind me, and they have spent the whole trip talking about cars. It has bored me shitless.

Strange Comment Spam

I checked my blog comments this morning, and got quite excited. Normally I get a comment or two per week, but today there were 11 new comments. And they were for a variety of different posts, ones from recently and some from quite a while ago. I clicked on the Comment arrow in the Dashboard, and was intrigued to see they were all meaningless jumled letters. 11 comments, all spam, all with 2 links in them, all not pointing at anything in particular. I mass-deleted them, but probably should have inspected them a little more closely first, just to see what the story with them was. I did notice they all came from different IP addresses, all used reasonable first names as the Commenter Name, and all had the same set of character in them: erdfcv. A quick Google on this provided not many clues. There is a user on immigration.com forums, and an eBay user, and a whole lot of foreign (non-English) language pages. Chinese, Arabic, Polish, Hungarian, and Korean, to name a few. Then I looked at the keyboard.

qwERt
 asDFg
  zxCVb    

I’m such a tool, this is not a random set of strings, but a common(ish) method of coming up with a set of letters. Like QWERTY but less recognisable.

Rail Transport.

Why is it that when I’m on time, or early, the train is late; but when I’m running late, the train is on time - or early? I had to run to catch it again. I’m so unfit. For someone who used to play or ref 12-odd games of touch per week, I’ve lost heaps of fitness. What is up with the 2 girls who catch the train from Lynton to Torrens Park? It’s a 15 minute walk!! Do yourselves a favour, save some money & walk. And get some better sunglasses. A week or so ago we had some rain - it seems to have cleared up a bit now - and I got off at Mile End, as I was on the later train and didn’t have time for a coffee in town. The underpass had a bit over an inch of water in it, and there was no other way off the platform. I had wet feet that day. As I catch the train I have ample time to ponder, and passing through the Keswick railyards fills me with sadness. I see dozens of old rail-cars. Do they still work? Is there some sort of rotation happening, or are they no longer used? Have we passed through the golden age of rail? Will governments see the long term benefits of having a comprehensive rail network? Or will rail fade, as they close down station after station? What would be required for TransAdelaide to re-open the stations like Millswood & Clapham? How would they know there was a demand for these shut-down stations, if they aren’t operated? Maybe lots of people would use the train from these zones, but don’t because it’s too far to walk to Lynton or Torrens Park. Was it really such a drain on resources to have these stations open at all? Surely their costs to upkeep would be insignificant compared to the overall costs of the rail network.

Review: Madagascar

The weekend before last, as I sat in bed on Saturday, I saw one of those promos about Madagascar. One where they show how they made it, and have a series of interviews with the cast and crew. After watching that, I wanted to see the film. I wish now I hadn’t seen the promo film, as it pretty much used all of the jokes in the movie. Except the Poo Flinging ones, but there were only two of them. It wasn’t an especially bad film, but once they got to the island, it sort of went nowhere (except for the occasional good bit). The first half-hour was fantastic, but they couldn’t keep going for long enough, and I tired of it well before the end. And the end was pretty poor, too. Alex should have eaten something. Kids should be shown more about what the real world is like. I’m not going to write any more - it wasn’t a thought-provoking film, and it should have been more fun than it was. Wait for it to come on TV.

Piracy as theft?

You wouldn’t steal someone’s car, so don’t steal Music/Movies.

I heard an interesting thought on the similarities between piracy of copyright material and theft.

No, I wouldn’t steal some guy’s Ferrari if it were left on the street, but if I were able to make an exact duplicate, without doing any damage to it, then I would. And what’s more, I was never going to buy a Ferrari in the first place. They haven’t lost a sale from me…

Business Ideas

At lunch on Sunday, I had to do my usual trick of re-fixing Ray & Joan’s digital set-top box. Not that anyone had stuffed it up or anything, but it must have been reset at some stage, and all of the ‘extra’ channels, which are just duplicates of the first, had reappeared. This in itself was a simple, 2 minute job, but it gave me an idea of a possible business venture. Setting up people’s entertainment units & systems, and teaching them how to use them. I often have to do similar tasks at both my parents’, and Jaq’s parents’ houses. Most of the time it’s reconnecting hardware, but sometimes it’s optimising settings. I wonder how much I could charge Joe and Jane Average to do this, and show them exactly how to use their stuff. I could do DVD/TV/STB installations, PC usage, and even digital cameras. Another thing I could do would be CD library -> MP3 conversion, and DVD -> AVI/MPEG conversion (for Xbmc, PVR, etc setups). I’m even thinking of a name: GeekGuys. www.geekguys.com.au - I’ll have to do a search and see what similar services are available.

I made some science.

Take the MIT Weblog Survey

You too can make science, by participating in the MIT weblog survey. Go on, you know you want to…

ecto: Auto abbr/acronym

There are a couple of instances of scripts out there that automatically apply abbr and acronym tags to pages, but I wanted to be able to do the same in ecto. This is also the first time I wrote a plugin script for ecto, and I wanted to do it in python. Please note that this here script is untested until I get onto my Mac and test the hell out of it. The script works, with the caveat listed in TODO.

 1     #! /usr/bin/env python
 2     
 3     'A script for ecto that adds abbr and acronym tags to the text'
 4         
 5     TODO = '''
 6     Fix it so that acronyms without a space either side (for example,
 7     that finish a sentence) work.
 8         
 9     Lookup on the internet for a list of acronyms/abbreviations?
10     '''
11         
12     acronyms={'WYSIWYG':'What You See Is What You Get',
13               'DOM':'Document Object Model'}
14     abbrs={'XHTML':'eXtensible HyperText Markup Language',
15            'NSLU2':'[Linksys] Network Storage Link (USB) 2.0'}
16         
17     # Add more values to your hearts content…
18     
19     # get input data - depends on implementation.  For ecto:
20     import sys
21     data = open(sys.argv[1]).read()
22         
23     # replace only the first instance of each acronym/abbreviation
24     for each in acronyms:
25         data.replace(' '+each+' ', '<acronym title="'+acronyms[each]+'">'+each+'</acronym>',1)
26     for each in abbrs:
27         data.replace(' '+each+' ', '<abbr title="'+abbrs[each]+'">'+each+'</abbr>',1)
28         
29     #return data to ecto
30     open(sys.argv[1],'w').write(data)

Note: Comments turned off: too much Spam on this entry.