Skip to content

Instantly share code, notes, and snippets.

View dnephin's full-sized avatar

Daniel Nephin dnephin

View GitHub Profile
@dnephin
dnephin / ApiBodyParser.scala
Last active January 1, 2016 22:39
Play custom JSON BodyParser
object ApiBodyParser extends BodyParsers {
def apply[T](key: String)(implicit rds: Reads[T]): BodyParser[T] = parse.json.flatMap {
jsValue => (jsValue \ key).validate[T] match {
case JsSuccess(item, path) => {
BodyParser("api parser") {
request => Done(Right(item), Input.Empty)
}
}
// TODO: json error message with validation error
"""
A supervisorctl plugin which returns the status of a process and exits with a
proper exit code.
This is a workaround for `https://github.com/Supervisor/supervisor/issues/24`_
Configuration
-------------
Add this section to your supervisord.conf. You may need to adjust the path.
@dnephin
dnephin / migration-to-pytest.rst
Last active August 29, 2015 14:02
staticconf - Migration from testify to py.test

staticconf - Migration from testify to py.test

Step 1. Create compatibility assertions

I wasn't interested in replacing every assert statement, so instead I created a compatibility module. For every testify assertion I used, I wrote a function with the same name and a very simple implementation using the assert statement.

This module is at testing/testifycompat.py

@dnephin
dnephin / docker inspect
Last active August 29, 2015 14:14
Docker override volumes in 1.4.1
Using
docker inspect -f '
{{ .Config.Volumes }}
{{ .Volumes }}
{{ .HostConfig.Binds }}' <container_name>
The container from the example looks correct (the volume is actually the path set by the bind)
@dnephin
dnephin / Dockerfile
Created January 27, 2015 03:53
Docker volumes set using bind at start time
FROM busybox:latest
RUN mkdir /data
RUN touch /data/file
@dnephin
dnephin / docker_tc.sh
Created August 5, 2015 19:01
docker_tc - using tc with a docker container
#!/bin/bash
#
#
#
@dnephin
dnephin / .pre-commit-config.yaml
Last active October 18, 2016 21:24
docker engine pre-commit hooks
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 'v0.4.2'
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
files: '\.(go|md|sh|yml|yaml|Dockerfile|json|ini)$'
exclude: '^vendor/'
- id: trailing-whitespace
files: '\.(go|sh|yml|yaml|Dockerfile|json|ini)$'
exclude: '^vendor/'
release-1.0.0.json
{
"download_count": 1839,
"name": "fig-Darwin-x86_64"
}
{
"download_count": 7739,
"name": "fig-Linux-x86_64"
}
release-1.1.0.json
web:
image: alpine:edge
environment:
- NAME: thename
command: echo $NAME
@dnephin
dnephin / __init__.py
Created November 18, 2015 22:42
py.test autouse session fixture in conftest.py
#