This file contains 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") | |
var request = require("request") | |
var filePath = __dirname + "/payload.tar.gz" | |
fs.createReadStream(filePath).pipe(request.put('http://api.lvh.me:3001/').pipe(process.stdout)) |
This file contains 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
doctype | |
html | |
head | |
link(rel="stylesheet" href="/main.css") | |
body | |
ul | |
li(class="#{ current.source == 'index' ? 'active' : '' }") | |
a(href="/") Home | |
li(class="#{ current.source == 'about' ? 'active' : '' }") | |
a(href="/about") About |
This file contains 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 Transition = function(callback){ | |
this.instantOperations = [] | |
this.deferredOperations = [] | |
this.total = 0 | |
this.count = 0 | |
this.callback = callback || new Function() | |
return this; | |
} | |
Transition.prototype.add = function(el, args, cb){ |
This file contains 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 assert = require('assert') | |
var agent = require('superagent') | |
http.createServer(function (req, res) { | |
res.writeHead(500, {'Content-Type': 'text/plain'}) | |
res.end('Hello World\n') | |
}).listen(1337, '127.0.0.1', function(){ | |
agent.get('http://127.0.0.1:1337/').end(function(err, response){ | |
assert.equal(response.status, 500) |
This file contains 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
{ | |
"redirects": { | |
"/:year/:month/:day/:slug": "/#{ year }/#{ slug }" | |
} | |
} |
This file contains 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
module.exports = function(req, rsp, stack, callback){ | |
var that = this | |
var index = 0 | |
function next(err){ | |
var layer = stack[index++] | |
if(!layer) return callback(req, rsp, next) | |
layer.call(that, req, rsp, next) | |
} |
This file contains 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
// test by running `node test.js` | |
var spawn = require("child_process").spawn | |
var child = spawn("sudo", [__dirname + "/bin/server"]) | |
child.stderr.on('data', function (data) { | |
child.stdin.write("somepassword" + '\n'); | |
}) |
This file contains 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 batcher = require("batcher") | |
var myUploader = function(item, done){ | |
uploadSomewhere(item, function(err, result){ | |
done(err, result) | |
}) | |
} | |
var myErrCheck = function(err, retry, pass){ | |
if(err.statusCode == 503){ |
This file contains 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 Geometry class was yanked from RMagick. However, it lets ImageMagick handle the actual change_geometry. | |
# Use #new_dimensions_for to get new dimensons | |
# Used so I can use spiffy RMagick geometry strings with ImageScience | |
class Geometry | |
# ! and @ are removed until support for them is added | |
#old# FLAGS = ['', '%', '<', '>']#, '!', '@'] | |
FLAGS = ['', '%', '<', '>', '!']#, '@'] | |
RFLAGS = { '%' => :percent, | |
'!' => :aspect, | |
'<' => :>, |
This file contains 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 dnode = require('dnode'); | |
exports.createServer = function(){ | |
var server = dnode({ | |
foo : function (s, cb) { | |
cb(s.replace(/[aeiou]{2,}/, 'oo').toUpperCase()) | |
} | |
}) | |