Skip to content

Instantly share code, notes, and snippets.

View 1stvamp's full-sized avatar
:shipit:

Wes Mason 1stvamp

:shipit:
View GitHub Profile
@1stvamp
1stvamp / heroku.sh
Created May 17, 2017 17:02
Script to test subprocess running heroku, outputs blank JSON object for config command
#!/bin/sh
if [ "$1" = "config" ]; then
echo '{}'
fi
exit 0
git diff --name-status master..$(git symbolic-ref --short HEAD)|awk '{print $2}'
@1stvamp
1stvamp / graph_walk.js
Created March 27, 2014 16:10
JavaScript Graph object traversal example
var Node = function(vertices) {
var myVertices = vertices || [];
this.addVertex = function(vertex) {
myVertices.push(vertex);
};
this.getVertices = function() {
return myVertices;
};
diff --git a/Dockerfile.j2 b/Dockerfile.j2
index 09f09f9..7ebbaad 100644
--- a/Dockerfile.j2
+++ b/Dockerfile.j2
@@ -9,4 +9,6 @@ COPY . /srv/helloworld/code
RUN echo "{{ BUILD_REVISION }}" > version-info.txt
RUN rm -rf env
RUN pip install -U .
-CMD bin/confd -confdir etc/confd/ -log-level info -backend etcd -node http://etcd-client:2379
+ENV HELLOWORLD_DB_HOST localhost
# standard wsgi middleware
def some_wsgi_middleware(app):
def middleware(environ, start_response)
def custom_start_response(status, headers, exc_info):
# they get overwritten here from func args
custom_start_response._status = status
custom_start_response._headers = headers
custom_start_response._status = custom_start_response._headers = None
# standard wsgi middleware
def some_wsgi_middleware(app):
def middleware(environ, start_response)
def custom_start_response(status, headers, exc_info):
# they get overwritten here from func args
custom_start_response._status = status
custom_start_response._headers = headers
response = app(environ, custom_start_response)
@1stvamp
1stvamp / tictactoe.py
Created March 2, 2016 19:12
Cooperatively made tic tac toe game - OLS MVD '16 sprint
board = {
'A': [' ', ' ', ' '],
'B': [' ', ' ', ' '],
'C': [' ', ' ', ' '],
}
def print_board():
for i in "ABC":
print(" | {} | {} | {} |".format(*board[i]))
@1stvamp
1stvamp / zip.py
Created February 23, 2016 11:31
Allow zip in templates in Ansible 1.x
# filter_plugins/zip.py
class FilterModule(object):
def filters(self):
return {'zip': zip}
@1stvamp
1stvamp / mkv_to_mp4.py
Created January 2, 2014 10:05
Script to convert mkv's in sub-dirs to mp4 containers using ffmpeg
import glob, sys, os, subprocess
path = os.path.abspath(os.path.dirname(__file__))
files = glob.glob('*/*.mkv')
ffmpeg = '/home/wes/ffmpeg-dmo-2.1.1/ffmpeg'
for f in files:
f = os.path.join(path, f).replace(' ', '\\ ').replace('(', '\(').replace(')', '\)').replace('&', '\&').replace(';', '\;')
@1stvamp
1stvamp / markgen.py
Last active January 1, 2016 22:49
Python module to allow the simple programmatic generation of Markdown mark-upped text.
def header(content, depth=1, underline=False):
if underline:
char = ('=', '-', '*')[(depth if depth < 4 else 3)]
return "{0}\n{1}".format(content, (char * len(content)))
return "{0} {1}".format(('#' * depth), content)
def quote(content, prefix='> '):
return "\n".join("> {0}".format(c) for c in content.split("\n"))