Skip to content

Instantly share code, notes, and snippets.

@devn
devn / jquerytest.cljs
Created December 16, 2011 06:01 — forked from ryancrum/jquerytest.cljs
How to use jQuery from ClojureScript
(ns jquerytest.core)
(def jquery (js* "$"))
(jquery
(fn []
(-> (jquery "div.meat")
(.html "This is a test.")
(.append "<div>Look here!</div>"))))
@devn
devn / fm.clj
Created December 9, 2011 04:46 — forked from harold/fm.clj
(definst fm [carrier 440 divisor 2.0 depth 1.0]
(let [modulator (/ carrier divisor)
mod-env (env-gen (lin-env 1 0 1))
amp-env (env-gen (lin-env 0 1 1))]
(* amp-env
(sin-osc (+ carrier
(* mod-env (* carrier depth) (sin-osc modulator)))))))
; Some of these are more or less interesting
(fm)
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
(ns demo.gemstoclojure
(:require [ring.adapater.jetty :as jetty]
[clojure.contrib.io :as io]
[clojure.contrib.classpath :as cp])
(:import [org.jruby.embed ScriptingContainer LocalContextScope]))
(def container (ScriptingContainer. LocalContextScope/THREADSAFE))
(println (cp/classpath))
(println (io/pwd))
@devn
devn / state-is-a-fold.clj
Created June 21, 2011 00:16 — forked from ordnungswidrig/state-is-a-fold.clj
State is a fold over events
(ns state-is-a-fold
(:use clojure.test))
;;; After all, state is a fold of events. For example let's say the events are a sequence of numbers
;;; and we are folding by addition:
(deftest simple
(let [events [1 5 2 4 3]
state (reduce + events)]
(is (= 15 state))))
@devn
devn / gist:1003844
Created June 2, 2011 02:53 — forked from weavejester/gist:1001206
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
watch( 'test/.*\.clj' ) {|md| test_stuff }
watch( 'src/.*\.clj' ) {|md| test_stuff }
def colorize(text, color_code)
"#{color_code}#{text}\e[1;37m"
end
def red(text); colorize(text, "\e[0;31m"); end
def green(text); colorize(text, "\e[0;32m"); end
@devn
devn / model.js
Created January 28, 2011 17:11 — forked from wagenet/model.js
MyApp.MyModel.mixin({
resourcePathFor: function(action, storeKey, item) {
var id, path;
id = storeKey ? MyApp.store.idFor(storeKey) : null;
switch(action) {
case 'fetch':
case 'create':
path = 'items';
~/projects/cloby ➔ cat examples/simple.rb
require 'cloby'
class MyClojureObj < Clojure::Object
def initialize
dosync { @foo = 'foo' }
end
attr_accessor :foo
end
user> (read-string (str {:hai "there" "hello" 3 5 "5"}))
{:hai "there", "hello" 3, 5 "5"}