Skip to content

Instantly share code, notes, and snippets.

View aeppert's full-sized avatar

Aaron Eppert aeppert

View GitHub Profile
@aeppert
aeppert / multiplicity_act.py
Created August 27, 2015 13:03
Python shell for having a singular script, via symlink, have multiple personalities easily.
#!/usr/bin/python
import sys
import os
from optparse import OptionParser
class cli_handlers(object):
def __init__(self, argv):
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
@aeppert
aeppert / gist:b57cb541d0a290837bf2
Last active August 29, 2015 14:24
Template for string conversion with padding and prefix facility
#include <iostream>
#include <sstream>
#include <string>
#include <limits>
using namespace std;
template <class T> std::string to_string(T t, ios_base & (*f)(ios_base&), std::string prefix = "", bool pad = true)
{
std::ostringstream oss;
@aeppert
aeppert / gist:00b1c97009a21c8eabe7
Created July 6, 2015 14:49
Build central to the root directory of the current Git repository
ROOTDIR=$(shell git rev-parse --show-toplevel)
@aeppert
aeppert / gist:1fda3505ea2376547e49
Created July 17, 2015 14:30
Access Class Name Internally.
#!/usr/bin/python
class testing:
def __init__(self):
pass
def get_name(self):
return self.__class__.__name__
t = testing()
print 't\'s class name is - \"%s\"' % (t.get_name())
@aeppert
aeppert / start_cifv2.sh
Last active August 29, 2015 14:27
Start CIFv2 in Docker with boot2docker on OS X
#!/bin/sh
#
# Aaron Eppert (aeppert@gamil.com)
#
# Wrapper script for starting the cifv2 Docker image via boot2docker
#
# NOTE: This assumes "boot2docker start" was run previously.
#
VBoxManage controlvm "boot2docker-vm" natpf1 "cifv2_forward_5000,tcp,,5000,,5000"
VBoxManage controlvm "boot2docker-vm" natpf1 "cifv2_forward_443,tcp,,8443,,443"
@aeppert
aeppert / calc.sh
Created August 11, 2015 19:39
Math on the command line
calc(){ awk "BEGIN{ print $* }" ;}
@aeppert
aeppert / cif.conf
Created August 19, 2015 15:53
NGINX Configuration for massive-octo-spice
server {
listen 80 default_server;
listen 443 ssl;
server_name 127.0.0.1; #_;
gzip on;
gzip_comp_level 2;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
@aeppert
aeppert / split_tokens.cc
Created September 8, 2015 19:13
split_tokens in C++
#include <string>
#include <sstream>
#include <vector>
std::vector<std::string> split_tokens(const std::string &s, char delim) {
std::stringstream ss(s);
std::string item;
std::vector<std::string> tokens;
while (getline(ss, item, delim)) {
if(item.length() > 0) {