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 / 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 / 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 / gist:e15f5cb2fbf74c1e0901
Last active September 7, 2015 07:55 — forked from schacon/gist:942899
delete all remote branches that have already been merged into development
$ 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 July 25, 2015 15:10
Undertow Hello World
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 February 24, 2015 10:47
Super simple grunt task to update a json config file in the package
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 November 27, 2014 09:08
Quick patch for KnockoutJS to handle date equality checks
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);
@csainty
csainty / TracingMiddleware.cs
Created July 2, 2014 20:40
TracingMiddleware.cs for @jchannon
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>
public class MyBootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoc.TinyIoCContainer container, Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
Nancy.Security.Csrf.Enable(pipelines);
}
}
class Foo {
func bar() -> String {
return "Hello"
}
}
func greet (f: Foo) -> String {
return f.bar()
}