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 draw-order (:use [penumbra.opengl] [penumbra.window])) | |
(defn- init [state] | |
(enable :depth-test) | |
(ortho-view 0 0 640 480 -1 1) | |
(scale 1 1 -1) | |
state) | |
(defn draw-square [x y w h] | |
(draw-quads |
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 scratchpad | |
(:use [aleph.core :only (siphon wrap-channel)] | |
[aleph.tcp :only (start-tcp-server)] | |
[aleph.formats :only (channel-buffer->string)])) | |
(defn echo-handler [channel connection-info] | |
(siphon (wrap-channel channel #(str "Response : " (channel-buffer->string %))) channel)) | |
;; Returns function to stop the server | |
(def server (start-tcp-server echo-handler {:port 8080})) |
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 dining-service | |
(:use aleph.core) | |
(:use aleph.http) | |
(:use net.cgrand.moustache) | |
) | |
(defn report-handler [response-channel request] | |
(enqueue response-channel | |
{:status 200 | |
:headers {"content-type" "text/plain"} |
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 clojfix.simple) | |
(use 'gloss.core 'gloss.io) | |
(import | |
[java.nio | |
ByteBuffer]) | |
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 test | |
(:use [gloss core io])) | |
(defcodec tag (enum :byte :end :byte :int16 :int32 :int64 :float32 :float64 :bytes :string :list :compound)) | |
(defcodec tstring (finite-frame :int16 (string :utf-8))) | |
(defcodec tbytes (repeated :byte)) | |
(declare tcompound) | |
(declare tlist) |
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 handler [ch _] (receive-all ch print) (enqueue ch "hi")) | |
(defn test-harness [] | |
(let [[a b] (channel-pair)] | |
(handler b nil) ;; give handler one side of the channel pair | |
(enqueue a 1 2 3) ;; these will be received by 'b', and the handler will print out '123' | |
(println (channel-seq a)))) ;; will print '["hi"]' |
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 handler [chi cho] | |
(let [parse (fn-match ([["GETT" ?gid ?uid]] | |
(if-let [v ((data gid) uid)] | |
(str v) | |
(str "ERROR_" gid "_" uid))) | |
([["STOP_SESSION"]] (close chi)) | |
([["STOP"]] (System/exit 0)))] | |
#_ (receive-all chi #(enqueue cho (str "You said: " % "\r\n"))) | |
(siphon (map* #(parse (re-seq #"\S+" %)) chi) cho))) |
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
(compile-frame | |
(ordered-map | |
:req (string :utf-8 :length 4) | |
:type :int32 | |
:data (string :utf-8 :prefix :int32)) | |
(fn [x] (update-in x [:data] #(->> % (interpose "\0") (apply str)))) | |
(fn [x] (update-in x [:data] #(seq (.split ^String % "\0"))))) |
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 retrieve-json | |
"retrieve json content" | |
[url] | |
(run-pipeline | |
(http-request {:method :get, :url url, :auto-transform true})) | |
:body | |
println)) | |
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
(def empty-frame (compile-frame [])) | |
(defn repeated-until [element done] | |
(let [element* (compile-frame element (fn [v] (if (nil? v) done v)) (fn [v] (if (= v done) nil v))) | |
self (promise) | |
impl (header element* (fn [elt] (if (nil? elt) empty-frame (compile-frame @self rest (partial cons elt)))) first)] | |
(deliver self impl) | |
impl)) |
OlderNewer