Skip to content

Instantly share code, notes, and snippets.

View evansolomon's full-sized avatar

Evan Solomon evansolomon

View GitHub Profile
@evansolomon
evansolomon / sources.list
Created April 1, 2012 21:08
Debian package list
# deb cdrom:[Debian GNU/Linux 6.0.3 _Squeeze_ - Official i386 NETINST Binary-1 20111008-19:55]/ squeeze main
#deb cdrom:[Debian GNU/Linux 6.0.3 _Squeeze_ - Official i386 NETINST Binary-1 20111008-19:55]/ squeeze main
deb http://ftp.us.debian.org/debian/ squeeze main
deb-src http://ftp.us.debian.org/debian/ squeeze main
deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main
<?php
/*
Plugin name: nginx Pretty Permalinks
Description: Remove index.php from permalinks
*/
add_filter( 'got_rewrite', '__return_true', 999 );
<?php
/*
Plugin Name: Kindle Book auto-tags
License: GPLv2 or later
*/
function kindle_book_auto_tagger( $post_id, $post ) {
// Check for the string with our tags
// Example string: "Customer tags: suspense, kindle free book, science fiction, post-apocalypse, fantasy."
$regex = '/customer tags: ?(.+)\./i';
@evansolomon
evansolomon / supercommits.php
Created April 30, 2012 23:10
Find SVN commits where a revision closed a ticket matching the same number
<?php
$revision_regex = '/^r(\d+) /';
exec( 'svn log | sed \'s/------------------------------------------------------------------------/NEWCHANGESET/g\' | sed -e \'/[^NEWCHANGESET]$/{N;s/\n//;}\' | sed -e \'/[^NEWCHANGESET]$/{N;s/\n//;}\' | sed -e \'s/NEWCHANGESET//\'', $commits );
foreach( $commits as $commit ) {
if( !$commit )
continue;
preg_match( $revision_regex, $commit, $revision );
@evansolomon
evansolomon / gist:2582421
Created May 3, 2012 01:30
Generic function for adding body classes in WordPress
<?php
function add_body_class( $new_classes ) {
// Turn the input into an array we can loop through
if ( !is_array( $new_classes ) )
$new_classes = explode( ' ', $new_classes );
add_filter( 'body_class', function( $classes ) use( $new_classes ) {
foreach( $new_classes as $new_class )
$classes[] = $new_class;
@evansolomon
evansolomon / capitalize-category-names.php
Created June 13, 2012 08:11
Capitalize category names in WordPress
<?php
/*
Plugin name: Capitalize category names on display
Description: Capitalize the first letter of a category name when it's displayed in the theme
*/
function capitalize_category_names_on_display( $name ) {
return ucfirst( $name );
}
add_filter( 'single_cat_title', 'capitalize_category_names_on_display' );
@evansolomon
evansolomon / analyze-passwords.php
Created June 18, 2012 18:03
Analyze passwords used by bots logging into a WordPress site caught by Admin Login Notifier
<?php
function unique_chars( $string ) {
$chars = array();
foreach ( str_split( $string ) as $character )
$chars[$character] = true;
return count( $chars );
}
@evansolomon
evansolomon / interal-linking-for-scheduled-posts.php
Created July 12, 2012 20:22
WordPress plugin to add scheduled posts to the internal linking dialog
<?php
/*
Plugin Name: Internal Linking for Scheduled Posts
Description: Add scheudled posts to the internal linking dialog in the WordPress editor.
Version: 1.0
Author: Evan Solomon
Author URI: http://evansolomon.me
*/
@evansolomon
evansolomon / gist:3106456
Created July 13, 2012 18:22
JS Setup WordPress Theme
<?php
function custom_js() {
// jQuery
wp_deregister_script('jquery');
wp_register_script(
'jquery',
includes_url( 'js/jquery/jquery.js' ),
array(),
@evansolomon
evansolomon / gist:3108240
Created July 13, 2012 23:37
Command line one liner to find and open function definitions in Sublime Text 2
# Alias ST2's command line tool for a shorter (easier-to-remember) name
alias st="/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl"
# Search for an open Sublime Text to a function definition
function fx() {
ack "function &?$1\(" | awk {'print $1'} | sed 's/:$//g' | xargs st
}
# Example usage from the root of a WordPress repository