Skip to content

Instantly share code, notes, and snippets.

View nickpoorman's full-sized avatar
Verified

Nick Poorman nickpoorman

Verified
  • US
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nickpoorman on github.
  • I am nickpoorman (https://keybase.io/nickpoorman) on keybase.
  • I have a public key whose fingerprint is F54D 717B 258B F44B A8F3 893B 59CC 07EF B0FC 5E29

To claim this, I am signing this object:

@nickpoorman
nickpoorman / repl.js
Created July 9, 2014 21:15
Simple repl for rethinkdb
/**
* simple repl for the database
*/
var r = require('rethinkdb');
var inspect = require('util').inspect;
var connectOpts = {
host: process.HOST || '127.0.0.1',
port: process.PORT || 28015,
};
@nickpoorman
nickpoorman / .gitignore
Created October 11, 2013 07:16
.gitignore
# node.js #
###########
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
@nickpoorman
nickpoorman / gitignore
Created March 14, 2013 00:36
gitignore problem
# node.js #
###########
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
@nickpoorman
nickpoorman / publicProperties.js
Last active December 11, 2015 23:58
Node Mongoose attr_accessible - how I make my sub documents have public attributes.
/* this method is async */
UserSchema.methods.toPublic = function(done) {
if(typeof done !== "function") {
return undefined;
}
// this is a shared object, so beware of concurrency issues
var publicObj = {
_id: this.id,
email: this.email,
@nickpoorman
nickpoorman / perFORrmanceloop.js
Created January 19, 2013 23:43
perFORrmance loop
for (var i = profile.readBooks.length - 1; i >= 0; i--) {
profile.readBooks[i]
};
@nickpoorman
nickpoorman / deepTrimAsync.js
Created January 7, 2013 12:12
Possibly a horrible way to trim elements in nested arrays?
function deepTrimAsync(array, cb) {
async.map(array, function(item, callback) {
if(!Array.isArray(item)) {
if(typeof item === 'string') {
item = sanitize(item).trim();
@nickpoorman
nickpoorman / test.js
Last active December 10, 2015 18:28
traverse test large :(
var traverse = require('traverse');
var bla = ["x", "y", "z", "x", "y", "z", "x", "y", "z", "x", "y", "z", "x", "y", "z", "x", "y", "z", "x", "y", "z", "x", "y", "z"];
var drp = ["a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c", "a", "b", "c"];
var foo = [bla, "l", "m", drp, "n", bla, "l", "m", drp, "n", bla, "l", "m", drp, "n", bla, "l", "m", drp, "n", bla, "l", "m", drp, "n"];
@nickpoorman
nickpoorman / test.js
Created September 14, 2012 17:06
Block Scoping
fs = require("fs");
try {
var config = JSON.parse(""+fs.readFileSync("config.json"));
} catch (ex) {
console.log('got an error: %s', ex);
process.exit(1);
}
console.log(config);
@nickpoorman
nickpoorman / gist:3716673
Created September 13, 2012 18:50
refactor bens function
Lexer: function(line) {
var lex = {
origLine: line,
line: line,
yytext: null,
token: null,
check: function(tok) {
if(tok == this.token) {
return this.yytext;
}