Skip to content

Instantly share code, notes, and snippets.

View ltw's full-sized avatar

Lucas Willett ltw

View GitHub Profile
@ltw
ltw / slack-pagerduty-oncall.py
Created August 17, 2022 17:36 — forked from markddavidoff/slack-pagerduty-oncall.py
Updates a Slack User Group with People that are on call in PagerDuty
#!/usr/bin/env python
from __future__ import print_function
import json
import logging
from urllib2 import Request, urlopen, URLError, HTTPError
from base64 import b64decode
@ltw
ltw / 04_wk8_review.md
Last active September 10, 2017 22:18
DBootcampC

Week 8: Review and Reflect

This is a week to handle final grading and remediation, and also to catch up on prior week's exercises. Please revisit and complete:

  • Week 7: React - complete the tutorials
  • Week 5: Data Structures - please complete any structures you didn't get to
  • Week 3: Algorithms - choose another sorting algorithm and implement it
  • Self-study with JavaScript - either front-end frameworks, node development, or functional JavaScript
@ltw
ltw / task_list.rb
Last active May 26, 2017 16:35 — forked from gmmowry/task_list.rb
# Today we'll be creating a Task List for an individual
# who has a lot of errands and tasks to complete and multiple
# locations or stores to go to in order to complete them.
# Create a class for a Task List.
# All TaskList instances should have an owner and a dute date
# passed in on creation. For instance, our owner could be "Tyler"
# and his due date would be "Sunday". The owner should not be
# changeable but you should be able to read it outside of the class.
@ltw
ltw / gh_script.rb
Created January 28, 2016 02:58
A script to check GitHub's status.
require 'json'
require 'net/http'
status = nil
until status == 'good'
url = URI('https://status.github.com/api/status.json')
response = Net::HTTP.get(url)
body = JSON.parse(response)
p body
status = body['status']
@ltw
ltw / Gemfile
Last active January 9, 2016 04:49
Assigner of GitHub PR fairly across multiple reviewers
source "https://rubygems.org"
gem 'octokit'
@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 / 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

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 / 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
@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