Skip to content

Instantly share code, notes, and snippets.

Chris Sainty csainty

Block or report user

Report or block csainty

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@csainty
csainty / stop.sh
Created May 23, 2016
Stop all docker containers
View stop.sh
docker ps -q | xargs -P 8 -n 1 time docker stop -t 60
@csainty
csainty / hello.md
Created May 11, 2016
Connect docker containers
View hello.md
# 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 / cleanup.sh
Last active May 16, 2016
Cleanup unused docker images
View cleanup.sh
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 / gist:e15f5cb2fbf74c1e0901
Last active Sep 7, 2015 — forked from schacon/gist:942899
delete all remote branches that have already been merged into development
View gist:e15f5cb2fbf74c1e0901
$ git branch -r --merged origin/development |
grep origin |
grep -v '>' |
grep -v 'master$' |
grep -v 'development$' |
xargs -L1 |
cut -d"/" -f2- |
xargs git push origin --delete
@csainty
csainty / HelloServer.java
Created Jul 25, 2015
Undertow Hello World
View HelloServer.java
import io.undertow.Undertow;
import io.undertow.util.Headers;
public class HelloServer {
public static void main(final String[] args) {
Undertow server = Undertow.builder()
.addHttpListener(8081, "localhost")
.setHandler((exchange) -> {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
exchange.getResponseSender().send("Hello World");
@csainty
csainty / gruntfile.js
Created Feb 24, 2015
Super simple grunt task to update a json config file in the package
View gruntfile.js
grunt.registerTask('config', function (env) {
var config = grunt.file.readJSON('src/config.json');
var envs = {
production: {
apiUrl: 'http://foo.com'
},
staging: {
apiUrl: 'http://bar.com'
}
};
@csainty
csainty / ko-date.js
Created Nov 27, 2014
Quick patch for KnockoutJS to handle date equality checks
View ko-date.js
function wrapEqualityComparerWithDateSupport(origFn) {
return function (a, b) {
return origFn(a, b) ||
(a instanceof Date && b instanceof Date && a.getTime() === b.getTime());
}
}
ko.observable.fn.equalityComparer = wrapEqualityComparerWithDateSupport(ko.observable.fn.equalityComparer);
ko.dependentObservable.fn.equalityComparer = wrapEqualityComparerWithDateSupport(ko.dependentObservable.fn.equalityComparer);
View TracingMiddleware.cs
namespace TracingMiddleware
{
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using MidFunc = System.Func<
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>,
System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>
View gist:3d50214a33ad1a0f81b8
public class MyBootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoc.TinyIoCContainer container, Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
Nancy.Security.Csrf.Enable(pipelines);
}
}
View gist:31f2dbea5ae152b695d6
class Foo {
func bar() -> String {
return "Hello"
}
}
func greet (f: Foo) -> String {
return f.bar()
}
You can’t perform that action at this time.