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
/* | |
Open all selected links. | |
Paste the following line into the address of a bookmark in your browser: | |
javascript:(function%20()%20%7B%0A%20%20%20%20try%20%7B%20%0A%20%20%20%20%20%20%20%20var%20as%20=%20getSelection().getRangeAt(0).commonAncestorContainer.getElementsByTagName('a');%0A%0A%20%20%20%20%20%20%20%20for%20(var%20i%20=%200;%20i%20%3C%20as.length;%20i++)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20el%20=%20as%5Bi%5D;%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20(el.href)%20window.open(el.href);%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%20catch%20(e)%20%7B%20//%20lets%20pretend%20this%20never%20happened%0A%20%20%20%20%7D%0A%7D)(); | |
*/ | |
(function () { |
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 pivot-on | |
"This is about the worst way you could ever write this" | |
[p coll] | |
(first (reduce (fn [[[l r] pivoted] v] | |
(if pivoted | |
[[l (conj r v)] true] | |
(if (p v) | |
[[l r] true] | |
[[(conj l v) r] false]))) | |
[[[] []] false] |
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
(use 'name.choi.joshua.fnparse) | |
(def tokenize (partial re-seq #"\\[\[\](){}]|\"(?:\\.|[^\"])*\"|[\[\](){}]|[^\[\](){}]+")) | |
(def initial-state (comp (partial array-map :remainder) tokenize)) | |
(def brackets {"[" "]" "(" ")" "{" "}"}) | |
(def opening (term (set (keys brackets)))) |
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
(->> (re-seq #"(?i)(\d+)\.|(yes|no)" "no1. asdf\n\nasdf foo yes2.\n\nfsdf\nno yes no") | |
(map rest) | |
(partition-by first) | |
(drop-while (comp nil? ffirst)) | |
(partition 2) | |
(map (fn [s] (let [[i & r] (keep identity (flatten s))] | |
[(Integer/parseInt i) | |
(-> (last r) .toLowerCase first (= \y))]))) | |
(into {})) |
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
/* | |
javascript:%28function%20%28%29%20%7B%0A%20%20var%20w%20%3D%20window.open%28window.location%2C%20window.title%2C%20false%29%3B%0A%20%20w.resizeTo%28320%2C480%29%3B%0A%20%20w.onload%20%3D%20function%20%28%29%20%7B%0A%20%20%20%20var%20b%20%3D%20w.document.body%3B%0A%20%20%20%20b.style.overflow%20%3D%20%22scroll%22%3B%0A%20%20%20%20w.resizeBy%28320%20-%20b.offsetWidth%2C%200%29%3B%0A%20%20%7D%3B%0A%7D%29%28%29%3B | |
*/ | |
(function () { | |
var w = window.open(window.location, window.title, false); | |
w.resizeTo(320,480); | |
w.onload = function () { | |
var b = w.document.body; | |
b.style.overflow = "scroll"; |
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
"""populate.py | |
This script takes a listing of folders and filenames (as generated by `ls -R > listing`) on standard input | |
and the pathname for a set of media as the argument to argv. | |
e.g: | |
python populate.py _source < test/listing.txt | |
The files listed in listing are then mocked from the media files using the filenames in the input, and |
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
; archaic, an alternative to https://gist.github.com/1343842 | |
(defn temp-gr | |
[start by end] | |
(fn [x] | |
(when (<= start x end) | |
(let [lower (* (quot x by) by) | |
upper (+ lower by)] | |
(keyword (str lower "-" upper)))))) |
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
function l_system (productions, depth, s) { | |
if (depth === 0) return s; | |
return $.map(s, function (v) { | |
return l_system(productions, depth - 1, productions(v) || [v]); | |
}); | |
} | |
function run_turtle (turtle, operations, commands) { | |
$.each(commands, function (_, c) { | |
(operations[c] || $.noop)(turtle); |
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
;; hacked out of clojure.repl/apropos and prepending namespaces | |
(defn apropos-ns | |
"Given a regular expression or stringable thing, return a seq of | |
all definitions in all currently-loaded namespaces that match the | |
str-or-pattern." | |
[str-or-pattern] | |
(let [matches? (if (instance? java.util.regex.Pattern str-or-pattern) | |
#(re-find str-or-pattern (str %)) | |
#(.contains (str %) (str str-or-pattern)))] |
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
ifr = document.createElement("iframe"); | |
document.body.appendChild(ifr); | |
ifr.contentDocument.write("<script language='javascript'>window.Object2 = Object;</script>"); | |
o = new ifr.contentWindow.Object2(); | |
o instanceof Object; // => false |
OlderNewer