Skip to content

Instantly share code, notes, and snippets.

Tobias McNulty tobiasmcnulty

Block or report user

Report or block tobiasmcnulty

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
View Keybase.md

Keybase proof

I hereby claim:

  • I am tobiasmcnulty on github.
  • I am tobiasmcnulty (https://keybase.io/tobiasmcnulty) on keybase.
  • I have a public key ASBZ7dIhp5zA1a__DiQ070SobSPwLXNJxh0RXTr26iW9cgo

To claim this, I am signing this object:

@tobiasmcnulty
tobiasmcnulty / form_group.py
Created Feb 5, 2017
Django form-like object that wraps a related group of forms.
View form_group.py
class FormGroup(object):
"""
Form-like object that wraps a related group of forms.
"""
def __init__(self, main_form, **other_forms):
self.main_form = main_form
self.other_forms = list(other_forms.values())
for k, v in other_forms.items():
setattr(self, k, v)
View AWS, ELB, CF and Let's Encrypt
Elastic Load Balancer, CloudFront and Let's Encrypt
View db_validating_cache_machine.py
class DbValidatingCacheMixin(object):
"""
Cache mixin that avoids returning database objects from the cache that
reference invalid databases (databases that no longer exist in the settings
file).
"""
def _validate(self, key, obj, default=None):
"""
If ``obj`` appears to be a model object or list of model objects that
@tobiasmcnulty
tobiasmcnulty / ansibleSetupPostfixSES.yml
Last active Sep 7, 2015 — forked from l0neranger/ansibleSetupPostfixSES.yml
Ansible Playbook - Postfix for SES Delivery
View ansibleSetupPostfixSES.yml
#
# According to AWS Docs - http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
#
# Rewrites all sender addresses to a single canonical ses verified address.
#
# Expects a vars files at ../vars/PostfixSES-vars.yml with the following variables:
# - ses_host: email-smtp.us-west-x.amazonaws.com
# - ses_port: 587
# - ses_username: ses-smtp-username
# - ses_password: ses-smtp-password
View coverage-ctracer.log
(coverage-test)tobias@tobias-MS-7924:~$ pip install coverage
Collecting coverage
Installing collected packages: coverage
Successfully installed coverage-3.7.1
(coverage-test)tobias@tobias-MS-7924:~$ coverage debug sys
-- sys ----------------------------------------
version: 3.7.1
coverage: /home/tobias/.virtualenvs/coverage-test/lib/python3.3/site-packages/coverage/__init__.py
cover_dir: /home/tobias/.virtualenvs/coverage-test/lib/python3.3/site-packages/coverage
pylib_dirs: /usr/lib/python3.3
View .vimrc
" Needed on some linux distros.
" see http://www.adamlowe.me/2009/12/vim-destroys-all-other-rails-editors.html
filetype off
"call pathogen#helptags()
"call pathogen#runtime_append_all_bundles()
syntax enable
"set background=dark
"colorscheme solarized
View coverage.log
(coverage-test)tobias@tobias-MS-7924:~/code/coverage-3.7.1$ ls
AUTHORS.txt build CHANGES.txt coverage coverage.egg-info dist doc igor.py __main__.py MANIFEST.in PKG-INFO README.txt requirements.txt setup.cfg setup.py tests tox.ini
(coverage-test)tobias@tobias-MS-7924:~/code/coverage-3.7.1$ python setup.py install
running install
running bdist_egg
running egg_info
writing dependency_links to coverage.egg-info/dependency_links.txt
writing top-level names to coverage.egg-info/top_level.txt
writing entry points to coverage.egg-info/entry_points.txt
writing coverage.egg-info/PKG-INFO
View app.yaml
http_transport:
transport_name: "httptransport"
web_path: "/api/"
web_port: 8889
health_path: "/health-status/"
reply_expected: True
  middleware:
    logging_mw: vumi.middleware.logging.LoggingMiddleware
rapidsms_relay_http:
@tobiasmcnulty
tobiasmcnulty / writecache.py
Created Sep 2, 2013
Simple write-through cache for Django querysets
View writecache.py
def get_cache_key(model, pk):
"""
Generates a cache key based on ``WRITE_CACHE_PREFIX``, the cache key prefix
defined in the settings file (if any), the Django app and model name, and
the primary key of the object.
"""
params = {
'prefix': getattr(settings, 'WRITE_CACHE_PREFIX', ''),
'app': model._meta.app_label,
'model': model._meta.object_name,
You can’t perform that action at this time.