Created
August 24, 2010 21:49
-
-
Save jed/548395 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) ); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is just a short app i threw together for a demo @ heroku... scales to, uh, 1 user.