Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / 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 / 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 / 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 / 3-22-2018-WG.md
Created March 22, 2018 23:21
GraphQL Working Group Notes - March 22, 2018

GraphQL Working Group – March 22, 2018

Introductions Agenda Recap Update on next spec release

  • In last meeting, SDL was the last blocker for next version of the spec
  • Identified compelling blocker: default values and null
  • Question: about timeframe between releases
  • This release is special, a lot of new releases
@coleturner
coleturner / Schema.test.js
Last active June 7, 2018 02:19
Quick Bootstrapping of Testing for Apollo Server
import {
makeExecutableSchema,
addMockFunctionsToSchema,
mockServer
} from 'graphql-tools';
const testCaseA = {
id: 'Test case A',
query: `
query {
@coleturner
coleturner / Animal.test.js
Created April 21, 2018 06:09
Quick bootstrapping for testing GraphQL Resolvers
// graphql/types/Animal/Animal.test.js
import * as AnimalResolvers from './Animal.resolvers.js';
export const animalNameTest = () => {
const obj = {
kind: 'Dog',
name: 'Koko',
breeds: ['Corgi', 'German Shepherd']
};
// Moves the menu bar to the right, moving code to the left window boundary
"workbench.sideBar.location": "right",
// Install prettier and run on save
"editor.formatOnSave": true,
// Drag and drop can get annoying after a while, but now I move things accidentally so ¯\_(ツ)_/¯
"explorer.confirmDragAndDrop": false,
// Disable JavaScript validate, prefer ESLint
"javascript.validate.enable": false,
// Verbose Eslint is good eslint
"eslint.trace.server": "verbose",
@coleturner
coleturner / distractions.userscript.js
Created June 27, 2018 00:13
Distraction blocking userscript
// ==UserScript==
// @name Distractions
// @version 0.1
// @description redirects to github issues
// @author You
// @include *.reddit.*
// @include *.imgur.*
// @run-at document-start
// @grant none
// ==/UserScript==