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
// create some nodes | |
var node1 = db.createNode(); | |
var node2 = db.createNode(); | |
// save them in parallel (works fine) | |
async.parallel([ | |
function (cb) { node1.save(cb) }, | |
function (cb) { node2.save(cb) } | |
], function (err) { | |
if (err) { |
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
#!/usr/bin/env node | |
function readline () { | |
var readline = require("readline"); | |
return readline.createInterface({ | |
input: process.stdin, | |
output: 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
require('child_process').spawn('ssh', [ 'user@nodejs.org', 'ls' ], { stdio: [ 'ignore', 'ignore', 'ignore' ] }); |
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
# | |
# user-jobs.conf | |
# | |
description "start user jobs when networking is up" | |
start on net-device-up | |
script | |
cat /etc/passwd | while read LINE |
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 http = require("http") | |
http.createServer(function (req, res) { | |
if (req.url === "/upload" && req.method === "POST") { | |
console.log('BEFORE', req._readableState.length) // 0 bytes have buffered here | |
setTimeout(function () { | |
console.log('AFTER', req._readableState.length) // this is big, and all in memory | |
res.end() |
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
// run this somewhere remote | |
// this is 'dest' in https://gist.github.com/4450228 | |
var fs = require('fs') | |
var http = require('http') | |
var PORT = 8080 | |
var peak = 0 | |
// watch mem usage | |
setInterval(function () { |
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
// run this locally: node <gist.js> | |
// then POST a big (>300mb) file to it with cURL: | |
// curl -X POST -d @"/path/to/big.file" localhost:8080 | |
var http = require('http') | |
var PORT = 8080 | |
var peak = 0 | |
// watch mem usage | |
setInterval(function () { |
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 PORT = 8080 | |
// watch mem usage | |
setInterval(function () { | |
console.log('memory usage ' + (process.memoryUsage().rss / (1024 * 1024)).toFixed(2) + 'mb') | |
}, 500) | |
http.createServer(function (req, res) { | |
console.log('- got request') |
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 util = require('util') | |
var stream = require('stream') | |
function Transformer (opts) { | |
stream.Duplex.call(this, opts) | |
this._buffer = [] | |
this.once('finish', this.done.bind(this)) | |
} | |
util.inherits(Transformer, stream.Duplex) |
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
#!/usr/bin/env bash | |
set -e | |
ua="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31" | |
url="http://thissongissick.com/blog/2013/listen-to-daft-punk-random-access-memories-full-album-stream/" | |
folder=~/Desktop/random\ access\ memories | |
count=0 | |
main() { |
OlderNewer