Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Noordhuis bnoordhuis

View GitHub Profile
@bnoordhuis
bnoordhuis / dummy.cc
Created Aug 5, 2010
Reproduce SIGSEGV in Buffer::New(size_t)
View dummy.cc
#include <v8.h>
#include <node.h>
#include <alloca.h>
#include <node_buffer.h>
using namespace v8;
using namespace node;
static Handle<Value> dummy(const Arguments& args) {
HandleScope scope;
View [nodejs doc] fs.utimes() and fs.futimes()
### fs.utimes(path, atime, mtime, [callback])
Asynchronous utimes(2). Updates the last access and last modified timestamps of
the file pointed to by `path`.
`atime` and `mtime` may be a (fractional) UNIX timestamp or a Date object.
No arguments other than a possible exception are given to the completion callback.
### fs.futimes(fd, atime, mtime, [callback])
@bnoordhuis
bnoordhuis / gist:658726
Created Nov 1, 2010
0001-Fix-undefined-symbol-errors-when-loading-native-modu.patch
View gist:658726
From 360b7b57b2e0261f6ba84f023fdc31f4f6e514f2 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Mon, 1 Nov 2010 20:34:11 +0100
Subject: [PATCH] Fix 'undefined symbol' errors when loading native modules.
---
Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
@bnoordhuis
bnoordhuis / gist:664983
Created Nov 5, 2010
0001-Ensure-that-non-ASCII-characters-in-the-status-line-.patch
View gist:664983
From 1ee950ffaccdf61c102b11990a07a22038a1ec7a Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Fri, 5 Nov 2010 23:27:55 +0100
Subject: [PATCH] Ensure that non-ASCII characters in the status line are allowed.
---
test.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/test.c b/test.c
@bnoordhuis
bnoordhuis / gist:667592
Created Nov 8, 2010
0001-Backport-base64-encoder-decoder-changes-from-master-.patch
View gist:667592
From 047a5e55a0ec54ff517fb2f0f6eac426e26f4127 Mon Sep 17 00:00:00 2001
From: Ben Noordhuis <info@bnoordhuis.nl>
Date: Mon, 8 Nov 2010 11:57:47 +0100
Subject: [PATCH] Backport base64 encoder/decoder changes from master to v0.2.
---
src/node_buffer.cc | 78 ++++++++++++++++++++++++++++++++++++---------------
1 files changed, 55 insertions(+), 23 deletions(-)
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
@bnoordhuis
bnoordhuis / gist:673377
Created Nov 11, 2010
readsync-busy-loop.js
View gist:673377
//
// test case: fs.readSync() eventually starts busy-looping in C++ land
//
// create a writer with `while true; do date >> /tmp/time.log; sleep 1; done`
// then run `node tail.js /tmp/time.log`
//
Buffer = require('buffer').Buffer;
fs = require('fs');
b = new Buffer(256);
@bnoordhuis
bnoordhuis / gist:702695
Created Nov 16, 2010
node.js + sendfile = file serving++
View gist:702695
http = require('http');
fs = require('fs');
fd = fs.openSync(__filename, 'r');
size = fs.fstatSync(fd).size;
server = http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Length': size,
'Content-Type': 'text/plain'
@bnoordhuis
bnoordhuis / gist:702701
Created Nov 16, 2010
Server.listen() doesn't listen (to me)
View gist:702701
s = require('http').createServer(function(req, res) {
res.writeHead(200, {'Content-Length':0});
res.end();
});
s.listen(8080);
View gist:709310
http = require('http');
client = http.createClient(80, 'www.google.com');
req = client.request('POST', '/', {'Content-Type':'application/x-www-form-urlencoded'});
req.on('response', console.log);
req.end();
View curl-imap-ssl.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <sys/select.h>
#include <curl/curl.h>
#define IMAP_URL "imap://testuser:testuser@localhost/Drafts"