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:

#!/usr/bin/perl

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;
        }
        $count++;
    }
    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. 🙂

Dumping daily link posting

I’ve been thinking about this one for a while, but I’ve now disabled the daily link posting by postalicious.  I also went back and purged all the link posts in the blog (which turned out to be about 50% of them).

If you are still interested in my daily link stream, I’ll continue to post it on delicious.  I’ve also started to experiment with a lifestream plugin on this blog.  I’m not sure if that will be useful or not, but it’s here for now.  I’m also hoping this give me more motivation to post more often.

Build your own real time whiteboard sharing on Linux

I can’t even remember the last time I had a coworker that was co-located with me in the same town.  Within IBM the other software developers that I typically work with are in: Minnesota, Texas, Germany, Great Britain, Switzerland, Germany, Brazil, and Australia.  These are the folks that I would have 1 or more technical discussions with a week.  If I openned that umbrella up to a month, we’d add another few countries, and a whole lot more states.

A truly unsolved challenge in collaboration is replacing white board discussions with some sort of online equivalent.  I’ve got a drawing tablet, but honestly, my brain doesn’t think quite as well with it as when I get on a proper whiteboard.  After a phone conversation earlier this week that I realized was circling for lack of common artifacts, I took some time to try and figure out how I could get people to see the whiteboard in my office.

Ingredients of Real Time Whiteboarding

  • Logitech 9000 web cam.  This has 1600×1200 resolution, runs about $90, and does low light scenarios really well.
  • mjpg_streamer
  • a Linux machine that’s at least a P4 processor

Install all this software onto you Linux machine.  Then run the following to start streaming your webcam as video in real time:

mjpg_streamer -i "input_uvc.so -d /dev/video0 -y -r 1600x1200" -o "output_http.so -w /webcam_www -p 8080"

Viewing the results

The results can be viewed a number of ways.  There is a built in client in the source tree (screen shot below is from that).  You can also view it from vlc or firefox with the url http://your.server.name:8080/?action=stream. (In firefox I found you need 1 reload to get it to update frames, not sure why).  If you want to just get the current frame you can use http://your.server.name:8080/?action=snapshot.

The results a quite impressive (you may need to right click to get to full res):

This is definitely readable to as small as you are going to be able to write.  It’s about a 5 second delay from capture point to writing, which isn’t too bad considering.  I’m definitely going to use this in the days ahead, as it works a heck of a lot better for me than trying to diagram in a computer program interactively.  You’ll get motion blur on people, but given that this is mostly about the text on the whiteboard, that’s not really a big deal.

Update: I figured out how to do this with firefox and vlc, so the text now reflects that.

Why web design committees are so tough

I’ve been part of a process of redesigning the Poughkeepsie Farm Project website, both visually and functionally since about March.  It’s a group effort, with a good number of people from the PFP, all of whom expressed interest at the PFP annual leadership kickoff.  Last night we did our first review of the graphic designs that were graciously done pro bono for the project.

It amazed me a bit how varied the feedback was.  On most points there were people that had absolutely opposite opinions, and who agreed or disagreed with a point varied over ever detail discussed.  It was spiritted but friendly.  After about an hour of discussion we boiled it down to a base design, plus 6 concrete pieces of feedback that everyone wanted to see integrated.

I was thinking about why there was so many differences of opinion, and I realized web design committees are so tough because our interactions with the web are so personal.  Browsing the web is a solitary experience.  Everyone forms their opinions of what is good and bad in a vacuum, not influenced by others.  This leads to opinions on good vs. bad designs that vary drastically.  Page width/height issues, rotating content/or not, colors that are good or bad, what makes a good logo, how busy should things be, how often should things change.

Every one of us has some strong opinions in those areas due to what each of us use the internet for.  That diversity of purpose is what makes the web as ubiquitous as it is, but it definitely makes the design process challenging, because we all tend to believe the rest of the world uses the internet the way we do.  Which, ironically, is the only demonstrably false opinion that arises during the process.

Daily links valuable or not?

I’m curious if the couple of people that read this find the daily links valuable or not?  I’ve been wondering if I should keep them here, or put up something like lifestream on a suburl with them, making the main blog just original content.  I’m currently on the fence, and comments would be appreciated.