Pat Hawks

Read this first

Grokking Signed Overflows

View →

Recursion: Moving away from the Base Case

Can we send in a negative number into the parameter of a recursive function, such that it steps further away from the base case with each iteration?


What will happen if we do? There are two answers, the practical and the theoretical.

Practical: The program will run for a while, but eventually crash.

With each iteration, we are moving further away from our base case. After some time, the computer will likely run out of memory and segfault.

Theoretical: But what if it didn’t crash?

Here is the code we will be examining:

#include <iostream>
using namespace std;

void recFun(int u)
    if (u == 1)
        cout << "Stop!" << endl;
        cout << u << endl;
        recFun(u - 1);

int main(void)

GCC is pretty smart, and if we ask it nicely, it can perform some optimizations that will allow our recursive function to execute without...

Continue reading →

Jekyll Meta Includes

 The Problem

In Jekyll, I have a lot of code that will include a <meta> tag if a certian property is set.

The code for this looks terrible, and is terribly repetative.

{% if site.title %}
    <meta property="og:site_name" content="{{ site.title }}" />
{% endif %}

{% if page.url %}
    <meta property="og:url" content="{{ page.url }}" />
{% endif %}

{% if page.thumbnail %}
    <meta property="og:image" content="{{ page.thumbnail }}" />
{% endif %}

{% if %}
    <meta property="article:published_time" content="{{ }}" />
{% endif %}


 The Solution

I have come up with a solution!

Using Jekyll’s (new?) Include paramaters, I can create one file that checks
to see if a certian variable exists and – if so – will include the proper <meta> tag.

This file looks like this.

{% if include.content %}
<meta property="{{ }}" content="{{ include.content

Continue reading →

Is Jekyll Lightweight?


Super lightweight CMS.

…once you install XCode (2.09 GB) and figure out how to get Ruby working.

View →

I hate Subversion

Pull Requests make Open Source Software.

GitHub makes Pull Requests easy.

When Pull Requests are easy, it encourages tinkering and sharing your changes upstream.

WordPress insists on using Subversion for the plugins repository.
This makes tinkering and sharing changes quite difficult, as it has to be done through some external means of communication.

What I would love would be if started using GitHub for the plugins repository.

Short of that, I would like to host my plugin on both GitHub and the WordPress Subversion beast. I would like both repositories to always be in sync.

This is far easier said than done.

I have been able to import my WordPress plugin’s Subversion repo to Github, but I still don’t really have a way to push to both locations at the same time.

Yes, I have tried git-svn. What a mess.

I guess I will probably end up using GitHub for development, and...

Continue reading →


iDesignTimes screenshot

I neither like you, nor follow you, nor do I appreciate the loud autoplaying video that has nothing to do with the content on the page.

This was my first time visiting your website; I followed a link from Techmeme.

If you pause the video, it will automatically resume playing (with sound) after an interval.

While not displayed here, if you scroll down just a bit, there is another Facebook/Twitter banner in the middle of the story!

I’ll not be returning.

View →

Cross-Origin Track

Can somebody please explain to me why <script>, <img>, <audio>, and <video> will happily display contents cross-origin, but <track> is freaking sacred and needs to follow much stricter rules?

This is madness!

If I can play a video from server X, why can’t I display captions from that server as well?

View →

HandBrake 0.9.9

It looks like the next version of HandBrake is nearing release.

For those not familiar, HandBrake is a wonderful video transcoder that supports many formats and lots of options for tweaking.

One of my favorite features from this new version (and one of the first you’re likely to notice) is the new interface for H.264 options. Rather than dealing with the Advanced panel, you can just specify the profile, level, and type of content to tune for.

For instance, if you need a video to work on a range of phones or tablets, you could specify Main profile, level 3.1 and tune for animation. Or maybe you’d tune for PSNR, or SSIM. And all this without having to deal with the Advanced options.

Still on my HandBrake wishlist:

  • Support for VP8 (or even the upcoming VP9)
  • More options for audio compression
  • OGG support, for encoding videos that work in older versions of Firefox (though I’m not...

Continue reading →

WebVTT Observations


The WebVTT Draft Spec has been updated to allow metadata headers. This corrects all the issues outlined in this post. :)

According to the WebVTT Draft Spec, a WebVTT file must start with the string “WEBVTT” followed by some text that does not include a line break, followed by two line breaks. This pretty much kills the idea of including header metadata. Yet, WebVTT files produced by YouTube break this rule and include some extra data in the header (along with line breaks), breaking the spec.

Kind: captions
Language: en

It would be nice if the spec allowed for metadata to be added like this. It would be nice if the spec allowed for something like RDF or microdata, but I understand that one of the beauties of WebVTT is its low markup to content ratio.

Additionally, it would be nice to have support for a GUID, or even an alternative content link to the webpage where...

Continue reading →

Jekyll Spaghetti Code

So, it’s probably just because I’m a WordPress guy, but after using Jekyll for a while, I feel like it’s primitive templating system breeds unmaintainable spaghetti code.

I have lots of code duplicated in funny places, which is bad.

I have to resort to all sorts of tricks to minify my output, otherwise any line with nothing but a Liquid tag (there are many lines like this) will output an indented blank line.

Creating an ATOM feed that includes everything I’m used to including is a nightmare.

layout: minify-xml
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="" xmlns:geo="" xmlns:georss='' xmlns:thr='' xmlns:gd='' xmlns:wfw=""

Continue reading →