Skip to content

Instantly share code, notes, and snippets.

@a-h
a-h / NinjectWebCommon.cs
Last active August 29, 2015 14:20
Ninject to Simple Injector
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Service.App_Start.NinjectWebCommon), "Start")]
[assembly: WebActivatorEx.ApplicationShutdownMethodAttribute(typeof(Service.App_Start.NinjectWebCommon), "Stop")]
// Once it's building, rename the class away from Ninject.
public static class NinjectWebCommon
{
// -- Ninject
// private static readonly Bootstrapper bootstrapper = new Bootstrapper();
public static void Start()
@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 / 11-weblogic.rb
Created June 11, 2015 14:38
WebLogic Logstash Filter
filter {
## WebLogic Server Http Access Log
if [type] == "weblogic-access" {
grok {
match => [ "message", "%{IP:client} - - \[(?<timestamp>%{MONTHDAY}[./-]%{MONTH}[./-]%{YEAR}:%{TIME}\s+%{ISO8601_TIMEZONE})] \"%{WORD:verb} %{URIPATHPARAM:uri}\s+HTTP.+?\" %{NUMBER:status} %{NUMBER:response_time}" ]
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}
@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 / 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 / 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)