Skip to content

Instantly share code, notes, and snippets.

John Boxall johnboxall

View GitHub Profile
# Print the headers of URL.
alias curl-headers='curl ${CURL_ARGS[@]} --dump-header -'
# Print Time to First Byte of URL.
alias curl-ttfb='curl ${CURL_ARGS[@]} --write-out "%{time_starttransfer}\n"'
# Print bytes file size of URL.
alias curl-size='curl ${CURL_ARGS[@]} --write-out "%{size_download}\n"'
alias curl-timing='curl ${CURL_ARGS[@]} --write-out "
namelookup: %{time_namelookup} Start to name resolving
connect: %{time_connect} Start to TCP connect to host
johnboxall / slack-cleanup.js
Last active Feb 2, 2017
Archive Slack channels with no messages in the last three months.
View slack-cleanup.js
// Archive channels with no new messages in the last two months.
// Usage: npm install slack async
// SLACK_TOKEN=XYZ node slack-cleanup.js
// Get your Slack Token:
"use strict"
const readline = require('readline')
const slack = require('slack')
const async = require('async')
johnboxall /
Created Apr 12, 2016
Example of using the `boto3` API to very slowly searching through a S3 bucket for objects which match a condition.
Outputs JSON key / value pairs of objects in an S3 bucket which redirect.
import csv
import json
import boto3
johnboxall /
Last active Jan 12, 2017
A script for generating refresh tokens to used to access Google APIs. Requires `python` + `jq`.
echo 'Google OAuth2'
echo ''
echo 'This script generates refresh token to retrieve an'
echo 'access token, to allows access to Google APIs :)'
echo ''
echo '--> Application Credentials:'
read -p 'Client ID: ' CLIENT_ID
read -p 'Client Secret: ' CLIENT_SECRET
echo ''
johnboxall /
Created Dec 22, 2014
TinyPNG script.
# Usage:
# ./ <filename> <filename> <filename>
# Upload the files to shrink and then save them locally under the same name.
# Only works with JPEG and PNG.
# Uses the TinyPNG API:
# Inspired by this Gist:
johnboxall /
Last active Dec 18, 2015
Not sure if httpbin is down or your tests are failing? Use `mock` to stub out your external calls!
import mock
import requests
import unittest
def get():
# Retrieves data from an external service eg. Twitter, Google
return requests.get('')
except requests.RequestException:
return None
johnboxall / web.go
Created Jun 3, 2013
Example of overriding `http.DefaultServeMux` of Go's HTTP server.
View web.go
package main
import (
type Handler struct {}
johnboxall / gist:5695301
Created Jun 2, 2013
Go's default redirect behaviour seems to merge slashes in HTTP redirects. How can you override this behaviour?
View gist:5695301
package main
import (
func TestMergeSlashes(t *testing.T) {
req, _ := http.NewRequest("GET", "", nil)
View preparser.html
<!doctype html>
<script src=""></script>
<script src="preparsed.js"></script>
<title>Pre-Parser Test</title>
<p>Check the wire level requests generated by this page.<p>
View recover.html
* In 1s, `onError` will be called to 'recover' the original document.
onError = function() {
var s;
while (s = document.scripts[0]) s.parentNode.removeChild(s);
You can’t perform that action at this time.