Skip to content

Instantly share code, notes, and snippets.

(ns clojure.gdx.myscreen
(:import (com.badlogic.gdx Gdx Screen)
(com.badlogic.gdx.scenes.scene2d Stage)
(com.badlogic.gdx.scenes.scene2d.ui Label Label$LabelStyle)
(com.badlogic.gdx.graphics Color)
(com.badlogic.gdx.graphics.g2d BitmapFont)
(com.badlogic.gdx.graphics.g2d SpriteBatch)))
(declare ^Stage stage)
@noisesmith
noisesmith / gist:6502843
Last active December 22, 2015 16:59 — forked from tdreyno/gist:6502823
(defn home-api-map
[]
{ :banner (model/pick :banner {:where {:slug "home"}})
:intro-headline (model/pick :headline {:where {:slug "intro"}})
:intro-slides (model/gather :slides {:where {:slug "intro"} :include {:slides {}}})
:intro-highlights (model/gather :highlight {:where {:slug "intro"}})
:tenants (model/gather :tenant)
:partners (model/gather :neighborhood-partner)
:whats-here-headline (model/pick :headline {:where {:slug "whats-here"}})
:project-highlights (model/gather :project-highlights {:include {:highlights {}}})
@noisesmith
noisesmith / expand-deps
Last active December 29, 2015 16:19
expand all clojure project deps for search / examination
#!/bin/bash
rm -rf alldeps/
for i in $(lein classpath | tr : '\n' | grep "\.jar$")
do DIR=alldeps/$(basename $i .jar)
mkdir -p $DIR
pushd $DIR
unzip $i
popd
@noisesmith
noisesmith / gist:7700208
Last active December 29, 2015 16:49 — forked from dabd/gist:7700137
(defn best
[f [h & t]]
(reduce #(if (f %1 %2) %1 %2) h t))
(defn most
[f [h & t :as coll]]
(if (seq coll)
(reduce (fn [[wins wins-score] x]
(let [x-score (f x)]
(if (> wins-score x-score)
(defn now-plus [n]
"Returns current time plus `n` minutes as string"
(let [f (SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")]
(.setTimeZone f (TimeZone/getTimeZone "GMT" ))
(.format f (Date. (+ (System/currentTimeMillis) (* n 60 1000))))))
@noisesmith
noisesmith / driver.clj
Created June 15, 2015 17:47
reproducing error with type reload
(ns driver
(:require type))
(defn reproduce
[]
(println (= type.Type (class (type/->Type)))))
{["e" "i"] 1864658105,
["c" "e"] 366389557,
["w" "e"] 693805971,
["v" "w"] 311238704,
["o" "v"] 1348289060,
["g" "o"] 1895243578,
["a" "t"] 443334995,
["h" "h"] 21807643,
["t" "m"] 797779624,
["l" "h"] 1961272944,
Clojure 1.7.0
user=> (require '[clojure.core.async :as > :refer [chan go go-loop thread <! >! <!! >!!]])
nil
user=> (def requests (chan))
#'user/requests
user=> (def results (chan))
#'user/results
user=> (go-loop [result "\n\ninit\n\n"] (println "got" (subs result 0 (min (count result) 10))) (recur (<! results)))
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x45273d40 "clojure.core.async.impl.channels.ManyToManyChannel@45273d40"]
user=> got
(ns client (:require [world :refer [map->World]]))
(map->World {})
$ rlwrap java -cp bench.jar clojure.main
Clojure 1.7.0
user=> (deftype T [] Object (finalize [this] (println "gone")))
user.T
user=> (let [t (T.)] (type t))
user.T
user=> (reduce +' (range 999999999))
gone