Skip to content

Instantly share code, notes, and snippets.

@odyssomay
odyssomay / gist:1209498
Created September 11, 2011 12:07
trace forms
(ns trace
(:use clojure.pprint))
(declare trace-form)
(def *ignore*
'#{def quote var try monitor-enter monitor-exit})
(defmulti trace-special-form (fn [form] (first form)))
(ns hammock-cafe.ui.history
(:require [io.pedestal.app.protocols :as p]
[io.pedestal.app.util.log :as log]
[io.pedestal.app.messages :as msg]))
(def last-page (atom nil))
(def dispatchers (atom {}))
(defn navigate [token]
(ns async-test.core
(:require [cljs.core.async :refer [chan]]
[clojure.string :as string])
(:require-macros
[cljs.core.async.macros :as m :refer [go alt! alts!]]))
(def c (chan))
(def loc-div (.getElementById js/document "location"))
(.addEventListener js/window "mousemove"
(ns async-test.throttle.core
(:require [cljs.core.async :refer [chan close!o sliding-buffer]]
[clojure.string :as string])
(:require-macros
[cljs.core.async.macros :as m :refer [go alts!]]))
(def c (chan (sliding-buffer 1)))
(def loc-div (.getElementById js/document "location"))
(.addEventListener js/window "mousemove"
(defn debounce
([c ms] (debounce (chan) c ms))
([c' c ms]
(go
(loop [start nil loc (<! c)]
(if (nil? start)
(do
(>! c' loc)
(recur (js/Date.) nil))
(let [loc (<! c)]
;; based on http://talks.golang.org/2012/concurrency.slide#50
(ns robpike
(:require [cljs.core.async :as async :refer [<! >! chan close!]])
(:require-macros [cljs.core.async.macros :as m :refer [go alt!]]))
(defn timeout [ms]
(let [c (chan)]
(js/setTimeout (fn [] (close! c)) ms)
c))
(ns async_match
(:require [cljs.core.async :refer [chan sliding-buffer]]
[clojure.string :as string])
(:require-macros
[cljs.core.async.macros :as m :refer [go alts!]]
[clojure.core.match.js :refer [match]]))
(def mc (chan (sliding-buffer 1)))
(def loc-div (.getElementById js/document "location"))
@jackrusher
jackrusher / OO.md
Created July 29, 2013 12:53
Gist blogging? Yet another exposition on the nature of OO programming.

Object-orientation

There are many articles and discussion threads on the web regarding the nature of Object-oriented (OO) programming. Most of them come at the question from a Programming Language Theory (PLT) perspective, attempting to assert a formal definition of OO programming and objects. I'm not going to do that here. Instead, I'm going to write about objects from an implementation perspective, approaching the subject first from below and then from above.

(defn take-until
([pred-sentinel in] (take-until pred-sentinel in (chan)))
([pred-sentinel in out]
(go (loop []
(if-let [v (<! in)]
(do
(>! out v)
(if-not (pred-sentinel v)
(recur)
(close! out)))
@bkirkbri
bkirkbri / core-async-helpers.clj
Last active December 21, 2015 12:59
Interfacing synchronous systems with core.async
(require [clojure.core.async
:refer [chan dropping-buffer thread <!! >!! >!]])
(defmacro try! [ch & body]
`(let [ch# ~ch]
(try ~@body (catch Throwable t#
(when ch# (>! ch# t#))))))
(defmacro try!! [ch & body]
`(let [ch# ~ch]