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 foo | |
(:use clojure.contrib.seq-utils)) | |
(gen-class | |
:name foo.Bar | |
; :init init | |
; :constructors {[clojure.lang.IFn]} | |
:methods [[callback [] Integer]] |
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
(defmacro sender [name freq iface ufun] | |
`(proxy [EchoSender] [~name ~freq ~iface] | |
(send [o#] dorun (. o# (first ~ufun) (second ~ufun))))) | |
(sender "moje" 500 MyMessage '(message "Hello World")) | |
;; Currently expands to: | |
(proxy | |
[EchoSender] |
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
(defproject org.clojars.ato/too-hot "1.0.0" | |
:description "A very simple Fahrenheit to Celsius converter." | |
:dependencies [[org.clojure/clojure "1.1.0"]] | |
:dev-dependencies [[lein-clojars "0.5.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 write [name data] | |
(let [buf (make-array Byte/TYPE 1024) | |
dest (FileOutputStream. name)] | |
(with-open [r (BufferedInputStream. data) | |
w (BufferedOutputStream. dest)] | |
(loop [bytes (.read r buf 0 1024)] | |
(when-not (= bytes -1) | |
(.write w buf 0 bytes) | |
(recur (.read r buf 0 1024))))) | |
(println "Wrote" name))) |
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 clojars.couch | |
(:use [com.reasonr.scriptjure :only (js)]) | |
(:require (couchdb [client :as couch]) | |
(clojars [maven :as maven]) | |
(clojure.contrib [error-kit :as kit]))) | |
(def *db* "clojars") | |
(defn get-doc | |
"Wrapper for couch/document-get that's shorter to type and just |
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
;; | |
;; My outer Clojure is 1.1.0-alpha | |
;; | |
(let [loader (URLClassLoader. | |
(into-array | |
URL [(URL. "file:///usr/share/java/clojure-1.0.0.jar")]) | |
(.getParent (ClassLoader/getSystemClassLoader))) | |
nested-rt (.loadClass loader "clojure.lang.RT") | |
get-var (.getMethod nested-rt "var" (into-array Class [String String]))] |
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 inside? [[z-re z-im]] | |
(> (+ (* z-re z-re) (* z-im z-im)) 4)) | |
(defn step [c-re c-im [z-re z-im]] | |
[(+ (* 2 z-re z-im) c-im) | |
(+ (- (* z-re z-re) (* z-im z-im)) c-re)]) | |
(doseq [y (range image-height) | |
:let [c-im (- max-im (y * im-factor))] | |
x (range image-width)] |
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 map-structure [xs [y & ys]] | |
(lazy-seq | |
(when y | |
(let [[head tail] (split-at (count y) xs)] | |
(cons head | |
(map-structure tail ys)))))) | |
(map-structure [1 2 3 4] [[0] [1 1 1]]) | |
;; => ((1) (2 3 4)) |
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
escaped_args="" | |
for arg in "$@"; do | |
escaped_args="$escaped_args"' "'$(echo "$arg" | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g')'"' | |
done | |
exec java -client -cp "$CLASSPATH" clojure.main -e "(use 'leiningen.core)(main $escaped_args)" |
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 take-tweets [n] | |
(take n (map read-json | |
(line-seq (reader | |
(get-stream)))))) | |
(defn tweet-text [n] | |
(map #(get % "text") | |
(take-tweets n))) | |
(defn search-text [s coll] |