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.
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.
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'endend
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]]>"
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.
SELECTCOUNT(*)FROMuserWHERE 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:
SELECTCOUNT(*),DATE(FROM_UNIXTIME(created))as created_date
FROM users WHERE login !=0GROUP BY created_date;
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).
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:
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.