Skip to content

Instantly share code, notes, and snippets.

View ltw's full-sized avatar

Lucas Willett ltw

View GitHub Profile
@ltw
ltw / ohyeah.rb
Last active December 21, 2015 03:39
Helping Tristan
def get_bucket(buckets_filled, max_buckets, idx)
quot, rem = idx.divmod(2)
quot = rem == 1 ? quot + (max_buckets/2) : quot
quot > buckets_filled ? :B : :A
end
p get_bucket(11, 12, 8) == :A ? "OH YEAH 1" : "shit 1" # AAAAAAAAAAAB
p get_bucket( 1, 12, 11) == :B ? "OH YEAH 2" : "shit 2" # ABBBBBBBBBBB
p get_bucket(11, 20, 1) == :A ? "OH YEAH 3" : "shit 3" # AAABABABABABABABABAB
p get_bucket(11, 37, 1) == :B ? "OH YEAH 4" : "shit 4" # ABABABABABABABABABABABBBBBBBBBBBBBBBB
@ltw
ltw / gist:6539620
Last active December 22, 2015 22:19
(import '[org.eclipse.jetty.server.handler GzipHandler])
(defn- configurator [server]
"Ask Jetty to gzip."
(.setHandler server
(doto (new GzipHandler)
(.setMimeTypes "text/html,text/plain,text/xml,application/xhtml+xml,text/css,application/javascript,text/javascript,image/svg+xml,application/json,application/clojure")
(.setHandler (.getHandler server)))))
(run-jetty #'app {:port port :join? false :configurator configurator})
@ltw
ltw / gist:7567283
Created November 20, 2013 17:26
output of `lein immutant overlay torquebox`
± SILENT=true cap torquebox:squash:uat torquebox:install
* 2013-11-20 11:05:10 executing `torquebox:squash:uat'
triggering start callbacks for `torquebox:install'
* 2013-11-20 11:05:10 executing `multiconfig:ensure'
* 2013-11-20 11:05:10 executing `torquebox:install'
* executing "IMMUTANT_HOME=/absolute/path/to/the/immutant-1.0.1-slim ~/bin/lein immutant overlay torquebox"
servers: ["my-server-uat.dcs1"]
[my-server-uat.dcs1] executing command
** [out :: my-server-uat.dcs1] Downloading http://downloads.immutant.org/incremental/torquebox/LATEST/torquebox-dist-bin.zip
** [out :: my-server-uat.dcs1] [=> ] 3% 2.29MB / 62.23MB

Keybase proof

I hereby claim:

  • I am ltw on github.
  • I am ltw (https://keybase.io/ltw) on keybase.
  • I have a public key whose fingerprint is 5A72 31D2 CA91 4525 3F9F 7ACE 1FB5 E1E6 7F97 AB9D

To claim this, I am signing this object:

@ltw
ltw / partial-git-checkout.sh
Created May 7, 2014 15:54
This is a rough first-pass implementation at a `git checkout` alias that matches on partial branch names. I'd ideally like to make this a little nicer and/or fuzzy-matching.
gcof () {
git branch | cut -c 3-1000 | grep $1 | head -1 | xargs git checkout
}
# $ git branch
# * master
# remember-the-fifth-of-november
# $ gcof fifth
# Switched to branch 'remember-the-fifth-of-november'
@ltw
ltw / places.md
Created May 25, 2014 04:14
Places my wife and I would like to visit at some point.

Places to Visit

USA

  • Alaska
  • California (north)
  • Colorado
  • Georgia
  • Hawaii (not main island)
  • Louisiana (New Orleans)
@ltw
ltw / supplemental_lectures.md
Created July 22, 2014 22:58
Supplemental lectures to give at DBC one day

Talks I'd like to give one day

  • the seven-layer OSI model of computing, and how that relates to debugging, latency, performance, and pain.
  • Why The Fuck Isn't The World Flat - a developer's guide to geospatial data.
  • Time, Asynchrony Other and Assumptions - a guide to linearizability, serializability, time-dependent occurrences and people, man. (aka Time Goes Backwards In Australia)
  • Introduction to Being Wrong - how to quickly realise you're wrong, and keep heading towards a solution.
@ltw
ltw / core.clj
Last active August 29, 2015 14:07
Matasano Clojure CLI Client
(ns matasano.core
(:require [clojure.tools.cli :as cli]
[matasano.challenge-1 :as c1]))
(def cli-options
[["-c" "--challenge CHALLENGE" "Challenge number"
:default 1
:parse-fn #(Integer/parseInt %)]])
(defn -main
var questions = [{
choices : [
{ name : "Answer One" }
{ name : "Answer Two" }
]
},
{}]
$("#questionTmpl").render(questions)
@ltw
ltw / group_maker.rb
Last active August 29, 2015 14:13
GroupMaker Pro™ (all props to @gfredericks)
require 'set'
names = [
# student names here
]
def get_group_set(coll)
if coll.count % 4 == 0
coll.each_slice(4).to_a
else
[coll[0..2]] + get_group_set(coll[3..-1])