Skip to content

Instantly share code, notes, and snippets.

View lukaszkorecki's full-sized avatar
🌴
🛹

Łukasz Korecki lukaszkorecki

🌴
🛹
View GitHub Profile
function add1(arg) {
return arg + 1;
}
function sub2(arg) {
return arg - 2
}
function add1ToColl(coll) {
nodeProg=$(which node)
if [[ "$nodeProg" = "" ]] ; then
nodeProg=$(which nodejs)
fi
@lukaszkorecki
lukaszkorecki / keycapsizes.txt
Last active May 30, 2016 18:17
Planck default keymap
/* Keycap sizes
* ,-----------------------------------------------------------------------------------.
* | R3 | R3 | R3 | R3 | R3 | R3 | R3 | R3 | R3 | R3 | R3 | R3 |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* | R2 | R2 | R2 | R2 | R2 | R2 | R2 | R2 | R2 | R2 | R2 | R2 |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* | R1 | R1 | R1 | R1 | R1 | R1 | R1 | R1 | R1 | R1 | R1 | R1 |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* | R1 | R1 | R1 | R1 | R1 | R1x2 | R1 | R1 | R1 | R1 | R1 |
* `-----------------------------------------------------------------------------------'
r.db('rethinkdb')
.table('jobs')
.filter(function(j) {
return j('type').eq('query')
.and(j('duration_sec').gt(0.001))
.and(j('info')('query').match('jobs').eq(null))
.and(j('info')('query').match('rethinkdb').eq(null))
})
.changes()
sudo apt-get -y update
sudo apt-get -y install python-software-properties
sudo apt-add-repository ppa:openjdk-r/ppa
if grep elasticsearch /etc/apt/sources.list; then
log "ES installed"
else
curl https://packages.elasticsearch.org/GPG-KEY-elasticsearch > /tmp/es-key
sudo apt-key add /tmp/es-key
@lukaszkorecki
lukaszkorecki / collectd.elasticsearch.conf
Created March 8, 2016 11:41
Various collectd configs found on the net
LoadPlugin match_regex
LoadPlugin target_set
PreCacheChain "RenameES"
<Chain "RenameES">
<Rule "rename_es">
<Match regex>
Plugin "^curl_json$"
PluginInstance "elasticsearch"
</Match>
<Target "set">
# dependencies
# - rmq admin + http api
# - curl
# - jq
# - nc
while true ; do
for m in $(curl $rabbiturl:15672/api/queues?pretty | jq '.[] | "rabbit.queue.\(.name):\(.messages)|g"') ; do
echo "Submitting ${m}"
echo $m | nc -w 1 -u 127.0.0.1 8125 &
(defn do-stuff [v & opts]
(->
v
first
:a
( (if opts inc identity ))
inc))
(do-stuff [{ :a 1 :b 2 }])
(defn lol [x] (str "lol" x))
(with-redefs-fn { #'lol (fn [x] (str "nope!" x))}
(fn [& _]
(lol 1) ;; => "nope!1"
))
(lol 1) ;; => "lol1"
@lukaszkorecki
lukaszkorecki / server.clj
Created December 30, 2015 21:11 — forked from drbobbeaty/server.clj
Simple clojure Ring example
(ns performance.server
"The routes for the web server."
(:require [cheshire.core :as json]
[clj-time.core :refer [now]]
[clojure.tools.logging :refer [infof warn warnf error errorf]]
[compojure
[core :refer [defroutes GET POST]]
[handler :as handler]]
[ring.middleware.jsonp :refer [wrap-json-with-padding]]
[ring.middleware.params :refer [wrap-params]]