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
{ :animatable sphere | |
:animation {:rotation | |
{:x (partial + 0.075) | |
:y (partial + 0.025) | |
:z (partial + 0.050) | |
:position | |
{:x #(js/Number (.toFixed (mod (+ % 0.025) 1) 2))}}} |
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
(extend-type Mesh | |
IRenderable | |
IAnimatable | |
(animate! [this options] | |
(doto this | |
(apply-nested! options)))) |
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 pmap | |
"Like map, except f is applied in parallel. Semi-lazy in that the | |
parallel computation stays ahead of the consumption, but doesn't | |
realize the entire result unless required. Only useful for | |
computationally intensive functions where the time of f dominates | |
the coordination overhead." | |
{:added "1.0" | |
:static true} | |
([f coll] | |
(let [n (+ 2 (.. Runtime getRuntime availableProcessors)) |
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
const sampler_t sampler = | |
CLK_NORMALIZED_COORDS_FALSE | CLK_FILTER_NEAREST | CLK_ADDRESS_CLAMP_TO_EDGE; | |
float add_color(float color) { | |
return color + 0.75; | |
} | |
__kernel void identity(read_only image2d_t inputImage, | |
write_only image2d_t outputImage) { |
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
translation-unit: | |
external-declaration+ | |
external-declaration: | |
<ws> function-definition <ws> | | |
<ws> declaration <ws> | |
function-definition: | |
declaration-specifiers <ws> declarator <ws> declaration-list? <ws> compound-statement | |
declaration-list: | |
(<ws> declaration)+ <ws> | |
ws: |
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 pub! | |
[coll port-key val] | |
`(cljs.core.async/put! (~port-key (:channels (meta ~coll))) ~val)) | |
(defmacro sub! | |
[[coll port-key] & body] | |
`(go! ;; this is just an infinite (go) loop, waiting for stuff to be pushed onto the channel | |
(let [~coll (cljs.core.async/<! (~port-key (:channels (meta ~coll))))] | |
~@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
(defn page! | |
[init-res req] | |
(reduce | |
(fn [coll n] | |
(if (not (= (mod (count coll) 200) 0)) (reduced coll) | |
(let [req (update-in | |
req [:query-params] | |
merge | |
{:since_id (:id_str (last coll))})] | |
(into coll (<!! (async-request req)))))) |
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 page! | |
[init-res req page-size] | |
(reduce | |
(fn [coll n] | |
(let [req (update-in | |
req [:query-params] | |
merge | |
{:max_id (:id_str (first coll))}) | |
res (<!! (async-request req)) | |
new-coll (into coll res)] |
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 page! | |
[init-res req] | |
(go | |
(loop [coll (into (sorted-set-by #(compare (:id %1) (:id %2))) init-res)] | |
(let [req (update-in | |
req [:query-params] | |
merge | |
{:max_id (:id_str (first coll))}) | |
res (<! (async-request req)) | |
new-coll (into coll res)] |
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 foldl | |
[f init xs] | |
(println xs) | |
(cond (empty? xs) (f) | |
(nil? init) (recur (partial f (first xs)) nil (rest xs)) | |
:else (recur (partial f init (first xs)) nil (rest xs)))) | |
(foldl + 0 (range 10)) | |
(0 1 2 3 4 5 6 7 8 9) | |
(1 2 3 4 5 6 7 8 9) |