Skip to content

Instantly share code, notes, and snippets.

@a-h
a-h / application.py
Created June 2, 2015 20:10
Flask and Mongo
import json
from bson import json_util, ObjectId
from flask import Flask
from flask import request
import flask
from pymongo import MongoClient
app = Flask(__name__)
app.debug = True
@a-h
a-h / filter.regex
Created June 11, 2015 14:14
Oracle WebLogic Grok Filter
%{IP:client} - - \[(?<timestamp>%{MONTHDAY}[./-]%{MONTH}[./-]%{YEAR}:%{TIME}\s+%{ISO8601_TIMEZONE})] \"%{WORD:verb} %{URIPATHPARAM:uri}\s+HTTP.+?\" %{NUMBER:status} %{NUMBER:response_time}
@a-h
a-h / driving.gv
Created September 18, 2015 08:20
GraphViz Example - Formatted
digraph G {
/* Set graph background attributes */
style=filled;
bgcolor="#548881";
rankdir=LR; /* Comment out if you want it to be oriented top to bottom */
/* Set default shape to be a box rather than an ellipse */
node [shape=box, fontsize=11, fontname="Calibri Bold", color="#2E5F58", style=filled, fillcolor="#2E5F58", fontcolor="#ffffff"];
/* Style the arrows, because I think that the arrow head is too big by default */
edge [color="#9DC8C2", arrowsize=0.5];
/* Tasks */
@a-h
a-h / driving.gv
Created September 18, 2015 08:20
GraphViz Example - Unformatted
digraph G {
"Find Driving Instructor" -> "Book Lessons" -> "Learn To Drive" -> "Book Practical Test" -> "Pass Practical Test";
"Study for Theory Test" -> "Book Theory Test" -> "Pass Theory Test" -> "Book Practical Test";
"Pass Practical Test" -> "Buy Car" -> "Buy Insurance" -> "Pay Tax" -> "Drive Somewhere Nice";
"Decide Which Car To Buy" -> "Buy Car"
}
@a-h
a-h / authentication.txt
Created September 22, 2015 08:06
Sequence Diagrams
@startuml
' http://plantuml.com/skinparam.html
skinparam handwritten true
skinparam monochrome true
skinparam packageStyle rect
skinparam defaultFontName FG Virgil
skinparam shadowing false
title Authentication Sequence
@a-h
a-h / Vagrantfile
Created October 16, 2015 08:18
Mongo Cluster Vagrant File
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
config.vm.box = "bento/centos-7.1"
@a-h
a-h / cluster_update.bash
Created October 21, 2015 20:06
Result of Running a Mongo Cluster Update
bash ./02_update_cluster.sh
SSH password:
PLAY [common] *****************************************************************
GATHERING FACTS ***************************************************************
ok: [mongo2]
ok: [mongo4]
ok: [mongo5]
ok: [mongo3]
@a-h
a-h / remove_lowest_homework_score.py
Created January 18, 2016 18:21
Aggregation Framework Grouping and Filtering
from pymongo.errors import AutoReconnect
from pymongo import MongoClient
import pprint
from itertools import islice
def get_chunks(iterable, max_chunk_size):
temp = list()
for item in iterable:
temp.append(item)
@a-h
a-h / webserver.py
Last active February 26, 2016 16:15
Python Web Server to Dump HTTP Post Contents
import flask
app = flask.Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def hello():
print("Headers")
for header in flask.request.headers:
print(str.format("{0}:{1}", header[0], header[1]))
print(str.format("Querystring: {0}", flask.request.query_string))
@a-h
a-h / show_variables.sh
Created March 21, 2016 17:49
Configure Boto Environment Variables
echo "AWS_ACCESS_KEY " $AWS_ACCESS_KEY
echo "AWS_ACCESS_KEY_ID " $AWS_ACCESS_KEY_ID
echo "AWS_SECRET_KEY " $AWS_SECRET_KEY
echo "AWS_SECRET_ACCESS_KEY " $AWS_SECRET_ACCESS_KEY
echo "AWS_SESSION_TOKEN " $AWS_SESSION_TOKEN
echo "AWS_SECURITY_TOKEN " $AWS_SECURITY_TOKEN