Skip to content

Instantly share code, notes, and snippets.

@luxbock
luxbock / bfs.clj
Created December 29, 2014 06:32
Clojure Zipper Breadth First Search
(defn breadth-first-search [z]
(letfn [(zip-children [loc]
(when-let [first-child (zip/down loc)]
(take-while (comp not nil?)
(iterate zip/right first-child))))])
(loop [ret []
queue (conj clojure.lang.PersistentQueue/EMPTY z)]
(if (seq queue)
(let [[node children] ((juxt zip/node zip-children) (peek queue))]
(recur (conj ret node) (into (pop queue) children)))
@luxbock
luxbock / core.cljs
Created December 10, 2014 16:31
freactive-datascript
(ns freactive-datascript.core
(:require [datascript :as d]
[datascript.core :as dc]
[clojure.data :as data]
[freactive.core :as f :refer [IReactive
*invalidate-rx*
*trace-capture*]]))
;;; Playground ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@luxbock
luxbock / profiles.clj
Last active August 29, 2015 14:07
profiles.clj
{:user
:dependencies [[im.chit/vinyasa "0.2.2"]
;; ...
[leiningen #=(leiningen.core.main/leiningen-version)]]
:injections [(require '[vinyasa.inject :as inject]
;; other requires
)
(inject/in
;; Inject as is
@luxbock
luxbock / asdfdsf.clj
Last active August 29, 2015 14:07
scen-c results
(def scen-c
{:algorithm 0
:abstraction 0
:rules {:stack 1000, :pot 100, :bb 20, :to-act 0
:max-bets 3 :actions [[1/2 3/4 1 :all-in] [1/2 1 :all-in]]}
:init-node {:player 1, :prev-action :check, :street 3}
:board [(card "2h") (card "3s") (card "4d") (card "Ts")]
:range-sb (hand-range "5s5h 6s5s 7c2h Th9h 9c9s AcAd KsKd")
:range-bb (hand-range "AcAd AsAh AdAh AsAd 7c9h")})
@luxbock
luxbock / crypto-coursera.org
Created October 3, 2014 16:07
crypto-notes
@luxbock
luxbock / asdfsf
Created October 3, 2014 15:35
hhh
Mono: DllImport error loading library '/Users/Olli/Google Drive/projects/demo_app/libsubgame.dylib': 'dlopen(/Users/Olli/Google Drive/projects/demo_app/libsubgame.dylib, 9): image not found'.
Mono: DllImport error loading library '/Users/Olli/Google Drive/projects/demo_app/libsubgame.so': 'dlopen(/Users/Olli/Google Drive/projects/demo_app/libsubgame.so, 9): no suitable image found. Did find:
/Users/Olli/Google Drive/projects/demo_app/libsubgame.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00'.
~/Google Drive/projects/demo_app $ mono SubgameConsole.exe
SubgameConsole - type ? for help
Unhandled Exception:
System.DllNotFoundException: libsubgame
at (wrapper managed-to-native) SubgameConsole.libsubgame:libsubgame_init (int)
at SubgameConsole.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libsubgame
at (wrapper managed-to-native) SubgameConsole.libsubgame:libsubgame_init (int)
at SubgameConsole.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
@luxbock
luxbock / clj-imenu.el
Last active August 29, 2015 14:06
clojure imenu support
(setq clojure-imenu-generic-expression
'((nil "^\\s-*(\\(?:s\\|t/\\)?defn-?\\s-+\\(?:\\^[^[:space:]\n]+\\s-+\\)?\\([^[:space:]\n]+\\)" 1)
("Variable""^\\s-*(\\(?:s\\|t/\\)?def[[:space:]\n]+\\(?:\\(?:\\^{[^}]+}[[:space:]\n]+\\)\\|\\(?:\\^:[^[:space:]\n]+\\s-+\\)\\)?\\([^[:space:]\n\)]+\\)" 1)
("Macro" "^\\s-*(defmacro\\s-+\\([^[:space:]\n]+\\)" 1)
("Record" "^\\s-*(\\(?:s/\\)?defrecord\\s-+\\([^[:space:]\n]+\\)" 1)
("Type" "^\\s-*(deftype\\+?\\s-+\\([^[:space:]\n]+\\)" 1)
("Protocol" "^\\s-*(\\(?:def\\(?:-abstract-type\\|interface\\+?\\|protocol\\)\\)\\s-+\\([^[:space:]\n]+\\)" 1)
("Multimethod" "^\\s-*(defmulti\\s-+\\([^[:space:]\n]+\\)" 1)
("Multimethod" "^\\s-*(defmethod\\s-+\\([^[:space:]\n]+\\)" 1)))
@luxbock
luxbock / anonymous-gist.clj
Created September 24, 2014 18:43
data-readers weirdness
(deftype Bar [a]
Object
(equals [self other] true)
(toString [_] (str a)))
(defn barme [a] (->Bar a))
(set! *data-readers* {'bar myns/barme})
;; #bar :foo => nil
@luxbock
luxbock / core.clj
Created September 21, 2014 12:00
lein-plz-nicknames
(ns lein-plz-nicknames
"Tiny script to check for additional projects discovered by crawling
crossclj.info and filtering for the popularity of the project."
(:require [me.raynes.laser :as l]
[clojure.string :as str]
[leiningen.plz :refer [fallback-nicknames]]))
(def prj-from-crossclj
"Fetches a list of projects from crossclj.info"
(apply str