Skip to content

Instantly share code, notes, and snippets.

View matutter's full-sized avatar

Mat Utter matutter

View GitHub Profile
@matutter
matutter / nginx-internal-auth.conf
Created August 24, 2018 01:01
Using an internal authentication service to verify requests.
http {
#...
server {
#...
location /private/ {
auth_request /auth;
auth_request_set $auth_status $upstream_status;
}
location = /auth {
@matutter
matutter / runGuard.py
Last active August 18, 2018 16:18
Using decorators in python 3
class RouterGuts(object):
def __init__(self, **kwargs):
self.name = kwargs.get('name')
self.route = kwargs.get('route')
def Handler(**kwargs):
def decorateHandlerClass(cls):
guts = RouterGuts(**kwargs)
setattr(cls,'_guts', guts)
@matutter
matutter / elk-config-links.txt
Created July 17, 2018 22:26
Useful links for ELK
@matutter
matutter / example.log
Last active June 24, 2018 16:35
Logstash config for basic logs
2018-06-24 09:34:16 main INFO { "event": "wing", "data": "wong" }
2018-06-24 09:34:16 main DEBUG { "event": "ping", "data": "pong" }
2018-06-24 09:34:16 main WARNING { "event": "ding", "data": "dong" }
2018-06-24 09:34:16 main CRITICAL { "event": "ping", "data": "pong" }
2018-06-24 09:34:21 main INFO { "event": "wing", "data": "wong" }
2018-06-24 09:34:21 main DEBUG { "event": "ping", "data": "pong" }
2018-06-24 09:34:21 main WARNING { "event": "ding", "data": "dong" }
2018-06-24 09:34:21 main CRITICAL { "event": "ping", "data": "pong" }
2018-06-24 09:34:26 main INFO { "event": "wing", "data": "wong" }
2018-06-24 09:34:26 main DEBUG { "event": "ping", "data": "pong" }
@matutter
matutter / default
Created June 24, 2018 00:53
ELK configs
# /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
@matutter
matutter / gauge-example.js
Created June 5, 2018 02:44
NodeJs gauge example
const Gauge = require('gauge');
const themes = require('./node_modules/gauge/themes');
const $ = require('chalk');
let x = themes.themes.colorBrailleSpinner;
x.preSubsection = $.bold.blue('|');
x.preProgressbar = '';
x.postProgressbar = '';
//console.log(x)
let g = new Gauge(null, { theme: x })
@matutter
matutter / run-sfood.sh
Created February 10, 2018 21:56
snakefood example
#!/bin/bash
sfood pocha/ -i -r | sfood-graph -p | circo -Tsvg > this.svg
@matutter
matutter / example_test_case.py
Created February 5, 2018 01:57
Pocha, it looks like Mocha for python
##
# Example of using pocha, this might be good?
from pocha import describe, it
@describe('A feature')
def test_case():
@it('Should behave as expected when doing A')
def _():
@matutter
matutter / acrogen.js
Created September 13, 2017 02:59
Random acronym generator
var english_words = require('an-array-of-english-words');
function lookup(word) {
return english_words
.filter(x => { return x.startsWith(word); })
.sort((a, b) => { return 0.5 - Math.random(); });
}
function suggest(word, count, cb, constants) {
@matutter
matutter / ansible.setup.md
Created July 13, 2017 00:52
Gist on setting up ansible on Ubuntu 16

Ansible Setup

  1. Add the ansible package repository sudo apt-add-repository ppa:ansible/ansible