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 kebab | |
(:require [camel-snake-kebab :as kebab] | |
[schema.coerce :as c] | |
[schema.core :as s])) | |
(def Data (s/either s/Keyword | |
{(s/recursive #'Data) (s/recursive #'Data)} | |
[(s/recursive #'Data)] | |
#{(s/recursive #'Data)} | |
s/Any)) |
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
;; Clojure | |
(require 'clojure-mode) | |
(setq auto-mode-alist (cons '("\\.cljs$" . clojure-mode) auto-mode-alist)) | |
(setq inferior-lisp-program "lein repl") | |
;; clj-refactor | |
(require 'clj-refactor) | |
(add-hook 'clojure-mode-hook (lambda () | |
(clj-refactor-mode 1) | |
(cljr-add-keybindings-with-prefix "C-c C-o"))) |
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- log-time [{:keys [ns name line]} f & args] | |
(let [start (System/nanoTime) | |
res (apply f args) | |
elapsed (quot (- (System/nanoTime) start) 1000)] | |
(log/debug (format "%s/%s:%s %dus" ns name line elapsed)) | |
res)) | |
(defn enable-timing [var] |
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- log-time [{:keys [ns name line]} f & args] | |
(let [start (System/nanoTime) | |
res (apply f args) | |
elapsed (quot (- (System/nanoTime) start) 1000)] | |
(log/debug (format "%s/%s:%s %dus" ns name line elapsed)) | |
res)) | |
(defn enable-timing [var] | |
(log/debug "enabling timings" var) | |
(add-hook var (partial log-time (meta var)))) |
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 current-nrepl-server-buffer () | |
(let ((nrepl-server-buf (replace-regexp-in-string "connection" "server" (nrepl-current-connection-buffer)))) | |
(when nrepl-server-buf | |
(get-buffer nrepl-server-buf)))) | |
(defun clear-buffers () | |
(interactive) | |
(cider-find-and-clear-nrepl-buffer) |
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
$ ssh -C -L 9010:localhost:9010 user@host |
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 fib-seq [b1 b2] | |
(lazy-seq | |
(cons b2 (fib-seq b2 (+ b1 b2))))) | |
(def fibs (fib-seq 0 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
(defn random-char-seq [] | |
(let [digits (range 48 58) | |
lower-case (range 65 91) | |
upper-case(range 97 123)] | |
(repeatedly ƒ(rand-nth (map char (concat digits lower-case upper-case)))))) | |
(apply str (take 60 (random-char-seq))) | |
=> "m9MSE2YVIZn8kjY6omvct7iQvOf1YMBILIOxsMcXguvN0uipqtvLcPvJXsTl" |
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 sin-vals [offset] | |
(map #(Math/sin %) (iterate (partial + 0.1) offset))) | |
(let [events (chan)] | |
;; produce seqs of sine values | |
(go-loop [n 0] | |
(<! (timeout 200)) | |
(>! events (sin-vals n)) | |
(recur (inc n))) |
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
(def url "http://localhost:3000/data") | |
(defn post-some-data [test] | |
(let [data (zipmap (clojure.data.generators/vec clojure.data.generators/scalar) | |
(clojure.data.generators/vec clojure.data.generators/scalar))] | |
[(clj-http.client/put url {:body (pr-str data) :content-type :edn :throw-entire-message? true}) | |
data])) | |
(defn get-data [id] | |
(update-in |