Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
post_slack() {
SLACK_URL="TODO:_FILL_ME_IN"
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"text\": \"$1\"}" \
@tatethurston
tatethurston / .eslintrc.js
Last active November 23, 2017 02:45
.eslintrc import/no-unresolved NODE_PATH
module.exports = {
"extends": "eslint:recommended",
"env": {
"node": true,
"mocha": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 8
},
@tatethurston
tatethurston / ajax.js
Created June 28, 2017 18:54
Retry jQuery AJAX requests with exponential backoff
import $ from 'jquery';
import uuidv4 from 'uuid/v4';
const wait = ms => $.Deferred(defer => setTimeout(defer.resolve, ms));
const request = (opts, numTries = 0) => {
/*
* Retry failed requests 2 additional times with exponential backoff
*/
const RETRY_COUNT = 2;
@tatethurston
tatethurston / exclude
Last active July 11, 2017 22:13
Docker .git/info/exclude
.dockerignore
Dockerfile
docker-compose.yml
# Common tasks `docker-compose run foo` (often there is already a Makefile)
scripts.sh

Keybase proof

I hereby claim:

  • I am tatethurston on github.
  • I am tatethurston (https://keybase.io/tatethurston) on keybase.
  • I have a public key whose fingerprint is 74A0 F797 E418 036C 6686 08AD A015 F117 B2FC 5848

To claim this, I am signing this object:

@tatethurston
tatethurston / file-upload-server.js
Created October 28, 2015 00:01
node file upload progress streaming
var http = require('http');
var fs = require('fs');
http.createServer(function(request, response){
var newFile = fs.createWriteStream('file-upload.jpg');
var fileSize = request.headers['content-length'];
var uploadedBytes = 0;
request.on('readable', function(){
var chunk = request.read();
@tatethurston
tatethurston / git-filter-branch
Created October 26, 2015 04:57
git-filter-branch
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch FILE_TO_REMOVE' \
--prune-empty --tag-name-filter cat -- --all
@tatethurston
tatethurston / JavaScript: Add jQuery
Created September 24, 2015 19:12
JavaScript: Add jQuery
/*
Add jQuery to current page so it is available in console
*/
var script = document.createElement('script');
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(script);