Categories
Uncategorized

Pretty Print XML with Perl

Let’s say you’ve got a file named “file.xml” and want it pretty printed, all indented nice and everything…

For just such an occasion I have a Perl script named “pretty.pl” and I just run my XML file through it like so: cat file.xml | perl pretty.pl

Here’s the code I use:

#!/usr/bin/perl

use XML::Twig;
use XML::Parser;

my $xml = XML::Twig->new(pretty_print => 'indented');

$xml->parse(\*STDIN);

$xml->print();

You can even pass it through right as it comes in over the wire: curl http://example.com/data/file.xml | perl pretty.pl

Here’s an example of data from Foursquare without pretty printing. (I used curl to grab the data. Also, I added in some line breaks, just to make it a little more readable.):

<?xml version="1.0" encoding="UTF-8"?>
<checkins><checkin><id>123847273</id>
<created>Mon, 09 Aug 10 00:50:33 +0000</created>
<timezone>America/Chicago</timezone><venue><id>2357761</id>
<name>The Kiltie</name><primarycategory><id>79067</id>
<fullpathname>Food:Ice Cream</fullpathname><nodename>Ice Cream</nodename>
<iconurl>http://foursquare.com/img/categories/food/icecream.png</iconurl>
</primarycategory><address></address><city></city><state></state>
<geolat>43.107391</geolat><geolong>-88.464475</geolong></venue>
<display>Pete P. @ The Kiltie</display></checkin></checkins>

And here’s the same data, again using curl to grab it, and then passing it through the pretty.pl script:

<?xml version="1.0" encoding="UTF-8"?>
<checkins>
  <checkin>
    <id>123847273</id>
    <created>Mon, 09 Aug 10 00:50:33 +0000</created>
    <timezone>America/Chicago</timezone>
    <venue>
      <id>2357761</id>
      <name>The Kiltie</name>
      <primarycategory>
        <id>79067</id>
        <fullpathname>Food:Ice Cream</fullpathname>
        <nodename>Ice Cream</nodename>
        <iconurl>http://foursquare.com/img/categories/food/icecream.png</iconurl>
      </primarycategory>
      <address></address>
      <city></city>
      <state></state>
      <geolat>43.107391</geolat>
      <geolong>-88.464475</geolong>
    </venue>
    <display>Pete P. @ The Kiltie</display>
  </checkin>
</checkins>

I still find Perl extremely useful for this sort of task… I’m sure there are other command line ways to do this, but this one works for me.

(Hat tip to A Curious Programmer where I picked up this Perl code from…)

Categories
Uncategorized

13 Years of RasterWeb!

13 Years

13 years of blogging… You can browse through the archives if you like. It’s all there.

I just keep going. I don’t know why… probably because it’s hard to stop. I don’t give up easily, and I like to keep trying. Things were obviously very different in 1997 when we started. There were a handful of blogs and you could read them all during your lunch hour. As much as I’m saddened to see an old friend abandon their blogs, I’m often quite pleased to see some are still at it.

This is the part where I thank Dave Winer, because without him, I wouldn’t have started blogging. (Even if he does block me on Twitter.)

I’m considering a few new taglines, perhaps: “Wisconsin’s longest running blog” or something… I dunno, any suggestions?

Anyway, I’m just here to congratulate myself on 13 years of blogging, and hope for another 13 to come… Keep up the good work, self!

Categories
Uncategorized

Mozilla Crash Reports

The Mozilla folks make it pretty easy to send them crash reports… In fact, I think it was Netscape that first implemented a way for the browser to easily submit a report when something went wrong and your browser crashed.

I did find some instructions for reporting a crash bug in Chrome, and of course Safari can also send crash reports. Hopefully this makes for better software in the future.

In digging into all the crash reporting, I found that Mozilla actually publishes the results they get. Head on over to their crash-stats site and take a look.

Mozilla Crash Reporting

You can do custom queries for a few different Mozilla products, so in this screen shot I chose the current stable version of Firefox running on Mac OS X. Hmmm, looks like the Flash Player caused the most crashes…

I couldn’t find if Google or Apple has anything like this, but if they don’t, they should think about it… There’s some great data in there.

Categories
Uncategorized

Photojojo Loves You!

PhotojojoI love Photojojo… They love making photography fun. They also love making you love them, and how do they do that?

Here’s their mission, placed prominently on their site:

We believe in doing one thing, and doing it very, very well

We find the best photo shiz anywhere

I’ve seen companies do the “love us” thing… The idea is to make your customers fall in love with you. Do whatever it takes to make them love everything about you. Deliver outstanding service, in fact, over-deliver outstanding service, go above and beyond, make them happy, get them excited, make sure that if they tell anyone else about you (and they will) that they are presenting you in a positive light. And you can’t just talk the talk, you have to walk the walk. Actions do speak louder than words.

Photojojo was a sponsor of PhotoCampMilwaukee back in 2009. They totally got it, and were more than happy to help us make that event happen.

Photojojo’s store is filled with stuff that isn’t high-end gear for serious photographers. It’s mostly simple things to make photography fun. (But there are some pretty useful items there as well.)

Even the little things about Photojojo are all about fun. For instance, their contact form doesn’t have some lame Captcha that forces you to decode a distorted string of numbers and letters… it looks like this:

Photojojo Contact Form

Yeah, fun stuff! It’s kind of what they’re all about… if you love photography, check out Photojojo… they love it too.

Categories
Uncategorized

Take Her From Behind!!!

Take Her From Behind!!!

download the large one

(consider it cc:by)

Inspired by a spam subject line. This would have been a drawing of a starship coming up from behind another starship on the attack, but that didn’t work out. I was also inspired by a web site called Spamusement which featured “Poorly-drawn cartoons inspired by actual spam subject lines” which sadly, stopped updating in 2007… I miss that site.