Skip to content

Instantly share code, notes, and snippets.

View AndreasMadsen's full-sized avatar

Andreas Madsen AndreasMadsen

View GitHub Profile
@AndreasMadsen
AndreasMadsen / testcase.js
Created June 9, 2012 20:55
compress bug?
var fs = require('fs');
var url = require('url');
var path = require('path');
var http = require('http');
var mime = require('mime');
var zlib = require('zlib');
// Define compression types
var compressors = {
gzip: zlib.createGzip,
@AndreasMadsen
AndreasMadsen / testcase.js
Created June 10, 2012 09:53
domain bug and design?
var domain = require('domain');
var url = require('url');
var util = require('util');
var events = require('events');
/* hack */
domain.Domain.prototype.run = function (fn) {
var active = this;
// sync thrown errors needs be be catch and deleayed by process.nextTick.
Andreass-MacBook-Pro:~ Andreas$ curl -v http://google.dk
* About to connect() to google.dk port 80 (#0)
* Trying 173.194.69.94... connected
* Connected to google.dk (173.194.69.94) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: google.dk
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
@AndreasMadsen
AndreasMadsen / speed.md
Created July 21, 2012 15:38
is v8 in 0.8 slow?

#Performance

See test/benchmark/compare.js for benchmark code.

Executed on cpu: 2.66 Ghz Intel Core i7 and node: v0.6.21-pre.

Case ms / run - less is better
a small document (693 B)
make apf
cd node_modules/packager; node package.js projects/apf_cloud9.apr
10:19:43.267 Start parsing main application
using file: /Users/Andreas/GitHub/cloud9/node_modules/packager/projects/projects/apf_cloud9.apr
path.existsSync is now called `fs.existsSync`.
10:19:43.287 Start parsing
10:19:43.289 Parsing settings
10:19:43.290 Parsing files
10:19:43.398 Getting filelist done.
10:19:43.398 Parsing defines
var fs = require('fs');
var util = require('util');
var Stream = require('stream');
var file = fs.createReadStream('file.csv');
var parser = new CSV();
// values will be emitted
parser.on('value', function (value) {
console.log(value);
@AndreasMadsen
AndreasMadsen / bench.js
Created August 5, 2012 16:07
Ahh, that ARGUMENTS thing - is loop really faster than slice, oohhh !#%
if (process.argv[2] === 'bench') {
var pre = process.hrtime();
if (process.argv[3] === '1') {
(function () {
var args = Array.prototype.slice.call(arguments);
})(1, 2.0, "string", {"foo": true});
}
else if (process.argv[3] === '2') {
Andreass-MacBook-Pro:node Andreas$ npm install -g vock@0.1.2
npm http GET https://registry.npmjs.org/vock/0.1.2
npm http 304 https://registry.npmjs.org/vock/0.1.2
npm http GET https://registry.npmjs.org/node-gyp
npm http GET https://registry.npmjs.org/msgpack-js
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/pripub
npm http GET https://registry.npmjs.org/prompt
Error: error in route
at /Users/Andreas/Sites/Admazely/director-wrapper/test.js:15:15
at Domain.bind.b (domain.js:201:18)
at Domain.run (domain.js:141:23)
at Server.<anonymous> (/Users/Andreas/Sites/Admazely/director-wrapper/test.js:10:7)
at Server.EventEmitter.emit (events.js:91:17)
at HTTPParser.parser.onIncoming (http.js:1793:12)
at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:111:23)
at Socket.socket.ondata (http.js:1690:22)
at TCP.onread (net.js:402:27)
@AndreasMadsen
AndreasMadsen / WhatIHaveDone.md
Last active February 13, 2022 16:15
Playing with smartos