Skip to content

Instantly share code, notes, and snippets.

View indexzero's full-sized avatar
🌎
Always bet on Open Source

Charlie Robbins indexzero

🌎
Always bet on Open Source
View GitHub Profile
@indexzero
indexzero / include.js
Created January 22, 2012 09:03
Find the source of your `sys` deprecation warnings in [email protected]
//
// Place this at the beginning of your node.js program before
// **any and all** require statements.
//
var util = require('util');
var _warning = util._deprecationWarning;
util._deprecationWarning = function () {
console.trace();
_warning.apply(util, arguments);
@indexzero
indexzero / readme.md
Created January 25, 2012 22:07 — forked from mislav/readme.md
CLI tool that checks the build status of current branch on Travis CI

Check build status of a project on the command line

Install (copy & paste):

curl -sL \
  gist.github.com/raw/1676577/eb66596ba3d69bf1ba9d782ce7ddaaab295cc4db/travis.rb \
  > ~/bin/travis && chmod +x ~/bin/travis

gem install hub | tail -2
@indexzero
indexzero / README.md
Created February 8, 2012 07:01
Two Github Feature Requests

Two Github Feature Requests

  1. Share gists internally within an Organization: 'nuff said.
  2. Promote public gists which mention projects I created or follow.
@indexzero
indexzero / outbound-proxy.js
Created February 9, 2012 21:44
A simple outbound proxy server with node-http-proxy
var httpProxy = require('http-proxy');
var server = httpProxy.createServer(function (req, res, proxy) {
//
// Inspect the request
//
console.dir(req);
//
// Proxy to the Remote Location
@indexzero
indexzero / proposal.md
Created February 13, 2012 01:41
Broadway v2 proposal from @pksunkara

broadway.js (module)

var App = function () {
  // Constructor
  this.on('app::*') {
    this.plugins.forEach(function (e) {
      if (e[eventname]) {
        e[eventname]();
 }
@indexzero
indexzero / proposal.md
Created February 13, 2012 01:53
Before and after proposal in broadway.

Before and After hooks in Broadway

There are two limitations in the current broadway implementation which this proposal intends to address:

  • Events emitted by broadway.App instances are not granular enough. Currently only these events are emitted:
    • init: Emitted when the App has completed initialization.
    • ['plugin', name, 'init']: Emitted when a given plugin has completed initialization.
    • ['plugin', name, 'error']: Emitted when there was an error initializing the given plugin.
    • ['broadway', 'logged']: Emitted when the application has logged a given message
  • It is not possible to run a specified function before or after a given plugin method or other broadway action. The need for this has become clear refactoring jitsu to use flatiron. These hooks need to support async actions as well as sync actions.
@indexzero
indexzero / app.js
Created February 25, 2012 06:29 — forked from jfhbrook/app.js
THE FRAMEWORK YOUR FRAMEWORK COULD CODE LIKE
var flatiron = require('flatiron'),
app = flatiron.app;
console.log('What\'s that in your hand? Look down,');
app.use(require('./tickets'));
console.log('look up. I HAVE IT. It\'s ' + app.qty + ' TICKETS to ' + app.description + '!');
console.log('Look again.');
app.use(require('./diamonds'));
@indexzero
indexzero / S2105-Response.md
Created March 8, 2012 06:29
Open Letter to Congress: Response to S.2105

Open Letter to Congress

Response to S.2105: To enhance the security and resiliency of the cyber and communications infrastructure of the United States.

I urge you to oppose John McCain's new cybersecurity legislation.

I come to this conclusion having read the important provisions of the Bill (for reference: [http://www.gpo.gov/fdsys/pkg/BILLS-112s2105pcs/pdf/BILLS-112s2105pcs.pdf][0]), specifically:

Title VII - Information Sharing

Violation of the Fourth Amendment

@indexzero
indexzero / gist:2331488
Created April 7, 2012 19:18 — forked from mikeal/gist:2331127
safe .toJSON()
function toString (obj) {
function _toString (i) {
if (obj[i] === null) return 'null'
if (typeof obj[i] === 'undefined') return 'undefined'
if (obj[i].toString) return obj[i].toString()
else return ''
}
return _toString
}
@indexzero
indexzero / example-user.js
Created May 4, 2012 16:46 — forked from nijikokun/example-user.js
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9-_]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);