Skip to content

Instantly share code, notes, and snippets.

@coleturner
coleturner / distractions.userscript.js
Created December 30, 2017 02:30
Block distractions
// ==UserScript==
// @name Distractions
// @version 0.1
// @description redirects to something productive
// @author You
// @include *.reddit.*
// @include *.imgur.*
// @run-at document-start
// @grant none
// ==/UserScript==
@coleturner
coleturner / deploy.sh
Created July 15, 2017 07:02
Simple deployment script for `nginx-proxy`
#!/bin/bash
if [ -z $1 ]; then echo "Please specify a deployment .env file"; fi
source $1
echo "Deploying $DOCKER_IMAGE to $VHOST using $1"
docker pull $DOCKER_IMAGE
docker run -d --name $VHOST -e VIRTUAL_HOST=$VHOST --env-file=$1 "${@:2}" $DOCKER_IMAGE
echo "Done!"
@coleturner
coleturner / git-tag.sh
Created November 22, 2016 19:48
SImple git tag shim for tracking per-day tags.
#!/usr/bin/env bash
DATE=`date +%Y%m%d`
NAME=$1
if [[ -z $NAME ]]; then
read -p "Enter a tag group name [demo]: " NAME
fi
NAME=${NAME:-demo}
@coleturner
coleturner / camel_case_argument_middleware.rb
Last active February 22, 2018 18:21
Parses camelCase arguments into snake_case for GraphQL Ruby
class CamelCaseMiddleware
def call(parent_type, parent_object, field_definition, field_args, query_context, next_middleware)
next_middleware.call([parent_type, parent_object, field_definition, transform_arguments(field_args), query_context])
end
def transform_arguments(field_args)
transformed_args = {}
types = {}
field_args.each_value do |arg_value|
@coleturner
coleturner / extract_all.sh
Last active July 8, 2016 04:39
Extract all *.rar files in a directory
#!/bin/bash
# @author Cole Turner
# @website http://coleturner.me/
# @readme This script will extract all .rar files in a directory
# while preserving the original files. If "unrar.lock" is
# present in the directory, the archive will be skipped.
# If the rar was previously extracted and "unrar.lock" is
# not present, it will be extracted again.