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 jquerytest.core) | |
(def jquery (js* "$")) | |
(jquery | |
(fn [] | |
(-> (jquery "div.meat") | |
(.html "This is a test.") | |
(.append "<div>Look here!</div>")))) |
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
(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) |
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
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 |
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 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)) |
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 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)))) |
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
~/$ 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] |
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
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 |
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
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'; |
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
~/projects/cloby ➔ cat examples/simple.rb | |
require 'cloby' | |
class MyClojureObj < Clojure::Object | |
def initialize | |
dosync { @foo = 'foo' } | |
end | |
attr_accessor :foo | |
end |
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
user> (read-string (str {:hai "there" "hello" 3 5 "5"})) | |
{:hai "there", "hello" 3, 5 "5"} |