Skip to content

Instantly share code, notes, and snippets.

@rcknight
rcknight / eventstore-mtgox.cs
Last active December 14, 2015 08:29
Placing events from the mtgox api into event store
using System;
using System.Net;
using System.Text;
using EventStore.ClientAPI;
using Newtonsoft.Json;
using SimpleJson;
using SuperSocket.ClientEngine;
using WebSocket4Net;
namespace websockets_test
@rcknight
rcknight / main.cs
Last active April 25, 2019 13:41
Example Event Store SignalR publisher. For real-time push of events to a web page.
using System;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin.Hosting;
using Owin;
namespace EventStoreSignalR
@rcknight
rcknight / nginx.txt
Last active December 16, 2015 15:49
Eventstore nginx config notes
//install nginx
sudo apt-get update
sudo apt-get install nginx
---------
//make a folder for our cache to live in
sudo mkdir /var/www
@rcknight
rcknight / EventDispatcher.cs
Created July 18, 2013 11:57
A very basic event dispatcher
public class EventDispatcher
{
private EventHandlerRegistry _registry;
public EventDispatcher(EventHandlerRegistry reg)
{
_registry = reg;
}
public void Dispatch(object e)
@rcknight
rcknight / Add Deviation
Created September 6, 2013 14:01
samplecommands for hoverhand
"http://batchesv3-test/deviations"
{
"Description": "A woftam occurred!",
"DeviationType": "Batch",
"DeviationReference": "14D0005",
"UserName": "Richard Knight"
}
@rcknight
rcknight / users.cs
Created October 17, 2013 09:09
Query all active ad users who are real people (has a job title)
using (var context = new PrincipalContext(ContextType.Domain, "PHARMAXO.local", "OU=Corsham,dc=pharmaxo,dc=local"))
{
var qbeUser = new UserPrincipal(context) { Enabled = true };
using (var searcher = new PrincipalSearcher(qbeUser))
{
var results = searcher.FindAll().Select(r => r.GetUnderlyingObject() as DirectoryEntry);
var names = results.Where(r => r.Properties["title"].Value != null && ((string)r.Properties["title"].Value) != "")
.Select(r => String.Format("{0} {1}", r.Properties["givenName"].Value, r.Properties["sn"].Value))
.OrderBy(r => r);
foreach(var name in names)
@rcknight
rcknight / log.txt
Created October 21, 2014 13:03
openide death
rich@Richs-MacBook-Pro [01:59:50] [~/fs-test]
-> % oi --logging init
9,9 - Assigned logger
49,39 - Parsing profiles
49,0 - Initializing application
61,12 - Initializing interpreters
65,3 - Adding interpreter: mono for .exe
65,0 - Getting definition builder
66,1 - Building definitions
92,27 - Adding item init
@rcknight
rcknight / subscriptions.md
Created June 14, 2017 06:40
Subscriptions notes

Connecting

  • Uri format
    • Single node tcp://user:password@myserver:11234
    • DNS discover://user:password@myserver:1234
    • Simplest possible eventstoreConnection.Create(Uri uri)
  • ConnectionSettings vs Connection Strings
    • Settings = fluent API (show example)
    • Connection string = Newer, familiar format, can store in config, probably better?
  • "ConnectTo=tcp://admin:changeit@localhost:1113; HeartBeatTimeout=500"
@rcknight
rcknight / index.js
Last active November 21, 2017 20:21
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var gs1js = require("gs1js")
var code = '0105000471007015' // 01 GTIN
+ '2110001136169476' + String.fromCharCode(29) // 21 Serial
//Variable length fields (like this serial number)
@rcknight
rcknight / Program.cs
Last active January 10, 2023 21:41
Event Store Checkpoint Weirdness
using System.Text;
using EventStore.Client;
var settings = EventStoreClientSettings.Create("esdb+discover://localhost:2113?tls=false");
var esClient = new EventStoreClient(settings);
// Give us something to catch up
await WriteEvents(1000);
ulong lastEventPosition = 0;
await CreateSubscription();