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
#!/usr/bin/env node | |
/* | |
* This is a git script that makes it easier to stash and unstash | |
* multiple patches in a dirty working tree. This is a first draft | |
* taken from this approach | |
* http://stackoverflow.com/questions/1360712/git-stash-cannot-apply-to-a-dirty-working-tree-please-stage-your-changes | |
* | |
* It's written with javascript for node.js, because I wanted to explore scripting | |
* with node. |
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
fs.createReadStream('jsconf.png') | |
.pipe( request.post({url:'http://transform.it/'}) ) | |
.pipe( response ); |
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
baz = -> alert 'baz' | |
foo -> alert 'foo' | |
bar -> | |
foo | |
baz = -> | |
foo = -> alert 'new foo' | |
baz() | |
foo() |
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
// This is the usual AMD form that supports the dependency array. | |
define(['mymodule'], function(mymodule) { | |
// The module mymodule should be loaded and available here. | |
mymodule.doSomething(); | |
}); | |
// This is the "basic" form that is now supported by node | |
define(function(require, exports, module) { | |
// This will be loaded synchronously in node. In the browser you need | |
// a build step and a smart loader to do this. |
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
function TwitterStream(tweetstream /* the raw data socket from twitter.com */) { | |
// some setup | |
this.bufferedstream = new BufferedStream(); // my version | |
tweetstream.pipe(buffer).pipe(this); | |
// Now I have a buffered data stream that I know I can pause/resume at will. No one else has to be affected by this. | |
} | |
// standard stream method | |
TwitterStream.prototype.write = function(chunk) { |
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
var data; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function(chunk) { | |
data += chunk; | |
}); | |
process.stdin.on('end', function() { |
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
var http = require('http'); | |
var server = http.createServer(function (req, resp) { | |
if(req.url.match('redir')) { | |
resp.writeHead(301, {'Location':'http://google.com/', 'Expires': (new Date).toGMTString()}); | |
resp.end(); | |
} else { | |
resp.writeHead(200, {'content-type': 'text/plain', 'content-length':4}); | |
resp.end('Main'); | |
} | |
}); |
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
var http = require('http') | |
, Stream = require('stream').Stream | |
, fs = require('fs') | |
, util = require('util'); | |
var slice = Array.prototype.slice; | |
/** |
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
.hanging { | |
display:-moz-inline-box; | |
display:inline-block; | |
vertical-align:top; | |
} |
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
var fs = require('fs'); | |
OAuth = require('oauth').OAuth; | |
var config = JSON.parse( fs.readFileSync(__dirname + '/default_config.json') ); | |
var oauth = config.oauth; | |
console.warn(oauth); | |
var oa = new OAuth(oauth.requestTokenURL | |
, oauth.accessTokenURL |