Skip to content

Instantly share code, notes, and snippets.

======================================================
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
@jaymzcd
jaymzcd / assign_file.py
Created July 13, 2011 11:23
Assign slugs and images based on a models fields - commands to use with a django shell
def assign_file_to_model(module, model_class=None, file_field='main_image', source_field='body', skip_existing=True, verbose=False):
""" We tend to have "main image" fields on models that hold a primary image used
across the sites for things like list pages and headers. Often on import of
existing data we have images mangled within copy or lists. """
import urllib2
from posixpath import basename
from BeautifulSoup import BeautifulSoup as Soup
from django.db import IntegrityError
@tomviner
tomviner / spottylotty.py
Created September 9, 2011 15:43
Spotify Ticket Lottery
from __future__ import division
import sys
import math
import random
# http://www.spotify.com/us/jobs/tech/ticket-lottery/
def bc(n, k, f=math.factorial):
"""Binomial coefficient in terms of Factorials
(n) = ____n!____
@jaymzcd
jaymzcd / git_tips.md
Created September 22, 2011 09:42
Few git things for pushing remotes/setting up on centos/rhel

Git things internally

Installation of Git on RHEL/CentOS

first, and you probably wont really ever need this unless you're doing a bare bones install of a cent/rhel box, the webtactic repo maintains a decently up to date git install that will cleaning go onto such a box:

sudo rpm -Uvh http://repo.webtatic.com/yum/centos/5/latest.rpm
sudo yum install --enablerepo=webtatic git-all

Now you have working git!

@dnouri
dnouri / gist:1600408
Created January 12, 2012 13:06
Use pyquery to search zope.testbrowser contents
from zope.testbrowser.browser import Browser
def _zope_testbrowser_pyquery(self):
from pyquery import PyQuery
return PyQuery(self.contents)
Browser.pyquery = property(_zope_testbrowser_pyquery)
# This will allow you to do in your tests:
# >>> "Home" in browser.pyquery('#navigation').text()
@stephenpaulger
stephenpaulger / sigquit.py
Created January 18, 2012 17:14
SIGQUIT handler
import signal
import sys
import time
def handle(sig, frame):
print all_signals[sig]
all_signals = dict((getattr(signal, attr), attr) for attr in dir(signal) if attr.startswith("SIG"))
@jaymzcd
jaymzcd / resolve_301.sh
Created February 3, 2012 13:59
resolve a list of 301'ing links to a file
while read line;
do curl -Is $line | egrep "Location" | awk -F": " '{print $2}' >> urls-resolved.txt;
done < urls-2.txt
@jaymzcd
jaymzcd / nicereadme.sh
Created February 13, 2012 16:39
Use documentup.com to prettify your markdown files from the commandline
function nicereadme {
TARGET_DOC=${1:-/tmp/doc.html}
INFILE=${2:-README.md}
curl -s -X POST --data-urlencode content@$INFILE http://documentup.com/compiled > $TARGET_DOC;
echo "$INFILE is pretty at file://$TARGET_DOC";
}
@jaymzcd
jaymzcd / mailbomb.py
Created February 14, 2012 17:38
Quick'n'dirty mailbomb of user X when annoying
import smtplib
import os
import sys
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email.Utils import COMMASPACE, formatdate
from email import Encoders
from random import randint
@cdennington
cdennington / gist:5098790
Last active December 14, 2015 14:08
Redmine issue update
//Set an Interval on the function to run every 10 secs
setInterval(function() {
//Get actual date
var date = new Date();
//console.log(date);
var reDate = /(\d+)\/(\d+)\/(\d+)/;
//Make comment date into actual date format
jQuery('a[title]').filter(function(){
var a = jQuery(this);
return a.attr('title').match(reDate);