Skip to content

Instantly share code, notes, and snippets.

@ewilde
ewilde / payment_logic
Last active March 20, 2019 07:39
Submitting a payment
let payment_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
let submission_id =xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
result = post payment with payment_id
if result = 409
log warn payment exists
result = post payment_submission with payment_id, submission_id
@ewilde
ewilde / makecrt.sh
Last active April 12, 2017 06:26
create x509 self-signed certificates
#!/bin/bash
set -ex
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cn=$1
out_dir=$2
key_file=$cn.key.pem
@ewilde
ewilde / linkerd.yaml
Created February 27, 2017 03:52
Lookup consul using path
# Do service discovery lookups against the Consul service catalog.
namers:
- kind: io.l5d.consul
includeTag: false
useHealthCheck: false
routers:
- protocol: http
label: /http-consul
identifier:
kind: io.l5d.path
@ewilde
ewilde / linkerd.yaml
Created February 22, 2017 19:30
linkerd configuration
# Do service discovery lookups against the Consul service catalog.
namers:
- kind: io.l5d.consul
includeTag: false
useHealthCheck: false
- kind: io.l5d.fs
rootDir: /opt/linkerd-0.8.6/disco/
routers:
@ewilde
ewilde / vault-install.sh
Last active September 27, 2020 17:56
Install hashicorp vault on ubuntu using systemd
#!/usr/bin/env bash
set -e
echo "Installing dependencies..."
sudo apt-get update -y
sudo apt-get install -y unzip
echo "Fetching vault..."
VAULT=0.6.5
@ewilde
ewilde / vault.service
Last active December 10, 2021 16:56 — forked from yunano/vault.service
for development only /etc/systemd/system/vault.service
[Unit]
Description=vault server
Requires=network-online.target
After=network-online.target consul.service
[Service]
EnvironmentFile=-/etc/default/vault
Restart=on-failure
ExecStart=/usr/local/bin/vault server $OPTIONS -config=/etc/vault.d/vault.conf
ExecStartPost=/bin/bash -c "echo 'Waiting for vault to start' && sleep 5s && for key in $KEYS; do echo unsealing with key $key && /usr/local/bin/vault unseal $key; done"
public class TaskSchedulerPool
{
private readonly List<Lazy<TaskScheduler>> _taskSchedulers;
public TaskSchedulerPool(int maxSize)
{
_taskSchedulers = Enumerable.Range(1, maxSize)
.Select(
_ => new Lazy<TaskScheduler>(() => new ConcurrentExclusiveSchedulerPair().ExclusiveScheduler))
.ToList();
@ewilde
ewilde / IOperationResult.cs
Created January 31, 2013 15:57
Create a operation timing class
/// <summary>
/// The result of a timing operation
/// </summary>
public interface IOperationResult : IDisposable, ISplitTimer
{
/// <summary>
/// Gets or sets the elapsed time this operation took to complete.
/// </summary>
TimeSpan Elapsed { get; set; }
@ewilde
ewilde / Example.cs
Created January 28, 2013 14:00
#structuremap instance factory pattern
public class Example
{
public IInstanceFactory InstanceFactory { get; set; }
public void GetInstanceWithArgument()
{
var foo = this.InstanceFactory<Employee, string>("ArgumentValue1")
}
}
@ewilde
ewilde / Example.cs
Last active December 11, 2015 17:28
#mspec base class which creates a subject with DI instead of mocks, useful for integration test
public class When_calling_foo_service : WithIntegrationSubject<ServiceClientWrapper<IFooService>>
{
Establish context = () => With<RunningService>();
Because of = () => FooActionResponse = Subject.Channel.Action(new FooActionRequest());
It should_return_a_response = () => FooActionResponse.ShouldNotBeNull();
static FooActionResponse FooActionResponse;
}