Skip to content

Instantly share code, notes, and snippets.

View gist:7991030
Tom Moertel <>
We are given the following problem:
Given a text file with 999,999 lines, one number per line,
numbers in random order from 1 to 1,000,000 but a single number is
missing, figure out what number is missing.
tmoertel / gist:7968466
Last active December 31, 2015 09:39
The following proof is a solution to the exercise I offered to readers in the blog post [A Great Old-Timey Game-Programming Hack](
View gist:7968466
Tom Moertel <>
The following proof is a solution to the exercise I offered to readers
in the following blog post:
"A Great Old-Timey Game-Programming Hack"
tmoertel / gist:7586779
Last active December 29, 2015 00:29
Summary of crashes in Android apps that use Chromecast device discovery
View gist:7586779
Summary: A few days ago, some Chromecast-supporting Android apps
started crashing upon launch. Other Android apps, notably YouTube,
remain unaffected, as do iOS apps and Chromecast support in Chrome
(see table below). Today, I discovered that these crashes go away
when I remove the SONOS BRIDGE device that connects my SONOS audio
system to the same network.
My hypothesis: There is some interaction between the Chromecast
device-discovery logic and the SONOS bridge's presence on the network
that causes the problem. The most likely explanation for why these
tmoertel / gist:5798134
Last active August 26, 2021 10:46
How to transform the vanilla recursive fib function into the iterative DP version through a series of mechanical steps.
View gist:5798134
# Transforming the vanilla recursive fib into the iterative DP version
# through a series of mechanical steps.
# For more on converting recursive algorithms into iterative ones, see:
# original function
def fib(n):
tmoertel / diskdiffs.R
Created April 29, 2012 04:40
Small R script to visualize bit differences between two disk images
View diskdiffs.R
disk_errors <- read.csv("disk_errors.csv", header=F)
names(disk_errors) <- c("byte_offset", "bit", "a", "b")
disk_errors <- mutate(disk_errors,
bit = factor(bit),
tmoertel /
Created April 29, 2012 04:38
Compare two disk images and emit CSV file listing bit-position differences
#!/usr/bin/env python
# Compare two disk images for bit differences.
# Usage: ./ diskA.dsk diskB.dsk
# Tom Moertel <>
# 2012-04-29
import sys
tmoertel / gist:177024
Created August 28, 2009 15:06
Puppet can't find class
View gist:177024
class x {
notify { xn: message => "x" }
define y() {
notify { yn: message => "y", require => Class["x"] }
y { "test": }
View gist:175795
# The Puppet definition below produces following error when called as
# set_up_service_with_ssh_key("X"):
# err: Could not create ssh key Y for X: user X doesn't exist
# But the ssh_authorized_key resource requires User["X"].
# Am I missing something?
define set_up_service_with_ssh_key($service_name) {
View gist:94874
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="" lang="en" xml:lang="en">
<base href="" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="en" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="alternate" type="application/atom+xml" title="YAPC|10"
View gist:91328
From: Tom Moertel <>
To: Perl trainers and instructors:;
At YAPC|10, we're handling courses and training a bit differently than
at previous YAPCs. We are making the official Call For Courses soon,
but because you have led Perl training at past YAPCs or have indicated
interest in offering courses at YAPC|10, we wanted to let you know
directly. If you know of anybody else who would want to know, please