Skip to content

Instantly share code, notes, and snippets.

View adamn's full-sized avatar
☀️
It's Always Sunny in Seattle

Adam Nelson adamn

☀️
It's Always Sunny in Seattle
View GitHub Profile
from django import template
from django.template.defaultfilters import stringfilter
register = template.Library()
@register.filter(name='prepend')
@stringfilter
def prepend(value, arg):
"""
Prepends value with arg if value exists, else returns ''
@adamn
adamn / manage.py
Created November 12, 2010 16:29
Example manage.py file for using a settings/ directory
#!/usr/bin/env python
import sys
from os.path import abspath, dirname, join
from django.core.management import execute_manager
try:
from settings import active as settings
except ImportError:
sys.stderr.write("Error: Can't find the module 'active' in the directory containing %r. \
@adamn
adamn / celeryd
Created November 16, 2010 21:54
Example celeryd config file located at /etc/default/celeryd
# This file should be named /etc/default/celeryd and is used by:
# /etc/init.d/celeryd
# http://celeryq.org/
# Where the Django project is.
CELERYD_CHDIR="/var/www/example-env/project-name/"
CELERYD_OPTS="-c 6"
# Name of the projects settings module.
DJANGO_SETTINGS_MODULE="settings.active"
@adamn
adamn / gist:1707483
Created January 30, 2012 23:26
Simple DynamoDB example for time-series data (i.e. counter for a given item_id at a time)
import time
import boto
from django.conf import settings
conn = boto.connect_dynamodb(aws_access_key_id=settings.AWS_ACCESS_KEY_ID,
aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY)
table_schema = conn.create_schema(
hash_key_name='item_id',
hash_key_proto_value='S',
@adamn
adamn / gist:7788482
Created December 4, 2013 14:39
Does Google simply allow all Internet hosts in its SPF records?
➜ ~ dig @8.8.8.8 _spf.google.com txt
; <<>> DiG 9.8.3-P1 <<>> @8.8.8.8 _spf.google.com txt
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5516
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
@adamn
adamn / pre-commit
Last active March 4, 2016 15:01 — forked from spulec/pre-commit
de-yipited and got rid of Sass
#!/usr/bin/env python
import os
import re
import subprocess
import sys
modified = re.compile('^(?:M|A)(\s+)(?P<name>.*)')
CHECKS = [
# From home connection (Faiba)
(kili)➜ Resources sudo mtr 41.190.141.245 --report
Start: Wed Feb 5 22:06:15 2014
HOST: Adams-MacBook-Air.local Loss% Snt Last Avg Best Wrst StDev
1.|-- 10.0.1.1 0.0% 10 1.4 2.4 1.0 8.4 2.2
2.|-- 192.168.1.1 0.0% 10 1.5 29.0 1.2 105.0 43.4
3.|-- 192.168.200.1 0.0% 10 4.0 12.5 2.7 52.4 16.3
4.|-- 41.222.9.105 0.0% 10 2.5 31.7 2.3 101.2 46.1
5.|-- 41.222.8.41 10.0% 10 2.8 9.7 2.6 25.5 9.5
(kili)➜ Resources sudo mtr dash.kili.io --report
Start: Fri Feb 7 11:01:39 2014
HOST: Adams-MacBook-Air.local Loss% Snt Last Avg Best Wrst StDev
1.|-- 41.188.154.65 0.0% 10 3.5 3.0 1.5 4.2 0.7
2.|-- 41.188.181.93 0.0% 10 2.6 2.7 1.8 4.5 0.6
3.|-- ge-0-0-2-pe.ppf.core.simb 0.0% 10 6.3 22.0 4.8 107.1 31.7
4.|-- 41.188.128.194 0.0% 10 19.2 91.8 18.2 721.1 221.2
5.|-- 41.212.40.241.wananchi.co 0.0% 10 30.4 17.5 15.3 30.4 4.6
6.|-- 41.212.1.162 10.0% 10 235.2 181.4 163.4 235.2 27.3
7.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0
➜ neutron sudo mtr 196.223.21.70 --report
Start: Wed Mar 5 14:08:20 2014
HOST: Adams-MacBook-Air.local Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.20.1 0.0% 10 2.8 4.3 1.1 10.0 2.8
2.|-- 41.212.36.69.wananchi.com 0.0% 10 5.8 17.7 3.3 39.0 13.6
3.|-- 41.212.1.161 0.0% 10 16.6 7.8 2.2 28.2 8.5
4.|-- ??? 100.0 10 0.0 0.0 0.0 0.0 0.0
➜ neutron
@adamn
adamn / gist:e2d3cebea822ba63d2e0
Created October 29, 2014 10:08
MTR on JTL Faiba to nation.co.ke
13:03:40 ~ $ sudo mtr www.nation.co.ke --report
Start: Wed Oct 29 13:03:44 2014
HOST: adam-2.local Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.1.1 0.0% 10 1.2 2.3 1.2 3.3 0.7
2.|-- 192.168.201.1 0.0% 10 2.8 3.2 2.4 5.7 0.8
3.|-- 41.57.108.5 0.0% 10 2.5 2.5 2.4 2.8 0.0
4.|-- 41.222.8.217 20.0% 10 106.6 121.7 106.6 144.4 17.5
5.|-- 195.229.27.57 80.0% 10 200.3 204.7 200.3 209.1 6.2
6.|-- 195.229.0.93 30.0% 10 213.3 213.3 195.6 224.1 9.1
7.|-- 195.229.3.177 80.0% 10 295.0 299.0 295.0 302.9 5.5