Skip to content

Instantly share code, notes, and snippets.

import os
import re
def logrotate(filename):
"""
Return the next available filename for a particular filename prefix.
For example:
# -*- coding: utf-8 -*-
"""
Example Usage
=============
>>> import datetime
>>> start = datetime.date(2009, 6, 21)
>>> g1 = daterange(start)
======================================================
Setting up Django using Apache/mod_wsgi on Ubuntu 8.10
======================================================
This article will cover setting up Django using Apache/mod_wsgi on Ubuntu
8.10. The article is targeted at a production environment, but keep in mind
this is a more generalized environment. You may have different requirements,
but this article should at least provide the stepping stones.
The article will use distribution packages where nesscary. As of 8.10 the
from django import forms
import datetime
class MonthYearWidget(forms.MultiWidget):
"""
A widget that splits a date into Month/Year with selects.
"""
from PIL import Image
from django.conf import settings
import S3, mimetypes
THUMBNAIL_SIZE = 70, 70
MEDIUM_SIZE = 150, 150
profile_image_path = settings.MEDIA_ROOT + '/images/roles/'
AWS_ACCESS_KEY_ID = 'YOUR_AWS_KEY'
AWS_SECRET_ACCESS_KEY = 'YOUR_AWS_SECRET'
@yashh
yashh / gist:219354
Created October 27, 2009 06:06 — forked from jseifer/gist:217637
#! /usr/bin/env ruby
#
# Save in your path as "isreg" and chmod +x. Then: isreg domain.com
#
puts `whois #{ARGV[0]}` =~ /No match for \"#{ARGV[0]}\"/mi ? "No" : "Yes"
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file
[supervisord]
logfile=/var/log/supervisord/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=info ; info, debug, warn, trace
pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
@yashh
yashh / fabfile.py
Created January 24, 2010 19:53 — forked from heckj/fabfile.py
#!/usr/bin/env python
from __future__ import with_statement # needed for python 2.5
from fabric.api import *
from fabric.contrib.console import confirm
# ================================================================
# NOTE:
# using this fabfile expects that you have the python utility
# fabric installed locally, ssh access to reamea.com, and your
# ssh public key associated with the account 'mboza@reamea.com'
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
"""
Simple python program demonstrating how certain blocking syscalls can be offloaded to a thread-pool and
then be able to fetch the results from these system calls in a non-blocking way by doing select() on
a pipe between the main thread and the threads in the pool.
This is the technique being used by node.js to offer a unified non-blocking Javascript API even for
things like file I/O which is traditionally done via blocking syscalls. This idea was described by
Ryan Dahl at JSConfEU 2009.
-- Harish Mallipeddi - Dec 3 2009