Skip to content

Instantly share code, notes, and snippets.

@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 / 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:
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;
/* 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;
}
// ==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';
@obeattie
obeattie / hide-blogger-warning.user.js
Created April 11, 2010 08:39
Automatically skips the obnoxious "Content warning" on Blogger sites (only those with blogspot.com domains) — and doesn't require a page reload to do so. Winnah. To install using Google Chrome or Grasemonkey, click raw and you'll be prompted to install th
// ==UserScript==
// @name Blogger Content Warning Skip
// @description Automatically skips the content warning on blogspot.com sites without reloading the page
// @match http://*.blogspot.com/*
// ==/UserScript==
var fireEvent = function(obj,evt){
var fireOnThis = obj;
if (document.createEvent) {
var evObj = document.createEvent('MouseEvents');
@obeattie
obeattie / ignorant_paginator.py
Created April 2, 2010 06:34
A Django Paginator implementation that is stupid. It only knows whether it can navigate forward or back, not how many pages are available. Useful for object lists of an unknown length.
from django.core.paginator import EmptyPage, InvalidPage, PageNotAnInteger, Page, Paginator
class IgnorantPage(Page):
"""The just-as-ignorant stepchild of IgnorantPaginator and Page."""
def __init__(self, *args, **kwargs):
ret = super(IgnorantPage, self).__init__(*args, **kwargs)
# Now, we need to know if we have a first and last dealio
self.__has_next = (len(self.object_list) > self.paginator.per_page)
self.object_list = self.object_list[:self.paginator.per_page]
return ret
Element.implement({
closest: function(selector){
/* Matches the nearest element with the passed selector -- much like
* Element.getParent, but with the starting element included */
return (this.match(selector)) ? this : this.getParent(selector);
},
addLiveEvent: function(eventType, selector, handler){
/* Binds a 'live event' to all the element. Whenever the event is allowed to bubble
* up to this element, event.target is checked to see whether it matches the passed
* selector. If it does, the handler will be fired */
@obeattie
obeattie / basecamp-custom.css
Created November 17, 2009 12:18
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).
/* Basic color replacements */
a:link, a:visited {
color: #039 !important;
}
a:hover {
color: #fff !important;
background-color: #039 !important;
}
[color]
ui = auto
[user]
name = Oliver Beattie
email = oliver@obeattie.com
[alias]
stat = status
co = checkout
br = branch
[core]