Skip to content

Instantly share code, notes, and snippets.

View ztellman's full-sized avatar
💭
boiling the ocean

Zach Tellman ztellman

💭
boiling the ocean
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ztellman on github.
  • I am ztellman (https://keybase.io/ztellman) on keybase.
  • I have a public key whose fingerprint is 48C0 998F 1CA0 2F62 928D 6DC8 5E23 CF68 58E9 BE47

To claim this, I am signing this object:

(ns advent17.core
(:require
[clojure.java.io :as io]
[clojure.string :as str]))
(defn neighbors [[x y z w]]
(->
(for [x' (range (dec x) (+ 2 x))
y' (range (dec y) (+ 2 y))
z' (range (dec z) (+ 2 z))
(ns com.x.aleph-test
(require [aleph.http :as http]
[manifold.deferred :as d]
[manifold.stream :as s]
[compojure.core :only [routes ANY GET PUT POST] :as compojure]
[compojure.handler :as handler]
[clj-http.client :as http-client]
))
(comment
@ztellman
ztellman / gist:5603216
Last active May 26, 2019 17:08
an exploration of the memory implications of call-site caching for protocols
;; let's create a simple protocol that just returns a number
user> (defprotocol NumberP (number [_]))
NumberP
;; now we'll create an implementation that always returns '1'
user> (deftype One [] NumberP (number [_] 1))
user.One
;; unsurprisingly, this type only has a single static value, which wraps the '1'
> (-> One .getDeclaredFields seq)
var text = new PointText({
position: view.center + [0, 200],
fillColor: 'black',
justification: 'center',
fontSize: 20
});
var originals = new Group({ insert: false }); // Don't insert in DOM.
var square = new Path.Circle({
@ztellman
ztellman / foami.clj
Last active September 22, 2017 16:05 — forked from cgrand/foami.clj
(ns foami.core
"FOreign Asynchronous Mechanism Interop"
(:require [clojure.core.async :as async]))
(defn put!
"Takes a `ch`, a `msg`, a single arg function that when passed `true` enables backpressure
and when passed `false` disables it, and a no-arg function which, when invoked, closes the
upstream source."
[ch msg backpressure! close!]
(let [status (atom :sending]
@ztellman
ztellman / gist:66ba4e65558a064920e9
Created October 31, 2014 10:07
reading list from PolyConf 2014

Fiction

  • Fictions and The Aleph by Borges
  • Invisible Cities by Calvino

More Technical

  • An Introduction to General Systems Thinking by Weinberg
  • Data and Reality by Kent
  • Patterns of Software by Gabriel
(use 'penumbra.opengl)
(require '(penumbra [app :as app]))
(def max-iterations 100)
(def num-paths 50)
(defn ikeda [x y u]
(iterate
(fn [[x_n y_n]]
(let [t_n (- 0.4 (/ 6 (+ 1 (* x_n x_n) (* y_n y_n))))]
(defmacro if-in-str [haystack & clauses]
`(do
~@(map
(fn [clause]
(let [needle (first clause)
is-present-form (second clause)
is-not-present-form (nth clause 2 nil)]
`(if (> (.indexOf ~haystack ~needle) -1)
~is-present-form
~is-not-present-form)))
(defn kafka-sink []
(let [s (s/stream)]
(s/consume-async
(fn [msg]
(d/future (synchronous-put-to-kafka msg))))
s))