Archive for the 'Tech' Category

Tinkering still

Yep, I’m at it again. I guess I’m a compulsive refactorer and want to keep improving my code.

I have updated my highlightcountries.user.js GreaseMonkey user script so you can specify any CSS styling for the lines. The current version has example styles for four countries.

Monkeying around

Well, I couldn’t leave my first GreaseMonkey user script alone, could I?

As an inveterate tinkerer, I started thinking of ways to make it more flexible. So now, highlightcountries.user.js highlights results of cyclists from three countries: Australia in gold, USA in blue and Italy in green.

This user script is designed to be edited. Highlight as many countries as you like with whatever colours you want and have some fun!

It was data crunching!

My recent wrangling of LDIF files is a classic case of Data Crunching, as outlined in Greg Wilson’s new book.

Reading an excerpt of this book, I realise that I’ve done a lot of this kind of work over the years. Greg makes it clear that, even if a program you write for crunching some data is Quick and Dirty™ (as we always called it when I was a graduate student), it should be well written, because you never know when you are going to need it again. Or worse, when someone else is going to need to pick it up and use it.

(Actually, I have already refactored my LDIF program into a pure-Java solution that can be used by any of the Java-heads at work. It also uses an vendor-supplied LDIF library, to remove the responsibility of parsing LDIF from my code. And I found a bug in the LDIF library!)

My first GreaseMonkey user script

I have recently started using GreaseMonkey seriously, and have written my first user script.

My script does one specific thing: it highlights results on cyclingnews.com by Australian cyclists so I can easily pick them out as I scan through the results pages. (Go Robbie! Go Stuey! Go Cookey! etc. etc.)

If you want to use highlightaussies.user.js or modify it for different colours and countries, have fun!

Update I have editied the script so it works correctly in Firefox on Windows with its CRLF line-endings.

Top-secret Mac dialog

John Gruber found in Mac OS X 10.4 the simplest possible dialog you could ever need.

Hankering after an XML file format

I had a task at work that required manual editing of LDIF files to repair a problem in an LDAP directory. The editing work was repetitive and error-prone and I could see no quick way to automate the changes.

For one file with 14 entries and another with 93, I had to:

  • only use entries that contain ‘problem’ attributes, ignoring others
  • write LDIF lines with an entry’s DN followed by changetype: delete and an empty line
  • write LDIF lines with an entry’s DN followed by changetype: add, then all the remaining attributes, excluding the ‘problem’ ones

After that the LDIF files will be used with ldapmodify to repair the directory.

For someone versed in XML and XSLT, doing this kind of work in LDIF file format feels extremely tedious. I couldn’t help myself: I wrote a Python script that parses the LDIF and writes a simple XML file with the same information. Then I wrote an XSLT stylesheet that edits the XML as described above. The XSLT emits LDIF directly, including ‘folding’ lines (as described in the RFC) longer than 78 characters.

I discovered DSML (Directory Services Markup Language) but could not find tools to convert LDIF to DSML. There are tools that interact with a directory using DSML files but they didn’t extract the ‘problem’ attributes (they were operational attributes actually) that I needed to filter on. Also, DSML is much more complex than I needed: my simple XML was enough.

On reflection, I probably should have used Python objects (and later Java objects after I rewrote the conversion program into the standard language where I work). But I was annoyed by what feels like an archaic file format that is not amenable to automated, declarative transformation using (now standard) tools.

Developers and architects: like managers and leaders?

Al Smith Jr’s JavaWorld article on developers and architects helps to clarify a distinction that is often muddied. But I don’t fully understand:

Knowing how to solve a problem’s context verses solving the problem itself distinguishes architects from developers.

I think I don’t connect with Smith’s meaning of context.

Reading it made me think of someone, somewhere, who stated that the distinction between managers and leaders is also muddied. I can’t remember who: was it Stephen Covey (of 7 Habits fame) or was it Alistair Mant?

My Firefox extensions etc.

After using Firefox for a while I have settled on a set of extensions and other bits I use both at home (Mac) and at work (Windows). I have experimented with others, but I consider these ones essential.

Open link in…
“Adds context menu items for opening links and images in a new background tab (or foreground tab if your tabs normally open in the background), in a new background or foreground window, and in the current tab.” I use this when I want to re-use a tab instead of opening a new window or tab.
Resize Search Box
“Allows you to use a resize thumb to resize the search box. The resize thumb can be enabled by customizing the toolbar.” Great for fitting long search strings into your search box.
Adblock
“Once installed, it’s a snap to filter elements at their source-address. Just right-click: Adblock: done. Filters use either the wildcard character (*) or full Regular Expression syntax. Hit the status-element and see what has or hasn’t been blocked.” I am rather aggressive in weeding out annoying ads. As more people start using Adblock, I wonder how it will affect web advertising revenue.
Bloglines Toolkit
“The Bloglines Mozilla extension adds a notifier and several additional features to Mozilla and Firefox browsers. In addition to embedding a notifier within the lower-right portion of the browser window, the extension adds a number of additional options to the right-click context menu.” If you use Bloglines and Firefox, you need this.
Change the cursor for links that open in new window
“This neat trick will change the mouse pointer when you hover it over links that will open a new window.” This is not an extension, but an addition to my userChrome.css file. It provides a useful warning of impending window duplication. When I see the crosshair cursor (signifying a link that will open in a new window) I head for the Ctrl key (Win) or Command key (Mac) so the link opens in a new tab instead.

« Previous Page