This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn data-object-to-map [obj] | |
(into {} | |
(for [f (.getFields (type obj)) | |
:when (zero? (bit-and (.getModifiers f) Modifier/STATIC))] | |
[(.getName f) (.get f obj)]))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn src-dir | |
"Returns the absolute file path of the src directory | |
enclosing the current .clj file's package dirs." | |
[] | |
(let [rel *file*] | |
(loop [cl (.. Thread currentThread getContextClassLoader)] | |
(when cl | |
(if-let [url (.findResource cl rel)] | |
(.replace (.getFile url) rel "") | |
(recur (.getParent cl))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clooj.help=> | |
(import java.io.File) | |
java.io.File | |
clooj.help=> | |
(System/getProperty "user.dir") | |
"/projects/clooj" | |
clooj.help=> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blah |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn hotpo | |
"One iteration of the hailstone sequence." | |
[n] | |
(if (even? n) | |
(/ n 2) | |
(inc (* 3 n)))) | |
(defn hotpot [x] | |
"Finds a hailstone sequence starting with integer x." | |
(take-while #(> % 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn clj->js | |
"Recursively transforms ClojureScript maps into Javascript objects, | |
other ClojureScript colls into JavaScript arrays, and ClojureScript | |
keywords into JavaScript strings." | |
[x] | |
(cond | |
(string? x) x | |
(keyword? x) (name x) | |
(map? x) (.-strobj (reduce (fn [m [k v]] | |
(assoc m (clj->js k) (clj->js v))) {} x)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns github-jsonp) | |
(defn store-callback [reference address-vec] | |
(fn [val] | |
(swap! reference assoc-in address-vec val))) | |
(defn base64-decode [x] | |
(js/atob (clojure.string/replace x #"\s" ""))) | |
(defn jsonp [url callback] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; uses hiccups/render-html | |
(defn new-window-document [] | |
(.. js/window open -document)) | |
(defn folder-chooser [id] | |
[:input {:id id | |
:type "file" | |
:webkitdirectory "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Expects paths to two files: Prints the code points in the first file but not in the second, | |
# and vice versa. | |
# Based on https://stackoverflow.com/questions/4458696/finding-out-what-characters-a-font-supports | |
from itertools import chain | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
U+0900 default 510×1477 510×1478 (+0,+1) | |
U+0901 default 510×1477 510×1478 (+0,+1) | |
U+0902 default 510×1477 510×1478 (+0,+1) | |
U+0903 default 782×1477 782×1478 (+0,+1) | |
U+0904 default 764×1477 764×1478 (+0,+1) | |
U+0905 default 764×1477 764×1478 (+0,+1) | |
U+0906 default 1023×1477 1023×1478 (+0,+1) | |
U+0907 default 474×1477 474×1478 (+0,+1) | |
U+0908 default 474×1477 474×1478 (+0,+1) | |
U+0909 default 548×1477 548×1478 (+0,+1) |
OlderNewer