Skip to content

Instantly share code, notes, and snippets.

View keithmorris's full-sized avatar

Keith Morris keithmorris

  • Athens, Georgia USA
View GitHub Profile
@keithmorris
keithmorris / wpinstall.sh
Created March 5, 2014 21:12
Download latest Wordpress with one command. This uses curl to download and pipes through tar and removes the base 'wordpress' directory so that it extracts to the current working directory.
#!/usr/bin/env bash
curl -s http://wordpress.org/latest.tar.gz | tar xf - --strip 1
echo "Done."
@keithmorris
keithmorris / MD-Sandbox.md
Last active September 11, 2019 11:31
Markdown Sandbox

Environment Aware Wordpress wp-config File

Summary

This is a customized Wordpress wp-config.php that allows loading of custom config files for specific environments. The supplemental config files follow the naming convention of wp-config-{environment}.php.

The purpose of this approach is to eliminate code changes when moving between environments (local, dev, stage, production, etc). The environments are fully customizable and based on programatically inspecting the $_SERVER['SERVER_NAME'] superglobal.

Usage

@keithmorris
keithmorris / json.rb
Created November 30, 2013 06:33
This is a simple plugin for Jekyll that allows you to output Ruby Data Structures as JSON data. It supports both `json` and `json_pretty` filters. Just drop it into your _plugins/ directory and go to town.
require "rubygems"
require "json"
module JsonFilter
def json(input)
input.to_json
end
def json_pretty(input)
JSON.pretty_generate(input)
@keithmorris
keithmorris / ArrayCompare.java
Created June 3, 2013 11:33
Compare two char[] arrays for characters they do not have in common.
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
char[] arrayA = {'a', 'e', 'i', 'o'};
char[] arrayB = {'i', 'o', 'u', 'y'};
ArrayList<Character> aList = new ArrayList<Character>();
<?php
require_once 'ControllerTestCase.php';
class AccountControllerTest extends ControllerTestCase
{
public function testSignupWithNoDataRedirectsAndHasErrors()
{
$response = $this->post('account@signup', array());
@keithmorris
keithmorris / boilerplate-widget.php
Created December 4, 2012 23:51 — forked from eddiemoya/boilerplate-widget.php
WordPress Boilerplate Widget
<?php /*
Plugin Name: Boilerplate Widget
Description: Starting point for building widgets quickly and easier
Version: 1.0
Author: Eddie Moya
/**
* IMPORTANT: Change the class name for each widget
*/
class Boilerplate_Widget extends WP_Widget {
@keithmorris
keithmorris / readme
Created December 4, 2012 21:57 — forked from ScottPhillips/readme
Boilerplate Wordpress Widget
How to Use
Step 1.
Copy the custom_widget.php file and place it in your WordPress theme folder. Assuming WordPress is installed in the root of your server the file will be place in /wp-content/themes/yourtheme/
Step 2.
Open up functions.php and include the following piece of code somewhere in the file. include TEMPLATEPATH . '/custom_widget.php';
Step 3.
Edit the custom_widget.php file to suit your needs.
@keithmorris
keithmorris / remove-words.php
Created November 27, 2012 16:22
PHP remove common words from a string
<?php
function removeCommonWords($input){
// EEEEEEK Stop words
$commonWords = array('a','able','about','above','abroad','according','accordingly','across','actually','adj','after','afterwards','again','against','ago','ahead','ain\'t','all','allow','allows','almost','alone','along','alongside','already','also','although','always','am','amid','amidst','among','amongst','an','and','another','any','anybody','anyhow','anyone','anything','anyway','anyways','anywhere','apart','appear','appreciate','appropriate','are','aren\'t','around','as','a\'s','aside','ask','asking','associated','at','available','away','awfully','b','back','backward','backwards','be','became','because','become','becomes','becoming','been','before','beforehand','begin','behind','being','believe','below','beside','besides','best','better','between','beyond','both','brief','but','by','c','came','can','cannot','cant','can\'t','caption','cause','causes','certain','certainly','changes','clearly','c\'mon','co','co.','com','come','comes','concerni
@keithmorris
keithmorris / strip-nonalphanumeric.php
Created November 27, 2012 15:58
Strip non alphanumeric characters from a string
<?php
/*
Found here:
http://www.emanueleferonato.com/2006/07/27/strip-non-alphanumeric-characters-from-a-string-with-php/
*/
$string_to_be_stripped = "Hi, I am a string and I need to be stripped...";
$new_string = ereg_replace("[^A-Za-z0-9]", "", $string_to_be_stripped );
?>
@keithmorris
keithmorris / Wordpress ROBOTS.TXT file
Created November 10, 2012 18:10 — forked from chuckreynolds/robots.txt
Hardened robots.txt for wordpress installs
# Robots Rule! - Sometimes... #
User-agent: *
Allow: /
# Disallow these directories, url types & file-types
Disallow: /cgi-bin
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/
Disallow: /search/*/feed