View .tmux.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# change command prefix binding | |
unbind C-b | |
set -g prefix C-a | |
# decrease command-sending delay | |
set -sg escape-time 1 | |
# make window and pane index one-based | |
set -g base-index 1 | |
setw -g pane-base-index 1 |
View db.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pg = require(‘pg’), connString = ‘***’; | |
function DB(cb) { | |
var that = this; | |
pg.connect(connString, function(err, client, done) { | |
if (err) return cb(err); | |
that.client = client; | |
cb(null, that); | |
}); | |
} |
View app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* relevant section of my db module */ | |
db.user = {}; | |
db.user.available = function(email) { | |
return knex('users') | |
.where('email', email) | |
.then(areNone); | |
}; | |
db.user.add = function(data) { | |
return knex('users') |
View app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* map query string fields to search filters */ | |
var inexactFilters = { | |
date_added : function(queryVal, job, cb) { | |
cb(moment(job.date_added).format('MM-DD-YYYY') === queryVal); | |
}, | |
tags : function(queryVal, job, cb) { | |
console.log(cb.toString()); | |
app.get('db').tag.getBelongingToJob(job.job_id).then(function(tags) { | |
cb(queryVal.split(',').filter(function(tag) { return tags.map(function(tag) { return tag.tag_content; }).indexOf(tag) !== -1; }).length > 0); |
View app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app.get('db') is a reference to my wrapper module over knex.js | |
// which just bundles actions/behavior into entity-named properties (tag, jobIndustries, etc.) | |
app.get('db').tag.getBelongingToJob(job.job_id) | |
.then(function(tags) { | |
job.tags = tags; | |
return app.get('db').jobIndustries.get(job.job_industry); | |
}).then(function(jobIndustry) { | |
job.job_industry = jobIndustry; | |
return app.get('db').jobCategories.get(job.job_category); |
View app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thisReturnsAPromise().then(function(val) { | |
if (something) { | |
anotherPromiseReturningFn(val.property).then(function() { | |
callback(); | |
}); | |
} else { | |
callback(); | |
} | |
}); |
View functions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Make Jobs Searchable */ | |
DROP TRIGGER make_job_searchable ON jobs; | |
DROP TRIGGER make_job_searchable_update ON jobs; | |
DROP FUNCTION make_job_searchable(); | |
CREATE FUNCTION make_job_searchable() RETURNS trigger AS $make_job_searchable$ | |
DECLARE | |
searchable_document text; | |
industries text; |
View app.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cb() { | |
app.get('db')[config.dbProperty].add(req.body, options.getAddObj(req.body)).then(function(id) { | |
res.redirect('/' + config.routeName + '/' + id); | |
}); | |
} | |
if (itemHasCompany(config.itemName)) { | |
return util.updateCompany(req.body, req.session.user, app).then(function() { | |
cb(); | |
}); | |
} |
View failing-stream.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################### | |
## ~~ HTML STREAM ~~ ## | |
##################################################################### | |
Your program will get some html written to stdin. Convert all the inner html to | |
upper-case for elements with a class name of "loud". | |
You can use `trumpet` and `through` to solve this adventure. | |
With `trumpet` you can create a transform stream from a css selector: |
View addLocations.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pg = require('pg'); | |
var request = require('request'); | |
function getUrl(location) { | |
return 'https://maps.googleapis.com/maps/api/geocode/json?address=' + location.address + ', ' + location.city + ', ' + location.state + ' ' + location.zip_code; | |
} | |
var count = 0; | |
pg.connect(connString, function(err, client, done) { |
OlderNewer