Skip to content

Instantly share code, notes, and snippets.

View lancegatlin's full-sized avatar

Lance Gatlin lancegatlin

View GitHub Profile
Alice's Adventures in Wonderland
ALICE'S ADVENTURES IN WONDERLAND
Lewis Carroll
THE MILLENNIUM FULCRUM EDITION 3.0
import java.time.Instant
import play.api.libs.json._
/*
* HTTP Archive Format 1.2
* note: HAR files can be exported/imported from the Chrome dev-tools network page
*
* Source: http://www.softwareishard.com/blog/har-12-spec
*/
/**
* Create an ExecutionContext for blocking operations that grows with demand
*
* @param threadNamePrefix the prefix to put at the beginning of the name of threads for this pool
* @param unhandledExceptionLogger a function to log unhandled exceptions
* @param minPoolSize the minimum number of threads to allocate for this pool
* @param maxPoolSize the maximum allowed number of threads to allocate for this pool (requests beyond
* this maximum will block the thread of the requester)
* @param keepAliveTime the amount of time to keep an unused thread alive before destorying it
* @return an ExecutionContext for blocking operations
/* Keypad to Karabiner mapping (to avoid interference with regular keyboard)
* note: using device id would make all this unnecessary
* ,---------------------------------------------. ,--------------------------------.
* | KP_COMMA | KP_1 | KP_4 | KP_7 | NUMLOCK | | lang1 | f22 | f19 | f16 | f13 |
* |----------+------+------+------+-------------| |--------+-----+-----+-----+-----|
* | KP_0 | KP_2 | KP_5 | KP_8 | KP_SLASH | | lang2 | f23 | f20 | f17 | f14 |
* |----------+------+------+------+-------------| |--------+-----+-----+-----+-----|
* | KP_DOT | KP_3 | KP_6 | KP_9 | KP_ASTERISK | | lang3 | f24 | f21 | f18 | f15 |
* `---------------------------------------------' `--------------------------------'
* ,-------------------------------. ,----------,-----------------.
// LESSON1: to return an Iterator, must pass in a reference (since Iterator always references something)
// LESSON1a: more generally, to return any type that "points" at data (i.e. whose lifetime is based on the lifetime of the input), must pass in a reference
// fn lesson1_broken(from: String) -> impl Iterator<Item=&str> {
// from.split(' ') // Iterator produced from borrow of from
// // from goes out of scope
// }
fn lesson1_fixed1(from: &mut String) -> impl Iterator<Item=&str> {
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<Pattern>
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
</Pattern>
</encoder>
</appender>
import sbt.Keys._
import sbt._
object CleanUpSlf4j {
// fix multiple slf4j deps
// see https://stackoverflow.com/questions/25208943/how-to-fix-slf4j-class-path-contains-multiple-slf4j-bindings-at-startup-of-pl
val settings : Seq[Def.Setting[_]] = Seq(
libraryDependencies ++= Seq(
Dependencies.slf4j,
Dependencies.logback
import sbt.Keys._
import sbt._
object IntegrationTest {
// Select integration tests that use local running resources
lazy val IntgLocalTest = config("intg_local") extend Test
// Select integration test that connect to dev env
lazy val IntgDevTest = config("intg_dev") extend Test
// Select all integration tests
lazy val IntgTest = config("intg") extend Test
Transcendicant:
One who dedicates their life to continuous, incremental all-self-improvement
* To seek the highest state of self freedom
* To grow resilient enough to hold and learn from all experience: the undesired, the shameful, the confused
* To sit in the discomfort of ultimate uncertainty, incompleteness, wrongness and unknowing
* To observe shame as the instinct to hide one's wrongness from others and self
* To discern and accept the utility of self-stories, ego-delusion and social programming, the useful illusions
* To continously renew the facts and data of being and re-tell only the smallest story necessary to act in the world
* To discard unneeded illusions and imagine beyond today's useful illusions
* To create new ways of thinking, new ways of being, new useful illusions
"Finally! Tagless and Fancy Free Monads"
In this talk, we'll explore "final tagless" as an alternative to the free monad.
At the end of this talk, you'll know:
* How to write Scala "final tagless" languages, bridges and interperters
* If monads are evil and the work of "he who shall not be named"
* The pros and cons between the free monad and "final tagless"
* Some suggestions on when to use the free monad or "final tagless"