Skip to content

Instantly share code, notes, and snippets.

View Markbnj's full-sized avatar

Mark Betz Markbnj

View GitHub Profile
definitions:
Registration:
type: object
required:
- state
- plate_number
properties:
state:
type: string
description: Two letter state abbreviation code
swagger: '2.0'
info:
title: My Cars API
description: Simple API for demonstrating json validation
version: 1.0.0
host: localhost
schemes:
- http
produces:
- application/json
@Markbnj
Markbnj / gce_project.sh
Created October 9, 2015 16:48
Grab Google compute engine project ID into environment variable
export GCLOUD_PROJ=$( gcloud info | awk '$1 == "Project:" {print $2}' | tr -d '[][:space:]' )
@Markbnj
Markbnj / update-policy.sh
Created September 15, 2015 06:33
Allow services to start in an Ubuntu 15.04 Docker container
# By default the /usr/sbin/policy-rc.d script in the ubuntu:15.04 docker image is set to return 101
# (action forbidden by policy) every time it is invoked. This prevents systemctl start requests for
# services from completing succesfully. The following command overwrites the contents of policy-rc.d
# to allow service starts.
#
# Note that this won't work right under bash due to expansion of the '!' character. Docker uses sh
# by default when executing the commands in the dockerfile, so this will work there, and you can
# also use sh interactively to run this.
echo "#!/bin/sh\nexit 0" > /usr/sbin/policy-rc.d
@Markbnj
Markbnj / cmdline-example.sh
Created August 24, 2015 19:18
Handling command line options in bash scripts, example
# Starts the elasticsearch node container, optionally setting
# a cluster name and host IP to expose to other nodes. Mounts
# the directory at /var/lib/elasticsearch to the same location
# on the host.
#
# exposes ports:
# 9200 = elasticsearch http
# 9300 = elasticsearch transport
#
IP=""
@Markbnj
Markbnj / removepyc.sh
Created August 23, 2015 18:37
Recursively remove all .pyc files from a python project
find . -name "*.pyc" -exec rm -rf {} \;
@Markbnj
Markbnj / install-pip.sh
Created August 23, 2015 02:48
Install updated pip
# get rid of the version installed with ubuntu
sudo apt-get remove --auto-remove python-pip
# get the official installer
wget https://bootstrap.pypa.io/get-pip.py
# install it
sudo -H python get-pip.py
@Markbnj
Markbnj / simple-redis-log-handler.py
Created August 12, 2015 16:56
Simple redis log handler for python
import logging
import redis
class RedisLogHandler(logging.Handler):
"""
Class used to emit log messages to a redis list
"""
def __init__(self, host, port, key, db=0, formatter=None, level=logging.NOTSET):
logging.Handler.__init__(self, level)
@Markbnj
Markbnj / remove-images.sh
Created August 11, 2015 21:22
Remove all Docker images
sudo docker rmi $(sudo docker images -a -q)
@Markbnj
Markbnj / remove-containers.sh
Created August 11, 2015 21:21
Stop and remove all Docker containers
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)