Skip to content

Instantly share code, notes, and snippets.

#+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
@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 = {};
@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 / 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 / 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 / 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 / README.md
Last active June 27, 2018 14:44
A program that observes input and reacts when it finds a specific value.

This is a simple program that watches stdin and echos to stdout. When it finds input like bleep it echos preemptive bloop.

go build
cat input.txt | ./bleep

Sample output:

public class StaticViewEngine : VirtualPathProviderViewEngine
{
public StaticViewEngine()
{
MasterLocationFormats = new string[] {
};
ViewLocationFormats = new[] {
"~/build/templates/{1}/{0}.html",
"~/build/templates/{0}.html",
"~/build/{1}/{0}.html",
@johncoder
johncoder / Program.cs
Created November 5, 2012 16:11
Laugh & Learn - Pick Your Poison
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication1
{
public class Program
{
public static void Main()
{
@johncoder
johncoder / WidgetTests.cs
Created October 22, 2012 13:24
Are My Seams Showing?
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace AreMySeamsShowing
{
[TestClass]
public class WidgetTests
{
private FooA fooA;