Skip to content

Instantly share code, notes, and snippets.

View wbyoung's full-sized avatar

Whitney Young wbyoung

  • FadingRed
  • Portland, OR
View GitHub Profile
@wbyoung
wbyoung / migration.js
Created May 10, 2014 20:04
People & Cars
'use strict';
exports.up = function(knex, Promise) {
var createTable = knex.schema.createTable.bind(knex.schema);
var sequence = [
createTable.bind(null, 'people', function (table) {
table.increments('id').primary();
table.string('name');
}),
createTable.bind(null, 'cars', function (table) {
@wbyoung
wbyoung / migration.js
Created May 11, 2014 02:13
Countries & Cities
'use strict';
exports.up = function(knex, Promise) {
var table = knex.schema.table.bind(knex.schema);
var createTable = knex.schema.createTable.bind(knex.schema);
var sequence = [
createTable.bind(null, 'countries', function(table) {
table.increments('id').primary();
table.string('name');
table.timestamps();
@wbyoung
wbyoung / sudoku.js
Created May 12, 2014 02:14
Sudoku Solver (Minified to hide solution).
"use strict";module.exports=function(){var t=require("lodash");var r=function(){var t={exports:{}};var exports=t.exports;"use strict";var r=function(t,r,o){for(var n=t[r];n!==t;n=n[r]){o(n)}};var o=function(t,r,o){for(var n=t[r];n!==t;n=n[r]){o(n)}};var n=function(t){t.next.prev=t.prev;t.prev.next=t.next;r(t.head,"down",function(t){r(t,"right",function(t){t.up.down=t.down;t.down.up=t.up;t.header.length-=1})})};var e=function(t){r(t.head,"up",function(t){r(t,"left",function(t){t.header.length+=1;t.up.down=t;t.down.up=t})});t.next.prev=t;t.prev.next=t};var i=function(t,a){var s=a||{};var l=s.maxSolutions||0;var u=arguments[2]||{};var v=u.k||0;var f=u.solutions||[];var c=u.partials||[];if(l&&f.length===l){return f}if(t.next===t){f.push(c.slice(0))}else{var h;var p;o(t,"next",function(t){if(!h||t.length<p){h=t;p=t.length}});if(h&&h.length>0){n(h);r(h.head,"down",function(o){c[v]=o.rowNumber;r(o,"right",function(t){n(t.header)});i(t,s,{k:v+1,solutions:f,partials:c});r(o,"left",function(t){e(t.header)})});e(h)}}ret
@wbyoung
wbyoung / .jshintrc
Created May 30, 2014 00:55
JSHint Config
{
"camelcase" : true,
"immed" : true,
"indent" : 2,
"latedef" : true,
"newcap" : true,
"nonew" : true,
"plusplus" : true,
"quotmark" : true,
"maxcomplexity" : 20,
@wbyoung
wbyoung / package.json
Created June 12, 2014 16:18
Simple static server
{
"name": "foursquare",
"version": "0.1.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "Whitney Young",
@wbyoung
wbyoung / httpd.conf
Created October 13, 2014 18:49
Run Apache in current directory with PHP enabled.
DocumentRoot "."
ServerName localhost
ErrorLog "apache_error_log"
LogLevel warn
LoadModule authz_host_module /usr/libexec/apache2/mod_authz_host.so
LoadModule auth_basic_module /usr/libexec/apache2/mod_auth_basic.so
LoadModule auth_digest_module /usr/libexec/apache2/mod_auth_digest.so
LoadModule deflate_module /usr/libexec/apache2/mod_deflate.so
LoadModule log_config_module /usr/libexec/apache2/mod_log_config.so
@wbyoung
wbyoung / app.js
Last active August 29, 2015 14:08
Example liftoff issue
var Liftoff = require('liftoff');
var argv = require('minimist')(process.argv.slice(2));
var invoke = function(env) {
console.log('modulePath: %j', env.modulePath);
console.log('configBase: %j', env.configBase);
console.log('cwd: %j', env.cwd);
};
var liftoff = new Liftoff({
var through = require('through2');
var setup = function(b, cb) {
b.on('reset', cb);
cb();
};
module.exports = function offsetify(b, externalBundles) {
setup(b, function() {
b.pipeline.get('sort').push(through.obj(function(row, enc, next) {
@wbyoung
wbyoung / aws-deploy.sh
Last active September 12, 2017 02:26
#!/bin/bash
set -e
JQ="jq --raw-output --exit-status"
escape-json() {
python -c "import sys; import json; sys.stdout.write(json.dumps(sys.stdin.read().strip())[1:-1])"
}
#!/bin/bash
set -e
JQ="jq --raw-output --exit-status"
# @env region
# @env task_family
# @returns via stderr
locate-task() {