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