Skip to content

Instantly share code, notes, and snippets.

View cpsubrian's full-sized avatar

Brian Link cpsubrian

  • Dropbox
  • Fremont, CA
View GitHub Profile
@cpsubrian
cpsubrian / csv.coffee
Created March 3, 2012 03:20
Parsing a csv
numRead = 0
numImported = 0
doneReading = false
csv = require('csv')()
csv.fromPath result.filepath, {columns: true}
finish = () ->
process.stdout.write '\n'
log ""
log "Imported #{numImported} users".green
@cpsubrian
cpsubrian / README.md
Created May 2, 2012 19:47
Tiered config example with nconf

Startup a service that depends on amino

./bin/myservice --conf=/path/to/my/conf

Startup a service using the default conf path

./bin/myservice

@cpsubrian
cpsubrian / router.js
Created May 16, 2012 19:43
Director routing regex issue
var path = /^\/socket\.io.+/;
app.router.get(path, handler);
console.log(app.router.routes);
/* CONSOLE OUTPUT
{ '^': { 'socket\\.io.+': { get: [Function: handler] } } }
*/
@cpsubrian
cpsubrian / out.txt
Created August 2, 2012 19:21
EADDRNOTAVAIL in simple node.js web server (OSX)
$ node http.js
events.js:48
throw arguments[1]; // Unhandled 'error' event
^
Error: connect EADDRNOTAVAIL
at errnoException (net.js:670:11)
at connect (net.js:548:19)
at Socket.connect (net.js:613:5)
at Object.<anonymous> (net.js:77:12)
@cpsubrian
cpsubrian / api.js
Created October 8, 2012 20:28 — forked from carlos8f/api.js
relations api
// relations api
// users
var carlos = 'carlos8f'
, brian = 'cpsubrian'
, sagar = 'astrosag_ngc4414'
// repos
var buffet = 'carlos8f/node-buffet'
, views = 'cpsubrian/node-views'
@cpsubrian
cpsubrian / tokens.js
Created October 23, 2012 23:32
Replace named tokens in a string.
var input = 'Hello, :name.first :name.last! :greeting';
function tokenReplace(str, values) {
return str.replace(/:([\w.]+)/g, function (token, name) {
return name.split('.').reduce(function (value, part) {
return value[part] || null;
}, values) || token;
});
}
@cpsubrian
cpsubrian / gist:4488592
Created January 8, 2013 22:27
SublimeLinter User Settings. Edit by going to menu `SublimeText2 -> Preferences -> Package Settings -> SublimeLinter -> Settings - User`
{
"sublimelinter": "load-save",
// jshint: options for linting JavaScript. See http://www.jshint.com/options/ for more info.
// By deault, eval is allowed.
"jshint_options":
{
// To fix column positions for JSHint errors you may want to add `"indent": 1` to your
// **User** "jshint_options". This issue affects users with tabs for indentation.
// This fix was reverted due to a conflict with using the `"white": true` option.
@cpsubrian
cpsubrian / .pash_profile
Created February 12, 2013 23:31
My Terminal Prompt
# GIT Prompt
parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
WHITE="\[\033[1;37m\]"
GREEN="\[\033[0;32m\]"
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
B_YELLOW="\[\033[1;33m\]"
GREY="\[\033[0;39m\]"
@cpsubrian
cpsubrian / gist:4989424
Last active December 13, 2015 23:09
Function generators.
function addX (x) {
return function (a) {
return a + x;
}
}
var add5 = addX(5);
var add10 = addX(10);
// What is result?
@cpsubrian
cpsubrian / README.md
Last active December 15, 2015 06:19
This would be the title!

Article Content

Using markdown:

  • Use lists
  • etc.