Skip to content

Instantly share code, notes, and snippets.

View freckletonj's full-sized avatar
🎯
Focusing

neurallambda freckletonj

🎯
Focusing
View GitHub Profile
@freckletonj
freckletonj / spiralizer.clj
Created March 31, 2016 18:23
Convert a sequence into spiral matrix
(defn rotate
"rotate a 2D matrix 90 degrees, it's ok if it's not a perfect square"
[mat]
(loop [remaining (map reverse mat)
result []]
(if (every? empty? remaining)
result
(recur (map rest remaining)
(conj result (remove nil? (mapv first remaining)))))))
@freckletonj
freckletonj / cljsfiddle_save.edn
Last active March 29, 2016 22:44 — forked from anonymous/cljsfiddle_save.edn
how to have an input with (essentially) two way binding
(def search-term (atom ""))
(defn input [model on-change]
(let [external-model (atom @model)
internal-model (atom (or @external-model ""))]
(fn [model on-change]
;; this is taken from recom - http://bit.ly/1SZ1OXn
(when (not= @external-model @model)
(.log js/console "changed to " @model)
(reset! external-model @model)
@freckletonj
freckletonj / notifications.cljs
Created March 25, 2016 22:12
ClojureScript Notifications
;; this is very much a gist, and it can be tweaked
;; ;; NOTIFICATIONS ----------
;; if (typeof Notification !== 'undefined') {
;; alert('Please us a modern version of Chrome, Firefox, Opera or Safari.');
;; return;
;; }
;; Notification.requestPermission(function (permission) {
;; if (permission !== 'granted') return;