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
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 |
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
;; 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 |
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 sort-by-keys [keys maps] | |
(sort (fn [x y] | |
(first (remove #(= 0 %) | |
(map #(compare (% x) (% y)) keys)))) | |
maps)) | |
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 zip-with [fs & arg-seqs] | |
(apply map (fn [f & args] (apply f args)) fs arg-seqs)) | |
;; => (zip-with [+ -] [1 2] [3 4]) => '(4 -2) |
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 zip-with [fs & arg-seqs] | |
(apply map (fn [f & args] (apply f args)) fs arg-seqs)) | |
;; => (zip-with [+ -] [1 2] [3 4]) => '(4 -2) |
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 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] |
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
(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) |
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 attendance.core | |
(:use karras.core | |
karras.collection | |
karras.sugar | |
compojure.core | |
ring.adapter.jetty | |
hiccup.core) | |
(:require [compojure.route :as route])) | |
(defn home [] |
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 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 "[email protected]:%s/%s.git" | |
(:owner repo) (:name repo)) |
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 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/") |