Skip to content

Instantly share code, notes, and snippets.

Avatar
🙈
Taking care of my kid

Matt Wright mattupstate

🙈
Taking care of my kid
View GitHub Profile
View humio.d.ts
declare module 'humio' {
interface Options {
ssl?: boolean;
host: string;
port: number;
basePath?: string;
dataspaceId?: string;
sessionId?: string;
includeClientMetadata?: boolean;
includeSessionId?: boolean;
@mattupstate
mattupstate / Scale to Fit.jsx
Created Aug 22, 2012
Photoshop script to scale an image to fill a specified rectangle and preserve aspect ratio. Save this in <Photoshop Install Folder>/Presets/Scripts and restart Photoshop.
View Scale to Fit.jsx
#target photoshop
main ();
function cloneRectangle(rect) {
return { x:rect.x, y:rect.y, width:rect.width, height:rect.height };
}
function rectangle(x, y, width, height) {
return { x:x, y:y, width:width, height:height };
@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 / url62.py
Created Dec 10, 2014
python url62 implementation
View url62.py
import string
import uuid
alphabet = string.digits + string.ascii_letters
def base62_encode(n):
ret = ''
while n > 0:
ret = alphabet[n % 62] + ret
n /= 62
@mattupstate
mattupstate / supervisord.sh
Created Apr 19, 2012
Super simple supervisor init.d script
View supervisord.sh
# Supervisord auto-start
#
# description: Auto-starts supervisord
# processname: supervisord
# pidfile: /var/run/supervisord.pid
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=supervisord
DESC="supervisod is a system for controlling process state"
SUPERVISORD=/usr/local/bin/supervisord
@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 / module.sublime-snippet
Created Jul 19, 2013
A simple Python module header snippet for Sublime Text
View module.sublime-snippet
<snippet>
<tabTrigger>module</tabTrigger>
<scope>source.python</scope>
<description>Module</description>
<content><![CDATA[# -*- coding: utf-8 -*-
"""
${1:name}
${1/./~/g}
@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) ->
@mattupstate
mattupstate / virtualbox.json
Created Sep 3, 2013
Ubuntu 12.04 VirtualBox Packer example
View virtualbox.json
{
"provisioners": [
{
"type": "shell",
"scripts": [
"scripts/base.sh",
"scripts/vagrant.sh",
"scripts/virtualbox.sh",
"scripts/ruby.sh",
"scripts/chef.sh",
You can’t perform that action at this time.