Skip to content

Instantly share code, notes, and snippets.

@jamis
jamis / keybase.md
Created Sep 23, 2014
Verifying my GitHub identity with Keybase.io
View keybase.md

Keybase proof

I hereby claim:

  • I am jamis on github.
  • I am jamis (https://keybase.io/jamis) on keybase.
  • I have a public key whose fingerprint is D6BF 2C78 D257 1F45 892A F160 3E22 BCB7 321F F098

To claim this, I am signing this object:

@jamis
jamis / grid.txt
Created Aug 4, 2015
A program for solving Sam Lloyd's "Back from the Klondike" puzzle.
View grid.txt
__________xxx__________
_______xxx477xxx_______
_____xx544833463xx_____
____x1451114517135x____
___x494967555876685x___
__x37298356739187585x__
__x14784292711822763x__
_x7218553113133428613x_
_x4267252422543281773x_
_x4165111914344319827x_
@jamis
jamis / maze.erl
Created Aug 17, 2015
An implementation of the Recursive Backtracker maze generation algorithm in Erlang
View maze.erl
-module(maze).
-export([generate/2,north/3,south/3,west/3,east/3,visualize/1]).
% Generate and return a maze of width W and height H.
generate(W,H) -> try_directions(random:uniform(W)-1, random:uniform(H)-1, directions(), {width,W,height,H,0}).
% Returns true if there is a passage north from the given position in the maze.
north(X,Y,Maze) -> at(X,Y,Maze) band 2#1 =/= 0.
% Returns true if there is a passage south from the given position in the maze.
@jamis
jamis / maze.hs
Last active Aug 29, 2015
An implementation of the Recursive Backtracker maze generation algorithm in Haskell
View maze.hs
{- --------------------------------------------------------------------------
- A naive random maze generator.
-
- $ ghc -o maze Maze.hs
- $ maze 10 10
-
- Author: Jamis Buck (jamis@jamisbuck.org)
- ------------------------------------------------------------------------ -}
module Main where
@jamis
jamis / client.rb
Created Aug 26, 2008
Demonstration of how to use Net::SSH::BufferedIo independently of Net::SSH
View client.rb
require 'net/ssh/buffered_io'
require 'socket'
client = TCPSocket.new("localhost", 1234)
client.extend(Net::SSH::BufferedIo)
loop do
readers, writers = IO.select([client], [client], nil, 1)
next if readers.nil?
@jamis
jamis / http-proxy-server.rb
Created Feb 3, 2009
A trivial HTTP proxy server for testing and troubleshooting
View http-proxy-server.rb
# This is a trivial HTTP proxy server, intended for use as a troubleshooting tool
# ONLY (not for real, actual, production use). I wrote this because I couldn't find
# a simple HTTP proxy that I could use to test HTTP proxy support in Net::SSH.
#
# This code is in the public domain, so do with it what you will!
require 'socket'
port = ARGV.shift || 8080
address = ARGV.shift || "127.0.0.1"
@jamis
jamis / codes.rb
Created Feb 4, 2009
A basic substitution-cipher puzzle generator. Uses Prawn (0.5 or later) for PDF output. Sample output: http://www.jamisbuck.org/files/codes.pdf
View codes.rb
# Generates a series of substitution cipher puzzles. The messages to
# "encrypt" are take from a text file passed on the command-line,
# where each message is on one line.
#
# The output is a PDF, "codes.pdf".
#
# This was written for my 7 year-old, who loves doing substitution
# ciphers.
require 'prawn'
@jamis
jamis / bundle.rb
Created May 15, 2009
Creates a stand-alone ruby script that bundles all dependencies
View bundle.rb
#!/usr/bin/env ruby
# ------------------------------------------------------------------------
# bundle.rb
# author: Jamis Buck <jamis@37signals.com>
# usage: ruby bundle.rb <config.yml>
#
# Takes a configuration file in YAML format and writes a single ruby script
# that includes all the dependencies you specify. For example:
#
@jamis
jamis / gist:194394
Created Sep 26, 2009
A great recipe for a flavorful pear pie.
View gist:194394
AWESOME PEAR PIE
----------------
Ingredients:
Crust:
* Your favorite 9" double crust pastry recipe (I use the one in the Better
Homes and Gardens cook book)
@jamis
jamis / i18n.vim
Created Oct 29, 2009
Quickly look up Rails translation strings
View i18n.vim
" Lets you quickly find translation strings. Position your cursor over a translation
" key, type '<leader>rt' (whatever your leader character is configured to be, usually
" backslash, but I have mine set to comma) and the screen will split to show the
" corresponding translation string in config/locales/en.yml.
"
" Right now, this only supports en.yml, and does not search any other locations.
" Also, error handling is abysmal. :) But it does what I need. If you hack it up
" and make it better, let me know!
" MatchPatternAtCursor lifted (and renamed) from rails.vim, thanks tpope! :)