Skip to content

Instantly share code, notes, and snippets.

View devth's full-sized avatar
Hacking on @yetibot

Trevor Hartman devth

Hacking on @yetibot
View GitHub Profile
sealed trait NestedProjection
case class Field(name: String) extends NestedProjection
case class NestedField(field: Field, child: NestedProjection) extends NestedProjection

Keybase proof

I hereby claim:

  • I am devth on github.
  • I am devth (https://keybase.io/devth) on keybase.
  • I have a public key whose fingerprint is 2E06 04DD 164E F921 8B97 EF06 EE84 56ED C976 4E34

To claim this, I am signing this object:

(def ^{:dynamic true} foo "ok")
(binding [foo "y u no"]
(def aa (go (Thread/sleep 10000) foo)))
(<!! aa) ;=> y u no
# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
set-window-option -g mode-mouse on
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
import scala.concurrent._
import scala.concurrent.duration._
import ExecutionContext.Implicits.global
val load = (x: Int) => future { Thread.sleep(200); x }
val f = Future.traverse(1 to 100)(load)
Await.result(f, Duration.Inf)
// scala.collection.immutable.IndexedSeq[Int] = Vector(1, 2, 3, 4, 5, 6, 7, 8,
// 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
// 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
function insertEvery(str, xChars, strToInsert) {
var newStr = "", times = Math.ceil(str.length / xChars);
for (var i = 0; i < times; i++) {
newStr += str.substr(i * xChars, xChars) + strToInsert;
}
return newStr;
}
;;; Pallet project configuration file
(require '[pallet.crate.java :as java]
'[pallet.crate.runit :as runit]
'[pallet.crate.lein :as lein]
'[pallet.crate.app-deploy :as app-deploy]
'pallet.compute)
(defplan setup-machine []
(package-manager :update)
(packages :apt ["git"]))
@devth
devth / stacksize.clj
Last active June 20, 2017 19:02
explore the size of the clojure stack
(defn stacksize [] (try (throw (Exception. "")) (catch Exception e (count (.getStackTrace e)))))
(defn prss [] (print (stacksize) " "))
; stack size doesn't increase with proper loop/recur
(loop [x 0] (prss) (when (> 10 x) (recur (inc x))))
; 24 24 24 24 24 24 24 24 24 24 24 nil
; stack size increases with recursion
(defn rec [x continuation]
(prss)
@devth
devth / coffee.md
Created February 5, 2014 15:43
Be a B+ Coffee Snob
  1. Boil some water in a kettle.
  2. Measure out 34.5 grams of beans on a kitchen scale, and grind them finely in a conical burr grinder.
  3. Put a No. 4 filter (I use Melitta) in a dripper sitting over a server.
  4. When the water comes to a boil, pour a little into the dripper to wet the filter, then discard the water that collects in the server. (Keep the kettle boiling.) Replace the dripper, and add the ground beans to the filter.
  5. Pour less than ½ cup of just-off-the-boil water over the coffee. Don’t pour so fast that the grounds start rising up the sides of the filter. (The idea is to let the water “wet” the grounds, unlocking flavors, in preparation for the bigger hot-water hit to come.) About 30 seconds later, pour in enough water to let the grounds rise three-quarters of the way up the filter, while breaking up any visible clumps of coffee on the surface by shaking the kettle a little. About 45 seconds later, repeat, letting the grounds rise up no higher than they did on the first pour.
  6. When the cof