Skip to content

Instantly share code, notes, and snippets.

@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);
@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 / 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();

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 / 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
@tatethurston
tatethurston / webpack.config.js
Created November 12, 2017 22:38
Webpack config with HMR + deterministic content hashing
const _ = require('lodash');
const isDev = process.env.NODE_ENV !== 'production'
const APP_PATH = '';
const BUILD_PATH = '';
const config = {
// Fail early
bail: true,
@tatethurston
tatethurston / poll.js
Created November 14, 2017 19:10
JavaScript polling
// fn: () => Promise<Boolean>
const poll = (fn, interval = 100, maxWait = 60000) => {
const start = Date.now();
let last = 0;
return new Promise((resolve, reject) => {
const _poll = () => {
const now = Date.now();
console.log(start, last, now, interval);
if (now > start + maxWait) {
@tatethurston
tatethurston / rails-api-setup.sh
Last active November 19, 2017 01:20
Rails 5 API setup
NAME=''
rails new $NAME \
--api \
--database=postgresql \
--skip-action-cable
cd $NAME
rm -rf \
@tatethurston
tatethurston / docker-compose.yml
Last active November 19, 2017 10:09
rails docker compose
version: '3'
services:
db:
image: postgres
# ports:
# - "5432:5432"
web:
image: ruby:2.3-onbuild
command: bundle exec rails s -p 5000 -b '0.0.0.0'
@tatethurston
tatethurston / deploy-to-s3.js
Last active November 19, 2017 12:46
node script for AWS S3 uploads
/*
* NOTE: You'll need to follow the steps outlined in aws-config.js.example
* before running this deploy script for the first time
*/
// https://github.com/andrewrk/node-s3-client
const s3 = require('s3');
const DIRECTORY = 'dist';