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 / 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 / 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 {
<?php
require_once 'ControllerTestCase.php';
class AccountControllerTest extends ControllerTestCase
{
public function testSignupWithNoDataRedirectsAndHasErrors()
{
$response = $this->post('account@signup', array());
@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>();
@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 / 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 / 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 / zip-em-up.sh
Created May 27, 2014 23:05
Zip files in current directory excluding .git*
zip -r -9 gpb-test.zip . -x ".git*"
@keithmorris
keithmorris / password.config
Created May 28, 2014 13:40
AWS Password protection
files:
"/etc/httpd/conf.d/allow_override.conf":
mode: "000644"
owner: ec2-user
group: ec2-user
encoding: plain
content: |
<Directory /var/www/html/myproject/>
AllowOverride AuthConfig
</Directory>
@keithmorris
keithmorris / reanme-dev.sh
Created May 29, 2014 01:27
Rename multiple files from command prompt
for i in .ebextensions/*.dev.yaml; do cp "$i" "`echo $i | sed 's/\.dev\.yaml/\.config/g'`"; done