Skip to content

Instantly share code, notes, and snippets.

Error: Offset is out of bounds
at [object Object].<anonymous> (fs:212:11)
at [object Object].flush (fs:877:10)
at fs:869:10
at node.js:773:9
process.on('uncaughtException', function uncaughtException(e) {
if(outfile && outfile.writable) {
outfile.end();
outfile.destroy();
}
console.error(e.message);
console.error(e.stack);
})
var outfile;
var fs = require('fs')
, Buffer = require('buffer').Buffer
, request = require('request');
var outStream = fs.createWriteStream('out.jpg', {encoding:'binary'});
request({'uri': 'http://marcorogers.com/blog/static/content/images/ebook_conversion_success.jpg'
, 'responseBodyStream': outStream}
, function(err, data, body) {
console.log('done');
});
import Options
from os import unlink, symlink, popen
from os.path import exists
import subprocess
srcdir = "."
blddir = "build"
VERSION = "0.0.1"
def set_options(opt):
var b = {};
b.valueOf = function() { return 'foo'; }
b.valueOf(); // 'foo'
b == 'foo' // true
valueOf(b); // '{}'
var extend = require('xmlx').extend;
var libxmljs = extend(require('libxmljs'));
@polotek
polotek / chaos_bench.txt
Created October 16, 2010 14:45
benchmarks for chaos on node.js
# MBP 2.4 GHz dual core i5, 8GB DDR3 RAM, Apple SSD 5 series chipset
benchmark starting...
clients: 10
operations: 1000
-------------------
writes: 21276.60/s
clients: 10
var Base = {
_ops: {},
_privateFnc: function () {},
abstract: function () {},
init: function (ops) {
this._ops = ops || {};
// INIT
}
};
var sys = require('sys');
var _ = require('underscore')._;
var XML = require('libxmljs');
var mem = require('myutils').loadmem(XML);
process.addListener('exit', function () {
sys.debug('exiting');
mem();
});
@polotek
polotek / clearfix.css
Created January 1, 2011 19:31
I'm not sure I like this method for clearing floats, but it works
.clearfix {display: inline-block;}
.clearfix:after {
content: " ";
display: block;
height: 0;
clear: both;
font-size: 0;
visibility: hidden;
}