Navigation Menu

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
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}
@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
@mpenet
mpenet / foami.clj
Last active August 29, 2015 14:07 — forked from ztellman/foami.clj
(ns foami.core
"FOreign Asynchronous Mechanism Interop"
(:require [clojure.core.async :as async]))
(defn put!
"Takes a `ch`, a `msg`, a single arg function that when passed `true` enables backpressure
and when passed `false` disables it, and a no-arg function which, when invoked, closes the
upstream source."
[ch msg backpressure! close!]
(let [status (atom :sending)]
(defn put!
"Takes a `ch`, a `msg`, a fn that enables backpressure, one that disables it,
and a no-arg function which, when invoked, closes the upstream source."
([ch msg suspend! resume! close!]
(let [status (atom ::sending)]
(async/put! ch msg
(fn [result]
(if-not result
(when close! (close!))
(do
(defn foo
[{:keys [x]
:or {x (println :set-default)}}]
x)
user> (foo {:x 1})
:set-default
1
jQuery.format = function(s, args) {
return s.replace(/\{([^}]+)\}/g, function(_, match){return args[match] || '';});
};
>> $.format('Hello {world}, {again}', {world: "universe", again: "testing"});
"Hello universe, testing"
>> $.format('Hello {0}, {1}', ["foo", "bar"]);
"Hello foo, bar"
var T = function(){ this.t = function(){return 't'} };
T.prototype.tp = function(){return 'tp'};
var inst = new T();
console.log(inst.hasOwnProperty('t'), inst.hasOwnProperty('tp'))
console.log(inst.t(), inst.tp())
>> true false
>> t tp
(defun compile-cljs-on-after-save-hook ()
(add-hook 'after-save-hook
'(lambda ()
(interactive)
(let* ((file-name (buffer-file-name))
(file-name-dir (file-name-directory file-name)))
(if (string-match "\.cljs$" file-name)
(async-shell-command
(concat "cljsc " file-name-dir
;; " '{:optimizations :advanced}' > "
@mpenet
mpenet / gist:1308683
Created October 24, 2011 09:42
cql dsl
(select :user
(limit 100)
(using :consistency :quorum)
(columns [:a :b]
:reversed true
:first 100)
(where
;; simple key lookup
(pk 1)