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
(defmacro bm [label & body] | |
`(let [start# (. System (nanoTime)) | |
result# ~@body] | |
(prn (str (name ~label) | |
" elapsed time: " | |
(/ (double (- (. System (nanoTime)) start#)) | |
1000000.0) | |
" msecs")) | |
result#)) |
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 fixed-shuffle [coll num] | |
(let [l (java.util.ArrayList. coll)] | |
(java.util.Collections/shuffle l (java.util.Random. num)) | |
(seq l))) |
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
;; GOOD -> | |
(defmacro x [& items] | |
`(let [~(symbol "one") 1 | |
~(symbol "two") 2] | |
(str ~@items))) | |
(x one two) | |
;;;;;;;;;;;;;;;;;; NO GOOD -> |
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
(require '[clojure.contrib.strint :as strint]) | |
(defmacro interpolate-with-map [s & {:as lettings}] | |
`(do | |
(let [{:keys [~@(map (comp symbol name) (keys lettings))]} ~lettings] | |
(strint/<< ~s)))) | |
(interpolate-with-map "test this ~{n}" :n 100) |
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
(group-by-nearness [100 99 80 79 75 50 20 19 1 0.1]) | |
;; => [[100 99] [80 79] [50] [20 19] [1 0.1]] |
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
SEVERE: /leads/register/d2ZwWEFJR1ZuSHEyc2RyQjRWd2QydTNvNjNSeFhKYTcyTGlBc0I3NUpBakM4REhNYVdKNG5lbFQ2REg5bVM4Y05Va0tZR0Z2MjRRUmtFYnhPZGlIZ3FjYTFtcGVyc3M5NUZFb2d2ckpIRXlBSy9NdkpMMStFdW4rdVRaWFRPd2lBWnpoNjh5MUZGd3VvRzU5L0xtSCtZK1l6WmJPOFNZVlJvYU4rc0FUN1JCR0ZzY2UvOS9DYUFPbWZNQzJCWklRTytXRHdldnZiSnpwbFFHOTdsT3M3MmJTL2Rvd0ZMNnlYQ3JLMFNwQkp2TWRFYkRVaDNDRGVlVlgwR1dlYkhSRnhBakRmVnBJM216L3VEY2J3dHVnNTYvSTVkVk1naDIydXRKWTkvc3I1U2djUXNPM25DalA2T0ZpTU1VYlRQdllFNEh6L3hQTmdoZFVKaXcyMmVob24vTHQ3eUxtMHNoQlg2N1ZtL1pYV0x6bVZPZytSS1dIY1paU2VYY2dUQ3VDaEVINTFLdVhESnFzL3YydVZISzBGbVVVdk14TGtQWnNBSC8wTnRLT3dJMlM5d3BwQjl6WGJ5ZGVLbzZoNFNSTUhMYmlTM2IvNWJ3YVVCbGMyN0JxdnVid3pGSHlwemJQVzRsd1hFeFh2ZFE9LS1xeG01MitZN1RXTzFBeGFkempiYlJZcS9sTHMwMWQwTGh0MHJtK0ZoTjhVPQ==?api_key=deaf58821cd873ca2a855d5744eb0072&api_version=1.7.8 | |
java.lang.AssertionError: Assert failed: (string? name) | |
at cloudwatch_clj.cloudwatch$build_metric_datum.doInvoke(cloudwatch.clj:55) | |
at clojure.lang.RestFn.invoke(RestFn.java:486) | |
at cloudwatch_clj.metrics$increment_co |
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
(query [q "test this" | |
colors ["red" "blue"]] | |
(or | |
(contains q) | |
(includes colors))) | |
;; "\"test this\" OR IN(\"red\", \"blue\")" |
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
<ResultSet version="1.0"> | |
<Error>0</Error> | |
<ErrorMessage>No error</ErrorMessage> | |
<Locale>us_US</Locale> | |
<Quality>87</Quality> | |
<Found>1</Found> | |
<Result> | |
<quality>39</quality> | |
<latitude>50.700100</latitude> | |
<longitude>-1.295939</longitude> |
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
class Array | |
# groups an array of sorted numbers | |
# into clusters, where each cluster contains | |
# values that are more close in value than | |
# either the left or right neighboring clusters. | |
def clusterize | |
c = [[]] | |
each_with_index do |x,i| | |
# first time 'round, add the value (x) |
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
(defmacro run [f] | |
`(let [s# (rest ~f)] | |
~@s#)) | |
(run (asdf prn "test")) |