Skip to content

Instantly share code, notes, and snippets.

View jed's full-sized avatar

Jed Schmidt jed

View GitHub Profile
@jed
jed / userAgentJavascriptTest.js
Created October 28, 2010 12:12
send different content based on sideloaded javascript
var urls = {}
require( "http" ).createServer( function( req, res ) {
var url = req.url, timeout
if ( url == "/favicon.ico" ) return res.writeHead( 404 ), res.end()
if ( url in urls ) return urls[ url ]( req, res )
url = "/vapor.js?" + Math.floor( Math.random() * 0xcfd41b9100000 ).toString( 36 )
> jedbook:desktop jed$ node /usr/local/lib/node/.npm/socket.io/0.6.1/package/exale/server.js
1 Dec 22:06:12 - Your node instance does not have root privileges. This means that the flash XML policy file will be served inline instead of on port 843. This might slow down initial connections slightly.
1 Dec 22:06:12 - socket.io ready - accepting connections
1 Dec 22:07:11 - Initializing client with transport "websocket"
1 Dec 22:07:11 - Client 8948545621242374 connected
1 Dec 22:07:11 - Client 8948545621242374 disconnected
1 Dec 22:07:16 - Initializing client with transport "xhr-polling"
1 Dec 22:07:16 - Client 2304718098603189 connected
1 Dec 22:07:47 - Initializing client with transport "websocket"
1 Dec 22:07:47 - Client 7040154365822673 connected
@jed
jed / error.txt
Created December 26, 2010 00:23
error in flickrtouchr when trying to download a picture with a slash in the title
Traceback (most recent call last):
File "flickrtouchr/flickrtouchr.py", line 368, in <module>
inodes[photoid] = getphoto(imgurl, target)
File "flickrtouchr/flickrtouchr.py", line 170, in getphoto
fh = open(filename, "w")
IOError: [Errno 2] No such file or directory: u"japan '09/20091002220101-3975078266_o-vanilla ice cream w/ coffee @ sushi sen, nishi azabu.jpg"
@jed
jed / guid.js
Created January 4, 2011 17:21
objective: a function for generating guids of unique entities
// objective: a function for generating guids of unique entities
// usage: guid( obj ) => integer
// approach 1
// entities kept in a hash array, key id found by iteration
// pros:
// (1) unobtrusive; doesn't pollute objects with expandos
// (2) ids can't be accidentally deleted/changed
// (3) ids can be assigned to any type of object
@jed
jed / guids.js
Created January 5, 2011 22:21
a javascript include that uses the DOM to test 4 guid schemes
var guid = {
// uses an expando to store the id on the object
// wicked fast, but not reliable without DOM hackery (see jQuery source)
"expando": function( last ) {
return function guid( obj ) {
if ( obj ) {
if ( obj.guid ) return obj.guid
obj.guid = last
@jed
jed / configure
Created January 21, 2011 03:04
results of ./configure on OS X 10.6.6
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok
Traceback (most recent call last):
File "/Users/jed/desktop/node/tools/waf-light", line 158, in <module>
Scripting.prepare(t, cwd, VERSION, wafdir)
@jed
jed / gist:843289
Created February 25, 2011 02:28 — forked from tobie/gist:842085
var domReady = !document.readyState && document.addEventListener
? function( fn ){ document.addEventListener( "domContentLoaded", fn ) }
: function( fn ){ setTimeout( /in/( document.readyState ) ? function(){ domReady( fn ) }, 50 ) : fn ) }
curl -N localhost:8080
@jed
jed / ATNDNT.js
Created April 2, 2011 10:41
a script that lets you know when your friends sign up for new ATND.org events
var http = require( "http" )
, url = require( "url" )
, exec = require( "child_process" ).exec
, username = process.argv[ 2 ]
, seconds = +process.argv[ 3 ] || 300
, friends
, events = {}
if ( !username ) {
@jed
jed / README.md
Created April 4, 2011 14:02
a small module for autorequiring. warning: MAGIC!

autorequire.js

Copyright (c) 2011 Jed Schmidt

a small module for auto-importing modules in node.js.

usage

require( "./autorequire" )
require.auto( <module-name> )