This file contains 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
public class SimpleMongoConnectionTest { | |
... | |
private static Process mongod; | |
// TODO - this a clumsy way to start/stop a mongod. works for now. | |
@BeforeClass | |
public static void startMongoDB() throws IOException, InterruptedException | |
{ |
This file contains 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
;; mutate a StringBuilder in place. Listen for the sound of a clojure bunny dying somewhere.. | |
;; | |
(defn remove-curlied-optimized2 | |
"Remove {something} from a string or {something else}" | |
[^String text] | |
(let [ tb (StringBuilder. text)] | |
(loop [lo (.lastIndexOf tb "{" ) | |
lc (.indexOf tb "}" lo)] | |
(assert (<= lo lc)) ; sanity check. | |
(if (= -1 lo) |
This file contains 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
package cemerick; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ThreadPoolExecutor; | |
import java.util.concurrent.TimeUnit; | |
import java.util.concurrent.atomic.AtomicLong; | |
@SuppressWarnings({"rawtypes", "unchecked"}) |
This file contains 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 follow-redirect | |
[client {:keys [uri url scheme server-name server-port] :as req} | |
{:keys [trace-redirects] :as resp}] | |
(let [url (or url (str (name scheme) "://" server-name | |
(when server-port (str ":" server-port)) | |
uri)) | |
raw-redirect (get-in resp [:headers "location"]) | |
redirect (str (URL. (URL. url) raw-redirect))] | |
((wrap-redirects client) (-> req | |
(merge (parse-url redirect)) |
This file contains 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 my.service | |
(:require [clojurewerkz.quartzite.scheduler :as qs] | |
[clojurewerkz.quartzite.triggers :as t] | |
[clojurewerkz.quartzite.jobs :as j]) | |
(:use [clojurewerkz.quartzite.jobs :only [defjob]] | |
[clojurewerkz.quartzite.schedule.simple :only [schedule with-repeat-count with-interval-in-milliseconds]])) | |
(defn -main | |
[& m] | |
(qs/initialize) |
This file contains 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 ratelimit | |
"Implement rate limiting using a token bucket" | |
(:require [clojure.core.async :as async :refer [<!! >! alts! go chan dropping-buffer close! timeout]])) | |
(defprotocol TokenBucket | |
(take-token [this]) | |
(release [this])) | |
(defn- ->period-ms [p] | |
(if (keyword? p) |
This file contains 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
(defprotocol Page | |
(next-page [this]) | |
(data [this]) | |
(next? [this])) | |
(defprotocol Paged | |
(paged-response [this uri query-params])) |
This file contains 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 csv-as-maps-seq [f] | |
(let [[header & data] (csv/read-csv (io/reader f))] | |
(map (partial zipmap header) data))) |
This file contains 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
; sleep for a bit, shouldn't cause a problem | |
;(Thread/sleep 5000) | |
;(Thread/sleep 10000) | |
(Thread/sleep 15000) |
This file contains 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 slf4j-version "1.7.5") | |
(def cascalog-version "2.0.0") | |
(defproject nesta-innovators "0.2.3-SNAPSHOT" | |
:description "Nesta Innovators" | |
:url "http://www.mastodonc.com" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[org.clojure/data.xml "0.0.7"] | |
[org.clojure/data.csv "0.1.2"] |
OlderNewer