Skip to content

Instantly share code, notes, and snippets.

View itsananderson's full-sized avatar

Will Anderson itsananderson

View GitHub Profile
@itsananderson
itsananderson / issues.md
Last active December 14, 2015 05:59
Issues setting up Vagrant on Windows

To get the setup scripts to work, you'll need to configure Git to check out line-endings "as-is", rather than converting to Windows style CRLF endings. Vagrant seems to choke pretty hard on the Windows style line-endings. You can specify this option when you install git, but if you've already installed it, run the following command from inside a Git Bash before you clone the GitHub repo

git config --global core.autocrlf input

Vagrant doesn't support vagrant ssh inside windows. You can use the following command from inside a "Git Bash" to connect to the VM:

ssh -i ~/.vagrant.d/insecure_private_key -p 2222 [email protected]

You can create a shortcut for this command by running the following:

@itsananderson
itsananderson / descriptions.md
Last active January 1, 2018 12:08
List of filters in WordPress 3.5.1
  • 'filter-names.txt' is just the filter names
  • 'filter-locations.txt' is the location where the filter was found, and the line contents
  • 'filter-everything.txt' is the other two files, tab-separated
@itsananderson
itsananderson / gist:3429020
Created August 22, 2012 20:19
Properly set up default settings
<?php
register_activation_hook( __FILE__, 'halloween_store_install' );
function halloween_store_install() {
//setup default option values
$default_options = array(
'currency_sign' => '$'
);
@itsananderson
itsananderson / mobile.php
Created June 24, 2012 08:02
Switch between two themes, depending on what domain is used to access a site
<?php
/*
* This solution assumes you've already set up your site so that the site domain is
* your "normal" (non-mobile) domain, and your theme is your non-mobile theme.
*
* In short, what it does it check to see if the site is being accessed through the
* mobile domain. If it is, the mobile theme is used instead of the normal theme, and
* all links point to the mobile domain (so navigatiion doesn't take visitors to the
* regular domain.
@itsananderson
itsananderson / gist:2904167
Created June 10, 2012 06:32
Filter everything in WordPress and output it
<?php
// add_action( 'all', array( __CLASS__, 'filter_it' ) );
// add_action( 'wp_redirect', array( __CLASS__, 'die_it' ) );
// static $actions = array();
public static function filter_it() {
$args = func_get_args();
self::$actions[] = $args;
@itsananderson
itsananderson / gist:2894021
Created June 8, 2012 06:44
Turn a time difference into a "description" (e.g. "2 days 12 hours 13 minutes")
<?php
$now = time();
$then = 12345;
$diff = $then - $now;
$days = floor( $diff / (60*60*24) );
$time = date( __( 'G \h\o\u\r\s i \m\i\n\u\t\e\s'), $diff );
@itsananderson
itsananderson / calendar.css
Created December 11, 2010 19:09
Basic calendar stylesheet
body {
font-family: Georgia;
}
table {
border: 1px solid #ccc;
border-spacing: 0;
}
th {
font-family: Verdana;
padding: 5px;