Skip to content

Instantly share code, notes, and snippets.

import re
from itertools import permutations
puzzle_input = """
Tristram to AlphaCentauri = 34
Tristram to Snowdin = 100
Tristram to Tambi = 63
Tristram to Faerun = 108
Tristram to Norrath = 111
Tristram to Straylight = 89
import errno
import logging
import mmap
import struct
from ctypes import *
logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)
def _get_terminal_size():
rows, columns = os.popen('stty size', 'r').read().split()
return int(rows), int(columns)
def _stdout_pipe(channel):
pipe = make_pipe()
channel.in_buffer.set_event(pipe)
return pipe.fileno()
// A circle is defined by x^2 + y^2 = r
// The perimeter of a circle is 2 \pi r
// Well, let's start with the easy one: four segments
// 1. If we say the radius is 150, then the points are:
// (0, 150) - (150, 0) - (0, -150-) - (-150, 0) - ...
interface DrawWithLength {
void draw_with_length(float length);
}
@ligfx
ligfx / ast.py
Last active August 29, 2015 14:13
lisppython
from collections import namedtuple
FloatExpression = namedtuple('FloatExpression', ['value'])
FormExpression = namedtuple('FormExpression', ['call', 'datums'])
IntegerExpression = namedtuple('IntegerExpression', ['value'])
ListExpression = namedtuple('ListExpression', ['datums'])
SymbolExpression = namedtuple('SymbolExpression', ['value'])
@ligfx
ligfx / gist:fab8b45680528582e87a
Last active August 29, 2015 14:10
parsing with derivatives
def expect(char, letter):
assert char == letter, "expected '%s', got '%s'" % (letter, char)
def helloStarParser(char):
expect(char, 'h')
return elloHelloStarParser
helloStarParser.matchesEmpty = True
def elloHelloStarParser(char):
expect(char, 'e')
@ligfx
ligfx / gibbs.R
Last active August 29, 2015 14:01
source("runhaskell.R")
plot(runhaskellJ("Gibbs.main"), type="l")
@ligfx
ligfx / docker.rb
Last active August 29, 2015 14:01
require "formula"
class Docker < Formula
homepage "http://docker.io"
url "https://github.com/dotcloud/docker.git", :tag => "v0.11.1"
option "without-completions", "Disable bash/zsh completions"
depends_on "go" => :build
@ligfx
ligfx / nice-docker-on-mac-os-x.md
Last active August 29, 2015 14:01
Nice Docker on Mac OS X

kitten

Setup

Compile docker using the patch described at docker/docker#5813 dynbinary and netgo. This disables the netgo package, which doesn't support mDNS name resolution. You can use my gist michaelmaltese/docker.rb:

brew install https://gist.githubusercontent.com/michaelmaltese/1756c9ce071dea6c4edf/raw/3976a993814d46febf144754f7f3bfe22cebed2f/docker.rb