Skip to content

Instantly share code, notes, and snippets.

View epicserve's full-sized avatar

Brent O'Connor epicserve

View GitHub Profile
@epicserve
epicserve / example_command.py
Created October 30, 2013 17:05
Example of how to setup logging for a Django management command.
from django.core.management.base import BaseCommand
from mymodule import main
import logging
class Command(BaseCommand):
help = 'Do foo'
def handle(self, *args, **options):
@epicserve
epicserve / README.md
Last active May 8, 2021 06:20
Django SSL Setup Guide

Django SSL Setup Guide

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
@epicserve
epicserve / gist:6545989
Created September 13, 2013 01:44
How nerds rename files
$ 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
@epicserve
epicserve / README.rst
Last active December 22, 2015 10:09
List the top pages for a website using Google Analytics

README

List the top pages for a website using Google Analytics. This is a base example that you could build off of to create lists on your website like, "Top Articles this Week", etc.

Installation

# 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
@epicserve
epicserve / redis_key_sizes.sh
Last active February 21, 2024 18:30
A simple script to print the size of all your Redis keys.
#!/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"; } '
}

A Simple Plan of Salvation

Question Scripture
What is sin? [1 John 3:4][1]
Can one sin by doing nothing? [James 4:17][2]
From where does sin come? [Mark 7:20-23][3]
What is the result of sin? [Romans 8:5-8][4]
What has been done about sin? [Romans 5:6-11][5]
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'
@epicserve
epicserve / test_emails.py
Created February 7, 2013 17:31
An example on how to test emails. The last two lines I would remove before committing to your repository, but if your working on an HTML email the last two lines are nice because you can see what the email would look like.
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):
@epicserve
epicserve / weather_codes.py
Created January 28, 2013 21:32
Yahoo and NOAA Weather Icons
# 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',