Please just $3 more

October 17th, 2010

Seven years ago Mogos and I took a long trip through Virginia and the surrounding environs. As we slowly inched north, we spent a night in a nondescript campground in Kentucky (painfully) named Twin Knobs. We pulled in late at night, and desperate for a place to crash, picked the first empty site we found, shoved some money in the donation box, and passed out. We woke the next morning to find, much to our delight, that we were married that night.

Newlyweds

Swoon.

Са́нкт-Петербу́рг

September 30th, 2010

Last year, in September of 2009, I traveled to Saint Petersburg, Russia to work with the fine folks at the State Hermitage Museum. I had the good fortune to spend 8 days in Petersburg. While not cooped up in a conference room in the museum, I spent my free time exploring the city. Here are some of my favorite pictures from the trip. You can see the whole set over at Flickr.

Handling Nested CDATA With Builder

September 21st, 2010

As noted by our associates at Atomic Object, XML doesn’t allow for nested<![CDATA[…]]> elements. In the course of rewriting some pieces of code, I developed the following Builder workaround to allow our application to export valid XML by breaking the nested CDATA elements into distinct chunks. When read back in via our Nokogiri-based parser, it concatenates the values automagically, and the end result is clean, valid XML.

Fix code:

module Builder
  class XmlMarkup < XmlBase
 
    def cdata_with_escaping!(text)
      if text =~ /(\]\]>)/
        text.gsub!(/(\]\]>)/, "]]]]><![CDATA[>")
      end
      cdata_without_escaping!(text)
    end
    alias_method_chain 'cdata!', 'escaping'
 
  end
end

Sample output:

>> xml = Builder::XmlMarkup.new(str)
>> xml.cdata!("<![CDATA[Foo bar sna]]>")
>> xml.target!
=> "<![CDATA[<![CDATA[Foo bar sna]]]]><![CDATA[>]]>"  # valid XML!
>> xml.cdata_without_escaping!("<![CDATA[Foo bar sna]]>")
>> xml.target!
=> "<![CDATA[<![CDATA[Foo bar sna]]>]]>" # invalid XML!

Sample parsing with Nokogiri:

>> doc = Nokogiri::XML("<baz><![CDATA[<![CDATA[Foo bar sna]]]]><![CDATA[>]]></baz>")
=> #<Nokogiri::XML::Document:0x825aff3c name="document" children=[#<Nokogiri::XML::Element:0x825afc1c name="baz" children=[#<Nokogiri::XML::CDATA:0x825af99c "<![CDATA[Foo bar sna]]>">]>]>
>> doc.css('baz').first.content
=> "<![CDATA[Foo bar sna]]>"

Tracking Drupal User Registrations by Date

September 10th, 2010

Today I wanted to graph the number of registrations recorded by a Drupal site grouped by date. Drupal stores all account data in the users table. To identify accounts that are registered and verified, I queried with “login != 0″ in my WHERE clause, e.g.

SELECT COUNT(*) FROM user WHERE login != 0;

Since Drupal stores all dates as PHP-style Unix timestamps, e.g. 1284157128, I needed to convert those into a form that MySQL understands. I used from_unixtime() to convert the date to a MySQL date type. By casting, I was then able to use the column in a GROUP BY clause, yielding my result:

SELECT COUNT(*), DATE(FROM_UNIXTIME(created)) as created_date
FROM users WHERE login != 0 GROUP BY created_date;

Which produced results just as I wanted them:

Blue State

September 1st, 2010

Exchange while taking Rufus for a walk:

Man on street: That’s a great dog there, a boxer, right?

Me: Yep!

Man: Aw, good dogs aren’t they?

Me: Yeah, he’s pretty stupid but he does love life.

Man: Must be a Republican!

Zing!

P4K Mobile Site

July 15th, 2010

A few beers, boredom, and frustration with the lack of a mobile site for this weekend’s Pitchfork Music Festival led me to hack up a quick mobile-friendly version of the schedule. It works for all iPhones and Android-based phones. If you save it to your iPhone home screen, you can use it offline (a bonus considering how over-taxed the AT&T network is during the festival).

See the mobile-friendly schedule – http://d-struct.org/projects/p4k2k10/

Don’t Be Afraid, Don’t Be Afraid, Don’t Be Afraid

July 10th, 2010

While digging through some boxes full of old papers, I found this leaflet from a Godspeed You! Black Emperor show in Detroit, circa 2001.

The reverse side:

Is now for the first time Dalí born.

June 14th, 2010

Senior year of high school my friends and I recreated this video for our final project in Spanish class. We weren’t quite sure what was going on in the video then, and to this day I’m still not very certain. In our low-budget remake, we jumped out of a cardboard box and sprayed milk all over my parents’ backyard. The neighbors, I can only imagine, were dumbfounded.

I present to you, as a service to Google and befuddled viewers, a transcription of the video, unedited:

Bonjour, Good Morning

Is now for the first time

Dalí born

with any kind of traumatism

A little blood,

symbolic blood

And milk,

again milk of today born

and some symbolic fish

of Mediterranean people

This is the blood of Gala …

…and the blood of the Divine Dalí

[scene]

How not to impersonate utility workers

June 12th, 2010

The scene went down recently here in Pilsen.

Wear silly vests and hard hats, and film it all on fancy DSLRs.

Have one person do all the work, and everyone else mill about and record the momentous event. Not suspicious at all.

Oh, no! The fuzz! How did they find us?

Oh, man, our progressive culture jamming is SHUT DOWN by the police!

Be certain, however, to record the heartbreaking takedown of the sign from multiple angles. This will play great on YouTube later.

The sign that could have changed the world: "Danger: You are 0.5 miles from the Fisk coal fired power plant."

Despite looking really silly trying to hang a fake sign, these folks do have a good cause. The Fisk Generating Station is a coal-fired power plant on Cermak Road, here in Pilsen. It’s a relic of a bygone era of power generation, and is a public health nightmare. Community groups have been trying for the past decade to shut down Fisk, to almost no success. The 25th alderman, Danny Solis, doesn’t appear to be championing the cause, and is in the pocket of Midwest Generation, the owners of the station.

The Chicago Reader has a number of good articles on the subject, including recent efforts by the Chicago Clean Power Coalition to push ordinances through Chicago City Council to regulate and shut down the plants.

ChicagoBusiness.com reports that, as  of April, there’s a new ordinance being pushed by a coalition of aldermen and civic organizations. Let’s hope that Chicago politics don’t get in the way of public health.

Scenes from a road trip

May 28th, 2010

I accompanied Melissa and her sister on a short trip to Columbus, Ohio two weekends past. This was the view from the backseat.


More.