Skip to content

Instantly share code, notes, and snippets.

View tphummel's full-sized avatar

Tom Hummel tphummel

View GitHub Profile

If Your State Was a California County…

If your state was a California county it would be…

State Population CA County Population
Wyoming 576,851 San Mateo 737,888
Vermont 643,077 San Mateo 737,888
Alaska 733,391 San Mateo 737,888
North Dakota 779,094 San Joaquin 789,410
@tphummel
tphummel / 2014-12-31.json
Last active August 14, 2021 20:54
Compile head to head scoring for group solitaire (aka nertz, pounce)
[
{
"Hand": 1,
"Player": "Neela",
"Score": 24,
"Winner": ""
},
{
"Hand": 2,
"Player": "Neela",
@tphummel
tphummel / export-pandora-thumbs.js
Created September 17, 2020 03:20
Re-improved Pandora Feeback Export Script
// original: https://pastebin.com/9br3VZjX
// improvements: add 'created at' field
(function() {
var pageSize = 100;
var stationPageSize = 250; // IMPORTANT: This script only gets the first page of stations. If you have more than 250 this may be a problem, sorry.
var webname = location.pathname.split("/").pop(); // Seems to be a variation of the username, can be retrieved from the URL
var includeThumbsDown = true;
var allThumbs = [];
@tphummel
tphummel / Dockerfile
Last active July 22, 2020 04:55
Http server binary in a scratch container
FROM scratch
COPY ./http /bin/app
ENTRYPOINT ["/bin/app"]
@tphummel
tphummel / README.md
Last active June 7, 2020 17:20
Metacritic Review Scrape

Scrape Reviews from Metacritic

  1. Browse a metacritic page of results like: All-Time Nintendo DS Reviews
  2. Open developer tools > Console
  3. Paste the javascript into the console prompt
  4. Execute the javascript
  5. the exported json is now in your clipboard. paste the json into a file and save.

Notes:

  • You can get 100 results per page so it isn't too bad doing it this way.
@tphummel
tphummel / git-to-csv.sh
Created February 9, 2020 03:27
convert master branch git log to csv
#!/usr/bin/env bash
set -o nounset
set -o errexit
set -o pipefail
set -x
IFS=$'\n\t'
main(){
for d in *; do
const assert = require('assert').strict
function dedupe (input) {
return Object.keys(input.reduce((memo, num) => {
memo[num] = true
return memo
}, {})).map((numStr) => {
return parseInt(numStr, 10)
})
}
@tphummel
tphummel / README.md
Last active September 1, 2019 21:44
craps simulator

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 05:38
Vagrantfile to install nginx, configure javascript custom modules, and a hello world example
# 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 February 13, 2019 05:20
compute total distance by lane of a running track
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([