Skip to content

Instantly share code, notes, and snippets.

View ltw's full-sized avatar

Lucas Willett ltw

View GitHub Profile

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 / 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
@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 / 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
fn main() {
for int::range(1, 101) |num| {
let mut answer;
if is_fifteen(num){
answer = "FizzBuzz"; }
else if is_three(num) {
answer = "Fizz";
}
else if is_five(num) {
answer = "Buzz"; }
@ltw
ltw / class_definitions.rb
Last active December 11, 2015 16:58
Fun with API Routes
# app/controllers/api/v1/users_controller.rb
class Api::V1::UsersController
def index
render json: { path: 'v1/users#index' }
end
def show
render json: { path: 'v1/users#show' }
end
end
@ltw
ltw / letterpress.rb
Created October 26, 2012 18:21 — forked from dpick/gist:3956825
class Letterpress
def self.run(board)
all_words = File.open('/usr/share/dict/words').readlines.map! { |line| line.strip.chomp }
valid_words = all_words.select { |w| w =~ /[^#{board.join}]/ }
valid_words = valid_words.select do |w|
bool = true
bool = false if w.size <= 2
split_word = w.downcase.split('')
@ltw
ltw / nested_factories.rb
Created January 25, 2012 00:22
Using different factory girl techniques to build specific factories
FactoryGirl.define do
factory :contact do
name 'Nigel Weiner'
factory :admin_contact do
admin true
end
end
end
@ltw
ltw / test.rake
Created January 24, 2012 22:16
List all routes available in a Rails application with the mappings back to controllers and actions
namespace :routes do
desc 'print list of routes'
task :list => [:environment] do
Rails.application.routes.routes.map do |route|
p "#{route.requirements[:controller]} #{route.requirements[:action]} #{route.verb}"
end
end
end
@ltw
ltw / best_model.rb
Created February 21, 2011 01:29
Order of a standard Model
class Model < ParentModel
include Foo::Bar
extend Bar::Baz
acts_as_authentic
dsl_specific_flags
module InternalModule
...
end