Skip to content

Instantly share code, notes, and snippets.

View gregnavis's full-sized avatar

Greg Navis gregnavis

View GitHub Profile
@gregnavis
gregnavis / Makefile
Last active September 4, 2015 02:44
A simple generator of Clifford attractors. Issue `make` to build it (requires `libnetpbm10-dev` on Debian).
CFLAGS=-lm -lnetpbm
clifford: clifford.c
@gregnavis
gregnavis / sudoku.rb
Created April 13, 2013 22:44
A simple Sudoku solver in Ruby.
class Sudoku
SIZE = 9
NUMBERS = (1..9).to_a
def initialize
@board = Array.new(SIZE) { Array.new(SIZE, nil) }
end
def [](x, y)
@board[y][x]
@gregnavis
gregnavis / call_tracer.py
Created February 26, 2014 12:23
This is an example of an automatic call tracer that can report the whole call tree. I use it instead of adding lots of logging statements.
import bdb
# This is a custom debugger that calls the specified handler on each function
# call.
class _CallTracerBdb(bdb.Bdb):
def __init__(self, call_handler, return_handler):
bdb.Bdb.__init__(self)
self._call_handler = call_handler
self._return_handler = return_handler
@gregnavis
gregnavis / insert_query.rb
Created April 15, 2015 21:44
An InsertQuery object that can be used to insert models in bulk.
class InsertQuery
def initialize(model_class, column_names, returning = nil)
@model_class = model_class
@column_names = column_names
@returning = returning
@rows = []
@executed = false
end