Skip to content

Instantly share code, notes, and snippets.

@abrooks
abrooks / python-closure-madness.py
Last active February 21, 2020 22:12
Python Closure Madness
#!/usr/bin/env python
# Originally created: 2011-09-12 17:32:25 - abrooks
import inspect, new
def close():
l = []
for x in range(0,3):
for y in range(0,3):
@abrooks
abrooks / datomic-transacitons.clj
Last active December 19, 2015 10:28
Crudely walking Datomic transaction history
(require '[datomic.api :as d])
(defn txns1
"Uses query to find txns. Believed to be less efficient."
[hdb]
(->>
(d/q '[:find ?tx
:where
[?tx :db/txInstant]]
hdb)
for R in {1..10}; do
~/​​wrapper-​​​​linux –m ~/​​i86bi_​​linux-​​​​adventerprisek9-​​​​ms –p $((2000 + R))\
-- -e 1 –s 1 $((10 * R)) &
sleep 1s
done
;;; Rich's example from http://www.assembla.com/wiki/show/clojure/Enhanced_Primitive_Support
(defn fib [n]
(if (<= n 1)
1
(+' (fib (dec' n)) (fib (-' n 2)))))
;;; Same example with ops' (not a great example, only showing usage)
(defn fib [n]
@abrooks
abrooks / cset.clj
Created January 29, 2010 02:24 — forked from anonymous/cset.clj
(defn- field-name [field]
(str "native-" (name field)))
(defn- cset!* [[obj field] value]
(clojure.lang.Reflector/setInstanceField obj (field-name field) value))
(defn cset! "C setter"
{:inline-arities #{2}
:inline (fn [field-form value-form]
(if (and (seq? field-form) (keyword? (second field-form)))