Skip to content

Instantly share code, notes, and snippets.

View doismellburning's full-sized avatar
🔥

Kristian Glass doismellburning

🔥
View GitHub Profile
@doismellburning
doismellburning / settings.py
Created December 20, 2016 13:51
Running Django on EC2? Use this if you need your instance's IP in `ALLOWED_HOSTS`
try: # pragma: no cover
# From http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
_local_ip = requests.get(
'http://169.254.169.254/latest/meta-data/local-ipv4',
timeout=0.1,
).text
ALLOWED_HOSTS.append(_local_ip)
except requests.exceptions.RequestException:
pass

I'm really interested in how y'all are doing Continuous Integration/Deployment of your Infrastructure-as-Code (particularly CloudFormation), especially without disruption to users!

Specifically, I'm trying to automate a "manual CloudFormation setup". Right now that's "templates in git with humans periodically run update-stack"; ideally it would become "PR merged? Rolling out the change".

(Part of me feels like I have "too many questions" and really just need to see a working setup, but hey)

@doismellburning
doismellburning / create_superuser.py
Created June 14, 2016 08:21
Non-interactively create/set a Django superuser
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth import get_user_model
from django.conf import settings
from django.db import transaction
class Command(BaseCommand):
# Excerpt
INT=$(iwconfig 2> /dev/null | grep -v "^ " | awk '{print $1}' | head -1 | egrep "^[a-z]")
if [ $? -eq 0 ]
then
echo "Removing Existing interface ${INT}"
ifconfig ${INT} down
iw dev ${INT} del
fi
sleep 1
@doismellburning
doismellburning / userstories.md
Last active October 30, 2017 16:25
Conference User Stories
commit d2a403c85ef68c4119de9208c15e9c4dc5df9b9b
Author: Kristian Glass <[email protected]>
Date: Fri Oct 31 00:36:56 2014 +0000
Magic anchor links
With thanks to http://ben.balter.com/2014/03/13/pages-anchor-links/
diff --git a/_config.yml b/_config.yml
index 1b00c31..ad61734 100644
from django.contrib.auth import get_user_model
from django.test import LiveServerTestCase
from selenium.webdriver.phantomjs.webdriver import WebDriver
class LiveTests(LiveServerTestCase):
@classmethod
def setUpClass(cls):
super(LiveTests, cls).setUpClass()
#!/usr/bin/python
from __future__ import absolute_import, division, print_function, unicode_literals
import csv
import subprocess
import sys
FILENAME = 'redirection.csv'
@doismellburning
doismellburning / Private-pypi-howto
Last active August 29, 2015 14:27 — forked from Jaza/Private-pypi-howto
Guide for how to create a (minimal) private PyPI repo, just using Apache with directory autoindex, and pip with an extra index URL.
*