Skip to content

Instantly share code, notes, and snippets.

@shaunlebron
shaunlebron / hourglass.py
Last active Sep 29, 2015
Measuring arbitrary times using arbitrary hourglasses
View hourglass.py
def print_target_moves(aTimeCapacity, bTimeCapacity, targetTime):
'''
Given two hourglasses with respective time capacities,
print out a process for measuring the given target time
without going over that time.
An hour glass can only be flipped when any of them have run out.
TODO: generalize to multiple hour-glasses
'''
moves = []
@shaunlebron
shaunlebron / river.lp
Created Mar 27, 2012
Carcassonne Contiguous River Generator
View river.lp
% the tile width of the rectangular map
#const width=4.
positions(0..11).
rotations(0..3).
% piece(number, side, side type [g=grass, w=water, c=city, r=road]).
piece( 1,0,g ;; 1,1,g ;; 1,2,g ;; 1,3,w).
piece( 2,0,g ;; 2,1,g ;; 2,2,g ;; 2,3,w).
piece( 3,0,g ;; 3,1,w ;; 3,2,g ;; 3,3,w).
View ConvertTableToTree.py
entries = getListOfTableEntriesSomeWhere()
entryTree = MyTree(entries)
################################
def group_entries(groupclass, entries, keyfunc):
return [groupclass(k,g) for k,g in itertools.groupby(entries,keyfunc)]
key_sys = lambda x: x.sys
key_subsys = lambda x: x.subsys
@shaunlebron
shaunlebron / test.clj
Created Nov 12, 2015
paren mode shift case
View test.clj
(def foo| (bar
baz))
View test.md
(define (make-link x)
  `(a [[href "#top"] [class "internal"]]
      ,(splice x)))
@shaunlebron
shaunlebron / parinfer-benchmarks
Created Dec 24, 2015
current parinfer benchmarks
View parinfer-benchmarks
$ node test/perf.js
Testing file with 2865 lines
indent: 62.065ms
paren: 52.131ms
$ /usr/sbin/system_profiler SPHardwareDataType
Hardware Overview:
Model Name: MacBook Pro
@shaunlebron
shaunlebron / gfm-bug-example.md
Last active Dec 24, 2015
A GFM bug - displaying code after a list
View gfm-bug-example.md
  • item 1

  • item 2

  • item 3

    // code here

should be equivalent to...

  • item 1
View gist:1f285bfb05305418f95d9e4cc7cf3c75
if [ ! -f .classpath ]; then
classpath=`boot show -c | tee .classpath`
else
classpath=`cat .classpath`
fi
planck -c $classpath ...
View sitegen-markdown.cljs
(ns sitegen.markdown
(:require
[clojure.string :as string]
[planck.core :refer [file-seq slurp]]
[clojure.walk :refer [keywordize-keys]]))
(def ^:dynamic *filename*)
(defn error [msg]
(throw (str "markdown metadata error: " msg " - " *filename*)))
View markdown_with_meta.cljs
(ns sitegen.markdown
(:require
[clojure.string :as string]
[planck.core :refer [file-seq slurp]]
[clojure.walk :refer [keywordize-keys]]
[cljs.pprint :refer [pprint]]))
(def ^:dynamic *filename*)
(defn error [msg]
(throw (str "markdown metadata error: " msg " - " *filename*)))