Skip to content

Instantly share code, notes, and snippets.

View boris317's full-sized avatar

Shawn Adams boris317

View GitHub Profile
import os
class WSGIApp(object):
def __init__(self):
setup_logger(os.environ.get('PYCSW_CONFIG'))
def __call__(self, env, start_repsonse):
""" Do reqeust stuff here """
application = WSGIApp()
def api_url_for(endpoint, **values):
# probably handle missing api_app key in some
# special exception.
api_app = current_app().config["api_app"]
with api_app.app_context():
return url_for(end_point, **values)
#!/bin/bash
DIR=$( cd "$( dirname "$0" )" && pwd )
source $DIR/../env.sh
if [ ! X_OPENSHIFT_RUNNING_LOCAL ]; then
source $X_OPENSHIFT_VENV/bin/activate
fi
@boris317
boris317 / build.sh
Created October 1, 2012 15:42
OpenShift action hooks for python tornado deployment.
#!/bin/bash
#
# .openshift/action_hooks/build
#
DIR=$( cd "$( dirname "$0" )" && pwd )
source $DIR/../env.sh
if [ ! -d $X_OPENSHIFT_VENV ]; then
echo "[build] $(virtualenv --distribute $X_OPENSHIFT_VENV)"
@boris317
boris317 / base_converter.py
Last active December 25, 2015 18:09
Encode base 10 integer into other bases
class BaseConverter(object):
"""
Class for encoding/decoding base 10 values to/from another base
"""
def __init__(self, base, base_digits):
"""
:param base: (int) the base (e.g 2, 16, 64)
:param base_digits: (iterator) of base digits (e.g "01" for base 2, etc)
"""
self.base = base
#!/usr/bin/env python
import sys
print "\\n".join([l.strip() for l in sys.stdin.readlines()])
@boris317
boris317 / test.js
Created July 29, 2016 01:32
RXJS Chaining HTTP Calls
var http = require('http');
var RX = require('rx');
var request = require('request');
function get(url) {
return RX.Observable.create(function(observer) {
request(url, function(err, response, body) {
if (err) {
observer.onError(err);
return;
Shawn's Intellij Shortcuts
Symbols:
⌥ Option
⌘ Command
⇧ Shift
⌃ Control
← Left arrow
→ Right Arrow
↑ Up Arrow
let plugins = getPlugins()
.flatMap(p => p)
// Group plugins by consumer_id or app_id
.reduce((obj, p) => {
let id = p.consumer_id || p.api_id;
if (id in obj) {
obj[id].push(p);
} else {
obj[id] = [p];
}
@boris317
boris317 / statsd-tcpdump.sh
Last active November 14, 2017 16:43
Verify data is being fed to collectd and statsd
# statsd
sudo tcpdump -i eth0 -p -n -s 1500 -A udp port 8125
# statsd flushing to graphite
sudo tcpdump 'port 2005 or 2009' -s0 -A
# collectd
sudo tcpdump -i eth0 -p -n -s 1500 -A udp port 25827