Skip to content

Instantly share code, notes, and snippets.

@zerokarmaleft
zerokarmaleft / strangeloop.org
Last active August 29, 2015 14:06
if I were going... :(

Wednesday

Workshops

  • Program Synthesis using miniKanren
"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 / 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
@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])
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 / aws-application.rb
Created April 21, 2011 19:51
Retrieving album cover art from AWS with MacRuby and Sucker
framework 'Cocoa'
require 'rubygems'
require 'sucker'
application = NSApplication.sharedApplication
worker = Sucker.new(
:locale => :us,
:key => aws_key,
@zerokarmaleft
zerokarmaleft / clj_lab.rb
Created September 26, 2011 18:07
accessing clojure's PersistentHashMap from jruby
require 'java'
require 'clojure'
module Clojure
include_package 'clojure.lang'
end
foo = Clojure::PersistentHashMap.create(:a, 1)
# => {:a=>1}
foo.assoc(:e, 5)
@zerokarmaleft
zerokarmaleft / stress-ref.clj
Created September 29, 2011 20:45
SLIME doesn't display the println
(defn stress-ref
[r]
(let [slow-tries (atom 0)]
(future
(dosync
(swap! slow-tries inc)
(Thread/sleep 200)
@r)
(println (format "r is: %s, history: %d, after: %d tries"
@r (ref-history-count r) @slow-tries)))
@zerokarmaleft
zerokarmaleft / gist:1338369
Created November 4, 2011 00:35
sm --trace cli dev setup core setup
+/Users/zerokarmaleft/.sm/core/cli/shell/dev/functions:69 sm_development_setup():66 > git clone https://github.com/sm/sm-extensions extensions
Cloning into extensions...
fatal: https://github.com/sm/sm-extensions/info/refs not found: did you run git update-server-info on the server?
+/Users/zerokarmaleft/.sm/core/cli/shell/dev/functions:70 sm_development_setup():67 > __sm.log.error 'There was an __sm.log.error cloning extensions repository from https://github.com/sm/sm-extensions into /Users/zerokarmaleft/projects/sm/extensions.'
+/Users/zerokarmaleft/.sm/core/sm/shell/log/functions:343 __sm.log.error():2 > printf 'ERROR(__sm.actions.call): There was an __sm.log.error cloning extensions repository from https://github.com/sm/sm-extensions into /Users/zerokarmaleft/projects/sm/extensions.\n'
ERROR(__sm.actions.call): There was an __sm.log.error cloning extensions repository from https://github.com/sm/sm-extensions into /Users/zerokarmaleft/projects/sm/extensions.
+/Users/zerokarmaleft/.sm/core/sm/shell/log/func
@zerokarmaleft
zerokarmaleft / gist:1410689
Created November 30, 2011 20:31 — forked from buddylindsey/gist:1410596
Max-Heap
#include <iostream>
#include <stdlib.h>
#include <limits.h>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
ofstream outfile;