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
(ns com.x.aleph-test | |
(require [aleph.http :as http] | |
[manifold.deferred :as d] | |
[manifold.stream :as s] | |
[compojure.core :only [routes ANY GET PUT POST] :as compojure] | |
[compojure.handler :as handler] | |
[clj-http.client :as http-client] | |
)) | |
(comment |
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
(ns foami.core | |
"FOreign Asynchronous Mechanism Interop" | |
(:require [clojure.core.async :as async])) | |
(defn put! | |
"Takes a `ch`, a `msg`, a single arg function that when passed `true` enables backpressure | |
and when passed `false` disables it, and a no-arg function which, when invoked, closes the | |
upstream source." | |
[ch msg backpressure! close!] | |
(let [status (atom :sending] |
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
(ns inkystarter | |
"Intro sketch for inky.cc, fork away." | |
(:require [inky.sketch :as sketch])) | |
(sketch/page-style! | |
(concat | |
sketch/default-styles | |
[:body {:font-family "'Helvetica Neue', Arial, sans-serif"} | |
:.sketch {:padding "30px"}])) |
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
(ns almost.haiku | |
(:require [inky.sketch :as sketch] | |
[dommy.core :as dom] | |
[clojure.string :as str] | |
[cljs.core.async :as async | |
:refer [<! >! put! chan timeout]]) | |
(:require-macros [dommy.macros :refer [sel1 node]] | |
[cljs.core.async.macros :refer [go]])) | |
(enable-console-print!) |
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
(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)) |
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 retrieve-json | |
"retrieve json content" | |
[url] | |
(run-pipeline | |
(http-request {:method :get, :url url, :auto-transform true})) | |
:body | |
println)) | |
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
(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 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 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 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 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 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
(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) |
NewerOlder