Skip to content

Instantly share code, notes, and snippets.

View matutter's full-sized avatar

Mat Utter matutter

View GitHub Profile
@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 / 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 / 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 / elk-config-links.txt
Created July 17, 2018 22:26
Useful links for ELK
@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 / 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 / gitlab-runner-urls.md
Last active April 22, 2019 17:18
URLs to download latest .deb and .rpm versions of gitlab-runner
@matutter
matutter / cpp_factory_w_statics.cpp
Created May 7, 2019 01:01
How a C++ factory pattern may be applied to subclasses using some static methods.
#include <iostream>
#include <vector>
class Base {
public:
Base() {}
virtual int func() = 0;
};
class Sub1 : public Base {
@matutter
matutter / asan-test.cpp
Created May 12, 2019 23:46
Small program demonstrates use of ASan for detecting leaks.
#include <iostream>
#include <stdlib.h>
#include <sanitizer/lsan_interface.h>
/**
* clang++ -g -fsanitize=address asantest.cpp
* ASAN_OPTIONS=detect_leaks=1 ./a.out
*
* ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer
@matutter
matutter / fn_decl.cpp
Created May 21, 2019 02:04
Example of using C++ lambdas with closure as classic C function pointers.
#include <iostream>
#include <functional>
typedef int (*int_fn_t)(int);
extern "C" void c_call(int_fn_t fn);
void c_call(int_fn_t fn) {
std::cout << fn(0) << std::endl;
}
typedef void (*void_fn_t)(void);