Skip to content

Instantly share code, notes, and snippets.

@johncoder
johncoder / calling-code.js
Last active July 14, 2016 22:12
generator executor
const context = {
sayHello: (message) => console.log(`hello, world! ${message}`)
};
function *doSomething() {
yield 1;
yield 2;
this.sayHello('about to yield!');
const three = yield new Promise((resolve, reject) => {
setTimeout(() => resolve(3), 1000);
@johncoder
johncoder / docker-compose.yml
Last active June 27, 2018 14:38
EventSourcing in Node.js
version: '3'
services:
eventstore:
container_name: geteventstore
image: eventstore/eventstore
ports:
- "2113:2113"
- "1113:1113"
volumes:
@johncoder
johncoder / index.js
Created June 7, 2017 15:09
event store sample
const Buffer = require('buffer').Buffer;
const uuid = require('uuid/v4');
const eventstore = require('eventstore-node');
const eventstoreUrl = process.env.EVENTSTORE_URL || 'tcp://localhost:1113';
const connSettings = {};
const esConnection = eventstore.createConnection(connSettings, eventstoreUrl);
esConnection.connect();
esConnection.once('connected', endpoint => {
console.log(`Connected to eventstore at ${endpoint.host}:${endpoint.port}`);
@johncoder
johncoder / main.go
Created January 17, 2018 15:59
event store in go
package main
import (
"bufio"
"bytes"
"encoding/binary"
"encoding/json"
"flag"
"fmt"
"io"
@johncoder
johncoder / socket-server.js
Last active November 8, 2018 14:00
A fledgling Socket Server lib
const crypto = require('crypto');
const net = require('net');
function createConnectionId() {
return crypto.randomBytes(16).toString('hex');
};
function create() {
// TODO(john): Timeout & Delete these after idling?
const connectedClients = {};
#+TITLE: Work
#+AUTHOR: John Nelson <email>
#+TAGS: travel(t) event(e) info(i) ping(p) procure(a) research(r) work(w) idea(d) essay(y) follow_up(f) task(k) dri(c)
#+TODO: TODO(t) CURRENT(c) WAIT(w) REVIEW(r) PROGRESS(o) | DONE(d) PUNT(p)
* research
* useful stuff
* re-file
* inbox