# 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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker ps -q | xargs -P 8 -n 1 time docker stop -t 60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AsyncCommand1 : IAsyncCommand | |
{ | |
public Task ExecuteAsync() | |
{ | |
int x = 2 + 2; | |
return Task.FromResult(true); | |
} | |
} | |
public class AsyncCommand2 : IAsyncCommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IAsyncCommand | |
{ | |
Task ExecuteAsync(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IQueries | |
{ | |
Foo GetFoo(int fooId); | |
IEnumerable<Foo> QueryFooByBar(int barId); | |
} | |
public interface ICommands | |
{ | |
void AddFooToBar(int barId, Foo foo); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IsEmailAlreadyInUse | |
{ | |
Task<bool> Execute(string emailAddress); | |
} | |
public interface CreateUser | |
{ | |
Task Execute(string username, string email); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IsEmailAlreadyInUse | |
{ | |
Task<bool> Execute(string emailAddress); | |
} | |
internal class SqlRepository : IsEmailAlreadyInUse | |
{ | |
Task<bool> IsEmailAlreadyInUse.Execute(string emailAddress) | |
{ | |
// Implementation goes here |
NewerOlder