Skip to content

Instantly share code, notes, and snippets.

View mrb's full-sized avatar
🍕
Helping companies market and sell more software

Michael Bernstein mrb

🍕
Helping companies market and sell more software
View GitHub Profile
@thezerobit
thezerobit / prolog peano
Created January 5, 2014 20:54
Peano relation in Prolog using the CLP(FD) that ships with SWI-Prolog.
:- use_module(library(clpfd)).
peano(N,z) :- N #= 0.
peano(N,s(PDec)) :-
N #> 0,
N - 1 #= NDec,
peano(NDec, PDec).
% ?- peano(4, Q).
% Q = s(s(s(s(z)))) ;
(load "mkprelude.scm")
(define peanoo
(lambda (n out)
(conde
[(== n (build-num 0)) (== '(O) out)]
[(fresh (n1 res)
(-o n (build-num 1) n1)
(conso 'S res out)
(peanoo n1 res))])))
@bryanwoods
bryanwoods / favoritebooks.txt
Created December 17, 2013 18:56
My favorite books I read in 2013, alphabetical by author's name
The Verificationist - Donald Antrim
what purpose did i serve in your life - Marie Calloway
The Last Samurai - Helen DeWitt
The White Album - Joan Didion
The Orphan Master's Son - Adam Johnson
Taipei - Tao Lin
The Twelve Tribes of Hattie - Ayana Mathis
The Road - Cormac McCarthy
Swamplandia! - Karen Russell
Journalism - Joe Sacco
(ns knossos.redis
(:use knossos.core))
;; System state
(defn node
"A node consists of a register, a primary it replicates from, whether it is
isolated from all other nodes, a local replication offset, and if it is a
primary, a map of node names to known replication offsets."
[name]
@patrickt
patrickt / Overture.hs
Created September 26, 2013 23:02
A drop-in replacement for the Haskell Prelude.
module Prelude.Overture
( module X
)
where
-- Haskell 98 stuff is easier to get at through the Prelude
-- than through the GHC-specific modules
import Prelude as X ( Bounded (..)
, Enum (..)
, Floating (..)
@ericmoritz
ericmoritz / .gitignore
Last active December 21, 2015 13:19
A simple Haskell program to bump a semantic version number by 1
*.hi
*.o
bin/
*~
(ns async-test.core
(:require [cljs.core.async :refer [chan]]
[clojure.string :as string])
(:require-macros
[cljs.core.async.macros :as m :refer [go alt! alts!]]))
(def c (chan))
(def loc-div (.getElementById js/document "location"))
(.addEventListener js/window "mousemove"
#!/bin/bash
# Bandwidth throttling for OSX,
# http://www.macosxhints.com/article.php?story=20080119112509736
case "$1" in
'start')
KB=$2
echo Throttling at $KB Kbytes/s
sudo ipfw pipe 1 config bw "$KB"KByte/s
-define(case_inf(E, E0, FC, E1, AC, E2, A, F, E3),
begin
AInf = (E),
if
not AInf ->
E0;
is_function(AInf) ->
FC = AInf,
E1;
is_tuple(AInf) andalso size(AInf) == 2 andalso is_function(element(2,AInf)) ->
@mrb
mrb / coll.rkt
Last active December 17, 2015 13:29
Annoted mark and sweep collector in Racket, with the test code removed. From https://github.com/plt/racket/blob/master/collects/tests/plai/gc/good-collectors/good-collector.rkt#L28-L30
#lang plai/collector
;; A tri-color mark and sweep algorithm. There are three sets of heap nodes:
;; gray, white, and black. Black nodes are known to not be garbage or hold
;; references to garbage, gray nodes are known to not be garbage but their
;; references have not been checked, and white nodes, the rest, are garbage.
;; * The black set begins empty
;; * The gray set begins with the roots
;; * All non root nodes begin in the white set
;; * Iterate over the gray set. "Blacken" each node by "graying" the nodes