Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View isaacs's full-sized avatar
🔮
only way out is through

isaacs isaacs

🔮
only way out is through
View GitHub Profile
@isaacs
isaacs / sax-test.js
Created February 16, 2010 01:36 — forked from tmpvar/sax-test.js
var sys = require("sys"), sax = require("../sax-js/lib/sax");
parser = sax.parser(false);
sax.EVENTS.forEach(function (ev) {
parser["on" + ev] = function (n) { sys.puts(ev + " " + sys.inspect(n)); };
});
parser.write("<span>Welcome,</span> to monkey land").close();
/*
$ node sax-test.js
opentag {
function( request, response ) {
/* Determine Encoding */
var isGzip = /gzip/.test( request.headers['accept-encoding'] ) ? true : false;
/* Extract Scope */
var sandbox = /\.+(.+)\.sb+/.exec( request.headers.host );
if ( sandbox !== null ) {
var scope = sandbox[1];
// This returns a Javascript string
require.registerExtension('.coffee', function(async, source, callback) {
return compileCoffee(source);
});
// True
require('coffee').test === 123;
// This returns a object
require.registerExtension('.mu', function(async, source, callback) {
var sys = require('sys');
var url= require('url');
var query = url.parse('http://www.freddymac.com?name=freddy&lastname=mac', true).query;
sys.puts(query.name); // -> freddy
// or use querystring directly:
var querystring = require("querystring");
var query = querystring.parse("name=joe&lastname=schmoe");
sys.puts(query.name); // -> joe
-- I used to do it like this:
SELECT * FROM table WHERE
hurr
AND (foo = 'bar')
AND (bar = 'foo')
-- Then later I spaced it out even more:
SELECT
// no global leakage this way
function createNamedFunction(name) {
var args = Array.prototype.slice.call(arguments, 1);
var code = args.pop();
return process.compile("(function "+name+"("+args.join(",")+"){"+body+"\n})"
, "createNamedFunction-"+name);
}
// this is an example of what the first pass at native (fab) templates will look like:
with ( require( "fab" ) ) fab
( listen, 0xFAB )
( /\// )
( /1/ )
( "This is a template with no variables: a unary app" )
// this is an example of what the first pass at native (fab) templates will look like:
var fab = require("fab")
, listen = fab.listen
( fab )
( listen, 0xFAB )
( /\// )
var http = require('http');
var timeInterval = 20; //ms
var maxOutstandingRequests = 10;
var successCount = 0;
var outstandingRequests = 0;
var options = {
hostname: 'www.google.com'
@isaacs
isaacs / video.md
Created September 13, 2012 02:54 — forked from napcs/video.md
Video project

Intro to Programming video

I want to make a video to show my class of would-be IT people. If you write code, would you send me a video clip (webcam, less than 30s) with the following?

  • Introduce yourself (name, where you work)
  • Why you love what you do
  • Why you love open-source software (optional, but would be super helpful)