Skip to content

Instantly share code, notes, and snippets.

View piscisaureus's full-sized avatar
🦕

Bert Belder piscisaureus

🦕
View GitHub Profile
@piscisaureus
piscisaureus / nni.cpp
Last active August 29, 2015 14:03
nni
#include <functional>
#include <iostream>
class JSAny {
void* substance;
};
class JSBool : public JSAny {
public:

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
http.createServer(function(conn) {
zone.data.start = Date.now();
doThis(conn);
doThat(conn);
new Zone(function() {
zone.data.bar = 49;
output = renterTemplate()
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!')
@piscisaureus
piscisaureus / command.js
Last active February 6, 2017 03:17
Command.js
var assert = require('assert');
var spawn = require('child_process').spawn;
module.exports = function Command(command, npmModule) {
return function(argv, options, loader) {
var options = {
env: process.env,
stdio: 'inherit',
windowsVerbatimArguments: true
@piscisaureus
piscisaureus / gist:9077207
Last active August 29, 2015 13:56
domenic.txt
// 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)
var assert = require('assert');
var nextTick = process.nextTick;
var uidCounter = 0;
var root;
global.zone = global.zone || null;
function uid() {
struct ConditionVariableFallback {
inline bool initialize() {
BOOL r;
wakeupType_ = NONE;
waitersCount_ = 0;
// Initialize a critical section that protects the waiters and release counters.
InitializeCriticalSection(&stateLock_);
@piscisaureus
piscisaureus / gist:7938154
Last active December 31, 2015 04:59
w3streams.txt
class Stream {
// Resolves with an ArrayBuffer or null.
// If max_bytes is unspecified, the maximum amount is implementation-dependent.
Promise read([uint max_bytes]);
// Resolves with a number of bytes read or null.
Promise readInto(ArrayBufferView dest);
// Open for debate. I don't think it's necessary.
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtJQPjUipy8uAIOeHDtuqG+emxo1/NO701w7vMy99w5djTDlCO918UfIjC499p98UHEHQnM0Y9FzAg+cDOoBFWpjxpraZMwXiLkEdL8qJpoyWYUcgebbQ3X9Hgd/ZtSEFmbBKU0t8fgtqUf6Dsa7ktJsAKTLYIUxY8d61Iga0j6AEK8dPscl4fBBn/HV4KI7dlz9kOSgfFfxM5FBy0PeEyvNk6yqYQC21Ia7JaO5aKk8WwDPa6Q5fD3G0byRqUeibL50mIy2xFwPq7JZqpeOFCeF5pdGLDLOaa+1qHT+uVR9GyLsvbSOuv9B9NgsZY3rCtwrwt4clkW4d7ZYLB10DoQ== bert@bert-laptop