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 set-style | |
[elt property value] | |
(doto (.-style elt) | |
(.setProperty property value)) | |
elt) | |
(defn set-styles | |
[elt s] | |
(let [style (.-style elt)] | |
(doseq [[property value] s] |
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
-> a = {json : "hello"} | |
Object {json: "hello"} | |
-> a.json | |
"hello" | |
-> a = {"json" : "hello"} | |
Object {json: "hello"} | |
-> a.json |
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
(defmacro wrap-request-binding | |
"Wraps the ring handler definition to provide request-scoped bindings | |
via symbol-capture on %." | |
[bindings handler-def] | |
`(fn [request#] | |
(let [~'% request# | |
~@bindings] | |
(~handler-def request#)))) | |
(defmacro request-binding-handlers |
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
com.garytrakhman.cordova_test.app.flat_button = function() { | |
var flat_button__delegate = function(text, p__6105) { | |
var vec__6108 = p__6105; | |
var width = cljs.core.nth.call(null, vec__6108, 0, null); | |
var height = cljs.core.nth.call(null, vec__6108, 1, null); | |
var b = function() { | |
var G__6109 = new goog.ui.Button([cljs.core.str(text)].join(""), goog.ui.FlatButtonRenderer.getInstance()); | |
G__6109.render(com.garytrakhman.cordova_test.app.top.call(null)); | |
return G__6109 | |
}(); |
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
;;; helpful to get rid of repetitive compojure destructuring. | |
(defmacro wrap-request-binding | |
"Wraps the ring handler definition to provide request-scoped bindings | |
via symbol-capture on %." | |
[bindings handler-def] | |
`(fn [request#] | |
(let [~'% request# | |
~@bindings] | |
(~handler-def req#)))) |
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
user=> (take 6 (cycle [1 2 3])) | |
(1 2 3 1 2 3) | |
user=> (source cycle) | |
(defn cycle | |
"Returns a lazy (infinite!) sequence of repetitions of the items in coll." | |
{:added "1.0"} | |
[coll] (lazy-seq | |
(when-let [s (seq coll)] | |
(concat s (cycle s))))) |
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 xml.test | |
(:require [clojure.java.io :as io] | |
[clojure.data.xml :as xml])) | |
;; wget | |
;; download.geofabrik.de/openstreetmap/north-america/us/maryland.osm.bz2 | |
(def xml-seq | |
#(-> (io/file "/home/gary/dev/maryland.osm") | |
io/input-stream |
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
(defmacro let-map | |
"Avoids having to build maps from let bindings manually" | |
[bindings] | |
(let [names (->> (take-nth 2 bindings) | |
(tree-seq #(or (sequential? %) (map? %)) identity) | |
(filter symbol?) | |
(into #{})) ; dumps it all into a set | |
bindings (destructure bindings)] | |
`(let [~@bindings] | |
(zipmap [~@(map keyword names)] |
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
(defmacro let-map | |
[pairs] | |
(let [names (map first (partition 2 pairs))] | |
`(let [~@pairs] | |
(zipmap | |
[~@(map (comp keyword name) names)] | |
[~@names])))) |
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
var jq = document.createElement('script'); | |
jq.src = "http://code.jquery.com/jquery-latest.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
jQuery.noConflict(); | |
$('div a').map(function(){return this.title;}).each(function(){console.log(this.toString())}) | |
Borges: A Life | |
Island | |
Smalltalk 80: Bits Of History, Words Of Advice |