Skip to content

Instantly share code, notes, and snippets.

View obeattie's full-sized avatar

Oliver Beattie obeattie

View GitHub Profile
// ==UserScript==
// @name Basecamp prettification
// @description A user stylesheet to make Basecamp a little bit prettier. Custom colors, a bit of jiggery-pokery with the header spacing, hide the milestones calendar from the dashboard page, hide the company logo (if you have one).
// @include https://*.basecamphq.com/*
// ==/UserScript==
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = 'http://gist.github.com/raw/236875/4316c5130f701fa7a62dd2b5e5859b9d8bb2fc55/basecamp-custom.css';
/* With today's realign Google seem to have taken it upon themselves to reduce the line-height of each
* message line… yet again. So, here's a quick-n-dirty fix :)
*
* Updated March 3 2009, since Google changed all the class names :\
*/
/* Message line */
div.nH table tbody tr {
line-height: 1.6;
}
for branch in $(git branch -a | awk '{ print $NF }' | awk '/^tags\// { print $1 }'); do
tag=$(echo $branch | cut -f 2- -d /);
# create the tag
git checkout $branch;
git tag -a -m "Tagging svn tag $tag." $tag;
git checkout master;
# delete the branch
git branch -rD $branch;
done;
@obeattie
obeattie / stream_stdin_http.py
Created October 14, 2010 15:03
Note this requires Python 3
#!/usr/bin/env python3
import http.server
import sys
import time
stdin = sys.stdin.detach()
class StreamingResponseRequestHandler(http.server.BaseHTTPRequestHandler):
def _stream_content(self, source):
while True:
@obeattie
obeattie / clickable-vml-polygons.html
Created April 12, 2011 12:15
Quick proof-of-concept for clickable regions in HTML5. Uses Raphaël to draw SVG.
<!DOCTYPE html>
<html xmlns:og="http://ogp.me/ns#">
<head>
<meta charset="utf-8" />
<title>Links demo</title>
<style>
* { margin: 0; padding: 0; }
</style>
<script type="text/javascript" src="https://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>
@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.
@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 / 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 / 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"
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