Skip to content

Instantly share code, notes, and snippets.

@jed
Created August 24, 2010 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jed/548395 to your computer and use it in GitHub Desktop.
Save jed/548395 to your computer and use it in GitHub Desktop.
fab = require( "fab" );
appCount = 79353;
with ( fab )
( fab )
( import, html )
( listen, 0xFAB )
( route, /^\/$/ )
( HTML, { class: "heroku" } )
( HEAD )
( STYLE )( "body { font-size:200% }" )()
()
( BODY )
( H1 )( "Welcome to Heroku" )()
( DIV )
( B, { id: "appcount" } )
( appCount.toString() )
()
( BR )
( "apps running right now" )
()
( SCRIPT, { src: "/update" } )()
()
()
()
( route, /^\/update/ )
( serverCount )
()
( "Not found.", { status: 404 } )
();
function serverCount( write ) {
function clientCount( count ) {
var d = document, s = d.createElement( "script" );
d.getElementById( "appcount" ).innerHTML = count;
s.src = "/update?" + +new Date;
d.body.appendChild( s );
}
return write( function( write ) {
return fab.stream( function( stream ) {
setTimeout( function() {
var s = "(" + clientCount + ")(" + appCount++ + ")";
return stream( write( s ), { headers: { } } )();
}, 0|( Math.random() * 3000 ) );
});
});
}
@jed
Copy link
Author

jed commented Aug 24, 2010

this is just a short app i threw together for a demo @ heroku... scales to, uh, 1 user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment