Skip to content

Instantly share code, notes, and snippets.

View theho's full-sized avatar

James Ho theho

View GitHub Profile
@theho
theho / FlaskAppFormatter.py
Last active August 29, 2015 14:21
Log Formatter for Flask to trim pathname relative to app_root
# app is flask app object
class FlaskAppFormatter(logging.Formatter):
def format(self, record):
if record.pathname and record.pathname.startswith(app.root_path):
record.pathname = record.pathname.lstrip(app.root_path)
return super(FlaskAppFormatter, self).format(record)
@theho
theho / satellizer.User.py
Created May 18, 2015 10:29
satellizer User model using @hydbrid_property
# Original file https://github.com/jimmyho/satellizer/blob/master/examples/server/python/app.py
from sqlalchemy.ext.hybrid import hybrid_property
class User(db.Model):
_password = db.Column('password', db.String(120))
# ... etc ...
@hybrid_property
// Add percentage of white to a color
@function tint($color, $percent){
@return mix(white, $color, $percent);
}
// Add percentage of black to a color
@function shade($color, $percent){
@return mix(black, $color, $percent);
}
/**
* Responsive mixin. The media breakpoints are as defined
* in the twitter bootstrap framework:
*
* - phone
* - tablet-portrait
* - tablet-landscape-desktop
* - large-desktop
*
* Additional parameters for tagetting retina and non-retina
# turn dict into an object that allows access to nested keys via dot notation
# from http://stackoverflow.com/questions/3797957/python-easily-access-deeply-nested-dict-get-and-set
# made three modifications:
# --added `get()` method
# --added `if not dict.__contains__...` to `__contains__()`
# --can now accept None as key
# JHO:
# --updated prints and Exceptions to be python3 friendly
# https://gist.github.com/einnocent/8854896
class dotdictify(dict):
'use strict';
/**
* This module monitors angularFire's authentication and performs actions based on authentication state.
* directives/directive.ngcloakauth.js depends on this file
*
* Modify ng-cloak to hide content until FirebaseSimpleLogin resolves. Also
* provides ng-show-auth methods for displaying content only when certain login
* states are active.
*