Skip to content

Instantly share code, notes, and snippets.

View troygoode's full-sized avatar
🤓
Building nerdy stuff.

Troy Goode troygoode

🤓
Building nerdy stuff.
View GitHub Profile
@troygoode
troygoode / keybase.md
Created July 14, 2014 19:53
Keybase Proof

Keybase proof

I hereby claim:

  • I am troygoode on github.
  • I am troy (https://keybase.io/troy) on keybase.
  • I have a public key whose fingerprint is 8917 81AC B1F8 0B7F 226B 8166 EA68 7C56 17DD 1FC0

To claim this, I am signing this object:

fillSkinPixels = (imagePath, regions) ->
Promise.cast()
.then ->
filepath.Abs imagePath
.then (path) ->
nude.DecodeImage path
.then (img) ->
Promise.cast()
.then ->
image.NewRGBA img.Bounds()
@troygoode
troygoode / script.sh
Last active August 29, 2015 13:56
mongo primer for @benjymessner
# withing the `mongo` REPL:
use benjy
db.tx_logs.insert({campaign: 'foo', medium: 'tv', timestamp: new Date(), some_value: 1})
db.tx_logs.insert({campaign: 'foo', medium: 'tv', timestamp: new Date(), some_value: 2})
show collections
@troygoode
troygoode / trim.js
Created January 2, 2014 22:01
recursive _.pick for @OronNadiv
var source = {
first: 'Barack',
last: 'Obama',
job: {
title: 'POTUS',
annualSalary: 400000
}
};
var schema = {
format: function (attrs) {
var retval = _.clone(attrs);
retval.stages = JSON.stringify(retval.stages);
return retval;
}
@troygoode
troygoode / server.js
Created December 8, 2013 22:58
node.js async example for @robconery
var http = require('http');
http.createServer(function (req, res) {
var requestId = Math.floor(Math.random() * 1000);
console.log('Request ID ' + requestId + ' received');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World from Request ID ' + requestId + '\n');
console.log('Request ID ' + requestId + ' responded');
@troygoode
troygoode / developer-excuses.coffee
Created August 15, 2013 20:24
developer-excuses.coffee
# Description:
# Retrieves random quote from developerexecuses.com
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@troygoode
troygoode / 1. route.coffee
Last active December 19, 2015 22:09
Quick Give & Oberon Syncing Problem Queue-Based Solution
rabbitmq = require 'rabbitmq'
queue = rabbitmq.queue 'queue://oberon/new-qgam-profile'
module.exports = (app) ->
app.post '/api/new-qgam-profile', (req, res) ->
message_json = req.body # assumed to look something like {customer_key: 'A', profile_id: 'B'}
queue.push message_json, (err) ->
#TODO: error handling
@troygoode
troygoode / Procfile
Last active December 29, 2020 17:14
basic example node.js (+express +jade) application configured to run in Heroku (views_layout.jade and views_home.jade should just be "layout.jade" and "home.jade" inside the "views" subdirectory) (public_home.js should just be "home.js" inside the "public" subdirectory)
web: node server.js
@troygoode
troygoode / middleware.js
Created June 21, 2013 20:25
basic auth unless cookie
var basicAuthUnlessCookie = function(req, res, next){
if(/* check for cookie here */){
//TODO: do something with the cookie
next();
}else{
express.basicAuth(function(user, pass){
return true; //TODO: implement
})(req, res, next);
}
});