Skip to content

Instantly share code, notes, and snippets.

Tom Hummel tphummel

Block or report user

Report or block tphummel

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tphummel
tphummel / README.md
Last active Sep 1, 2019
craps simulator
View README.md

craps toy/simulator

usage

➜  node craps-toy.js
┌─────────┬──────┬──────┬─────┬─────────────┐
│ (index) │ die1 │ die2 │ sum │   result    │
├─────────┼──────┼──────┼─────┼─────────────┤
│    0    │  1   │  4   │  5  │ 'point set' │
@tphummel
tphummel / Vagrantfile
Last active May 29, 2019
Vagrantfile to install nginx, configure javascript custom modules, and a hello world example
View Vagrantfile
# vagrant box add --name ol76 --checksum cfb58aaa12f56702afd739966273df63cd3ff3362e6a5a3fa6fa9ffcec4762e3 --checksum-type sha256 https://yum.oracle.com/boxes/oraclelinux/ol76/ol76.box
# https://nginx.org/en/docs/njs/examples.html#subrequest
Vagrant.configure("2") do |config|
config.vm.box = "ol76"
config.vm.network "forwarded_port", guest: 80, host: 8111, host_ip: "127.0.0.1"
config.vm.synced_folder ".", "/vagrant_data"
config.vm.provision "shell", inline: <<-SHELL
sudo cat > /etc/yum.repos.d/nginx.repo <<EOF
@tphummel
tphummel / lanes.js
Created Feb 13, 2019
compute total distance by lane of a running track
View lanes.js
let laneWidthMeters = 1.22
function getLanes({laneOneMeters, aRadMeters, bRadMeters, numLanes}) {
let turnMeters = 2 * Math.PI * aRadMeters
let straightMeters = laneOneMeters - turnMeters
let lanes = [
['#', 'distance (m)', 'turn (m)', 'straight (m)'],
]
lanes.push([
@tphummel
tphummel / README.md
Last active Oct 31, 2018
Eat Club Analytics
View README.md

Eat Club Analytics

  1. log in and browse: https://www.eatclub.com/orders/past
  2. scroll to the bottom of the page and keep clicking more until your entire history is shown on the page.
  3. open chrome web console (or comparable)
  4. open javascript console
  5. run the following command
copy(Array.prototype.slice.call(document.querySelectorAll("div.item-cont.row")).map((r)=>{ return Array.prototype.slice.call(r.querySelectorAll("div.column")).map((c)=>{ return c.innerText.split("\n") }) }).map((o)=>{ return {date: o[0][0], location: o[0][1], dish: o[1][0], type: o[2][0]} }))
@tphummel
tphummel / http-to-s3.js
Created Feb 25, 2018
pipe the content of a webpage to a file in s3
View http-to-s3.js
var http = require('http')
var path = require('path')
var AWS = require('aws-sdk')
function httpToS3 (event, context, callback) {
var s3 = new AWS.S3()
var now = (new Date()).toISOString()
http.request({
protocol: 'http:',
@tphummel
tphummel / sparse-streaks.md
Last active Jan 16, 2018
Find Streaks in Daily Data with Sparse/Missing Days
View sparse-streaks.md

install libraries

brew update
brew install tphummel/util/date-range
brew install tphummel/util/streak
brew install jq
brew install csvkit
@tphummel
tphummel / README.md
Last active Sep 11, 2017
Athena, S3, and HiveQL for CloudTrail Analysis
View README.md

Doing CloudTrail Analysis with Athena, S3, HiveQL

Problem

I discovered a security group which got opened too widely. I want to figure out when it happened and who did it.

Prerequisites

This article assumes you have CloudTrail enabled and there is a complete history of your account activity sitting in an S3 bucket.

Approach

@tphummel
tphummel / README.md
Last active Feb 12, 2017
run queries on a user's starred github repos
View README.md

run queries on a user's starred github repos

download data

for i in {1..20}
do
  curl -H "Accept: application/vnd.github.v3.star+json" "https://api.github.com/users/tphummel/starred?page=$i" > "p$i.json"
done
@tphummel
tphummel / add-users.sh
Created Jul 15, 2016
add github user keys to authorized_keys via cloud-init/userdata
View add-users.sh
#!/usr/bin/env bash
set -o nounset
set -o errexit
set -o pipefail
IFS=$'\n\t'
main(){
users=( "tphummel" "githubuser2" "githubuser3" )
ssh_user="ssh_user"
You can’t perform that action at this time.