Skip to content

Instantly share code, notes, and snippets.

View wilkes's full-sized avatar

Wilkes Joiner wilkes

View GitHub Profile
def copy_to_temp(file_upload):
tmp = tempfile.NamedTemporaryFile(delete=False)
while True:
data = file_upload.read(8192)
tmp.write(data)
if not data:
break
tmp.flush()
return tmp
;; in the repl
(use 'kibitz.growl)
(def a (growl-watch-project "path-to-your-project"))
;; keep the agent around since kibitz is a bit buggy now
(defn sort-by-keys [keys maps]
(sort (fn [x y]
(first (remove #(= 0 %)
(map #(compare (% x) (% y)) keys))))
maps))
(defn zip-with [fs & arg-seqs]
(apply map (fn [f & args] (apply f args)) fs arg-seqs))
;; => (zip-with [+ -] [1 2] [3 4]) => '(4 -2)
(defn zip-with [fs & arg-seqs]
(apply map (fn [f & args] (apply f args)) fs arg-seqs))
;; => (zip-with [+ -] [1 2] [3 4]) => '(4 -2)
(ns karras.test-hooks
(:require [karras.core :as karras])
(:use karras.entity
karras.sugar
[karras.collection :only [drop-collection collection]]
clojure.test
midje.semi-sweet
robert.hooke))
(defn get-type [entity-or-type]
(deftest using-hooke
(let [count (atom 0)]
(defn log-create [f & args]
(let [result (apply f args)]
(when (= Company (first args))
(swap! count inc))
result))
(add-hook #'create log-create)
@wilkes
wilkes / core.clj
Created June 3, 2010 21:14 — forked from bhenry/core.clj
(ns attendance.core
(:use karras.core
karras.collection
karras.sugar
compojure.core
ring.adapter.jetty
hiccup.core)
(:require [compojure.route :as route]))
(defn home []
(ns backup-user
(:use github-clj
[clojure.contrib.pprint :only [pprint]]
[clojure.contrib.shell-out :only [sh]])
(:import [java.io File]))
(defn clone-repo [repo dir]
(sh "git" "clone"
(format "git@github.com:%s/%s.git"
(:owner repo) (:name repo))
(ns github-clj
(:use clojure.contrib.json.read)
(:require [clojure.http.client :as http]))
;; List all repose GET repos/show/:user
(defn auth-info [login token]
(http/url-encode {"login" login "token" token}))
(def base-url "http://github.com/api/v2/json/")