Skip to content

Instantly share code, notes, and snippets.

🙈
Taking care of my kid

Matt Wright mattupstate

🙈
Taking care of my kid
Block or report user

Report or block mattupstate

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mattupstate
mattupstate / nginx_status_decoder.lua
Last active Aug 29, 2015
heka Nginx status decoder and filter
View nginx_status_decoder.lua
--[[
Parses a payload containing the contents of the output from the Nginx `stub_status`
module. See: http://nginx.org/en/docs/http/ngx_http_stub_status_module.html
Config:
- payload_keep (bool, optional, default false)
Always preserve the original log line in the message payload.
@mattupstate
mattupstate / diskusage.lua
Last active Oct 8, 2015
heka disk usage decoder and filter
View diskusage.lua
--[[
Graphs disk usage data containing fields entield `DiskSize`, `DiskUsed`,
`DiskAvailable`, and `DiskPercentUsed`
Config:
- sec_per_row (uint, optional, default 60)
Sets the size of each bucket (resolution in seconds) in the sliding window.
- rows (uint, optional, default 1440)
Sets the size of the sliding window i.e., 1440 rows representing 60 seconds
@mattupstate
mattupstate / docker-regsitry.conf
Created Nov 6, 2014
An example Nginx config for a private Docker registry to enable unauthenticated, read-only access on non-volatile HTTP methods
View docker-regsitry.conf
upstream docker-registry {
leastconn;
server hostname1:port;
server hostname2:port;
}
server {
listen 80;
server_name docker.your.domain;
rewrite ^ https://$server_name$request_uri? permanent;
View logstash.conf
input {
file {
path => [ "/var/log/*.log", "/var/log/messages", "/var/log/syslog" ]
start_position => "beginning"
}
}
output {
elasticsearch_http {
host => "elasticsearch.company.internal"
@mattupstate
mattupstate / as_blueprint.py
Last active Aug 27, 2019
An `as_blueprint` method for Flask MethodView classes
View as_blueprint.py
from flask import Flask, Blueprint
from flask.views import MethodView
class ApiResource(MethodView):
endpoint = None
url_prefix = None
url_rules = {}
@classmethod
@mattupstate
mattupstate / uuid_url64.py
Last active Jul 9, 2019
Generate unique, URL friendly ID's based on UUID with Python
View uuid_url64.py
import re
import uuid
import base64
def uuid_url64():
"""Returns a unique, 16 byte, URL safe ID by combining UUID and Base64
"""
rv = base64.b64encode(uuid.uuid4().bytes).decode('utf-8')
return re.sub(r'[\=\+\/]', lambda m: {'+': '-', '/': '_', '=': ''}[m.group(0)], rv)
@mattupstate
mattupstate / oat.py
Last active Aug 29, 2015
Naive attempt at porting Oat (https://github.com/ismasan/oat) to Python
View oat.py
import warnings
from collections import OrderedDict
from itertools import chain
from inflection import pluralize
class Adapter(object):
@mattupstate
mattupstate / app.py
Created Jan 22, 2014
Odd behavior regarding ordering_list and association_proxy with SQLAlchemy
View app.py
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.orderinglist import ordering_list
app = Flask(__name__)
app.debug = True
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
db = SQLAlchemy(app)
@mattupstate
mattupstate / helpers.py
Last active Jan 4, 2016
A helper function for grabbing pseudo-namespaced configuration options from a Flask application
View helpers.py
def namespaced_config_options(app, prefix):
"""Returns a dictionary of configuration options built from
the specified Flask application and string prefix. Keys in the
resulting dictionary will be lowercase.
:param app: a Flask application
:param prefix: a configuration namespace prefix. e.g. `IMAGE_STORE`
"""
rv = {}
for key, value in app.config.iteritems():
@mattupstate
mattupstate / windowResize.coffee
Created Dec 4, 2013
A generic window resize directive to which you can add to any element to call a function on your controller
View windowResize.coffee
angular.module('something')
.directive 'windowResize', ($window, $parse) ->
restrict: 'A'
link: (scope, element, attrs) ->
w = angular.element($window)
fn = $parse(attrs['windowResize'])
handler = (event) ->
You can’t perform that action at this time.