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 / 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 / .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 / 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 / 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 / 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 / promise.js
Created May 10, 2014 03:51
Bluebird 1.2.4 Node.js installation
/**
* Copyright (c) 2014 Petka Antonov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:</p>
*
@wbyoung
wbyoung / gulpfile.js
Last active August 29, 2015 14:00
gulpfile.js
'use strict';
var gulp = require('gulp');
var path = require('path');
var es = require('event-stream');
var $ = require('gulp-load-plugins')();
var _ = require('lodash');
var SERVER_PORT = process.env.PORT || 9000;
var LIVERELOAD_PORT = process.env.LIVERELOAD_PORT || 35729;
@wbyoung
wbyoung / ssh-keygen-and-pbcopy.sh
Last active August 29, 2015 13:59
Create and copy SSH key
RSA="${HOME}/.ssh/id_rsa"
PUB="${RSA}.pub"
if ! [ -f "${RSA}" ] && ! [ -f "${PUB}" ]; then
/usr/bin/ssh-keygen -q -t rsa -N "" -f "${RSA}"
fi
/bin/cat "${PUB}" | /usr/bin/pbcopy
@wbyoung
wbyoung / game-longname.json
Created April 4, 2014 20:58
JSI game description with longer names
{
"rooms": [
{
"name": "A",
"north": "DD",
"east": "BB",
"south": null,
"west": null
},
{
@wbyoung
wbyoung / game-reordered.json
Created April 4, 2014 20:54
JSI game description with rooms reordered
{
"rooms": [
{
"name": "C",
"north": null,
"east": null,
"south": null,
"west": "B"
},
{