Skip to content

Instantly share code, notes, and snippets.

View andrewschoen's full-sized avatar

Andrew Schoen andrewschoen

View GitHub Profile
@andrewschoen
andrewschoen / plugins
Last active December 16, 2015 22:16
Sensu ansible playbook
Plugins I'm using:
https://github.com/sensu-plugins/sensu-plugins-load-checks
https://github.com/sensu-plugins/sensu-plugins-memory-checks
https://github.com/sensu-plugins/sensu-plugins-disk-checks
https://github.com/sensu-plugins/sensu-plugins-cpu-checks
# NOTE: Needs it's own venv with latest psycopg2
import os
import psycopg2
from psycopg2.extras import DictCursor
import json
import time
import datetime
SLEEP_SECONDS = 10
# makes sure the DDT never turns on
def custom_show_toolbar(request):
return False
@andrewschoen
andrewschoen / gist:3144320
Created July 19, 2012 14:29
Postgres Backup & Restore
Backup: $ pg_dump -U {user-name} {source_db} -f {dumpfilename.sql}
Restore: $ psql -U {user-name} -d {desintation_db} -f {dumpfilename.sql}
@andrewschoen
andrewschoen / middleware.py
Created May 14, 2012 14:10
Django middleware to create a 'page header' in django-cms navigation.
from django import http
class NotAPageMiddleware(object):
"""
This middleware checks to see if the cms page is assigned to a specific template
and if so will redirect to the next published child page. Needs to be after the
cms page middleware.
"""
def process_response(self, request, response):
in_admin = request.path.split('/')[1] == "admin"
@andrewschoen
andrewschoen / custom_nav_tags.py
Created May 11, 2012 14:54
template tag for django-cms menus that roots at a given menu level
from menus.menu_pool import menu_pool
from django import template
from menus.templatetags.menu_tags import cut_after
register = template.Library()
@register.inclusion_tag('cms/dummy.html', takes_context=True)
def show_rooted_sub_menu(context, levels=100, root_level=0, template="menu/sub_menu.html"):
"""
show the sub menu of the current nav-node.
@andrewschoen
andrewschoen / future_value.py
Created May 3, 2012 18:18
Future value calculation with a increasing amount of contribution annually, up to X amount.
import numpy as np
import locale
locale.setlocale(locale.LC_ALL, '')
def sliding_payment_fv(start_pmt=100, annual_pmt_increase=100, max_pmt=300,
years=10, interest_rate=0.05, present_value=100):
future_value = 0
pmt = start_pmt
for year in range(years):
@andrewschoen
andrewschoen / django-cms-requirements.txt
Created April 19, 2012 21:43
django-cms project requirements.txt
PIL==1.1.7
django==1.3
django-filer==0.8.2
easy-thumbnails==1.0-alpha-15
cmsplugin-filer==0.8.0
django-cms==2.2
django-reversion==1.4
django-debug-toolbar==0.8.4
django-tinymce==1.5.1a1
http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download
@andrewschoen
andrewschoen / osx_geodjango_deps.sh
Created April 3, 2012 15:34 — forked from estebistec/osx_geodjango_deps.sh
GeoDjango dependencies on OSX
# The GeoDjango installation page [1] makes the OSX setup seem kind of gnarly. homebrew has
# come a long way and can do a lot of the heavy lifting of building libs needed by GeoDjango.
# When I get some time I'll submit a patch to that page on the Django site with this info...
# [1] https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#macosx
# Freshen homebrew
brew update
brew upgrade
# The main stuff we need
@andrewschoen
andrewschoen / hack.sh
Created March 31, 2012 14:35 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#