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 winston.logging | |
| (:import (org.apache.log4j Logger | |
| BasicConfigurator | |
| Level) | |
| (org.apache.log4j.spi RootLogger)) | |
| (:import org.apache.commons.logging.LogFactory)) | |
| (BasicConfigurator/configure) | |
| (. (Logger/getRootLogger) (setLevel Level/WARN)) |
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 nth-> | |
| "Fast lookup into nested vectors. Indices must be ints" | |
| [coll [id & idx]] | |
| (let [coll (with-meta coll {:tag Indexed})] | |
| (if (seq idx) | |
| `(nth-> (.nth ~coll ~id) ~idx) | |
| `(.nth ~coll ~id)))) |
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 || | |
| "unarrow. Ignores the first argument, then calls (apply f args). Returns the first argument, so arrowing can continue" | |
| [in f & args] | |
| (apply f args) | |
| in) |
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 slow-uber "0.1.0-SNAPSHOT" | |
| :description "A lein project demonstrating slow uberjar" | |
| :dependencies [[org.clojure/clojure "1.2.0"] | |
| [org.clojure/clojure-contrib "1.2.0"] | |
| [log4j "1.2.14"] | |
| [commons-logging/commons-logging "1.1.1"] | |
| [commons-dbcp/commons-dbcp "1.4"] | |
| [commons-email/commons-email "1.1"] | |
| [commons-codec/commons-codec "1.4"] | |
| [org.compass-project/compass "2.1.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
| ;;; the docstring doesn't quite match the implementation, but you get the idea. | |
| (defmacro fold | |
| "sugar on reduce, similar to how 'for' is a nicer version of 'map'. | |
| init is a symbol that evaluates to a value (local or var) or a vector of a symbol and an initial value. In the loop, init is bound to the result of the previous loop. | |
| Binding can take any arguments supported by for, but should only bind one variable. | |
| " | |
| ;; (fold r [i (range 10)] ;; existing symbol |
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
| (defmulti coerce (fn [tag val] tag) | |
| (defmethod coerce :int [tag val] | |
| (if (string? val) | |
| (Integer/parseInt val) | |
| val)) | |
| (defpage "/foo/:id" {^:int id :id} | |
| ...) | |
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 inspect | |
| "prints the expression '<name> is <value>', and returns the value" | |
| [value] | |
| `(let [result# ~value] | |
| (println '~value "is" (with-out-str (clojure.pprint/pprint result#))) | |
| result#)) |
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
| ;; requires [org.ccil.cowan.tagsoup/tagsoup "1.2"] | |
| (defn startparse-tagsoup [s ch] | |
| (let [p (new org.ccil.cowan.tagsoup.Parser)] | |
| (. p (setContentHandler ch)) | |
| (. p (parse s)))) | |
| (defn parse-html-string [html] | |
| (xml/parse (new org.xml.sax.InputSource | |
| (new java.io.StringReader html)) |
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
| java.sql.SQLException: No suitable driver | |
| at java.sql.DriverManager.getDriver(DriverManager.java:279) | |
| at com.mchange.v2.c3p0.DriverManagerDataSource.driver(DriverManagerDataSource.java:223) | |
| at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:134) | |
| at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:182) | |
| at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:171) | |
| at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:137) | |
| at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1014) | |
| at com.mchange.v2.resourcepool.BasicResourcePool.access$800(BasicResourcePool.java:32) | |
| at com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask.run(BasicResourcePool.java:1810) |
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 builder-group | |
| (pallet.core/group-spec | |
| "Linux image for building" | |
| :node-spec (pallet.core/node-spec | |
| :image {:os-family :ubuntu :image-id "us-east-1/ami-06ad526f"} | |
| :network {:inbound-ports [22]}) | |
| :phases {:bootstrap (resource/phase | |
| (automated-admin-user/automated-admin-user)) | |
| :configure (pallet.resource/phase | |
| (pallet.action.package/package "git"))})) |