Skip to content

Instantly share code, notes, and snippets.

View electroniceagle's full-sized avatar

Brian Schott electroniceagle

View GitHub Profile
@electroniceagle
electroniceagle / poc.py
Last active August 29, 2015 14:21 — forked from shaunbrady/poc.py
#!/usr/bin/python
import pprint
import inspect
from copy import deepcopy
class NimbisActionPluginMeta(type):
# we use __init__ rather than __new__ here because we want
# to modify attributes of the class *after* they have been
# created
@electroniceagle
electroniceagle / gist:8444359
Created January 15, 2014 20:50
This code snippet takes a Django secret from an environment variable or generates a random one automatically exactly once for testing. This hasn't been tested with multiple processes, so might not work as expected in a situation such as running a Celery daemon.
# use secret from environment or make a random one exactly once
SECRET_KEY = os.environ.get(
'DJANGO_SECRET',
os.environ.update({
'DJANGO_SECRET': ''.join([random.SystemRandom().choice(
string.digits + string.letters + string.punctuation)
for i in range(50)])}))
@electroniceagle
electroniceagle / gist:7045599
Created October 18, 2013 18:05
setting up a master slave configuration on ec2, lineinfile currently failing
#!/usr/bin/env ansible-playbook
# Borrowed heavily from:
# https://github.com/64BitsPerMinute/ansible-elasticsearch-ec2-example/blob/master/deploy_elasticsearch.yml
---
- name: Provision the system modeler grid
hosts: localhost
gather_facts: False
connection: local
vars:
ec2_access_key: '{{ nimbis_wolfram_aws_access_key }}'
@electroniceagle
electroniceagle / dropdown.html
Created August 4, 2012 03:00
django mezzanine alternative dropdown menu with login_required filter
{# place this at templates/pages/menus/dropdown.html to override the mezzanine dropdown menu #}
{% load i18n pages_tags %}
{% spaceless %}
{% if page_branch_in_menu %}
{% if branch_level == 0 %}
<ul class="nav pull-right">
{% for page in page_branch %}
{% if page.in_menu %}
{% if page.login_required and request.user.is_authenticated or not page.login_required %}