Skip to content

Instantly share code, notes, and snippets.

Tom Moertel <[email protected]>
2013-12-16
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.
Source: http://blog.moertel.com/posts/2013-12-14-great-old-timey-game-programming-hack.html#comment-1165807320
@tmoertel
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](http://blog.moertel.com/posts/2013-12-14-great-old-timey-game-programming-hack.html).
Tom Moertel <[email protected]>
2013-12-14
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"
http://blog.moertel.com/posts/2013-12-14-great-old-timey-game-programming-hack.html
@tmoertel
tmoertel / gist:7586779
Last active December 29, 2015 00:29
Summary of crashes in Android apps that use Chromecast device discovery
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
tmoertel / gist:5798134
Last active April 8, 2024 21:34
How to transform the vanilla recursive fib function into the iterative DP version through a series of mechanical steps.
# 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:
# http://blog.moertel.com/posts/2013-05-11-recursive-to-iterative.html
# original function
def fib(n):
@tmoertel
tmoertel / diskdiffs.R
Created April 29, 2012 04:40
Small R script to visualize bit differences between two disk images
library(ggplot2)
library(scales)
library(plyr)
library(reshape2)
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
tmoertel / cmpdisks.py
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: ./cmpdisks.py diskA.dsk diskB.dsk
#
# Tom Moertel <[email protected]>
# 2012-04-29
import sys
@tmoertel
tmoertel / gist:177024
Created August 28, 2009 15:06
Puppet can't find class
class x {
notify { xn: message => "x" }
}
define y() {
notify { yn: message => "y", require => Class["x"] }
}
y { "test": }
# 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) {
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<base href="http://yapc10.org/yn2009/" />
<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"
From: Tom Moertel <[email protected]>
To: Perl trainers and instructors:;
Reply-To: [email protected]
Subject: YAPC|10: CALL FOR COURSES
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