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 swanker "0.1.0-SNAPSHOT" | |
:description "Swank REPL for various usages" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.4.0"] | |
[swank-clojure "1.4.2"] | |
[javax.servlet/servlet-api "2.5" :scope "provided"]] | |
:aot [swanker.core]) |
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 pomoclojo.core | |
(:import [org.apache.commons.exec | |
PumpStreamHandler | |
DefaultExecutor | |
ExecuteWatchdog | |
CommandLine] | |
[java.io ByteArrayOutputStream]) | |
(:use [clj-time.core :only [in-secs in-minutes now interval plus minus within? minutes secs]])) | |
(defn execute |
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
INFO: Initiating Jersey application, version 'Jersey: 1.4 09/11/2010 10:30 PM' | |
Jul 27, 2012 6:00:42 PM com.sun.jersey.spi.inject.Errors processErrorMessages | |
SEVERE: The following errors and warnings have been detected with resource and/or provider classes: | |
WARNING: A sub-resource method, public javax.ws.rs.core.Response com.cloudera.hoop.Hoop.root(java.security.Principal,com.cloudera.hoop.GetOpParam,com.cloudera.hoop.FilterParam,com.cloudera.hoop.DoAsParam) throws java.io.IOException,com.cloudera.lib.service.HadoopException, with URI template, "/", is treated as a resource method | |
SEVERE: Method, public javax.ws.rs.core.Response com.cloudera.hoop.Hoop.get(java.security.Principal,com.cloudera.hoop.FsPathParam,com.cloudera.hoop.GetOpParam,com.cloudera.hoop.OffsetParam,com.cloudera.hoop.LenParam,com.cloudera.hoop.FilterParam,com.cloudera.hoop.DoAsParam) throws java.io.IOException,com.cloudera.lib.service.HadoopException, annotated with GET of resource, class com.cloudera.hoop.Hoop, is not recognized as valid |
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 servlets | |
"Map of servlet classes to ring handlers, add here. Needs to be quoted so symbols resolve to themselves." | |
'{:my.servlet.class.Servlet hr/app}) | |
(defmacro make-servlet | |
"Call to generate a servlet class given the class name and a ring handler." | |
[servlet handler] | |
(let [servlet (name servlet) | |
prefix (str servlet "-")] | |
`(do (println "Compiling Servlet" ~servlet) |
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 OPTIONS | |
"Generate a OPTIONS route with the given response." | |
[response] | |
(fn [request] | |
(when (= (:request-method request) :options) | |
response))) | |
(defroutes routes | |
(GET "/" [] "<h1>Hello World</h1>") | |
(context (:registry contexts) [] registry) |
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 assert-only-expected-keys | |
"Make sure that there are no extra keys in the item" | |
[keyset item] | |
(mapv (fn [k] (is (keyset k) (str k " is not one of " keyset))) | |
(keys item)) | |
item) | |
(defn assert-all-expected-keys | |
"Make sure that every expected key exists in the item" | |
[keyset item] |
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
var jq = document.createElement('script'); | |
jq.src = "http://code.jquery.com/jquery-latest.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
jQuery.noConflict(); | |
$('div a').map(function(){return this.title;}).each(function(){console.log(this.toString())}) | |
Borges: A Life | |
Island | |
Smalltalk 80: Bits Of History, Words Of Advice |
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 let-map | |
[pairs] | |
(let [names (map first (partition 2 pairs))] | |
`(let [~@pairs] | |
(zipmap | |
[~@(map (comp keyword name) names)] | |
[~@names])))) |
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 let-map | |
"Avoids having to build maps from let bindings manually" | |
[bindings] | |
(let [names (->> (take-nth 2 bindings) | |
(tree-seq #(or (sequential? %) (map? %)) identity) | |
(filter symbol?) | |
(into #{})) ; dumps it all into a set | |
bindings (destructure bindings)] | |
`(let [~@bindings] | |
(zipmap [~@(map keyword names)] |
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 xml.test | |
(:require [clojure.java.io :as io] | |
[clojure.data.xml :as xml])) | |
;; wget | |
;; download.geofabrik.de/openstreetmap/north-america/us/maryland.osm.bz2 | |
(def xml-seq | |
#(-> (io/file "/home/gary/dev/maryland.osm") | |
io/input-stream |