Skip to content

Instantly share code, notes, and snippets.

@tombatron
tombatron / gist:2851183
Created June 1, 2012 10:58
Base tests for Google App Engine Projects (Python)
import os
import unittest
import xmlrpclib
from google.appengine.datastore import datastore_stub_util
from google.appengine.ext import testbed
from webtest.app import TestApp
import main
class TestingHighReplicationConsistencyPolicy(datastore_stub_util.BaseHighReplicationConsistencyPolicy):
def _ShouldApply(self, txn, meta_data):
@tombatron
tombatron / all-pictures.js
Created August 24, 2012 02:39
Javascript fragment used to display all pictures on my baby's blog.
(function ($) {
"use strict";
var nextLinkRegex = /<a.* href='(.*)'>Older Posts<\/a>/g,
picturesRegex = /<a.*><img.*><\/a>/g,
$babyPictureList = $('#baby_pictures');
(function scrapePictures(url) {
var nextUrl = null;
@tombatron
tombatron / Moving On
Created August 30, 2012 11:08
You don't have to go home, but you can't stay here.
There comes a time in every developer's life when it's time to move on. Sometimes it's your choice, sometimes the choice is made for you, either way you're going. This post is about how I've dealt with both situations.
Your Choice
So you've decided it's time for you to move on.
There are a few questions that you need some solid answers to first.
Why are you leaving?
@tombatron
tombatron / gist:4010049
Created November 4, 2012 03:42
A VBScript class for converting Kofax MFA files to regular TIFF files.
Class MfaImageConverter
Private sourceFileStream
Private sourceFileHexStream
Private convertedFileStream
Private convertedFileHexStream
Private Sub Class_Initialize()
Set sourceFileStream = CreateObject("ADODB.Stream")
sourceFileStream.Type = 1 ' Binary
@tombatron
tombatron / gist:4416637
Created December 31, 2012 01:22
Decompress zlib'd data
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ionic.Zlib;
namespace TestZlib
{
class Program
@tombatron
tombatron / life.py
Last active December 11, 2015 23:58
PyLife
import curses
import random
class Life(object):
max_x = 200
max_y = 60
_grid = {}
import random
import numpy
class Cell(object):
x = None
y = None
is_alive = None
_neighbors = None
@tombatron
tombatron / gist:5173058
Created March 15, 2013 20:58
Archiving only changed files between revisions in hg.
From bash...
hg grep -r rev1:rev2 --all . | cut -d : -f 1 | sort -u | sed 's/^/-I /' | xargs echo hg archive
namespace TestingApplication
{
using CommandLine;
using CommandLine.Text;
public class Options
{
[VerbOption("testverbone", HelpText = "Test Verb One.")]
public RssSubOptions RssVerb { get; set; }
@tombatron
tombatron / gist:a27a695ff4d9792b621a
Created October 18, 2014 23:42
Custom Command Line Prompt
export PS1="(#\#) @ \d \t : \w \r\n->"