Skip to content

Instantly share code, notes, and snippets.

@dncrews
dncrews / jquery.combobreaker.js
Created November 9, 2012 21:57 — forked from Problematic/ComboBreaker.js
Simple key-combo detector. Uses jQuery
(function($) {
$.fn.comboBreaker = function(options) {
var index = 0, timeout = null, dfd = $.Deferred();
options = $.extend({}, $.fn.comboBreaker.defaults, options);
if (! options.combo) {
throw new Error("combo not set");
}
@dncrews
dncrews / herokuDrainProcessing
Last active December 20, 2015 14:09
Quick script if you want to add (or remove) a drain from all of your Heroku apps (or those matching a specific prefix)
#!/bin/bash
while getopts "arp:d:" opt; do
case $opt in
a)
adding=true
;;
r)
adding=false
;;
@dncrews
dncrews / localeCopier.js
Created August 7, 2013 18:26
I'm writing this for the purpose of copying all of my local `locale` files from all of my node projects that are using `strong` translation library (https://github.com/fs-webdev/strong) or (https://github.com/timshadel/strong) to a centralized place so that I can create a "translation memory".
/**
* I'm writing this for the purpose of copying all of my local
* locale files from all of my node projects that are using
* `strong` translation library (https://github.com/fs-webdev/strong)
* or (https://github.com/timshadel/strong) to a centralized place
* so that I can create a "translation memory".
*
* Usage:
*
* node localeCopier.js # from path defaults to "."; to path defaults to "~/Documents/locales"
@dncrews
dncrews / gist:6544608
Created September 12, 2013 22:19
JS get a cookie
getCookie : function(cookieID) {
var dc = document.cookie, prefix = cookieID + "=", begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0)
return null;
}
else
begin += 2;
var end = document.cookie.indexOf(";", begin);
@dncrews
dncrews / .bash_aliases
Last active December 24, 2015 09:59
Alias for foreman to use Procfile.dev if it exists.
alias fs="([[ -a Procfile.dev ]] && foreman start -f Procfile.dev) || foreman start"
var euLocales = [
"de-at", //Austria
"fr-be", //Belgium (French)
"nl-be", //Belgium (Dutch)
"bg", //Bulgaria
"el-cy", //Cyprus
"cs", //Czech Republic
"da", //Denmark
"et", //Estonia
"fi", //Finland (Finnish)
@dncrews
dncrews / .aliases.sh
Last active August 29, 2015 14:21
Annoying Version of `cd`
#######################################################
## Adds some frustration the `cd` command
## https://gist.github.com/dncrews/1ba8919b24b2e4569c2f
## Author: Dan Crews <crewsd@gmail.com>
#######################################################
#!/bin/sh
alias cd=annoyingCD
function annoyingCD () {
@dncrews
dncrews / inventory.graphql
Last active January 3, 2020 05:00
Simple E-Commerce v1.0.0
type Inventory {
total: Int!
available: Int!
}
extend type Product @key(fields: "id") {
id: ID! @external
inventory: Inventory!
}
@dncrews
dncrews / order.graphql
Last active January 3, 2020 05:08
Creating Order v1.1.0
type Order {
id: ID!
productsConnection: OrderProductsConnection!
}
input OrderInput {
lineItems: [OrderLineItemInput!]!
paymentToken: String!
}
@dncrews
dncrews / productInventoryQuery.graphql
Created January 3, 2020 05:16
Get product inventory v1
query ProductInventory {
product(id: "product-1") {
inventory: {
available
}
}
}