Skip to content

Instantly share code, notes, and snippets.

@csainty
csainty / stop.sh
Created May 23, 2016 12:50
Stop all docker containers
docker ps -q | xargs -P 8 -n 1 time docker stop -t 60
@csainty
csainty / cleanup.sh
Last active May 16, 2016 07:01
Cleanup unused docker images
docker rmi $(grep -xvf <(docker ps -a --format '{{.Image}}' | sed 's/:latest//g') <(docker images | tail -n +2 | grep -v '<none>' | awk '{ print $1":"$2 }' | sed 's/:latest//g'))
@csainty
csainty / hello.md
Created May 11, 2016 15:05
Connect docker containers
# Create a network
$ docker network create foo
24ec61d239758d698d07cbb13f1adb0616d2011495fbff911930f743bd9bfc23

# Create two containers (separate terminals)
$ docker run --rm -it --name c1 --net foo centos:7 bash
$ docker run --rm -it --name c2 --net foo centos:7 bash

# Ping
@csainty
csainty / gist:6536769
Last active December 22, 2015 21:59 — forked from jchannon/gist:6536653
using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnString"].ConnectionString))
{
var parameters = model.Keywords.Select((keyword, index) => new { Name = "@P" + index, Value = keyword });
var sql = String.Format("SELECT * FROM Table WHERE Id IN ({0})", String.Join(",", parameters.Select(x => x.Name)));
connection.Open();
using (var command = new SqlCommand(sql))
{
foreach (var p in parameters)
{
public class AsyncCommand1 : IAsyncCommand
{
public Task ExecuteAsync()
{
int x = 2 + 2;
return Task.FromResult(true);
}
}
public class AsyncCommand2 : IAsyncCommand
[AsyncStateMachine(typeof (Class1.<ExecuteAsync>d__0))]
[DebuggerStepThrough]
public Task ExecuteAsync()
{
Class1.<ExecuteAsync>d__0 stateMachine;
stateMachine.<>4__this = this;
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start<Class1.<ExecuteAsync>d__0>(ref stateMachine);
return stateMachine.<>t__builder.Task;
public interface IAsyncCommand
{
Task ExecuteAsync();
}
public interface IQueries
{
Foo GetFoo(int fooId);
IEnumerable<Foo> QueryFooByBar(int barId);
}
public interface ICommands
{
void AddFooToBar(int barId, Foo foo);
}
public interface IsEmailAlreadyInUse
{
Task<bool> Execute(string emailAddress);
}
public interface CreateUser
{
Task Execute(string username, string email);
}
public interface IsEmailAlreadyInUse
{
Task<bool> Execute(string emailAddress);
}
internal class SqlRepository : IsEmailAlreadyInUse
{
Task<bool> IsEmailAlreadyInUse.Execute(string emailAddress)
{
// Implementation goes here