Skip to content

Instantly share code, notes, and snippets.

(defroutes targeting-criteria
(context "/accounts/:account-id" [account-id]
(GET "/targeting_criteria" [] "")
(GET "/targeting_criteria/:id" [id] id)
(POST "/targeting_criteria/:id" [id] id)
(PUT "/targeting_criteria/:id" [id] id)
(DELETE "/targeting_criteria/:id" [id] id)
(GET "/targeting_criteria/tailored_audiences" [])
(defn handle-player-movement
[key-handler]
(let [coords (atom [0 0])]
(.addEventListener key-handler goog.events.KEY
(fn [e]
(let [dir (case (.-keyCode e)
KeyCodes.UP :up
KeyCodes.DOWN :down
KeyCodes.RIGHT :right
KeyCodes.LEFT :left)]
(defmulti move (fn [coords e]
(case (.-keyCode e)
KeyCodes.UP :up
KeyCodes.DOWN :down
KeyCodes.RIGHT :right
KeyCodes.LEFT :left)))
(defmethod move :up
[[x y] e]
[x (inc y)])
(defn move
[[x y] e]
(case (.-keyCode e)
KeyCodes.UP [x (inc y)]
KeyCodes.DOWN ...
KeyCodes.RIGHT ...
KeyCodes.LEFT ...)))
(defn handle-player-movement
[key-handler]
(deftype ConcatVec [meta cnt cnt-a cnt-b a b ^:mutable __hash]
ISequential
Object
(toString [coll]
(pr-str* coll))
IWithMeta
(-with-meta [coll meta] (ConcatVec. meta cnt cnt-a cnt-b a b __hash))
IMeta
static NSString *readToken (PushbackReader *rdr) {
NSMutableString *sb = [NSMutableString string];
unichar ch = [rdr read];
for (;;) {
if (!ch || isWhitespace(ch))
return [NSString stringWithString:sb];
[sb appendFormat:@"%C", ch];
ch = [rdr read];
}
return nil;
data JSValue = JSString String
| JSNumber Double
| JSBool Bool
| JSNull
| JSObject [(String, JSValue)]
| JSArray [JSValue]
deriving (Eq, Ord, Show)
getString :: JSValue -> Maybe String
getString (JSString str) = Just str
(deftemplate index
(io/resource "public/html/index.html")
[]
[[:script (enlive/attr= :src "../js/main.js")]]
(enlive/before (enlive/html [:script {:src "../js/out/goog/base.js"}]))
[:body]
(enlive/append (enlive/html [:script "goog.require(\"ag_console.start\")"])))
(defmethod native-size clojure.lang.BigInt
"Determine the number of bits necessary to represent an integer of arbitrary precision."
[n]
(count (take-while pos? (iterate #(quot % 2) n))))
(defprotocol Typeable)
(defprotocol Read)
(defprotocol Show)
(defprotocol Ord)
(defprotocol Enumerable)
(defprotocol Bounded)
(defprotocol Eq)
(deftype Bool [true?]
Typeable