Pipe Viewer (pv) is Pretty Swell

A pretty common task in my workflow is updating my development database to what's currently on the live servers. The database isn't too large, but it does take about 30 seconds to import -- and I do positively loathe not knowing what's going on. Enter pipeviewer! I remembered reading a post that was linked off reddit some number of internet decades ago.

With this mighty tool in hand, I set to apply it to those 30 seconds of terrifying mystery that MySQL was plaguing my dreams with.

pv databasedump.sql | mysql -uDATABASEUSER -p databasename

And like magic, a beautiful progress bar was rendered. Life had incrementally improved.

I'd also recently used pv to watch the progress of dd-ing an ISO onto a USB stick, like so:

pv -ptre ubuntu-10.04-desktop-i386.iso | dd of=/dev/disk1 bs=1mb
  • The "-ptre" turns on all the rate monitors and progress bars and such.
  • /dev/disk1 is where OSX had my USB stick mounted.
  • bs=1mb sets the blocksize of dd to 1 megabyte, which made the copying process go a lot faster (minutes instead of hours.)
Posted in Messing With Stuff | Tagged , , | Leave a comment

Django TestCase Comedy

Here's a little snippet that'll entertain the vast throngs of people who are interested in both Rock Paper Scissors strategy and Django unit testing.

def test_desperate_futility_of_avalanche(self):
        for futile_attempt in range(100):
            Round.objects.create(game=self.normal_game,
                                 initiator_choice=self.rock,
                                 opponent_choice=self.rock)
        self.failUnlessEqual(self.normal_game.result(), UNRESOLVED)

For the uninitiated:

Posted in Comedy, Messing With Stuff | Tagged , , , , | 1 Comment

I will thoughtfully respond to all spam comments on this post

Hit me, robots!

Posted in Comedy | Tagged | 22 Comments

My Incredible New Web Property

Through the magic of statistical analysis, I have created a mostly-correct am-i-jogging-in-the-near-future detector.

Will I Jog?

Behold!

Posted in Comedy, Projects | Tagged , , | 2 Comments

Implementing Partials in Python

A colleague of mine was wistfully pining for Haskell-style currying in Python. This sounded like an interesting syntactic feature, so I decided to see if I could toss together something that would at least emulate the behavior of returning functions when a function is called with too few arguments. I've always admired the flexibility of python, so it seemed like an interesting challenge to prove that.

Using a decorator seemed like a bit of a copout due to the additional syntax required, but was otherwise ideal, as it made checking arguments fairly trivial.

def partial(f):
    def wrapper(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except TypeError, t:
            return lambda *_args,**_kwargs:f(*(args+_args), **(dict(kwargs.items()+_kwargs.items())))
    return wrapper

Read More »

Posted in Messing With Stuff | Tagged , , | Leave a comment