Assumptions:
- You use Django with [Django-Storages][storages] for saving your STATIC and MEDIA files to S3
- You use Nginx to reverse proxy to Django
- You want to protect any URLs that start with /admin or /subscribe
from django.core.management.base import BaseCommand | |
from mymodule import main | |
import logging | |
class Command(BaseCommand): | |
help = 'Do foo' | |
def handle(self, *args, **options): |
$ for i in *.rb; do num=`echo $i | perl -wpe 's/[^\d]//g;'`; if [ "$num" -lt "10" ]; then num=`printf %02d $num`; mv $i "ex$num.rb"; fi; done |
# example monit check for monitoring a gunicorn process | |
# warning: Doesn't work yet | |
check process www.example.com with pidfile /var/run/gunicorn_www.example.com.pid | |
start program = "/sbin/start gunicorn_www.example.com" | |
stop program = "/sbin/stop gunicorn_www.example.com" | |
if failed unixsocket /tmp/gunicorn_www.example.com.sock then start | |
if memory usage > 10% then alert | |
if cpu > 10% for 1 cycles then alert |
#!/usr/bin/env bash | |
# This script prints out all of your Redis keys and their size in a human readable format | |
# Copyright 2013 Brent O'Connor | |
# License: http://www.apache.org/licenses/LICENSE-2.0 | |
human_size() { | |
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } ' | |
} |
include_recipe "apt" | |
include_recipe "python" | |
execute "upgrade packages" do | |
command "apt-get -y upgrade" | |
action :nothing | |
end.run_action(:run) | |
package 'vim' | |
package 'python-setuptools' |
from djagno.test import TestCase, Client | |
from django.core.urlresolvers import reverse | |
from django.core import mail | |
c = Client() | |
class TestEmails(TestCase): | |
def test_submit_event(self): |
# source: http://w1.weather.gov/xml/current_obs/weather.php | |
# icon_url: http://w1.weather.gov/images/fcicons/<weather_code>.jpg | |
noaa_weather_codes = { | |
'bkn': 'Mostly Cloudy | Mostly Cloudy with Haze | Mostly Cloudy and Breezy', | |
'nbkn': 'Mostly Cloudy | Mostly Cloudy with Haze | Mostly Cloudy and Breezy', | |
'skc': 'Fair | Clear | Fair with Haze | Clear with Haze | Fair and Breezy | Clear and Breezy', | |
'nskc': 'Fair | Clear | Fair with Haze | Clear with Haze | Fair and Breezy | Clear and Breezy', | |
'few': 'A Few Clouds | A Few Clouds with Haze | A Few Clouds and Breezy', | |
'nfew': 'A Few Clouds | A Few Clouds with Haze | A Few Clouds and Breezy', | |
'sct': 'Partly Cloudy | Partly Cloudy with Haze | Partly Cloudy and Breezy', |