Skip to content

Instantly share code, notes, and snippets.

@stantonk
stantonk / nr.py
Created February 1, 2017 00:16
beginning of grabbing stats from NewRelic API
import json
import logging
import requests
import sys
from collections import namedtuple
from functools import partial
from urlparse import urlparse
from urlparse import parse_qs
@stantonk
stantonk / # mysql@5.5 - 2017-01-26_14-33-42.txt
Created January 26, 2017 20:48
mysql@5.5 on macOS 10.11.6 - Homebrew build logs
Homebrew build logs for mysql@5.5 on macOS 10.11.6
Build date: 2017-01-26 14:33:42
@stantonk
stantonk / pre-push.sh
Created December 5, 2016 20:05
Run unittests as a pre-push hook to avoid merging code that fails tests.
#!/usr/bin/env bash
################################################################################
# Use as a global mercurial/git pre commit or pre push hook to detect the type
# of project and run unittests before allowing a commit or push to a remote
# repository.
#
# Handy so that you don't have to remember to add test running hooks to every
# repo clone/fork you have.
################################################################################
echo "run-test-hooks executing..."
@stantonk
stantonk / JDBIjOOQ.java
Last active July 8, 2022 15:06
JDBI + jOOQ. Combine SQL Builder of jOOQ with all the awesomeness of JDBI, but avoid using jOOQ's codegen, having to keep it up to date with schema changes (just update the single query that's changed) or overcomplicating your build process. jOOQ never touches the database.
// see:
// http://jdbi.org/fluent_queries/
// http://www.jooq.org/doc/3.7/manual/getting-started/use-cases/jooq-as-a-standalone-sql-builder/
// Your Java Bean
public static class Reminder {
private long id;
private long customerId;
public Reminder(long id, long customerId) {
import re
import sys
# note, currently doesn't handle:
# Jun 29 00:00:03 host tag: message repeated 3 times: [ 192.168.1.1 - - "POST /api/someendpoint/
r = re.compile(r'(\w{3,}\s+\d{2,}\s+\d{2,}:\d{2,}:\d{2,})\s+([\w-]+)\s+([\w-]+):\s+((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3},?\s?)+)\s+-\s+-\s+\"(GET|POST|PUT|PATCH|HEAD|DELETE) ((\/[\w_]+)+)\/\??(.*) HTTP\/\d\.\d" (\d{3,}) (\d+|-)')
anonymizers = (
(re.compile(r'(\d+,?)+'), 'id'), # one or more optionally csv separated ids
@stantonk
stantonk / keybase.md
Created May 27, 2016 16:20
keybase.md

Keybase proof

I hereby claim:

  • I am stantonk on github.
  • I am stantonk (https://keybase.io/stantonk) on keybase.
  • I have a public key whose fingerprint is 21AE 63EF 74EC 1D5D C904 98A8 1538 E2F1 20F5 28F9

To claim this, I am signing this object:

@stantonk
stantonk / Vagrantfile
Created January 22, 2016 06:17
Provision Jenkins + Docker in Vagrant w/ Oracle JVM Java 8.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
@stantonk
stantonk / get_stats.py
Last active November 4, 2017 14:29
Get a histogram, mean, median, stddev, and percentiles from a pipe on the command line with numpy
#!/usr/bin/env python
"""
Note: requires numpy. `sudo pip install numpy`
Example:
$ echo -e "1\n2\n5\n10\n20\n" | get-stats
mean=7.6
median=5.0
std=6.94550214167
@stantonk
stantonk / 0_reuse_code.js
Created November 15, 2015 21:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@stantonk
stantonk / prove_signed_post_request_fail.py
Created November 9, 2015 19:10
Demonstrate bug in signing of POST requests in instagram/python-instagram
# -*- coding: utf-8 -*-
from instagram.client import InstagramAPI
import time
access_token = "REDACTED"
api = InstagramAPI(access_token=access_token, client_id='REDACTED', client_secret='REDACTED')
media_id = 'REDACTED'
response = api.media(media_id=media_id)