Skip to content

Instantly share code, notes, and snippets.

@SteveBate
SteveBate / Docker-Mongo.md
Created May 27, 2021 12:18
Docker and MongoDb

create a docker data container to share data with mongodb containers

  • docker create -v /data/db --name dbstore mongo bin/true

create a standard container that uses the previously created data container (--volumes-from)

  • docker run -d -p 30001:27017 --name mgodb --volumes-from dbstore mongo mongod

or if we want to run as a replica set first create a network so that all instances can talk to each other:

  • docker create network my-mongo-cluster

then create containers executing mongod with replSet parameter each with their own data container

@SteveBate
SteveBate / Docker commands.md
Last active November 26, 2023 19:55
Docker

build a docker image from a Dockerfile using the files in the current (.) directory

  • docker image build -t stevebate/devrepo:tc-v1 .

list the docker images on disk

  • docker images

list of containers (instances)

  • docker ps
  • docker container ls -a (-a flag to see exited containers)
@SteveBate
SteveBate / PipeLine.ts
Created June 10, 2018 11:49
Typescript implementation of the latest C# version of the Pipe and Filters approach
/**
* Type of the message all pipeline messages must inherit from.
*
*/
export abstract class BaseMessage {
cancellationToken: CancellationToken = new CancellationToken();
onError = () => {};
onStart = () => {};
onComplete = () => {};
@SteveBate
SteveBate / Pipeline.cs
Last active December 11, 2017 07:34
Latest implementation of the in-process pipe and filter model
void Main()
{
var msg = new BritvicImportMessage
{
File = @"c:\test.txt",
OnStart = () => Console.WriteLine("Starting"),
OnSuccess = () => Console.WriteLine("Success!"),
OnComplete = () => Console.WriteLine("Done!"),
OnError = (ex) => Console.WriteLine("Logging Exception: " + ex),
OnStep = Console.WriteLine
@SteveBate
SteveBate / Sale - Event Sourcing.cs
Created June 21, 2017 16:19
Example of a Sale inside a POS system using event sourcing (Linqpad)
void Main()
{
var p1 = new StockItem { PartNo = "P100", Description = "Coca Cola", Qty = 1, Cost = 1.00m };
var p2 = new StockItem { PartNo = "P101", Description = "Pepsi Max", Qty = 2, Cost = 1.00m };
var p3 = new StockItem { PartNo = "P102", Description = "Pint San Miguel", Qty = 1, Cost = 3.50m };
var cfg = new SaleConfig { AddOnTax = false, TaxRate = 20.0m };
var sut = new Sale(Guid.NewGuid(), cfg);
sut.AddItem(p1);
sut.AddItem(p2);
@SteveBate
SteveBate / bubblechart.js
Last active April 26, 2016 15:26
Example D3 bubble chart based on the one in 'Facts Are Sacred' book on page 52
var dataset = {
"dispatched": {
"CCE018 - Acme Glass Division": "42",
"CCE033 - Cold Shopper Marketing": "730",
"CCE034 - Home Shopper Marketing": "31",
"CCE035 - T C C C Portfolio": "10",
"CCE036 - Portfolio X Franchise": "21",
"CCE037 - Cold Operations Trading": "500",
"CCE038 - Home Operations Trading": "9",
@SteveBate
SteveBate / webpack.config.js
Created April 14, 2016 14:43
A simple starter configuration file for webpack
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
module.exports = {
context: __dirname,
devtool: debug ? "eval-source-map" : null,
entry: "./js/scripts.js",
output: {
path: __dirname + "/js",
filename: debug ? "bundle.js" : "bundle.min.js"
@SteveBate
SteveBate / loggable_response.go
Created November 15, 2015 09:44
Package response implements a ResponseWriter that captures additional info useful in logging scenarios
// Package response implements a ResponseWriter that captures additional info useful in logging scenarios
// such as response status code, request duration and a unique request id
package response
import (
"fmt"
"net/http"
"time"
// this is actually another gist (not go gettable)
@SteveBate
SteveBate / uuid.go
Created November 14, 2015 17:50
A package to create a unique identifier (UUID)
// Creates a unique identifier
package uuid
import (
"crypto/md5"
"crypto/rand"
"encoding/binary"
"fmt"
"io"
"os"
@SteveBate
SteveBate / fnv_hash.go
Last active October 6, 2015 09:49
FNV-1 hashing function - an implementation in Go that matches the output of using the builtin fnv package
package main
import (
"fmt"
"hash/fnv"
)
func main() {
// the data to be hashed