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 / 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 / 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 / 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"; }