Skip to content

Instantly share code, notes, and snippets.

from django.core.management.base import BaseCommand
from rq.registry import FailedJobRegistry
from django_rq.queues import get_queue
from django_rq.utils import get_jobs
class Command(BaseCommand):
help = 'Delete failed jobs from Django RQ.'
@jbarham
jbarham / newest_mtime.py
Last active January 2, 2017 00:10
Returns timestamp of most recently modified file under given path
#!/usr/bin/env python
import sys, os, time
def newest_mtime(path):
"""Returns timestamp of newest file under path."""
newest_time = 0
for root, dirs, files in os.walk(path):
for fname in files:
mtime = os.stat(os.path.join(root, fname)).st_mtime
@jbarham
jbarham / ipv6octal.py
Created May 29, 2012 23:40
Converts an IPv6 address to octal format for tinydns
# This function is a translation of the PHP function described at
# http://thisisnotajoke.com/2011/07/12/aaaa-for-tinydns-php-function/
def ipv6octal(ipv6):
while len(ipv6.split(':')) < 8:
ipv6 = ipv6.replace('::', ':::')
octets = []
for part in ipv6.split(':'):
if not part:
octets.extend([0, 0])
else: