Skip to content

Instantly share code, notes, and snippets.

View potch's full-sized avatar

Potch potch

View GitHub Profile
@potch
potch / LICENSE.txt
Created January 3, 2012 21:47 — forked from 140bytes/LICENSE.txt
zTemplate - a 140byt.es entry for string interpolation
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
@potch
potch / README.rst
Created January 10, 2012 23:52
BugColorZilla!

Bugzilla Color Friend!

A dotjs script to add some color to Bugzilla.

It's The Worst!™

@potch
potch / example.html
Created January 26, 2012 18:42
TextMate command to smart-wrap a line to 78 chars, accounting for indent.
<!-- before -->
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
<!-- after -->
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
@potch
potch / newmig.sh
Created January 27, 2012 00:33
Generate the next migration file name. takes a file-slug as an argument.
#!/bin/zsh
NUM=`ls migrations | sort -n | tail -n1 | awk -F- '{print $1}'`
NUM=$(($NUM+1))
echo "$NUM-$1.sql"
g=$(ps -ex | grep Growl | grep -v grep)
if [ -z "$g" ] # Growl isn't running
then
echo "starting Growl..."
/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app/Contents/MacOS/GrowlHelperApp&
else
echo "stopping Growl..."
ps -ex | grep Growl | grep -v grep | awk '{print $1}' | xargs kill
fi
ps -ex | grep Growl | grep -v grep
@potch
potch / bezzy.js
Created March 5, 2012 21:58
bezier curve function generator returns a function(t) that accepts [0..1] and returns an [x,y] pair at that point.
function bezzy() {
var pts = Array.prototype.slice.call(arguments),
funcs = [];
function b1(p1, p2) {
return function(t) {
var i = 1 - t;
return [p1[0]*i+p2[0]*t, p1[1]*i+p2[1]*t];
}
}
function b2(p1, p2, p3) {
@potch
potch / semispace.js
Created April 27, 2012 21:50
Whitespace is for losers, and ASI seems too magical. SemiSpace™- leave nothing to chance.
;;;;;;;;;;;;;;;;;;;;;;;;;;var n = ~~(Math.random() * 9 - 4);;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;function sign(n) {;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;return n && 1 + 2 * -(n < 0);;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;function sign2(n) {;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;return n && Math.abs(n) / n;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@potch
potch / mozApp.js
Created May 3, 2012 16:22
simple open web app lib
// manage a webapp.
// place <link rel="app-manifest" href="path-to-manifest.webapp"> in your <head>
// mozApp.install() attempts installation
// mozApp.uninstall() removes
// mozApp.isRunning() indicates whether the app is currently installed and open
var mozApp = (function() {
var manLink = document.querySelector('link[rel="app-manifest"]'),
manifestURL = manLink.href;
var self = false;
@potch
potch / README.rst
Created July 2, 2012 20:20
dotjs script to toggle collapsing comments on HN
var searchForm = $('#search-form'),
searchEl = $('#search'),
nav = $('#tabs'),
fields = 'id,assigned_to,priority,summary,status,last_change_time,whiteboard',
fieldsPretty = {
'assigned_to': 'assigned to',
'last_change_time': 'changed'
},
sortField = localStorage['sort-field'] || 'last_change_time',
sortDirection = localStorage['sort-direction'] === 'true',