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:9185061
Created February 24, 2014 10:15
twttr.txt.regexen.extractUrl
/(((?:[^A-Za-z0-9@@$##￾￿‪-‮]|^))((https?:\/\/)?((?:(?:(?:[^/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$// …  ᠎

    -
 - //￾￿‪-‮/](?:[_-]|[^/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$// …  ᠎

    -
 - //￾￿‪-‮/])*)?[^/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$// …  ᠎

    -
 - //￾￿‪-‮/]\.)*(?:(?:[^/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$// …  ᠎

    -
 - //￾￿‪-‮/](?:-|[^/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$// …  ᠎

    -
 - //￾￿‪-‮/])*)?[^/\!'#%&'\(\)*\+,\\\-\.\/:;<=>\?@\[\]\^_{|}~\$// …  ᠎

    -
 - //￾￿‪-‮/]\.)(?:(?:(?:aero|asia|biz|cat|com|coop|edu|gov|info|int|jobs|mil|mobi|museum|name|net|org|pro|tel|travel|xxx)(?=[^0-9a-zA-Z@]|$))|(?:(?:ac|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cs|cu|cv|cx

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}
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
@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.
;; 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:5421208
Created April 19, 2013 15:46
en stopwords
a
a's
able
about
above
according
accordingly
across
actually
after
(extend-type js/NodeList
Seqable
(-seq [array] (array-seq array 0)))
(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"
(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
/**
* <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>