Skip to content

Instantly share code, notes, and snippets.

View itsananderson's full-sized avatar

Will Anderson itsananderson

View GitHub Profile
@itsananderson
itsananderson / README.md
Last active August 29, 2015 13:58
Shows repo counts in GitHub repository list

Installation & Usage

  • Copy the text in bookmark.js
  • In your browser, create a new bookmark and paste the copied text into the "URL" field of the bookmark.
  • Navigate to a GitHub user/organization repository list and click on your newly created bookmark
  • Repository counts will appear under the various repository filters
  • UDATE 4/11/14: Now gives valid counts on front page
@itsananderson
itsananderson / place-kitten.ps1
Last active August 29, 2015 13:57
Fetch placeholder images from placekitten.com
# Usage:
# place-kitten.ps1 [-OutputDirectory <directory>] [resolution [...]]
#
# Examples
# place-kitten.ps1 400/300 1200/900 1920/1080
# place-kitten.ps1 -OutputDirectory c:\kitty 400/300 1200/900
Param(
[string]$OutputDirectory=$(pwd),
[string]$DimensionFile="",
@itsananderson
itsananderson / package-project1-error.txt
Last active August 29, 2015 13:56
Pass Dynamic Flags to NuGet With PowerShell Splatting
nuget : Unknown option: '-Build:True'
At line:1 char:38
+ nuget pack $project $nugetArgs
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Unknown option: '-Build:True':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
@itsananderson
itsananderson / invoke-command.php
Created January 14, 2014 04:51
Look up commands by name and invoke the associated function
<?php
class WP_SMS_PLUGIN {
var $commands = array(
'post' => array( __CLASS__, 'post_message' ),
'get' => array( __CLASS__, 'get_recent_posts' )
);
public function add_command( $command, $callback ) {
$commands[$command] = $callback;
@itsananderson
itsananderson / test-search-replace.php
Created January 9, 2014 08:40
Tests various inputs into Search_Replace_Ccmmand::recursive_unserialize_replace
<?php
require_once getcwd() . '/php/class-wp-cli.php';
require_once getcwd() . '/php/class-wp-cli-command.php';
require_once getcwd() . '/php/commands/search-replace.php';
class UnserializeReplaceTest extends PHPUnit_Framework_TestCase {
function testReplaceString() {
$orig = 'foo';
@itsananderson
itsananderson / mongodb.txt
Created October 15, 2013 01:42
Setting up MongoDB on OS X
To have launchd start mongodb at login:
ln -sfv /usr/local/opt/mongodb/*.plist ~/Library/LaunchAgents
Then to load mongodb now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mongodb.plist
Or, if you don't want/need launchctl, you can just run:
mongod
@itsananderson
itsananderson / hook-css.php
Last active December 16, 2015 03:19
Change 'gravity-forms' to whatever is shown in the URL for the Gravity Forms page. Example "options-general.php?page=gravity-forms"
<?php
function hook_my_css() {
$screen = get_current_screen();
if ('gravity-forms' == $screen->id ) {
wp_enqueue_style( 'my-css', plugins_url( '/my.css', __FILE__ ) );
}
}
add_action( 'admin_print_scripts', 'hook_my_css' );
@itsananderson
itsananderson / plugin-deploy.sh
Created April 5, 2013 22:13
Git Bash (Windows) compatible script for publishing Git projects to SVN
#!/bin/bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
DRY=${3-''}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)

normally you have to do multiple newlines

to get Markdown to break text apart

Otherwise it will simply join it together

But if you add two spaces at the end of a line
it will insert a <br /> tag

@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 vagrant@127.0.0.1

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