Skip to content

Instantly share code, notes, and snippets.

View joemccann's full-sized avatar
💭
Thinking

Joe McCann joemccann

💭
Thinking
View GitHub Profile
var input = document.getElementById('myfileinput');
var files = input.files;
var file = files[i];
var xhr = new XMLHttpRequest();
xhr.open('post', '/path/to/destination', true);
xhr.onreadystatechange = function() {
if (this.readyState != 4) { return; }
// request finished - handle response
};
@tmpvar
tmpvar / gist:608282
Created October 3, 2010 04:50
fun with growlnotify and json-command
curl -d "track=nodejs,tmpvar,jsdom,carena,cider,conductor" http://stream.twitter.com/1/statuses/filter.json -uUSER:PASS 2> /dev/null | json text -C | while read line; do growlnotify -m "$line"; done
@tmpvar
tmpvar / gist:608277
Created October 3, 2010 04:32
fun with json-command & notify-send
curl -d "track=nodejs,tmpvar,jsdom,carena,cider,conductor" http://stream.twitter.com/1/statuses/filter.json -uUSER:PASS 2> /dev/null | json text -C | while read line; do notify-send -c normal -t 1000 "twitter message" "$line"; done
@jchris
jchris / reduce.js
Created November 26, 2010 04:41
unique key count reduce
function(ks, vs, rr) {
// values are discarded by reduce
// todo: configurable key function, for complex queries
var fk, lk;
function uniqCount(keys) {
var count = 0, obj = {};
for (var i=0; i < keys.length; i++) {
if (!obj[keys[i]]) {
count++;
obj[keys[i]] = true;
require.registerExtension('.js', function(js){
return js.replace(/^ *\/\/debug: */gm, '');
});
@isaacs
isaacs / callbacksarehard.js
Created January 12, 2011 02:29
let's go shopping!
// before
mainWindow.menu("File", function(err, file) {
if(err) throw err;
file.openMenu(function(err, menu) {
if(err) throw err;
menu.item("Open", function(err, item) {
if(err) throw err;
item.click(function(err) {
if(err) throw err;
mainWindow.getChild(type('Window'), function(err, dialog) {
@brianleroux
brianleroux / makefile
Created February 25, 2011 20:46
launch emulators
emulate:
emulator -cpu-delay 0 -no-boot-anim -cache ./cache -avd default > /dev/null 2>&1 & # put the avd's chatty ass in the background
open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
palm-emulator --start "SDK 1.4.5.465 (320x480)"
@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> )
@davidwood
davidwood / gist:954363
Created May 3, 2011 22:05
Serve current directory over HTTP using Python
python -m SimpleHTTPServer
By default, SimpleHTTPServer serves on port 8000. To specify a port, use (where 9090 is the port you want):
python -m SimpleHTTPServer 9090
And to run it in the background, use:
python -m SimpleHTTPServer &
@phaze9
phaze9 / titanium.macapp.bash
Created July 1, 2011 09:05
Titanium Studio Local Packaging Example
/Library/Application\ Support/Titanium/sdk/osx/1.1.0/tibuild.py -d ~/tmp -n -t bundle -a /Library/Application\ Support/Titanium/sdk/osx/1.1.0/ ~/Projects/Titanium\ Studio\ Workspace/MyApp