Skip to content

Instantly share code, notes, and snippets.

View prestontimmons's full-sized avatar

Preston Timmons prestontimmons

View GitHub Profile

Generate self-signed wildcard ssl certificate with openssl

1. Generate key

Replace *.example.com with your domain. When asked for CommonName during the openssl dialog, set it to *.yourdomain.com.

Generate::

sudo openssl genrsa -out example.com.key 1024

# Alter table to InnoDB engine
ALTER TABLE table_name ENGINE = InnoDB;
# Correct sequence value in Postgres
select setval('videos_video_id_seq', (select max(id) + 1 from videos_video));
# Run Django test suite
svn co http://code.djangoproject.com/svn/django/trunk/ django_src
cd django_src
echo "DATABASE_ENGINE = 'sqlite3'" > settings.py
PYTHONPATH=`pwd` ./tests/runtests.py --settings=settings -v1
@prestontimmons
prestontimmons / age.py
Created May 6, 2010 18:00
Calculate age from a given date
from datetime import date
import unittest
def calculate_age(birth_date, until=None):
"""
Calculates the age of a person from their birth date to a given
date, accounting for birth dates during leap year. The date
defaults to today if no date is specified.
"""
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
/* cross-browser opacity ------------------*/
selector {
filter: alpha(opacity=40); /* ie */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=40)"; /* ie8 */
opacity: 0.8;
}
@prestontimmons
prestontimmons / basic.diff
Created October 27, 2010 04:03
Patch to convert basic model doctests to unit tests.
diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py
index ffce4cb..5f51fd8 100644
--- a/tests/modeltests/basic/models.py
+++ b/tests/modeltests/basic/models.py
@@ -15,411 +15,3 @@ class Article(models.Model):
def __unicode__(self):
return self.headline
-
-__test__ = {'API_TESTS': """
@prestontimmons
prestontimmons / gist:745682
Created December 17, 2010 20:49
Using lambda to sort a list of structured data in Python
# Using a lambda to sort a list of structured data in Python
sorted(list_o_stuff, key=lambda k: k.key)
@prestontimmons
prestontimmons / gist:768578
Created January 6, 2011 21:03
ip address ranges
United States: 71.170.*.*
Canada: 24.36.0.*
United Kingdom: 82.0.*.*
Australia: 203.19.*.*
South Korea: 112.175.246.*