Skip to content

Instantly share code, notes, and snippets.

@ato
ato / gist:212785
Created October 18, 2009 18:29
liverepl.sh
#!/bin/sh
# Starter script for Clojure liverepl
[ -z "$JDK_HOME" ] && JDK_HOME=/usr/lib/jvm/default-java
LIVEREPL_HOME="$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
CLOJURE_JAR="$LIVEREPL_HOME/clojure.jar"
if [ ! -f "$JDK_HOME/lib/tools.jar" ]; then
echo 'Unable to find $JDK_HOME/lib/tools.jar'
echo "Please set the JDK_HOME environment variable to the location of your JDK."
@ato
ato / scroller.c
Created October 25, 2009 12:53 — forked from farcaller/scroller.c
// simplified and fixed bug where too many \b characters were printed
#include <stdio.h>
#include <unistd.h>
int main (int argc, const char *argv[])
{
int i;
const char scroller[] = "|/-\\";
for(i=0; i<20; ++i) {
printf("%c", scroller[i % (sizeof(scroller) - 1)]);
@ato
ato / wget.sh
Created October 27, 2009 22:58
# wget with notifications!
function wget() {
command wget "$@"
ret=$?
notify-send -i $HOME/.icons/down.svg "Download complete" "wget $*" &> /dev/null
return $ret
}
@ato
ato / fod.clj
Created November 1, 2009 12:38
(def randArray
(for [y (range 100)]
(persistent!
(reduce (fn [v _] (conj! v (rand)))
(transient []) (range (* 100 1000))))))
(def sums (map #(reduce + %) randArray))
(time (dorun (map println sums)))
(defn dostuff []
(couch/get document-id)
(couch/set document-id))
(defn dootherstuff []
(couch/get document-id))
(defn main []
(couch/with-couch host db
(dostuff)
@ato
ato / esj.clj
Created November 4, 2009 23:57
(defn esj-problem
[n limit s]
(if-not (seq s) ; reached end of input?
(when-not (zero? n) ; if there's anything left-over return it
(list n))
(if (>= n limit) ; have we reached the limit?
(lazy-seq ; if so, spit out a new output
(cons n (esj-problem 0 limit s)))
; haven't reached limit, gobble some more input
(recur (+ n (first s)) limit (next s)))))
(defmacro one []
"a one")
(defmacro two []
"and a two")
(defmacro whee [sym]
`(~sym))
(defmacro wheez [s]
@ato
ato / jarspec.clj
Created November 11, 2009 02:14
proposed changes to clojure dep specification
;; (based on http://github.com/technomancy/leiningen)
;;
;; Base changes:
;;
;; - defproject becomes defjar (allow multiple jars per project)
;;
;; - use group.id/jarname "1.0" instead of ["group.id" "jarname" "version"]
;; more clojureish and easier to type
;;
;; - drop :version keyword, version should always be required so it's
(defn make-repo
"Does the crazy factory voodoo necessary to get an ArtifactRepository object."
[id url]
(-> (.lookup container ArtifactRepositoryFactory/ROLE)
(.createDeploymentArtifactRepository
id url (.lookup container ArtifactRepositoryLayout/ROLE "default") true)))
% scp compojure/pom.xml compojure/target/compojure-0.3.1.jar clojureql/jarspec.clj clojureql/build/clojureql.jar clojars@clojars.org:
Welcome to Clojars, ato!
pom.xml 100% 2610 2.6KB/s 00:00
compojure-0.3.1.jar 100% 451KB 451.4KB/s 00:00
jarspec.clj 100% 219 0.2KB/s 00:00
clojureql.jar 100% 206KB 205.9KB/s 00:00
Deploying org.clojars.ato/compojure 0.3.1
[INFO] Uploading project information for compojure 0.3.1
[INFO] Retrieving previous metadata from clojars