Skip to content

Instantly share code, notes, and snippets.

View pdokas's full-sized avatar
🌵
Fnord

Phil Dokas pdokas

🌵
Fnord
View GitHub Profile
@pdokas
pdokas / svn-color.py
Created March 28, 2012 18:37 — forked from rharmes/svn-color.py
Colorize SVN
#
# 1) Alias this: alias svn=/Users/foo/dev/svn-color.py
# 2) Paste the script below into the above file
# 3) chmod 777 <the file>
# 4) Delete this quote block so the env line is line 1
#
#!/usr/bin/env python
"""
@pdokas
pdokas / svn-color.py
Created October 6, 2011 20:03
Colorize SVN
#
# 1) Alias this: alias svn=/Users/foo/dev/svn-color.py
# 2) Paste the script below into the above file
# 3) chmod 777 <the file>
# 4) Delete this quote block so the env line is line 1
#
#!/usr/bin/env python
"""
Emphasis: https://github.com/NYTimes/Emphasis
announcement: http://open.blogs.nytimes.com/2011/01/11/emphasis-update-and-source/
source: https://github.com/NYTimes/Emphasis/blob/master/js/emphasis-src.js
location on nytimes.com: http://graphics8.nytimes.com/js/app/common/emphasis/app.js
Cortex: http://cortexapp.com/
--
The problem
@pdokas
pdokas / ssh_auto_login.sh
Created February 17, 2011 01:30
How to move your public key to the authorized keys on another box
cat ~/.ssh/id_dsa.pub | ssh user@server 'touch .ssh/authorized_keys && cat >> .ssh/authorized_keys'
@pdokas
pdokas / pinboard.in.earnings.js
Created December 16, 2010 22:40
Calculates how much money the pinboard.in signup price algorithm nets over time
var NUMBERZ = function(min, max) {
var sum = 0, i;
min *= 1000, max *= 1000;
for (i = min; i < max; i++) {
sum += +(i / 1000).toFixed(2);
}
return +sum.toFixed(2);
}
@pdokas
pdokas / insertCommas.js
Created December 1, 2010 20:55
Convert an integer into a comma-delimited string
function insertCommas(n, delim) {
var n = ''+n, l = n.length,
delim = delim || ',';
return (l > 3) ? insertCommas(n.substr(0, l-3)) + delim + n.substr(l-3) : n;
}
@pdokas
pdokas / Example.js
Created December 1, 2010 19:02
Add a context param to $.fn.bind()
$('h1').bind('click', function() {
this.log('clicked!');
}, console);
$('h2').bind('click', {msg: 'clicked!'}, function(e) {
this.log(e.data.msg);
}, console);
javascript:void%28s%3Dprompt%28%27Find%20text%3A%27%2C%27%27%29%29%3Bs%3D%27%28%27+s+%27%29%27%3Bx%3Dnew%20RegExp%28s%2C%27gi%27%29%3Brn%3DMath.floor%28Math.random%28%29*100%29%3Brid%3D%27z%27%20+%20rn%3Bb%20%3D%20document.body.innerHTML%3Bb%3Db.replace%28x%2C%27%3Cspan%20name%3D%27%20+%20rid%20+%20%27%20id%3D%27%20+%20rid%20+%20%27%20style%3D%5C%27color%3A%23000%3Bbackground-color%3Ayellow%3B%20font-weight%3Abold%3B%5C%27%3E%241%3C/span%3E%27%29%3Bvoid%28document.body.innerHTML%3Db%29%3Balert%28%27Found%20%27%20+%20document.getElementsByName%28rid%29.length%20+%20%27%20matches.%27%29%3Bwindow.scrollTo%280%2Cdocument.getElementsByName%28rid%29%5B0%5D.offsetTop%29%3B
@pdokas
pdokas / attr-iteration.js
Created November 14, 2010 01:54
Iterate over all attributes in a DOM node
if (node.attributes.length) {
// Get the known-existent list of attributes and iterate over them
var attrs = node.attributes;
for (var length = attrs.length, i = 0; i < length; i++) {
// IE 5-8 (all currently shipping versions) always list all possible attributes, specified or not.
// The "specified" member of each attribute indicates whether it was existent in the HTML and is required for the purpose here.
// IE will also report the unique jQuery identifiers as well as jQuery's sizzle engine cache attributes, so parse those out entirely.
if (attrs[i].specified
&& attrs[i].nodeName.indexOf('jQuery') == -1
&& attrs[i].nodeName.indexOf('sizcache') == -1
----------
/ \
/ REST \
/ IN \
/ PEACE \
/ \
| Judge Dredd |
| 0 Au |
| killed by |
| incompatible RAM |