Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
kevinswiber / wip.js
Last active December 16, 2015 08:29
A limited work-in-progress system with Pipeworks.
var pipeworks = require('pipeworks');
var wip = 0;
var limit = 2;
var total = 0;
var check = function(context, next) {
if (wip === limit) {
console.log('I\'ll eat', context.food, 'later...');
setTimeout(check.bind(this, context, next), 2000);
@othiym23
othiym23 / express-domains.js
Created June 18, 2013 18:54
Simple way to put an error on a domain if one is available, and use the default Express error handler otherwise.
var domain = require("domain");
var defaultHandler = require("express").errorHandler();
module.exports = function errorHandler(err, req, res, next) {
if (domain.active) {
domain.active.emit("error", err);
}
else {
return defaultHandler(err, req, res, next);
}
public class SlightlyBetterButStillNotGreatDispatcher
{
private readonly IEventStoreConnection _connection;
private readonly IPersistGetEventStorePosition _positionCheckpoint;
private readonly IPublisher _next;
private readonly Action<EventStoreCatchUpSubscription> _onLiveProcessingStarted;
private EventStoreAllCatchUpSubscription _subscription;
public SlightlyBetterButStillNotGreatDispatcher(IEventStoreConnection connection, IPersistGetEventStorePosition positionCheckpoint,
@staltz
staltz / introrx.md
Last active July 13, 2025 10:33
The introduction to Reactive Programming you've been missing
@jen20
jen20 / MessageIdentity.cs
Created August 19, 2014 17:39
Generator for deterministic GUIDs
public class MessageIdentity
{
public Guid NameSpace;
private readonly byte[] _namespaceBytes;
public MessageIdentity(Guid guidNameSpace)
{
NameSpace = guidNameSpace;
_namespaceBytes = guidNameSpace.ToByteArray();
SwapByteOrder(_namespaceBytes);
@morganrallen
morganrallen / _README.md
Last active January 15, 2023 19:41
Janky Browser

JankyBrowser

The only cross-platform browser that fits in a Gist!

One line install. Works on Linux, MacOSX and Windows.

Local Install

$&gt; npm install http://gist.github.com/morganrallen/f07f59802884bcdcad4a/download
@jkrems
jkrems / generators.md
Last active February 24, 2020 19:09
Generators Are Like Arrays

In all the discussions about ES6 one thing is bugging me. I'm picking one random comment here from this io.js issue but it's something that comes up over and over again:

There's sentiment from one group that Node should have full support for Promises. While at the same time another group wants generator syntax support (e.g. var f = yield fs.stat(...)).

People keep putting generators, callbacks, co, thunks, control flow libraries, and promises into one bucket. If you read that list and you think "well, they are all kind of doing the same thing", then this is to you.

@jen20
jen20 / wtf.go
Last active October 14, 2019 12:28
var order = [...]int{3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15}
func wtfToUUID(netEncoded []byte) uuid.UUID {
uuidBytes := make([]byte, 16)
for i := 0; i < len(order); i++ {
uuidBytes[i] = netEncoded[order[i]]
}
return uuidBytes
}
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using EventStore.ClientAPI.Embedded;