Skip to content

Instantly share code, notes, and snippets.

View potch's full-sized avatar

Potch potch

View GitHub Profile
// Simple Asynchronous Cache
// miss: a function that computes the value for the given key.
// Takes two parameters:
// * key: the key passed to AsyncCache.get()
// * set: a callback that sets the value for key
// hash: an optional function that generates a hash string for a given key.
// Takes one parameter:
// * key
function AsyncCache(miss, hash) {
var cache = {},
@potch
potch / vtruncate.js
Created December 9, 2010 11:35
A vertical truncation jquery plugin.
$.fn.vtruncate = function(opts) {
opts = opts || {};
var showTitle = opts.showTitle || false,
truncText = opts.truncText || "…",
split = [" ",""];
this.each(function() {
var $el = $(this),
oldtext = $el.attr("oldtext") || $el.text(),
txt, cutoff;
if ($el.attr("oldtext")) {
@potch
potch / hud.py
Created December 30, 2010 20:50
Hudson Checker with growl notification
#!/usr/bin/env python
from pyquery import PyQuery as pq
import re
import os
import time
HUDSON_URL = 'https://hudson.mozilla.org/job/amo-master/lastBuild/'
old_status = ''
@potch
potch / .bz
Created February 1, 2011 00:47
Bugzilla checker (bugzilla.mozilla.org)
MILESTONE='5.12.9'
ASSIGNEDTO='bob@butts.biz'
PRODUCT='addons.mozilla.org'
BUGZILLA='https://bugzilla.mozilla.org/show_bug.cgi?id='
QUERY="https://bugzilla.mozilla.org/buglist.cgi?bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&email1=$ASSIGNEDTO&emailassigned_to1=1&emailtype1=exact&product=$PRODUCT&query_format=advanced&order=Assignee&target_milestone=$MILESTONE&ctype=csv"
@potch
potch / TODO.sh
Created February 16, 2011 22:04
TODO helper for team projects. no warranties.
#!/bin/sh
if [[ $1 ]]; then
ack "TODO\s?\($1\)"
else
ack --noheading "TODO\s?\(([^\)]+)\)" --output='$1' -h | sort -f | uniq -ic | sort -r
fi
@potch
potch / mobile-frame.css
Created February 18, 2011 01:22
puts a Nexus S frame around your Firefox 4 content for mobile development
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("localhost") {
html {
margin-top: 129px !important;
padding-bottom: 260px !important;
}
body {
width: 320px;
position: relative;
@potch
potch / git-url
Created May 10, 2011 22:16 — forked from jbalogh/git-url
git-url: helps you close bugs good
#!/bin/sh
# Usage: `git url` or `git url <commitish>`
#
# * copies the commit's github url to your clipboard
# * prints out the log message
# * opens the bugzilla page if it found a bug number
#
# Set up the github url with `git config github.url <url>`.
# Only for the Mac.
@potch
potch / synt_helper_functions.js
Created July 23, 2011 06:53
Helpful bits for synthesizing/analyzing audio
// The sample rate of your audio playback;
const RATE = 44100;
// Magic number!
var Hz = 2 * Math.PI / RATE;
// Frequencies of some notes
var freqTable = [16.35,17.32,18.35,19.45,20.6,21.83,23.12,24.5,25.96,
27.5,29.14,30.87,32.7,34.65,36.71,38.89,41.2,43.65,46.25,49,51.91,55,58.27,
61.74,65.41,69.3,73.42,77.78,82.41,87.31,92.5,98,103.83,110,116.54,123.47,
@potch
potch / gist_line_numbers.css
Created September 26, 2011 18:53
CSS to add line numbers to embedded gists
.gist-highlight {
border-left: 3ex solid #eee;
position: relative;
}
.gist-highlight pre {
counter-reset: linenumbers;
}
.gist-highlight pre div:before {
@potch
potch / LICENSE.txt
Created December 30, 2011 20:49 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE