Skip to content

Instantly share code, notes, and snippets.

(defn codec-finder
"Returns a function to find the first [path, format] pair in the applicable layout that matches
keyseq exactly."
[layer codec-type]
(let [layout-fn (memoize (fn [id] (layout :read layer id)))]
(fn [keyseq]
(let [layout (layout-fn (first keyseq))]
(when-let [[path format] (first (filter #(match-path? (first %) keyseq)
layout))]
(or (get format key)
(-> []
(given (tempid? filenameid) (conj [:db/add filenameid :file/name filename]))
(given (tempid? pathid) (conj [:db/add pathid :file/name path]))
(given (tempid? nodeid) (conj {:db/id nodeid :node/filename filenameid :node/object id}))
(given newpath (conj [:db/add nodeid :node/paths pathid]))
(given (tempid? id) (conj {:db/id id :git/sha sha :git/type type})))
{:dependencies '[[org.clojure/clojure "1.4.0"]
[org.clojure/clojure "1.3.0" :classifier "sources"]
[org.clojure/clojure "1.3.0"]]}
(preprocess-repos [["foo" {:url "http://foo.com"
:username "u"
:password "p"}]
["bar" "http://bar.com"]])
; [["foo" {:username "u", :url "http://foo.com", :password "p"}], ["bar" {:url "http://bar.com"}]]
(preprocess-deps '[[org.thnetos/cd-client "0.3.0" :classifier "foo"]
[org.clojure/tools.nrepl "0.2.0-beta2" :extension "bar"]])
; [[[org.thnetos/cd-client "foo" nil] {:version "0.3.0"}] [[org.clojure/tools.nrepl nil "bar"] {:version "0.2.0-beta2"}]]
FAIL in (test-merge-profile-paths) (project.clj:86)
expected: (= {:url "http://", :username "u", :password "p"} (-> {:repositories [["foo" {:url "http://", :creds :gpg}]], :profiles {:blue {:repositories {"foo" {:url "http://", :username "u", :password "p"}}}}} (merge-profiles [:tes :qa :blue]) :repositories last last))
actual: (not (= {:username "u", :url "http://", :password "p"} {:creds :gpg, :url "http://"}))
user=> (meta ^:foo [1 2 3])
{:foo true}
user=> (meta ^:foo '(1 2 3))
{:line 1}
fallout:drip develop$ (export LEIN_JAVA_CMD=; time lein version)
Leiningen 2.0.0-SNAPSHOT on Java 1.6.0_29 Java HotSpot(TM) 64-Bit Server VM
real 0m2.368s
user 0m5.499s
sys 0m0.211s
fallout:drip develop$ time lein version
Leiningen 2.0.0-SNAPSHOT on Java 1.6.0_29 Java HotSpot(TM) 64-Bit Server VM
real 0m0.628s
@ninjudd
ninjudd / bar.sh
Created August 30, 2012 20:44
Command substitution hangs if the command starts a process in the background.
foo=$(./foo.sh)
echo "foo is '$foo'"
@ninjudd
ninjudd / gist:3491702
Created August 27, 2012 19:46
Lein with Decaf
fallout:~ master$ time lein version
Leiningen 2.0.0-SNAPSHOT on Java 1.6.0_29 Java HotSpot(TM) 64-Bit Server VM
real 0m2.041s
user 0m5.020s
sys 0m0.189s
fallout:~ master$ time LEIN_JAVA_CMD=decaf lein version
Leiningen 2.0.0-SNAPSHOT on Java 1.6.0_29 Java HotSpot(TM) 64-Bit Server VM
(defun compress-space-forward ()
"*Replaces all spaces, tabs and newlines after point with a single space."
(interactive)
(re-search-forward "[ \t\n\r]+\\([^ \t\n\r]\\)" nil t)
(replace-match " \\1" nil nil))
(defun compress-space-backward ()
"*Replaces all spaces, tabs and newlines after point with a single space."
(interactive)
(re-search-backward "\\([^ \t\n\r]\\)[ \t\n\r]+" nil t)