Skip to content

Instantly share code, notes, and snippets.

View joemccann's full-sized avatar
💭
Thinking

Joe McCann joemccann

💭
Thinking
View GitHub Profile
@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;
@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
var express = require('express'),
request = require('request'),
BufferList = require('bufferlist').BufferList,
sys = require('sys');
var app = express.createServer(
express.logger(),
express.bodyDecoder()
);
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active May 16, 2024 16:51
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@tanepiper
tanepiper / twitter_oauth_getter.js
Created September 11, 2010 16:14
A small command line nodejs script for doing Twitter OAuth.
#!/usr/bin/env node
var argv = require('optimist')
.usage('Usage: --key=[consumer key] -secret=[consumer secret]')
.demand(['key', 'secret'])
.argv
;
var OAuth = require('oauth').OAuth;
var Step = require('step');
@jeffrafter
jeffrafter / server.js
Created August 28, 2010 21:37
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
module.exports = tree
tree.sync = treeSync
var fs = require("fs")
, path = require("path")
function tree (root, cb) {
fs.lstat(root, function (er, s) {
if (er) return cb(er)
s.name = root
@mattdenner
mattdenner / card.css
Created August 11, 2010 10:10
How to do backface hiding when -webkit-backface-visibility doesn't work!
/*
The back of the card is rotated 180 degrees from the card itself, giving
the illusion that it really is the back! Unfortunately hiding the back
face of both "faces" doesn't work with webkit builds (requires Snow Leopard!)
but we set it anyway.
*/
.card #back { -webkit-transform: rotateY(180deg); }
.card .face { -webkit-backface-visibility: hidden; }
/*
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
};