1. Ever wondered what your most used shell commands are? Here's a very silly way I knocked up to find out mine.

    history|perl -anle'$C ++;END &#39|head -10

    Some people would have you believe that perl is difficult to read.

    posted by cms on
    tagged as
  2. David Cross was in the New Pornographers promo video for 'Use It.' When I went to see David Cross curate his cabaret show last year in London, one of the acts presented was Kristen Schall , who showed a film from her ongoing 'Penelope Princess of Pets' series. Now TNP have a video for Mutiny, I Promise you, featuring Penelope Princess of Pets.

    <embed>

    It's all linked. I henceforth predict the Flight of the Conchords will support the forthcoming A.C. Newman tour.

    Kate was right, that's clearly a cardboard theremin. Not often you get to say that.

    posted by cms on
    tagged as
  3. I'm organizing my photos to make use of some free prints on offer from photobox. Hence I've uploaded a selection of older shots that I'm mulling through. There may be some repeats from earlier posts.
    Older photos

    posted by cms on
    tagged as
  4. If you have a Django 1.0 deployment configured to use sqlite3, and are struggling to understand sporadic eruptions of what are clearly exceptions thrown by closing a database cursor with uncommitted work; either manage.py commands on the shell, or page requests to the application generate stack traces centered around messages like ' Unable to close due to unfinalised statements ' then it might be a file permissions problem.

    In my case, neither my developer shell account, nor the user id of the running apache httpd processes had write permissions to the directory with the sqlite3 database file. Not immediately apparent from the wording used in the error messages.

    posted by cms on
    tagged as
  5. Font Feed is an interesting looking, appropriately stylish, aggregator of things typographic.

    posted by cms on
    tagged as
  6. I have some Objective C classes that I've built for use in a project. They are model and utility classes, and have no direct UI responsibility. To aid in automated testing and debugging, I've built them as a project that creates a static library. The project has a test target that runs suites of automated unit tests, and a library target that builds a C-style static library archive binary. The install configuration of this target copies the library to $HOME/lib/ , and the class headers to $HOME/include/$LIBNAME.

    This way when I use these classes in another project, I can just #import the headers in the sources, add the static library to the project frameworks list, add the include and lib directories to the compiler and linker search paths in the XCode target inspector, and build as normal. Build times are reduced, base classes are frozen in a stable, well tested implementation, code re-use is easier, everybody wins.

    Recently I broke this happy pattern, a little perplexingly, with what I thought was a fairly innocuous piece of refactoring. I noticed that one of my classes was rather a simple set container, and its implementation really little more than a thin wrapper around NSMutableArray , with only a trivial specialisation of behaviour. As it was only used within a parent class structure, with no interface outside the library innards, it seemed a bit of overkill to have it implemented as a sizeable class. The special behaviour really boiled down to maybe two additional methods on top of the normal array interface.

    I first refactored it to be a subclass of NSMutableArray, but that actually introduced more complexity. NSMutableArray is implemented as a class cluster , with an abstract API around a private hidden shadow class. In order to subclass it, you are expected to provide your own implementations of a subset of its interface. In my case, this would have made for more code than the class I was trying to replace.

    Of course, Objective-C allows you to define categories on any existing classes. Categories allow you to formally define and implement additional methods onto an existing class definition at compile time. I could re-implement my class as a tiny category on NSMutableArray, removing lots of my code, and reducing the size of my library footprint and perhaps add some value by introducing NSMutableArray's extensive interface.

    Surprisingly, it wasn't plain sailing. Coding up the category, and tweaking the library to use NSMutableArray in place of the now-redundant class was straightforward. Once the updated code passed the original test suite, it was deployed as a library. The first time I built a project using it, it crashed on startup, with an unhandled exception. I cleaned all targets and rebuilt. Same problem. I checked the library headers to confirm that the new data structures were properly defined on include. No problems there, but still a hard crash on initialisation.

    The system logs had an entry for the crash; selector not recognized attached to symbols that were recognisably the new array methods from my category. Running 'nm' against the library file showed the symbols present, and correctly defined as a category on NSMutableArray. I was stumped. After a bit of googling, I came up with the correct solution.

    It turns out that in order to link against a static library that contains Objective C categories, you need to pass the linker a special flag, '-ObjC'. Adjusting the build settings of my project to include this flag in the 'Other linker flags' entry of the target inspector fixed it so that the symbols are correctly resolved at runtime. Here is the official word, Technical Q&A QA1490.



    posted by cms on
    tagged as
  7. For the benefit of anyone else who missed the memo, Pulitzer Prize winning stripper, Berkely Breathed is back in the funny pages with a syndicated Sunday slot. Set back in Bloom County , with a mostly familar cast, with the mildest focus shift to centralising around the escapades of the titular waterfowl. It's readable online at Salon.com , although sadly there's not a feed, so you may need to schedule a reminder of your own.

    Economic tailspin, leg-warmers, tired, bloated government set on self-destruct, jingo-tastic US presidential campaign underway, and Bill The Cat! The 80s are most definitely back.

    posted by cms on
    tagged as
  8. Apple released iTunes version 8 this week , which introduced some excellent new features , such as Genius playlists, but broke the fancy perl script that I wrote to rotate my music library on my iPod touch.

    While revisiting this, I took the opportunity to re-implement it, aiming to fix a few of it's faults, most specifically the terrible performance. I decided to use Python this time around, chiefly because of the existence of appscript , an apple event bridge with a nice syntax. Python's object and sequence semantics are a slightly better fit with AppleScript's data models, and appscript should be a more optimal solution than Mac::Glue for sending lots of messages iteratively.

    I've also improved the actual command recipe, using 'duplicate' rather than 'add' to build the playlist seems more efficient. Also the overhead of having to periodically build glue modules with the ' gluemac ' tool is removed. Sadly appscript isn't shipped with OS X, but installing it ( at least on Leopard ), is as simple as ' sudo easy_install appscript '.

    The concept behind the tool is the same : use a nominated playlist to synchronise the albums with the iPod, and pick a random set of albums from buckets organised by album rating. Currently it's set to shuffle in 10 '2 star' albums, 20 'three star' albums, and 30 'four star' albums, selected from a 'just music' smart playlist that filters the master library, removing all spoken word, and podcasts and other miscellany from the pool.

    Here's the source . I'm far less experienced at python than I am perl, so I wouldn't claim it was a particularly idiomatic solution. It does run many times more quickly than the perl / Mac::Glue solution, taking a minute or so, rather than the best part of an hour. I would put all the performance gains down to the AppleEvents bridge , appscript interface, and using more efficient apple event set operations, rather than iterating over individual data.





    posted by cms on
    tagged as
  9. Some advice for when you're debugging code using the whizz-bang, illustrated debugger in XCode 3, and suddenly find that none of your breakpoints are triggered. XCode forgets all your breakpoints! Even plain breaks at line numbers disappear when you hit "Go". You may have some, or even all, of the following symptoms.


    • The little blue indicators in source view just turn yellow (for 'pending') when the debugger loads your executable, and never go blue again.


    • The tickbox for 'Use' in the debugger breakpoint list view, turns to a dash for half-checked.



    • Attempts to set symbolic breakpoints which used to match multiple symbols don't match any symbols.



    • "break info" in the gdb console doesn't list anything.


    If you're anything like me, you might be muttering loudly by this point, and perhaps banging things. Cleaning the entire project, and rebuilding all the dependencies doesn't seem to help. Nonetheless there may yet be hope! In my case, setting the debugging option 'Load symbols lazily' to off, magically fixed things again. This setting is found in the IDE preference pane - XCode -> Preferences -> Debugging .

    posted by cms on
    tagged as
  10. As hinted in my last post, we've recently spent a week away. Visiting with Judi and Jonathan in Normandy in their ongoing barn conversion, failing to construct a goat-shed, appreciating unusual motor vehicles, hanging in a yurt, eating great food, drinking French beer, enjoying good company, and marvelling in some simply astonishing weather.
    France, Aug '08

    posted by cms on
    tagged as