Skip to content

Instantly share code, notes, and snippets.

View cjpartridgeb's full-sized avatar

Chris Partridge cjpartridgeb

View GitHub Profile
@cjpartridgeb
cjpartridgeb / gist:5727139
Created June 7, 2013 04:53
curry car part stamper
var partStamper = function(id) {
return function(part) {
part.stamp(id);
}
};
var stamper1 = partStamper('car1');
car1.parts.forEach(stamper1);
var stamper2 = partStamper('car2');
function check(id) {
return function(article, callback) {
// scope with id
// and the article itself
};
}
exports.checkAll = function (d, callback) {
async.each(d.articles,
check(d.id),
@cjpartridgeb
cjpartridgeb / binding.gyp
Created June 4, 2013 00:23
building node-chimera on Ubuntu 12.04 Grab node-chimera master Grab phantomjs master Copy qt folder from phantomjs/src/qt to node-chimera/qt Run ./scripts/compile_openssl.sh Run ./scripts/compile_qt.sh Run ./scripts/compile_binary.sh Tested on two separate machines, both Ubuntu 12.04, on node 0.8.23 & node 0.10.9
{
'targets': [
{
'target_name': 'chimera',
'sources': [
'src/top.cc',
'src/cookiejar.cc',
'src/chimera.cc',
'src/browser.cc'
],
{ "keys": ["ctrl+k", "ctrl+["], "command": "insert_gist_list" },
{ "keys": ["ctrl+k", "ctrl+]"], "command": "gist_add_file" }
{ "keys": ["ctrl+k", "ctrl+["], "command": "insert_gist_list" },
{ "keys": ["ctrl+k", "ctrl+]"], "command": "gist_add_file" }
{
"name": "wanderfoot",
"version": "0.0.1",
"contributors" : [
{
"name": "jarrod parkes",
"email": "parkesfjarrod@gmail.com"
}
],
"description": "wanderfoot application",
@cjpartridgeb
cjpartridgeb / gist:5507358
Created May 3, 2013 05:28
for happyGilmorian
var http = require('http');
var sockjs = require('sockjs');
var node_static = require('node-static');
// 1. Echo sockjs server
var sockjs_opts = {sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"};
var sockjs_echo = sockjs.createServer(sockjs_opts);
sockjs_echo.on('connection', function(conn) {
conn.on('data', function(message) {
@cjpartridgeb
cjpartridgeb / gist:5431818
Created April 22, 2013 01:09
for rpcesar
var RTII = function(req, res, next){
types.list(function(types_){
req.types = types_;
return next();
});
};
app.get('/some/handler/that/needs/types', RTII, function(req, res){
// req.types available here
});
@cjpartridgeb
cjpartridgeb / gist:5235434
Created March 25, 2013 07:22
middleware example
// mw.getUserAndAgency
var middleware = function(req, res, next) {
req.statsdName = 'user_middleware';
var get = cabinet
.read('users', req.token.user_id)
.with('agencies');
get.execute(function(err, empty, result) {
SELECT subscriptions.id, subscriptions.agency_id, subscriptions.expiry,
CASE
WHEN subscriptions.expiry > date_part('epoch'::text, now())::bigint THEN 'current'::text
ELSE 'expired'::text
END AS status
FROM subscriptions
ORDER BY subscriptions.expiry DESC;
-- This returns:
-- 25;1;1394321699;"current"