Skip to content

Instantly share code, notes, and snippets.

View beastaugh's full-sized avatar

Benedict Eastaugh beastaugh

View GitHub Profile
@beastaugh
beastaugh / cleanup.rake
Created July 23, 2008 23:33
Delete minified and concatenated CSS and JS files
require 'find'
require 'rubygems'
require 'rake'
desc "Remove minified CSS and JS files from this directory and its children."
task :killmin do
Find.find(File.dirname(__FILE__)) do |path|
if FileTest.directory?(path)
if File.basename(path)[0] == ?.
Find.prune # Don't look any further into this directory.
@beastaugh
beastaugh / parse_query_string.js
Created August 26, 2008 14:30
Turn a document query string into a JavaScript object
/**
* Parse an HTTP query string into a JS object.
*/
var parseQueryString = function(query) {
var uri = query || document.location.href,
params = {},
args, i, pair, key, value;
if (!uri) return params;
@beastaugh
beastaugh / change_credits.php
Created August 27, 2008 20:38
Change the Tarski footer credits.
<?php
/*
Plugin Name: Change Credits
Plugin URI: http://tarskitheme.com/
Description: Change the Tarski footer credits.
Author: Benedict Eastaugh
Version: 1.1
Author URI: http://extralogical.net/
*/
@beastaugh
beastaugh / kcombinator.js
Created August 28, 2008 14:05
The K Combinator in JavaScript
/**
* An implementation of the K Combinator.
* http://wiki.tcl.tk/1923
*
* Copied from Mikael Brockman's code in Ruby on Rails' ActiveSupport library.
* http://weblog.jamisbuck.org/2006/10/27/mining-activesupport-object-returning
*/
function returning(value, block, context) {
block.call(context || null, value);
return value;
@beastaugh
beastaugh / custom_404.php
Created September 20, 2008 14:33
Change Tarski's error 404 page content.
<?php
/*
Plugin Name: Custom 404 Content
Plugin URI: http://tarskitheme.com/
Description: Change Tarski's error 404 page content.
Author: Benedict Eastaugh
Version: 1.0
Author URI: http://extralogical.net/
*/
#!/usr/bin/env ruby
require 'rubygems'
require 'hpricot'
require 'open-uri'
# Screen scraper for xkcd. The basic idea is to find out whether the comic
# always has the longest title of any image on the page. Inspired by this
# Hacker News posting: http://news.ycombinator.com/item?id=316621
comic_url = 'http://imgs.xkcd.com/comics/'
javascript:(function(){var e="http://imgs.xkcd.com/comics/",t=document.getElementsByTagName("img"),n=t.length;while(n--){if(t[n].src.substring(0,e.length)===e){alert(t[n].title);return;}}})();
@beastaugh
beastaugh / change_comment_text.php
Created December 8, 2008 13:33
Change comment text to something else.
<?php
/*
Plugin Name: Change Comment Text
Plugin URI: http://tarskitheme.com/
Description: Change comment text to something else.
Author: Benedict Eastaugh
Version: 1.0
Author URI: http://extralogical.net/
*/
@beastaugh
beastaugh / posted_at.php
Created December 10, 2008 10:35
Add timestamps to post dates.
<?php
/*
Plugin Name: Posted At
Plugin URI: http://tarskitheme.com/
Description: Add timestamps to post dates.
Author: Benedict Eastaugh
Version: 1.0
Author URI: http://extralogical.net/
*/