Skip to content

Instantly share code, notes, and snippets.

Benjamin Teuber bsteuber

Block or report user

Report or block bsteuber

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View schachcafe.clj
(def weak-minor-5
[:length-range 9]
[:gcp-range 0 14]])
(def weak-major-4
[:length-range 8]
View gist:3ebab902294a05c01d01
;; no assumtion of outer state/events
;; more setup work, more flexibility and straightforward testing
(defn my-component [model event-channel]
(for [blub @model]
[:div.blub {:on-click #(>! event-channel [:blub-click (:id blub)])}
(:text blub)])])
;; uses global app-state and global event-queue
bsteuber / gist:0421e6bdb5243d3c7e27
Created Jul 12, 2014
Change function printing behavior of cljs
View gist:0421e6bdb5243d3c7e27
(extend-type js/Function
(-pr-writer [a writer opts]
(-write writer "#<Fn>")))
;; will give a warning, but work...
View gist:2165263
(defn replace-pred-once [pred replacement list]
(let [[bef
[elt & aft]] (split-with (complement pred)
(concat bef [replacement] aft)))
(comment (replace-pred-once #{5} :foo [1 2 3 4 5 6 7 8 5 3])
=> (1 2 3 4 :foo 6 7 8 5 3)
View gist:2036624
(defun clojurescript-repl ()
(run-lisp "lein1 trampoline cljsbuild repl-listen")
(paredit-mode +1))
View gist:1547828
(defn fullhouse3 [hand]
(let [index (->> hand
(group-by :rank)
(sort-by (fn [same] [(count same)
(:rank (first same))]
[fst snd] index]
(when (and (= (count fst) 3)
(>= (count snd) 2))
View gist:1077871
(defn rec-find [pred x]
(pred x) true
(sequential? x) (some #(rec-find pred %)
(map? x) (some #(rec-find pred %)
(vals x))))
You can’t perform that action at this time.