This file contains hidden or 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(head, req){ | |
if(req.query.include_docs){ | |
var shared = require("share/streaming"); | |
shared.streaming(function(row){return row.doc}); | |
} else { | |
start({ | |
code: 400, | |
headers: {"Content-Type": "application/json"} | |
}); | |
var msg = "The docs streaming route must be called with include_docs=true!"; |
This file contains hidden or 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
# After staring at this for five minutes, I believe that what it does | |
# is takes ruby string/integer literals and tries to print an | |
# obfuscated symbols-only expression for it | |
require 'set' | |
$symbols = "!@$#^%&*.()[]{}|\\/=?+-_;:`~".split('').to_set | |
def regex_escape(s) | |
s.gsub(/([\|\{\}\$\^\-\.\(\)\\\/\[\]\+\?\*])/){|m|"\\" + m} |
This file contains hidden or 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
(let [fs (atom [])] | |
(doseq [x (range 4) | |
:let [y (inc x) | |
f (fn [] y)]] | |
(swap! fs conj f)) | |
(map #(%) @fs)) | |
;; => [4 4 4 4] |
This file contains hidden or 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
palehorse.core=> (defroutes appp (GET "/" [] {:foo [1 2 3]})) | |
#'palehorse.core/appp | |
palehorse.core=> (appp {:request-method :get :uri "/"}) | |
{:foo [1 2 3], :status 200, :headers {}, :body ""} |
This file contains hidden or 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 poly-tiler.grids | |
"Messing around with describing/exploring grids. | |
At the moment we're only looking at the graphs suggested by the | |
lines and vertices of a 2D tesselation, though this may trivially be | |
the same as looking at the faces as well. | |
We assume that a grid can be totally specified by the degree of its | |
vertices and the girth, which is the shortest cycle in the graph (also | |
the number of sides of the faces). |
This file contains hidden or 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
(def all-bit-length-triples | |
(sort-by (fn [a] (vec (cons (apply max a) | |
(concat | |
(sort a) | |
a)))) | |
(for [a (range 9), b (range 9), c (range 9)] | |
[a b c]))) | |
(defn bindex | |
"Given a number in (range 256), returns the position of the rightmost |
This file contains hidden or 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
;; This returns a response quickly (as I would expect), but if we add 4 | |
;; to the domain it runs for a while... | |
(run 1 [x11 y11 x12 y12 x21 y21 x22 y22] | |
(infd x11 y11 x12 y12 x21 y21 x22 y22 (domain 0 1 2 3 #_4)) | |
(<fd x11 x12) (<fd x21 x22) | |
(<fd y11 y12) (<fd y21 y22) | |
(conde | |
[(<fd x22 x11)] | |
[(<fd x12 x21)] |
This file contains hidden or 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 condr* | |
[& goals] | |
(if (= 1 (count goals)) | |
(first goals) | |
(let [goals (shuffle goals)] | |
(conde | |
[(first goals)] | |
[(apply condr* (rest goals))])))) | |
(defmacro condr |
This file contains hidden or 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 diagrams.core | |
(:require [hiccup.core :as h])) | |
(let [prelude "<?xml version=\"1.0\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN \" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd \">\n"] | |
(defn svg-str | |
[contents] | |
(str prelude (h/html [:svg {:height 400 :width 400 :xmlns "http://www.w3.org/2000/svg"} contents]) "\n"))) | |
(defn circle | |
[x y r & {:as attrs}] |
This file contains hidden or 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
(defmacro eval-let | |
[lettings code] | |
(let [pairs (partition 2 lettings)] | |
`(eval (list `let [~@(apply concat (for [[name val] pairs] [(list 'quote name) val]))] ~code)))) | |
;; (eval-let [a 14 b 48] '(+ a b)) => 62 |