Skip to content

Instantly share code, notes, and snippets.

View ebinnion's full-sized avatar

Eric Binnion ebinnion

View GitHub Profile
@ebinnion
ebinnion / .bash_profile
Last active August 29, 2015 14:00
Gist of helpful commands that I use in development.
PATH=$PATH:~/bin
export PATH
alias ll='ls -lah'
# Git aliases
alias softreset='git reset --soft HEAD^'
alias hardreset='git reset --hard HEAD^'
# Following http://viget.com/inspire/terminal-aliases-for-git
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
@ebinnion
ebinnion / wp_engine_max_cdn.txt
Last active August 29, 2015 14:01
WP Engine to Max CDN integration. This is added to the WP Engine tab of the WordPress admin. Relies on pull zone being set up on Max CDN and Cnames added correctly.
#http:\/\/manofhustle.com\/(\S*\.(?:jpe?g|png|gif|ttf|otf|svg|woff|xml))# => http://cdn.manofhustle.com/$1
#http:\/\/manofhustle.com\/(\S*js)# => http://js.manofhustle.com/$1
#http:\/\/manofhustle.com\/(\S*css)# => http://css.manofhustle.com/$1
@ebinnion
ebinnion / functions.php
Created May 12, 2014 06:41
A method to enqueue and auto version CSS and JavaScript in WordPress.
<?php
/**
* Auto-versioning CSS and JavaScript in WordPress
* @author Eric Binnion
* http://manofhustle.com
*/
add_action("wp_enqueue_scripts", "auto_version_scripts", 20);
function auto_version_scripts() {
// Get last modified timestamp of CSS file in /css/style.css
<?php
$listings = array(
array(
'address' => '3410 Taft Blvd',
'city' => 'Wichita Falls',
'state' => 'Tx',
'zip' => 76308
)
);
<?php
/**
* Plugin Name: Multiple Roles per User
* Description: Allows anyone who can edit users to set multiple roles per user. In a default WordPress environment that wouldn't have much of an effect, since the user would have the privileges of the top-privileged role that you assign to him. But if you have custom roles with custom privileges, this might be helpful.
* Version: 1
* Author: nikolov.tmw
* Author URI: http://paiyakdev.com/
* License: GPL2
*/
/*
@ebinnion
ebinnion / slideshow.php
Last active August 29, 2015 14:01
Crane|WEST Slideshow CPT Snippet with Aqua Resizer
<?php
$slides = new WP_Query(
array(
'post_type' => 'slideshow',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'asc',
)
);
@ebinnion
ebinnion / redirect_non_admin.php
Created May 23, 2014 20:40
Redirect non-admin user in WordPress
<?php
add_action( 'wp_login', 'redirect_non_admins', 10, 2 );
function redirect_non_admins( $user_id, $user ) {
$user = wp_get_current_user();
$admin_roles = array('administrator');
if( 0 == count( array_intersect( $admin_roles, $user->roles ) ) ) {
wp_redirect( home_url() );
exit;
}

Pure SASS-adaption of Lea Verou's contrast-ratio javascript. Can be useful when eg. generating colored buttons from a single supplied color as you can then check which out of a couple of text colors would give the best contrast.

This script currently lacks the support for alpha-transparency that Lea supports in her script though.

In addition to the color-contrast adaption there's also some math methods that were needed to be able to calculate the exponent of a number and especially so when the exponent is a decimal number. A 2.4 exponent is used to calculate the luminance of a color and calculating such a thing is not something that SASS supports out of the box and not something I found a good pure-SASS script for calculating and I much prefer pure-SASS over ruby extensions. The math methods might perhaps be unecessary though if you're running Compass or similar as they may provide compatible math methods themselves.

Normal usage: `color: pick_best_color(#f00

# View my Jekyll blog http://paulstamatiou.com and my jekyll migration post http://paulstamatiou.com/how-to-wordpress-to-jekyll/
#
#
# based on the import script by icebreaker, which is based on mojombo's
# https://github.com/mojombo/jekyll/blob/master/lib/jekyll/migrators/wordpress.rb
# https://gist.github.com/303570
# edited to rewrite image URLs to use my CloudFront URL
require 'rubygems'
require 'sequel'