Monday, May 23, 2016


I followed a slashdot article about node.js to this rather bizarre take about functional programming, and from there rediscovered the short programming (or post-progammin) essays of James Hague. (I especially liked  You Don't Read Code, You Explore It, but his "Previously" links on each essay are so well-chosen that it's a very easy rabbit hole to go down.)

It took me a minute to remember I was familiar with some his previous work, specifically Halcyon Days, a series of interviews with some great creators of the golden age of video games. At one point I owned the 3.5" floppies of these, but its been available for free, online, for much longer than that. Great reading. (Also Hague is a fan of Susan Lammers' Programmers at Work, some truly lovely interviews, mostly "serious" programmers but the interview with the designer of Pac-Man is a treat.)

Sunday, May 22, 2016

somerville success!

I admit, design- and "juiciness" wise it's not my best work, but this year the Somerville Porchfest Map Webpage stayed alive throughout the very popular event - the first time it did so in the event's 5 or so year history! I think I tried to reach out to them last year, but this year they finally took me up on my offer - I worked with the organizers and one of their developers to work in a system that dumped a static version of the band list to JSON, and then had the webpage grab that in one giant gulp (with the same kind of Google Maps integration.) I also spent some cycles grabbing the thumbnails and making a CSS sprite sheet.

I finally got to meet the people I was volunteering for and with on the day (My tuba and I also participated in two different groups, a Porch-i-oke Sing-along and the School of Honk.) In retrospect I probably should have pushed to meet earlier, just because there were some features (like linking back to their main band display pages) that would have been on their wishlist that I didn't think of.

The days leading up to the event were kind of frantic, in fixing data issues and tracking down missing bands. The data was pretty messy, for sure (hence my recent post on Debugging JSON) but we got through. It was a HUGE amount of data though - many, many bands.

Maybe next year I'll pitch a more-geared-to-mobile site, like I had for JP Porchfest.  As a pipedream it would be great to have a Porchfest Mobile App, but making a version for both iOS AND Android sounds onerous, unless maybe I was able to make an HTML5 version and bundle it via Phonegap or something.

One further observation I made on my regular blog:
Trying to figure out why my page for the Somerville Porchfest was looking wonky - the "Music Genre" selector was stretched to an ungainly degree. Apparently, up 'til now we haven't had "genres" such as "definitely not 'country' per se - but instead classic country" or "post MAN-o-pause-al rock super group" 
Note to self: bands are bad at taxonomy. 
And so it goes! Or went.

Tuesday, May 17, 2016

debugging JSON

Iffy JSON can be a serious pain in the butt; the parser that JQuery uses by default is extremely picky and prone to failing silently; and some sources of JSON tend to exclude ANY whitespace and so can swamp many text editors (that really weren't designed for lines hundreds of thousands of characters long) - finding some garbage characters that choke can be a serious chore. has been my default "make sure this works", I like how it evaluates it two ways - sometimes a block of "almost JSON" will choke $.getJSON but - protip - if you precede the block with var someVar =  and end it with ;, and then include it as .js, it gets by.

That's a suboptimal hack, and that site, while sometimes useful, does a poor job of telling you what characters are causing things to choke... recently I discovered - this site is pretty great, because it does "prettify"-step BEFORE checking to see if everything is valid, and gives a more or less reasonable explanation of what's wrong.

Anyway, here is some perl I hacked together in an emergency way for the work I'm doing with Somerville Porchfest, to clean up the "almost JSON" they're handing me:

open(READ, "bands.raw.json");
open(WRITE, "> bands.json");
while(defined($line = <READ>)){
    $line =~ s/\\\'/\'/g; #replace \' with '                                    
    $line =~ s/\\\"/\'/g; #replace \" with '                                    
    $line =~ s/\\x3c/\</g; #replace \x3c with <                                 
    $line =~ s/\\x3e/\>/g; #replace \x3c with >                                 
    $line =~ s/\\x26/\&amp\;/g; #replace \x26 with &amp;                        
    $line =~ s/[^[:ascii:]]//g; #ascii only please                              
    $line =~ s/\\r/ /g;  #remove embdedded \r                                   
    $line =~ s/\\n/ /g;  #remove embedded \n                                    
    $line =~ s/\t/    /g; #repalce tabs with spaces                             
    print WRITE $line;
close WRITE;

close READ;

I've seen worse! That line with [:ascii:] seems especially useful in the future, via this perlmonks thread.

Monday, May 2, 2016

make URLs clickable in javascript

Autolinker.js seems to a decent solution to making URLs clickable with in a js variable. (Though I couldn't get the min.js version in the zip file to work.)