Skip to content

Instantly share code, notes, and snippets.

View ltw's full-sized avatar

Lucas Willett ltw

View GitHub Profile
@ltw
ltw / invisicomments.vim
Created January 19, 2015 01:29
Hide comments with a keystroke! (or four)
" Toggle comments as invisible
nmap <Leader>Ci :hi! link Comment Ignore<CR>
nmap <Leader>Cc :hi! link Comment Comment<CR>
@ltw
ltw / aly_skincare.md
Last active August 29, 2015 14:15
A good Combination skin routine.
  1. Switch cleanser to CeraVe Gentle Foaming Cleanser.
  2. Cleanse in the PM as well as AM.
  3. Switch moisturizer to CeraVe Moisturizing Cream (the white and blue tub)
  4. Moisturize in the PM, and cut down on the morning cleanses to only when it feels greasy.
  5. Add an AHA toner in between cleansing and moisturizing (when you feel you need it, and only in the PM) (Suggestion: Paula's Choice Hydralight Healthy Skin Refreshing Toner)
  6. Add a sunscreen that you like in the AM. (Suggestion: Neutrogena Ultra Sheer Dry-Touch Sunblock)
  7. Very shortly after (or before even), add a good makeup and sunscreen remover in the PM. (Suggestion: Paula's Choice Gentle Touch Makeup Remover)

Final Routine:

@ltw
ltw / hot.clj
Last active August 29, 2015 14:16 — forked from mattbaker/engima-encode.racket
(def encode
[reflector rotor-l rotor-m rotor-r letter]
(->> (letter-to-index letter)
(rotor-translate-left (rotate rotor-r 1))
(rotor-translate-left rotor-m)
(rotor-translate-left rotor-l)
(reflect reflector)
(rotor-translate-right rotor-l)
(rotor-translate-right rotor-m)
(rotor-translate-right (rotate rotor-r 1)
@ltw
ltw / 1_rest-routes.md
Last active October 27, 2015 03:33
Let's talk about REST, shall we?

REST Routing

So here's one way to think about routes:

-- retrieving data about a contact or contacts
# index   GET /contacts         Contact.all
# show    GET /contacts/1       Contact.find(1)

-- helping you create a new contact
@ltw
ltw / simplified_bcrypt.rb
Created March 23, 2015 16:14
A very, very simplified explanation of how BCrypt equality works.
module BCrypt
class Password
def initialize(password_hash)
@password_hash = password_hash
end
def self.create(password)
@password_hash = encrypt(password)
end
@ltw
ltw / ar-associations.rb
Created September 22, 2015 15:06
ActiveRecord Breakout Code Notes
# id | user_id
class Profile
belongs_to :user
# is actually:
# def user
# User.find_by(id: self.user_id)
# end
end

Rules for PersonWordSayerThrow

The point of this game is there is no point of this game. It's to pass the time while the Executive VP of Deutsche Bank finds his point somewhere amongst his default corporate jargon, and the managers in the room somehow, despite nine hands and four flashlights, still fail to find their asses.

The rules of this game are relatively simple: you are trying to sneak into corporate conversation sports references, war references, old-timey sayings and made-up technical jargon.

  1. Points are tracked on a per-meeting basis, while leaderboards are typically weekly - do whatever makes sense for your organization.
  2. Scores are as follows:
  • Sports reference: 1 pt
  • War reference: 2 pts
@ltw
ltw / friends.rb
Created October 26, 2015 18:32
A brief model of Friendship in ActiveRecord
# users
# id | name | email
class User < ActiveRecord::Base
has_many :friendships
has_many :friends, through: :friendships
def friends
User.join(:friendships).where('friendships.user_id = ? OR friendships.friend_id = ?', self.id, self.id)
end
@ltw
ltw / 1_README.md
Last active June 2, 2021 17:16
Find overlapping slots in SQL

This is an exploration of effective schema design for a "free time" appointment scheduler. It makes one strong assumption:

Your database is PostgreSQL 9.0+.

Given that, the result is not too bad - seems effective in this particular use-case. I don't really want to translate this into ActiveRecord though. *sigh*

Run this using:

$ psql -f 4_runner.sql
@ltw
ltw / Gemfile
Last active January 9, 2016 04:49
Assigner of GitHub PR fairly across multiple reviewers
source "https://rubygems.org"
gem 'octokit'