Kayak Adventure on Wappingers Creek

Last night Jim and I decided to take advantage of the evening and do the 7.5 mile stretch of wappingers creek that runs near my house.  There is only one put in, and one take out, between water falls, and it’s a one way trip down stream, so you need to plan with 2 cars.

For those that haven’t noticed, we’ve gotten nearly 10 inches of rain this month, so the river level is high, and thus pretty fast still.  There is only one section of this that I think you could call white water, which occurs about a mile in.  But it’s in a wide part of the river and very straight, so you just don’t let it turn you around.  The real challenges of the trip were the whirl pools, which there are many.  As we were in 14.5 ft boats, they are more susceptible to being turned around, which you want to avoid at all costs (my shoulder is going to be sore from a last minute recovery the one time I nearly got spun around).  There are also 2 low trees that you need to get your positioning right on (failure to do that on the first one got me a little wet, though not out of my boat), and one log jam that I had to just bump up into then muscle over a log to get back into the main flow.

Over the course of the trip we saw Malards, and Wood Ducks, adult and babies.  At one point we kicked up 40 or so wood ducklings that led us down the river for 2 miles until they finally figured out they could go to the shore to get out of our way.  It was pretty cool to see that flock of wood ducklings splash away in front of us. πŸ™‚  We also managed to see a beaver swimming across, as well as a couple of great blue herrons hanging out in a large dead tree towards the end of the journey.  A beautiful site at sunset.

I only got my arm wet as I dodged under the first low tree, but Jim did manage to get fully out of his boat right before put out, as he got a little close to a tree that took him out.  Overall it was a great 2 hour evening boating adventure.  We’ll definitely do it again, though it wouldn’t hurt to let the water level go down just a bit so the tree dodging isn’t so bad. πŸ™‚

The importance of getting government data online

Wired has a great interview with the Federal Gov CIO, which actually dates back just prior to data.gov‘s launch.  It’s definitely worth a read.

I firmly believe that this is the most important change that the current administration can make.  The Federal government did a tail spin into secrecy over the past couple of decades, and while I believe the previous administration took this to a new height, it seems like it was part of a trend that definitely predates them.  Secrecy breeds distrust in government, as well as bad decisions, as people don’t have access to all the facts.

Sunlight is definitely the best disinfectant, and nothing has quite the same power of light as the whole of the internet gazing in.

Open APIs for NY State Senate

Hours before the entire NY State Senate imploded into a bunch of whining 1st graders, the previous leadership pushed out something quite interesting: open.nysenate.gov.

To pursue its commitment to transparency and openness the New York State Senate is undertaking a cutting-edge program to not only release data,
but help empower citizens and give back to the community. Under this
program the New York Senate will, for the first time ever, give
developers and other users direct access to its data through APIs and release its original software
to the public. By placing the data and technological developments
generated by the Senate in the public domain, the New York Senate hopes
to invigorate, empower and engage citizens in policy creation and

It remains unclear what will happen once squabble-gate ends, and we get a NY State government again, but hopefully a step into open like this is hard to step back from, especially if more people know about it.  So spread the good word, and cross your figures that we get some sort of government back some time this year.

Building Thumbnails for PDFs

<Note: thanks to Buffy Miller for giving me a much slicker solution here>

Often I want to post a PDF on a web page, but would like the cover of the PDF to be the clickable element.  This just makes things look slicker.  This can easily be done with the imagemagick set of commands.  Using imagemagick, you can select the page you want to convert out of the pdf (using the [] annotation), get the right size (using -resize) and format (based on file extension).  The following command does the conversion in a single go:

convert -resize 150 inputfile.pdf[0] outputfile.png

One of these days I’ll get around to making a mediawiki extension that does that by default for pdf media attachments.

The End of Fail

Via rc3.org I came across this blog post:

FAIL is over. Fail is dead.
Because it marks a lack of human empathy, and signifies an absence of
intellectual curiosity, it is an unacceptable response to creative
efforts in our culture. “Fail!” is the cry of someone who doesn’t
create, doesn’t ship, doesn’t launch, who doesn’t make things.
And because these people don’t make things, they don’t understand the
context of those who do. They can’t understand that nobody is more
self-critical or more aware of the shortcomings of a creation than the
person or people who made it.

I really like the take.  It’s way easier to be a critic than a creator, and people have found a winning strategy on the internet to just hate things, loudly, and cleverly.  It’s a pretty easy pattern to use to get fame, but at the end of the day it often just discourages new creation. 

If you think something is a fail, look harder.  Maybe it wasn’t ever trying to do what you thought.  Maybe the things that make it interesting are values and capabilities you don’t understand or even knew existed.  Maybe it has some real warts, but real gems as well.  An open mind and the benefit of the doubt leads to much more interesting discovery of information.

Remotely editing files securely with emacs

A long time ago I used the built in ftp support for emacs to be able to remotely edit files on another system.  This gave me all the convenience of a local editor (especially on slower links), with the ability to do edits right in place on other systems.  On whim I did a quick search to see if there was a way to do this over an encrypted session while trying to fix some php templates.

