Skip to content

Instantly share code, notes, and snippets.

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 Jan 5, 2014
Peano relation in Prolog using the CLP(FD) that ships with SWI-Prolog.
View prolog peano
:- 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)))) ;
View gist:8265340
(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 Dec 17, 2013
My favorite books I read in 2013, alphabetical by author's name
View favoritebooks.txt
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
View gist:7965505
(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 Sep 26, 2013
A drop-in replacement for the Haskell Prelude.
View Overture.hs
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 Dec 21, 2015
A simple Haskell program to bump a semantic version number by 1
View .gitignore
*.hi
*.o
bin/
*~
View radical.cljs
(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"
View throttle
#!/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
View macro.erl
-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 Dec 17, 2015
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
View coll.rkt
#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
You can’t perform that action at this time.