This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from alembic import context | |
from pyramid.paster import setup_logging | |
from sqlalchemy import create_engine, pool | |
# this is the Alembic Config object, which provides | |
# access to the values within the .ini file in use. | |
config = context.config | |
# Interpret the config file for Python logging. | |
# This line sets up loggers basically. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_static_regex = re.compile( | |
r''' | |
(?P<root>/static/[a-zA-Z0-9._/-]+) | |
- | |
(?P<buster>[a-fA-F0-9]+) | |
(?P<ext>\.[a-zA-Z0-9]+) | |
$''', | |
re.VERBOSE, | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _build_facade(): | |
import sys | |
from .meta.api import scan | |
this = sys.modules[__name__] | |
registry = {} | |
scan(this, registry=registry) | |
globals().update(registry) | |
_build_facade() | |
del _build_facade |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StaticFactory(object): | |
def __init__(self, request): | |
request.is_static_asset = True | |
config.add_static_view('static', static_pkg, factory=StaticFactory) | |
config.add_request_method(lambda r: False, 'is_static_asset', reify=True) | |
_default_vary = set([ | |
'Cookie', | |
'Accept', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import engine | |
from sqlalchemy import event | |
class DbStats(): | |
def __init__(self): | |
self.clear() | |
def clear(self): | |
self.total_queries = 0 | |
self.total_time = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoRequestParamsPredicate(object): | |
def __init__(self, val, config): | |
self.val = bool(val) | |
def text(self): | |
return 'no_request_params = %s' % self.val | |
phash = text | |
def __call__(self, context, request): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExactRequestParamPredicate(object): | |
def __init__(self, val, config): | |
val = _as_sorted_tuple(val) | |
reqs = [] | |
for p in val: | |
k = p | |
v = None | |
if '=' in p: | |
k, v = p.split('=', 1) | |
k, v = k.strip(), v.strip() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# PROVIDE: ec2_fetchkey | |
# REQUIRE: NETWORKING | |
# BEFORE: LOGIN ec2_firstboot | |
# Define ec2_fetchkey_enable=YES in /etc/rc.conf and create /root/firstboot | |
# to enable SSH key fetching when the system next boots. | |
# | |
: ${ec2_fetchkey_enable=NO} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to your .bash_profile | |
function lsockets { | |
lsof -a -c $1 -i -l -P | |
} | |
# example: | |
# | |
# lsockets steward | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat << EOF > /dev/null | |
These procedures are helpful if you have a structure like this in your source tree and it can be anything like | |
Google protobuf, grammar syntax, shared source code of some sort that gets transformed to Python and C++, or | |
really anything that has a common base from which it is derived but when included (subtree'd/submoduled in git) | |
we only need the language specific part, not the rest. | |
What we do is create completely new branches in which we place a copy from the proper subdirectory from the | |
master branch. Yes that technically means we are duplicating files/commits in two different locations, but it | |
is a better option that having your Python specific source tree carrying around C++ files it does not need. |
NewerOlder