Skip to content

Instantly share code, notes, and snippets.

Avatar

Bert Belder piscisaureus

  • Amsterdam
View GitHub Profile
View gist:9077207
// Stream type: tcp
* fundamental unit: byte
* list representation: buffer
readOne() -> yields a byte (represented as a number)
read() -> yields a Buffer containing a 1..N bytes, implementation decides
// Stream type: text lines (e.g. after splitting a text files into lines)
* fundamental unit: line (string)
* list representation: array
readOne() -> yields a line (a string)
View zone-yield.js
var contents = yield fs.readFile('bla');
yield zone.create(() => {
http.get('google.com/bla').pipe(fs.createWriteStream('cache/file1'))
http.get('google.com/bl2').pipe(fs.createWriteStream('cache/file2'))
http.get('google.com/bl3').pipe(fs.createWriteStream('cache/file3'))
});
console.log('all done!')
View zone-local-storage.js
http.createServer(function(conn) {
zone.data.start = Date.now();
doThis(conn);
doThat(conn);
new Zone(function() {
zone.data.bar = 49;
output = renterTemplate()
View nu.md

Introducing zones.

Before we get started: 'zone' is a library that makes programming with node much easier. It's work in progress, but you can try it out now.

You get goodies like:

  • Automatic exception handling
  • Long stack traces
  • Detect and handle common pitfalls with callbacks
View nni.cpp
#include <functional>
#include <iostream>
class JSAny {
void* substance;
};
class JSBool : public JSAny {
public:
View gist:f678b71b5df2195a607f
d:\a\node_modules\strong-agent\src\compat.h(71): error C2061: syntax error : id
entifier 'FunctionCallback' [D:\a\node_modules\strong-agent\build\strong-agent.
vcxproj]
d:\a\node_modules\strong-agent\src\compat.h(139): error C4430: missing type spe
cifier - int assumed. Note: C++ does not support default-int [D:\a\node_modules
\strong-agent\build\strong-agent.vcxproj]
d:\a\node_modules\strong-agent\src\compat.h(139): error C2143: syntax error : m
issing ',' before '&' [D:\a\node_modules\strong-agent\build\strong-agent.vcxpro
j]
d:\a\node_modules\strong-agent\src\compat.h(140): error C2146: syntax error : m
View gist:3287ced95217eb2c5199
D:\iojs>git config --system -l
core.symlinks=false
core.autocrlf=input
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=/bin/curl-ca-bundle.crt
View gist:465171
@echo off
Setlocal
set P=%~dp0
set S=%~f1
set PATH=%P%bin\;%PATH%
IF NOT "%S%"=="" GOTO :Script
"%P%node\bin\node.exe"
View 0001-Fix-http-and-net-tests-failing-due-to-race-condition.patch
From f9f06c17236b783f2b8c9d6531180f68c9acf8cd Mon Sep 17 00:00:00 2001
From: Bert Belder <bertbelder@gmail.com>
Date: Thu, 12 Aug 2010 01:38:42 +0200
Subject: [PATCH] Fix http and net tests failing due to race condition
Plus some minor cosmetic corrections
---
test/simple/test-http-1.0.js | 28 +++---
test/simple/test-http-chunked.js | 18 ++--
test/simple/test-http-client-race-2.js | 94 ++++++++++----------
View 0001-Implement-process.title-for-cygwin.patch
From 33f60624e24d66d7bc601c0e51ae361beb88a4e6 Mon Sep 17 00:00:00 2001
From: Bert Belder <bertbelder@gmail.com>
Date: Fri, 13 Aug 2010 03:45:51 +0200
Subject: [PATCH] Implement process.title for cygwin
---
src/platform_cygwin.cc | 136 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 133 insertions(+), 3 deletions(-)
diff --git a/src/platform_cygwin.cc b/src/platform_cygwin.cc