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
#!/usr/bin/bash | |
filename="$1" | |
wait="🕜" | |
# test 🕜🕜🕜🕜pausing | |
function keystroke-delay { | |
delay=`bc <<END | |
scale=2 |
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
; e.g. usage | |
:filespecs [{:type :path :path "source/directory" :root "destination/directory/"}] | |
; at the end of project.clj | |
(require 'leiningen.jar) | |
(in-ns 'leiningen.jar) | |
(defmethod copy-to-jar :path [project jar-os acc spec] | |
(let [root-file (io/file (:path spec)) |
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
; a toy example of a nested reduction; especially when function bodies are nontrivial, or when the nesting | |
; gets much deeper than 2 levels, it's easy to lose track of which values are being reduced over at each | |
; level, etc | |
(let [x {:a [1 2 3] :b [4 5 6]}] | |
(reduce | |
(fn [x [k vs]] | |
(reduce | |
(fn [x v] (update x :sum (fnil + 0) v)) | |
x |
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
;; benchmarking different sorted-set implementations | |
;; /ht https://gist.github.com/tonsky/c5605058f29c620242eb7e0130234a8c | |
;; | |
;; results after the code... | |
;; TODO | |
;; * some impls provide specialized ctors for pre-sorted and/or distinct initial members | |
;; * | |
(ns cemerick.sorted-set-bench |
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 delegate-printing-for | |
"Registers the necessary methods to delegate printing of instances of [class] to [fn]." | |
[class fn] | |
#?@(:clj [(defmethod print-method class | |
[x writer] | |
(.write ^java.io.Writer writer (fn x))) | |
(defmethod print-dup class | |
[x writer] | |
(print-method x writer)) | |
(#'clojure.pprint/use-method |
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
### Keybase proof | |
I hereby claim: | |
* I am cemerick on github. | |
* I am cemerick (https://keybase.io/cemerick) on keybase. | |
* I have a public key whose fingerprint is B7DA 0140 4D66 4907 EBDF 1398 C926 963F B974 E677 | |
To claim this, I am signing this object: |
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
; I'm hoping to find a common name for a particular operation over sets that I've | |
; been thinking of as a "join" of sorts. | |
; | |
; It's _not_ a relational join -- the values involved aren't relations (for me | |
; at the moment, they're actually graphs essentially representing | |
; disjoint recursive sets, but I think that's probably irrelevant | |
; detail) -- but it feels like it's in the spirit of a full outer join | |
; | |
; Given N sets, recursively produce all unions of those sets that are disjoint. |
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
;;; strint.clj -- String interpolation for Clojure | |
;; originally proposed/published at http://cemerick.com/2009/12/04/string-interpolation-in-clojure/ | |
;; Copyright (c) 2009, 2016 Chas Emerick <chas@cemerick.com> | |
;; | |
;; All rights reserved. | |
;; | |
;; Redistribution and use in source and binary forms, with or without | |
;; modification, are permitted provided that the following conditions are met: | |
;; |
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 percentage-spec (s/conformer #(or (some-> (re-matches #"(-?\d+(\.\d+)?)%" %) (nth 1) Double/parseDouble) | |
::s/invalid) | |
#(str % "%"))) | |
(s/def ::absolute-coordinate number?) | |
(s/def ::pct-coordinate percentage-spec) | |
(s/def ::coordinate (s/or :abs ::absolute-coordinate | |
:pct ::pct-coordinate)) | |
(def specrec (s/cat :lx ::coordinate |