Low and behold, there is.  It only takes the following 2 lines in your .emacs file:

(require 'tramp)
(setq tramp-default-method "scp")

Then you just open /servername:directory.  Relative directories base off your home dir, absolute do what you would expect.  This is just far too handy, and I can’t believe I’ve gone this long without knowing about it.

Getting Back into Blood Bowl

When I was 12 my friend Travis introduced me to Dungeons and Dragons, which led to a 4 year romp through all manner of Role Playing Games and Table Top Games.  The list is extensive, and I’ve honestly probably complete forgot the names of most of them, as I realized in catching up with Jay on facebook last night.  We even wrote our own game, and 85 page rulebook, during that time.  It was the earliest piece of creative construction that I’m really proud of. 

But 4 years after 12, you turn 16, discover girls, get in fights with friends (often over the girls), and assume everything is *so important* all the time (definitely including the girls).  The games were left behind as a casualty of growing up, and an attempt to change image from being “one of those geeks” to something else.

At the age of 32 I happily accept and embrace my geekiness.  Recently Pyg (local friend, and an avid gamer) started talking about blood bowl again.  Of all the games I left behind, that was probably my favorite.  Think rugby meets lord of the rings.  It’s played with miniatures on a table top pitch.

I kept thinking, and saying, “I’d be up for giving that a shot again”.  Pyg printed out a couple of copies of the living rules for us to read up on, and finally we got a free evening for both of us to give it a shot.  We’ve played a couple of games now, and have finally sorted out the rules again, which have evolved quite a bit since I bought my set back in 1991.
It’s a heck of a lot of fun, leading to some epic moments as when Pyg had completely knocked out every single player I had with time running out, while he was behind by 1 TD (some of that was because we were interpretting rules a bit wrong, but it’s level of epic was pretty impressive.)

It takes about 3 hours to run a match, and is a great thing to do over beer and wings.  I’m looking forward to our next match now that we’ve got a clearer view on the rules, and we can actually start building some teams that last beyond just a single match.

The Power of Perl: Converting an A4 PDF to Letter with Margins

Because I’ve moved into the more elegant waters of Ruby and Mono, I sometimes forget just how power Perl can be.  Sometimes 8 lines of perl is all you need to solve a problem.

The Problem

So, I’ve gotten back in to Blood Bowl with my friend Pyg, but that’s mostly for another blog post.  As we’ve been relearning the rules, Pyg found a much better consolidated rule set on the web as a PDF, in A4, as it was created by Brits.  A4, is the far more logical way to make paper that’s normal page size ish.  However, it is slightly longer and slightly narrower than our Letter paper standard.

The real challenge here was that I wanted to create something that was bindable at our local Office Max. “Printing” the A4 PDF to a Letter PDF in evince gave me something with about 3/4 inch of white margin on the right side of every page.  If I could get that to alternate between the right and left sides of the page, then I’d be golden.

As you can see, left as is, bindng double sided would both look silly, and actually bunch through some of the text on the right side pages.

The Solution – Hack the PDF

PDF is just a document standard.  That means a lot of it is in plain text, for a gracious definition of that word.  I openned the file up in emacs and started searching for words that might represent this.  Eventually I found the following snippet in the PDF:

<< /Type /Page
   /Parent 1 0 R
   /MediaBox [ 0 0 611.999983 791.999983 ]
   /Contents 196 0 R
   /Group <<
      /Type /Group
      /S /Transparency
      /CS /DeviceRGB
   /Resources 195 0 R

This is part of the Page definition, and what’s important is that MediaBox tag.  The 4 numbers there are X, Y, Width, Height of the content.  After some experimentation I determined that the values I needed for “right side pages” were: -52 0 559.999983 791.999983.  I need to set every other (of 84 pages) to that.  There are MediaBox definitions that have nothing to do with Page, so I can’t just look for them.  It has to be a MediaBox in that Page definition.

Changing your line break

Perl has a lot of operations that are line oriented, so you get 1 line at a time.  But one of the greatest powers of perl is it’s really easy to change what it considers a line break.  This is done with the line ending special variable $/.  A common trick is to $/ = undef; which means the first read of a file will read the entire thing into a string.  For this problem I decided that if I made << my seperator, I’d get the Page definition and MediaBox on the same line, making life much easier.  But enough of the details, here is the code:


use strict;

local $/ = ‘<<‘;

my $count = 0;

while (<>) {
    if ($_ =~ m{/Type /Page}) {
        if (($count % 2) == 0) {
            $_ =~ s{MediaBox [.*?]}{MediaBox [ -52 0 559.999983 791.999983 ]}gs;
        } else {
            $_ =~ s{MediaBox [.*?]}{MediaBox [ 0 0 611.999983 791.999983 ]}gs;
    print $_;

This reads in the first pdf from standard in, the second to standard out.  Because I could change the line seperator I don’t have to keep track of state of if I’ve seen a Page seperator, and if I’m still in that block (i.e. proper formal parsing).  That lets me do it in 2 matches.

The results, as just as you would like, and made for some nice printouts for binding:

Sometimes you just need to roll up your sleeves and bang out some perl code. πŸ™‚