Skip to content

Instantly share code, notes, and snippets.

View timwhitlock's full-sized avatar

Tim Whitlock timwhitlock

View GitHub Profile
@timwhitlock
timwhitlock / no-widows.php
Created February 2, 2012 16:42
Simple wordpress plug to avoid typographical widows
<?php
/*
Plugin Name: No Widows
Plugin URI: http://timwhitlock.info/
Description: Prevents typographical widows in titles and post body content
Author: Tim Whitlock
Version: 1.0
Author URI: http://timwhitlock.info/
*/
@timwhitlock
timwhitlock / require_wp_db_patch.php
Created January 27, 2012 10:48
What require_wp_db function in Wordpress would look like, if it worked
<?php
function require_wp_db() {
global $wpdb;
if ( isset($wpdb) ){
return;
}
// Should check for override db.php file first
// - including both means fatal error on duplicate class
if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ){
require_once( WP_CONTENT_DIR . '/db.php' );
#!/bin/bash
# dos2unix utility using translate characters command
# requires /usr/bin/tr
for f in "$@"
do
if [ -f "$f" ]; then
echo "dos2unix $f"
cat $f | /usr/bin/tr -d "\015" > "$f.tmp"
mv "$f.tmp" "$f"
retweet.html
rt-loader.js
$ git diff install.old install.php
diff --git a/install.old b/install.php
index d23073b..6b2202e 100644
--- a/install.old
+++ b/install.php
@@ -39,7 +39,7 @@ require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
require_once( dirname( __FILE__ ) . '/includes/upgrade.php' );
/** Load wpdb */
@timwhitlock
timwhitlock / evil.php
Created August 21, 2010 12:10
The most evil PHP function in the World (courtesy of Wordpress)
<?php
/**
* Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
*
* Also forces $_REQUEST to be $_GET + $_POST. If $_SERVER, $_COOKIE,
* or $_ENV are needed, use those superglobals directly.
*
* @access private
* @since 3.0.0
*/
@timwhitlock
timwhitlock / wp-cdn.php
Created August 21, 2010 11:18
Simple tools for deploying Wordpress assets on a CDN
<?php
/**
Plugin Name: CDN Tools
Plugin URI: http://web.2point1.com/tag/wp-cdn
Description: Simple tool for deploying Wordpress assets on a CDN
Version: 0
Author: Tim Whitlock
Author URI: http://twitter.com/timwhitlock
*/
/* [twhitlock] define some configs before Wordpress can beat our plug-ins to it */
define('WP_CDN_ROOT','http://cdn.timwhitlock.info/wordpress');
define('WP_CONTENT_URL', WP_CDN_ROOT.'/wp-content');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
@timwhitlock
timwhitlock / dictionary-com.js
Created August 9, 2010 14:00
improved dictionary.com bookmarklet
// source
void ( function(){
try {
var s = window.getSelection();
var q = s ? s.toString().replace(/(^\W+|\W+$)/g,'') : '';
if( ! q ){
q = prompt('Enter a word to look up');
if( ! q ){
return;
}
isNaN(NaN); // true
NaN == NaN; // false
typeof NaN; // "number"