Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar

Weston Ruter westonruter

View GitHub Profile
@westonruter
westonruter / svg-tree-drawer-shortcode.php
Created September 6, 2010 05:01
WordPress Shortcode to put JSON into SVG Tree
<?php
function svg_tree_func($atts, $json = null) {
static $counter = 0;
$counter++;
extract(shortcode_atts(array(
// additional options can go here
), $atts));
$data = json_decode($json);
@westonruter
westonruter / list-paths-from-svn-revs.pl
Created September 10, 2010 01:48
list-paths-from-svn-revs.pl
#!/usr/bin/env perl
# Author: Weston Ruter @ X-Team <http://weston.ruter.net/>
use strict;
if(@ARGV < 2){
die "Usage: ./list-paths-from-svn-revs.pl URL REV [REV...]\n";
}
my $repo_url = shift @ARGV;
@westonruter
westonruter / mousewheel-scrollable-text-inputs.user.js
Created November 10, 2010 10:53
MouseWheel-scrollable Text Inputs User Script for Chrome: Enable horizontally scrollable text inputs via mousewheel (like Firefox)
// ==UserScript==
// @name MouseWheel-scrollable Text Inputs
// @description Enable horizontally scrollable text inputs via mousewheel, to make Chrome behave like Firefox.
// @include *
// @namespace http://weston.ruter.net/
// ==/UserScript==
document.addEventListener('mousewheel', function(e){
var target = e.target;
if(target.nodeName.toLowerCase() == 'input'){
@westonruter
westonruter / remove-autocomplete-off.user.js
Created November 13, 2010 20:37
Remove autocomplete=off User Script
// ==UserScript==
// @name Remove autocomplete=off
// @description Decide for yourself whether or not you want the browser to remember login credentials.
// @namespace http://weston.ruter.net/
// @match *
// ==/UserScript==
Array.prototype.forEach.call(document.querySelectorAll('[autocomplete]'), function(el){
el.setAttribute('autocomplete', 'on');
});
@westonruter
westonruter / media-fragments-for-media-elements.user.js
Created November 14, 2010 09:47
User script to add support for Media Fragment time offsets (e.g. #t=20) to standalone HTML5 media elements.
// ==UserScript==
// @name Media Fragments for Media Elements
// @description Adds support for Media Fragment time offsets (e.g. #t=20) to standalone HTML5 media elements (i.e. audio, video); allows you to bookmark time indexes by in media (via pausing) and then navigate between them with browser navigation.
// @namespace http://weston.ruter.net/
// @include *
// ==/UserScript==
/**
* Issues or potential issues:
* - If currentTime gets set too soon (before media initializes) does an error occur?
@westonruter
westonruter / functions.php.patch
Created November 25, 2010 11:33
WordPress patches needed to allow each theme to serve its own favicon; hack to disable wp_favicon_request()
Index: wp-content/themes/twentyten/functions.php
===================================================================
--- wp-content/themes/twentyten/functions.php (revision 16586)
+++ wp-content/themes/twentyten/functions.php (working copy)
@@ -39,6 +39,32 @@
*/
/**
+ * Allow each theme to serve their own favicon (e.g. for multisite WordPress)
+ */
@westonruter
westonruter / wordpress-esi-shortcode.php
Created January 12, 2011 20:51
WordPress [esi] Shortcode for doing Edge Side Includes (ESI)
<?php
/**
* Edge Side Includes (ESI) Shortcode
*/
function esi_shortcode($attrs){
$attrs = shortcode_atts(array(
'src' => '',
'ttl' => '1h',
'dca' => 'none',
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>New hot and cool tags for preformatted text. | Brendan Eich</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="WordPress 3.0.4" />
<link rel="stylesheet" href="http://brendaneich.com/brendaneich_content/themes/brendan/style.css" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://brendaneich.com/feed/" />
<link rel="alternate" type="text/xml" title="RSS .92" href="http://brendaneich.com/feed/rss/" />
<?php
define('ARRAY_CACHE_FILE', dirname(__FILE__) . '/array-cache.txt');
function get_array(){
if( time() - filemtime(ARRAY_CACHE_FILE) < 3600 ){
return unserialize( file_get_contents(ARRAY_CACHE_FILE) );
}
$array = generate_array(); // ...
file_put_contents( ARRAY_CACHE_FILE, serialize(array) );
@westonruter
westonruter / config.diff
Created February 27, 2011 20:48
Using colordiff for my svn diff command (set in ~/.subversion/config)
@@ -28,7 +28,7 @@
### Set diff-cmd to the absolute path of your 'diff' program.
### This will override the compile-time default, which is to use
### Subversion's internal diff implementation.
-# diff-cmd = diff_program (diff, gdiff, etc.)
+diff-cmd = colordiff
### Set diff3-cmd to the absolute path of your 'diff3' program.
### This will override the compile-time default, which is to use
### Subversion's internal diff3 implementation.