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

Recipe for customizing a SmartoOS image and cloning it

1. Create base image

1.1. Download and install the base image:

[root@00-0c-29-aa-24-ba ~]# imgadm list
UUID                                  NAME             VERSION  OS       PUBLISHED
9eac5c0c-a941-11e2-a7dc-57a6b041988f  base64           13.1.0   smartos  2013-04-26T15:17:57Z
@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
> [email protected] 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));
}