Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am zerokarmaleft on github.
  • I am zerokarmaleft (https://keybase.io/zerokarmaleft) on keybase.
  • I have a public key ASCmPSKLtqR_ZyuG3chst6HWkG8UrLmlmB_4Hbpvq4i0iQo

To claim this, I am signing this object:

upstream http_backend {
server localhost:3000;
keepalive 32;
}
server {
location /ralphedwards/ {
proxy_pass http://http_backend/;
proxy_http_version 1.1;
proxy_set_header Connection "";
@zerokarmaleft
zerokarmaleft / arith.clj
Last active August 29, 2015 14:10
TAPL with core.typed
(ns arith.core
(:require [clojure.core.typed :refer [ann defalias Rec U Val Int]]
[clojure.core.match :refer [match]]))
(defalias Expr
(Rec [Expr]
(U '[(Val :zero)]
'[(Val :succ) Expr])))
(ann evaluate [Expr -> Int])
@zerokarmaleft
zerokarmaleft / core.cljs
Last active August 29, 2015 14:10
core.async and js-csp side-by-side
(ns vending-machine.core
(:require [cljs.core.async
:refer [<! >! chan timeout]]
[figwheel.client :as figwheel
:include-macros [true]]
[om.core :as om
:include-macros true]
[sablono.core :as html
:refer-macros [html]])
(:require-macros [cljs.core.async.macros
"X1. A drinks dispenser has two buttons labelled ORANGE and
LEMON. The actions of pressing the two buttons are /set-orange/ and
/set-lemon/. The actions of dispensing a drink are /orange/ and
/lemon/. The choice of drink that will be dispensed is made by
pressing the corresponding button. Before any button is pressed, no
drink will be dispensed."
(declare orange lemon)
(def c (chan))
@zerokarmaleft
zerokarmaleft / strangeloop.org
Last active August 29, 2015 14:06
if I were going... :(

Wednesday

Workshops

  • Program Synthesis using miniKanren
@zerokarmaleft
zerokarmaleft / memoization.py
Created September 10, 2014 20:18
Memoization is a performance optimization, not a means to achieve referential transparency
# Memoization doesn't get you all the way there. While a memoized
# function might exhibit referential transparency *at two successive
# callsites*, your program as a whole will not exhibit that
# property. An example with destructive updates of a mutable data
# structure, an inherently effectful operation:
phonebook = {}
# assuming this function is augmented with memoization
var Lazy = require('lazy.js');
function isHeads(x) { return x >= 0.5; }
function isTails(x) { return x < 0.5; }
function toss(n) {
var successes = Lazy.generate(function() { return Math.random(); })
.take(n)
.filter(isHeads)
.size();
{-# LANGUAGE DeriveGeneric
, FlexibleInstances
, OverloadedStrings
, ScopedTypeVariables
, TypeSynonymInstances #-}
module Main where
import Control.Monad
import Data.Aeson.Types
{-# LANGUAGE OverloadedStrings, ScopedTypeVariables, DeriveGeneric #-}
module Main where
import Data.Aeson.Types
import qualified Data.ByteString.Lazy as BSL
import qualified Data.ByteString.UTF8 as UTF8
import GHC.Generics
import Network.Riak