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 non-caching-riemann-client | |
[{:keys [host port] :as riemann-config}] | |
(assert host) | |
(assert port) | |
(let [c (riemann.client/tcp-client :host host :port port)] | |
;; disable dns caching | |
;; If we let riemann cache dns lookups, it can't reconnect to the riemann server after that restarts | |
(-> c | |
.transport | |
.transport |
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
;; fontlock logic vars (for datomic and cascalog) | |
(font-lock-add-keywords | |
'clojure-mode | |
`((,(concat "\\<" | |
"\\?[a-z0-9-]+" | |
"\\>") | |
0 | |
font-lock-keyword-face))) |
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 eval-with-bindings [bindings form] | |
(assert (even? (count bindings)) "an even number of forms in binding vector") | |
(let [binding-pairs (partition 2 bindings) | |
args (mapv first binding-pairs) | |
vals (map second binding-pairs)] | |
`((eval (fn ~args ~form)) | |
~@vals))) | |
(let [foo inc] | |
(eval '(foo 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
;; Toggle a counter that tracks how manny times a function is called | |
(defn instrument-fn [f] | |
(let [counter (atom 0)] | |
(-> (fn [& args] ;; NOTE could unroll for 1-n args for speed | |
(swap! counter inc) | |
(apply f args)) | |
(with-meta | |
{:uninstrumented f | |
:counter counter})))) |
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
{"AWSTemplateFormatVersion":"2010-09-09", | |
"Description":"Creates a classic-link enabled VPC, the custom resource hangs", | |
"Parameters":{}, | |
"Resources": | |
{"VPC": | |
{"Type":"AWS::EC2::VPC", | |
"Properties": | |
{"EnableDnsSupport":true, | |
"EnableDnsHostnames":true, | |
"CidrBlock":"10.0.0.0/16", |
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
sudo wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo | |
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo | |
sudo yum install -y apache-maven | |
mvn --version |
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 invert | |
"inverts a graph represented as a map from source to target nodes" | |
[graph] | |
(reduce-kv (fn [acc src trgs] | |
(if (seq trgs) | |
(reduce (fn [acc- trg] | |
(update acc- trg (fnil conj #{}) src)) | |
acc | |
trgs) | |
;; to preserve nodes without edges |
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
(defun add-clj-format-before-save () | |
(interactive) | |
(add-hook 'before-save-hook | |
'cider-format-buffer | |
t | |
t)) | |
(add-hook 'clojure-mode-hook 'add-clj-format-before-save) |
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
(let [l [0 0 1 1 1 14 5 13 6 3 ] | |
m [0.01 0.02 0.05 0.1 0.2 0.5 1 2 5 10 20 50 100] | |
subtotals (map * m l) | |
total (reduce + subtotals)] | |
(doseq [[munt totaal] (sort-by key > (zipmap m subtotals))] | |
(printf "%s\t%.2f%n" munt (float totaal))) | |
total) |
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 io.micrometer.core.instrument.MeterRegistry | |
import io.micrometer.core.instrument.Tag | |
import java.time.Instant | |
import java.util.concurrent.TimeUnit | |
import java.util.concurrent.atomic.AtomicLong | |
import java.util.function.ToDoubleFunction | |
fun MeterRegistry.timeGaugeMillis(name: String, tags: Iterable<Tag>, initialValue: Long = 0): (Instant) -> Unit { | |
val a = AtomicLong(initialValue) | |
a.apply { |
OlderNewer