Skip to content

Instantly share code, notes, and snippets.

View orb's full-sized avatar

Norman Richards orb

View GitHub Profile
deploy_revision "/opt/myapp/deploy" do
scm_provider Chef::Provider::Git
repo "git@github.com:MyCompany/awesome.git"
revision "master"
user "myappuser"
group "myappgroup"
# ... pre/post actions
end
@orb
orb / union.clj
Created August 29, 2012 00:21
clojure light table demo code
;; code from Austin Clojure Meetup light table live coding
;; implement union alogrithm from Sedgewick/Wayne class
;; -- https://class.coursera.org/algs4partI-2012-001/
;; lecture notes week 1 - https://d19vezwu8eufl6.cloudfront.net/algs4partI/slides%2F15UnionFind.pdf
;; every state has a unique group id
(def no-connections
[0 1 2 3 4 5 6 7 8 9])
;; two states are connected if they have the
@orb
orb / hw2-tests.sml
Last active December 13, 2018 04:37
val test1a = [
all_except_option("foo", []) = NONE,
all_except_option("foo", ["bar"]) = NONE,
all_except_option("foo", ["foo"]) = SOME([]),
all_except_option("foo", ["foo","x","y"]) = SOME(["x","y"]),
all_except_option("foo", ["x","foo","y"]) = SOME(["x","y"]),
all_except_option("foo", ["x","y","foo"]) = SOME(["x","y"])]
val test1b = [
(*
comments on euler 1 in SML
http://smlpraxis.com/blog/2013/02/14/multiples-of-3-and-5/
*)
fun multiples_of n max =
let fun build_multiples current_mult list_so_far =
if current_mult >= max
then list_so_far
else let val next_mult = current_mult + n
@orb
orb / stream-maker.rkt
Created February 23, 2013 05:54
My version of stream-maker from PL class. This function works under the assumption that there is some state that is passed along from thunk to thunk as context. The current stream output value can be computed using val-fn. The state to pass to the next thunk is computed using the next-state function. I think it's much easier to understand, thoug…
(define (my-stream-maker val-fn next-state seed)
(define (stream-thunk current-state)
(lambda () (cons (val-fn current-state)
(stream-thunk (next-state current-state)))))
(stream-thunk seed))
(define ones
(my-stream-maker identity
identity
@orb
orb / mupl-ski.rkt
Created March 4, 2013 17:41
SKI in MUPL in Racket
(define S (fun "S" "x" (fun #f "y"
(fun #f "z"
(call (call (var "x") (var "z"))
(call (var "y") (var "z")))))))
(define K (fun "K" "x" (fun #f "y" (var "x"))))
(define I (fun "I" "x" (var "x")))
;; SKK
(define SKK
(call (call S K) K))
<html>
<head>
<title>TEST</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
Bitcoin price is <b id="price">--</b>
<script>
$(function(){
$.get("https://data.mtgox.com/api/1/BTCUSD/ticker", function(data) {
@orb
orb / dollars_and_cents.clj
Last active December 17, 2015 19:58
Skeptics Guide to the Universe - Episode 410 - WTN http://www.theskepticsguide.org/ a core.logic finite domains example
(ns dollars-and-cents
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.fd :as fd]))
;; A bank teller made a mistake today. The teller switched the dollars
;; and cents when they cashed a check for Mrs. Jones, giving her
;; dollars instead of cents and cents instead of dollars.
;; After buying a newspaper for 5 cents, Mrs. Jones realized that she
@orb
orb / sudoku.clj
Last active April 24, 2020 12:04 — forked from swannodette/gist:3217582
updated for the latest core.logic, with some minor tweaks for (I hope) clarity
(ns sudoku
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.fd :as fd]))
(defn init-board [vars puzzle]
(matche [vars puzzle]
([[] []]
succeed)
(ns logic.nono
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.fd :as fd]))
(def max-size 25)
(defn count-ones [marks howmany post-marks]
(conde
[(emptyo marks)