start new:
tmux
start new with session name:
tmux new -s myname
(defmacro my-let | |
[bindings & body] | |
(assert (-> bindings count even?) "Bindings count can only be even.") | |
`((fn [~@(take-nth 2 bindings)] | |
~@body) | |
~@(take-nth 2 (rest bindings)))) |
(ns my-test-ns | |
(:require [clojure.test :refer :all]) | |
(:import [java.util.concurrent CountDownLatch TimeUnit]) | |
(defmacro with-latch | |
[countdown-from & body] | |
`(let [latch# (CountDownLatch. ~countdown-from) | |
~'latch latch#] | |
~@body | |
(.await latch# 5 TimeUnit/SECONDS) |
;; Writing something remotely reminding nlet | |
(defmacro body-and-bindings | |
[bindings & body] | |
`(let [~(first bindings) 1 | |
~(second bindings) 2] | |
~@body)) | |
;; Expands to: | |
(let* [a 1 b 2] (+ a b)) |
(defn ^String head | |
"Returns the first n characters of s." | |
[n ^String s] | |
(if (> (count s) n) | |
s | |
(.substring s (- 0 n)))) |
In order to setup leiningen with pgp, you have to create a ~/.lein/credentials.clj
file and put following contents into it:
{
#"https:\/\/your.nexus.server.address\/" {:username "your_username" :password "supersecret"}
}
After that you can run lein deploy
.
(defn repeatedly* | |
"Like `repeatedly` but faster and returns given collection type." | |
[coll n f] | |
(if-not (instance? clojure.lang.IEditableCollection coll) | |
(loop [v coll idx 0] | |
(if (>= idx n) | |
v | |
(recur (conj v (f)) (inc idx)))) | |
(loop [v (transient coll) idx 0] | |
(if (>= idx n) |
(defn vec-contains? | |
[vec value] | |
(not (nil? (some #(= value %) vec)))) | |
(vec-contains? ["a" "b" "c"] "a") ;; true | |
(vec-contains? ["a" "b" "c"] "e") ;; false |
setwd("~/analytics/") | |
kp = read.csv("grouped_keys_combined") | |
colnames(kp) = c("Day", "Minute", "Strokes") | |
attach(kp) | |
parseTimestamp <- function(ts) as.POSIXct((ts + 120*60*1000) / 1000, origin="1970-01-01", tz="CEST") | |
kp$DayParsed <- parseTimestamp(kp$Day) | |
head(kp$DayParsed) | |
library("ggplot2") |
(defn handler | |
[] | |
(println "HANDLER")) | |
(defn wrap-1 | |
[handler] | |
(fn [request] | |
(println 1) | |
(handler request) |