Skip to content

Instantly share code, notes, and snippets.

View mpenet's full-sized avatar
🪲
breeding bugs

Max Penet mpenet

🪲
breeding bugs
View GitHub Profile
@mpenet
mpenet / gist:5178232
Created March 16, 2013 20:39
problem with Seq* ?
user> (defn foo [x] (apply str x))
#'user/foo
user> (ann foo [(Seq* String) -> String])
[user/foo (Fn [(Seq* java.lang.String) -> java.lang.String])]
user> (cf (foo (seq ["a" "b"])))
Exception Type Error, NO_SOURCE_FILE:1
/**
* <p>Represents a point on the surface of a sphere. (The Earth is almost
* spherical.)</p>
*
* <p>To create an instance, call one of the static methods fromDegrees() or
* fromRadians().</p>
*
* <p>This code was originally published at
* <a href="http://JanMatuschek.de/LatitudeLongitudeBoundingCoordinates#Java">
* http://JanMatuschek.de/LatitudeLongitudeBoundingCoordinates#Java</a>.</p>
(defmacro has
([p k v]
`(.has ^GremlinPipeline ~p ~(name k) ~v))
([p k c v]
`(.has ^GremlinPipeline ~p ~(name k)
(convert-symbol-to-compare '~c)
~v)))
(defmacro has-not
(defn x->sha1
[x]
(->> (.getBytes (pr-str x))
(.digest (java.security.MessageDigest/getInstance "SHA1"))
(#(apply str (map (fn [i] (format "%02x" (bit-and i 0xff))) %)))))
(prn (x->sha1 {:a 2}))
"0be74d5e229441849c6c1e4a5e4b80c4c7b84312"
(extend-type js/NodeList
Seqable
(-seq [array] (array-seq array 0)))
@mpenet
mpenet / gist:5421208
Created April 19, 2013 15:46
en stopwords
a
a's
able
about
above
according
accordingly
across
actually
after
;; example of query that takes results by pairs,
;; and uses the last value of x to create the new chunks, incrementing its value.
(lazy-query (select :items
(limit 2)
(where {:x 1}))
(fn [query coll]
(merge query (where {:x (-> coll last :x inc)}))))
@mpenet
mpenet / gist:5793357
Last active December 18, 2015 13:58
Freezing speed up attempt, using non sync versions of bytearray iostream from apache Harmony.
linux-headers-3.12.6-031206-generic_3.12.6-031206.201312201218_amd64.deb
linux-headers-3.12.6-031206_3.12.6-031206.201312201218_all.deb
linux-image-3.12.6-031206-generic_3.12.6-031206.201312201218_amd64.deb

On the evilness of the clojure array-map and why you should avoid relying on its ordering:

user> (reduce #(assoc %1 %2 %2) (array-map) (range 10))
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9}

user> (reduce #(assoc %1 %2 %2) (array-map) (range 30))
{0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7, 8 8, 9 9, 10 10, 11 11, 12 12, 13 13, 14 14, 15 15, 16 16, 17 17, 18 18, 19 19
, 20 20, 21 21, 22 22, 23 23, 24 24, 25 25, 26 26, 27 27, 28 28, 29 29}