Skip to content

Instantly share code, notes, and snippets.

View nickpoorman's full-sized avatar
Verified

Nick Poorman nickpoorman

Verified
View GitHub Profile
@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 / gist:2352433
Created April 10, 2012 16:05
Deadlock Env
>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]
> rails -v
Rails 3.2.3
@nickpoorman
nickpoorman / Console
Created June 23, 2012 19:09
Awesome Print with Mongoid in Rails
User.all.each { |p| ap p.attributes}
@nickpoorman
nickpoorman / app.coffee
Created August 20, 2012 10:33
Express.js Backbone.js pushState router
# if the resource is not found then forward to backbone's router
app.use (req, res) ->
newUrl = req.protocol + '://' + req.get('Host') + '/#' + req.url
res.redirect newUrl
@nickpoorman
nickpoorman / gist:3669240
Created September 7, 2012 20:12
Can't get attributes
define(["app",
// Libs
"backbone", "validator",
// Modules
// Plugins
"util", "plugins/jquery.cookie"
//"plugins/backbone.layoutmanager"
],
function (app, Backbone, Validator, Util, Cookie) {
@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;
}
@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 / 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 / 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 / perFORrmanceloop.js
Created January 19, 2013 23:43
perFORrmance loop
for (var i = profile.readBooks.length - 1; i >= 0; i--) {
profile.readBooks[i]
};