Skip to content

Instantly share code, notes, and snippets.

View obeattie's full-sized avatar

Oliver Beattie obeattie

View GitHub Profile
#!/bin/sh
set -e
if [ ! -e /tmp/aggergate ]; then
time nice /home/crowdtube/crowdtube/bin/aggergate.py
fi
if [ ! -e /tmp/rank ]; then
time nice /home/crowdtube/crowdtube/bin/rank.py
def remove_offset(x, y):
if y < 0:
return (x + abs(y))
else:
return (x - y)
-----------------------------
KARAOKE BUILDER STUDIO
www.KaraokeBuilder.com
-----------------------------
HEADERV2
'--- Template Information ---
'Palette Colours (0-15)
<head>
<meta property="og:site_name" content="Lucky Voice" />
<title>Lucky Voice - Welcome</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<!-- Main stylesheet -->
<link href="http://cdn.shopify.com/s/files/1/0034/5362/assets/styles.css?100005" rel="stylesheet" type="text/css" media="all" />
<!--[if IE 6]><link href="http://cdn.shopify.com/s/files/1/0034/5362/assets/ie6.css?100005" rel="stylesheet" type="text/css" media="all" /><![endif]-->
/* Draggable lists */
ul.reorderable {
position: relative;
z-index: 1;
border-top: 1px solid lighten(@mute, 10%);
border-bottom: 1px solid lighten(@mute, 10%);
li {
.unselectable;
position: relative;
import datetime
import decimal
import functools
import re
from dateutil import rrule
from django.utils import simplejson
from project.utils.dt import utils as dt_utils
from project.utils.misc import is_iterator
@obeattie
obeattie / stunnel.aug
Created August 21, 2011 12:42
Augeas schema for stunnel configuration
(* Stunnel configuration file module for Augeas *)
module StunnelConfig =
autoload xfm
let comment = IniFile.comment IniFile.comment_re IniFile.comment_default
let sep = IniFile.sep "=" "="
let setting = "chroot"
| "compression"
@obeattie
obeattie / locked_file_contextmanager.py
Created July 21, 2011 09:37
Context manager that acquires an exclusive lock on a file during the managed block
import contextlib
import fcntl
import os
@contextlib.contextmanager
def locked_file(path, mode='w'):
"""Context manager which will lock (and return a descriptor to) the passed file path on entry. The lock is
always released on exit. Will block until the lock is obtained."""
assert os.path.exists(path)
@obeattie
obeattie / s3signurl.py
Created July 19, 2011 10:27
Quick, dirty Python script that spits out a signed url for Amazon S3
#!/usr/bin/env python
import optparse
import sys
from boto.s3.connection import S3Connection
def sign(bucket, path, access_key, secret_key, https, expiry):
c = S3Connection(access_key, secret_key)
return c.generate_url(
expires_in=long(expiry),
@obeattie
obeattie / reindent.py
Created July 6, 2011 07:55
Modified version of the Reindent script by Tim Peters (http://pypi.python.org/pypi/Reindent/) that I made a few years ago. I think the only modification is to modify the indentation handling so that it will match the next indent level on blank lines, not
#! /usr/bin/env python
"""reindent [-d][-r][-v] [path ...]
-d (--dryrun) Dry run. Analyze, but don't make any changes to, files.
-r (--recurse) Recurse. Search for all .py files in subdirectories too.
-n (--nobackup) No backup. Does not make a '.bak' file before reindenting.
-v (--verbose) Verbose. Print informative msgs; else no output.
-h (--help) Help. Print this usage information and exit.