Skip to content

Instantly share code, notes, and snippets.

View pgte's full-sized avatar
🏠
Working from home

Pedro Teixeira pgte

🏠
Working from home
View GitHub Profile
@pgte
pgte / results.json
Created July 21, 2013 18:20
level-writestream benchmark results
{"max":100000,"chunkSize":500,"highWaterMark":500,"maxConcurrentBatches":4,"timeoutBetweenChunks":0,"valueSize":10,"wrap":false,"ellapsed":3403}
{"max":100000,"chunkSize":500,"highWaterMark":500,"maxConcurrentBatches":4,"timeoutBetweenChunks":0,"valueSize":10,"wrap":true,"ellapsed":2656}
{"max":100000,"chunkSize":500,"highWaterMark":500,"maxConcurrentBatches":4,"timeoutBetweenChunks":0,"valueSize":100,"wrap":false,"ellapsed":3437}
{"max":100000,"chunkSize":500,"highWaterMark":500,"maxConcurrentBatches":4,"timeoutBetweenChunks":0,"valueSize":100,"wrap":true,"ellapsed":2662}
{"max":100000,"chunkSize":500,"highWaterMark":500,"maxConcurrentBatches":4,"timeoutBetweenChunks":0,"valueSize":1000,"wrap":false,"ellapsed":4186}
{"max":100000,"chunkSize":500,"highWaterMark":500,"maxConcurrentBatches":4,"timeoutBetweenChunks":0,"valueSize":1000,"wrap":true,"ellapsed":2549}
{"max":100000,"chunkSize":500,"highWaterMark":500,"maxConcurrentBatches":4,"timeoutBetweenChunks":10,"valueSize":10,"wrap":false,"ellapsed":3353}
{"max
→ cd projects/test
pedroteixeira@Pedros-MacBook-Pro:~/projects/test (master)
→ npm install kinect
npm http GET https://registry.npmjs.org/kinect
npm http 200 https://registry.npmjs.org/kinect
> kinect@0.1.7 install /Users/pedroteixeira/projects/test/node_modules/kinect
> node-gyp rebuild
gyp http GET http://nodejs.org/dist/v0.8.21/node-v0.8.21.tar.gz
@pgte
pgte / prophet.js
Last active December 14, 2015 14:08
var previousDistance = Number.MAX_VALE;
var dir = 0;
function tick(distance) {
console.log('distance:', distance);
var randomTurn = 2 - Math.round(Math.random() * 4);
console.log(randomTurn);
if (distance >= previousDistance) dir += randomTurn;
var directions = ['up', 'down', 'left', 'right'];
var direction = directions[dir % directions.length];
previousDistance = distance;
module.exports = function(conf) {
return function(a, b) {
return a + b;
};
};
var BufferedStream = require('bufferedstream')
, inherits = require('util').inherits
;
function Transformation(callback) {
BufferedStream.apply(this)
this.callback = callback
}
inherits(Transformation, BufferedStream)
pedroteixeira:test pedroteixeira$ node test.js
uncaught exception [Error: abc1]
uncaught exception [Error: def]
uncaught exception [Error: abc2]
uncaught exception [Error: def]
@pgte
pgte / expect.js
Created November 25, 2011 17:55
expect.js
(function() {
function _deepEqual(actual, expected) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (actual instanceof Date && expected instanceof Date) {
return actual.getTime() === expected.getTime();
// 7.3. Other pairs that do not both pass typeof value == "object",
@pgte
pgte / mem_usage.js
Created October 23, 2011 09:00
Memory usage of constructor techniques:
Client:
console.log('BEFORE:', process.memoryUsage());
var Rectangle = require('./rectangle');
var rectangles = [];
for(var i = 0; i < 100000; i++) {
rectangles.push(new Rectangle(1,2,3,4));
}
@pgte
pgte / design_doc_source.json
Created September 12, 2011 14:42
design doc source
{
"_id": "_design/CQS/test10",
"_rev": "1-b906ada82e09f7dd1f85f4f8ee0e1b7b",
"name": "test10",
"ApproximateNumberOfMessages": 0,
"ApproximateNumberOfMessagesNotVisible": 0,
"VisibilityTimeout": 30,
"CreatedTimestamp": "2011-09-12T14:37:35.981Z",
"LastModifiedTimestamp": "2011-09-12T14:37:35.981Z",
"Policy": null,