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
import com.datastax.driver.core.*; | |
import com.datastax.driver.core.exceptions.InvalidTypeException; | |
import java.nio.ByteBuffer; | |
public class LongToDateDemo { | |
public static class LongToDateCodec extends TypeCodec<Integer> { | |
// Piggyback on the default codecs' implementation |
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 invoke-private-method [obj fn-name-string & args] | |
(let [m (first (filter (fn [x] (.. x getName (equals fn-name-string))) | |
(.. obj getClass getDeclaredMethods)))] | |
(. m (setAccessible true)) | |
(. m (invoke obj args)))) | |
(defn private-field [obj fn-name-string] | |
(let [m (.. obj getClass (getDeclaredField fn-name-string))] | |
(. m (setAccessible true)) | |
(. m (get obj)))) |
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.core.async :as a]) | |
(def xform (comp (map inc) | |
(filter even?) | |
(dedupe) | |
(flatmap range) | |
(partition-all 3) | |
(partition-by #(< (apply + %) 7)) | |
(flatmap flatten) | |
(random-sample 1.0) |
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
;;;;;;;;;;;;;;;;;; | |
;; $Rev$ | |
;; textflow is a trivial generator of RFC like call flow (a.k.a sequence diagrams) | |
;; | |
;; Example usage: | |
;; (flow [Alice Bob Tzach] | |
;; [[mmm Tzach Bob] | |
;; [xxx Bob Alice] | |
;; [] | |
;; [zzz Alice Tzach]]) |
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
#!/bin/bash | |
containers=`sudo find /var/lib/docker/graph/ -maxdepth 1 -type d -printf "%f "` | |
docker rmi $containers |
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 mlimotte.util) | |
; A variation on clojure.core/merge-with | |
(defn merge-with-key | |
"Returns a map that consists of the rest of the maps conj-ed onto | |
the first. If a key occurs in more than one map, the mapping(s) | |
from the latter (left-to-right) will be combined with the mapping in | |
the result by calling (f key val-in-result val-in-latter)." | |
[f & maps] |
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
#!/bin/sh | |
policy=${HOME}/.jstatd.all.policy | |
[ -r ${policy} ] || cat >${policy} <<'POLICY' | |
grant codebase "file:${java.home}/../lib/tools.jar" { | |
permission java.security.AllPermission; | |
}; | |
POLICY | |
jstatd -J-Djava.security.policy=${policy} & |
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
import com.google.protobuf.DescriptorProtos; | |
import com.google.protobuf.Descriptors; | |
import com.google.protobuf.DynamicMessage; | |
import com.google.protobuf.Message; | |
import java.util.HashMap; | |
/** | |
* ProtobufEnvelope - allows creating a protobuf message without the .proto file dynamically. | |
* |