Skip to content

Instantly share code, notes, and snippets.

View mattwiebe's full-sized avatar

Matt Wiebe mattwiebe

View GitHub Profile
@mattwiebe
mattwiebe / unCamelCase.js
Created June 3, 2011 05:27
unCamelCase.js
/**
* Turns someCrazyName into Some Crazy Name
* Decent job of acroynyms:
* ABCAcryonym => ABC Acryoynm
* xmlHTTPRequest => Xml HTTP Request
*/
String.prototype.unCamelCase = function(){
return this
// insert a space between lower & upper
.replace(/([a-z])([A-Z])/g, '$1 $2')
@mattwiebe
mattwiebe / jquery.afterscroll.js
Created September 13, 2011 21:05
Do something after you scroll past a certain element. Maybe do something else when you scroll back above it.
/*!
* jQuery AfterScroll 1.0
*
* Do something once the bottom of an element comes into view,
* and something when you scroll above it too.
*
* (c) 2011 Matt Wiebe http://somadesign.ca/
* GPL2 / MIT dual-license, just like jQuery
* http://jquery.org/license/
*
@mattwiebe
mattwiebe / ttfautohint_install.sh
Created August 18, 2011 19:10
Install ttfautohint on Mac OS X
# Mac OS X has some outdated build dependencies.
# This script will bring you up-to-date, then install ttfautohint.
# Only tested under 10.7.1, but should work
# You'll obviously need Developer Tools installed first.
mkdir ~/tmp
cd ~/tmp
curl -O http://mirrors.kernel.org/gnu/m4/m4-1.4.16.tar.gz
tar -xzvf m4-1.4.16.tar.gz
cd m4-1.4.16
./configure --prefix=/usr/local
@mattwiebe
mattwiebe / podbean-oembed.php
Created April 21, 2018 16:24
PodBean oEmbed support in WordPress
<?php
/**
* Add Support for PodBean Embed URLs in WordPress.
* Modified from https://core.trac.wordpress.org/ticket/31068#comment:12 to use newer oEmbed endpoint
*
* Just paste an episode URL on a line.
* @link https://core.trac.wordpress.org/ticket/31068#comment:12
* @see wp_oembed_get()
* @param $providers [array] Existing oEmbed Providers
* @return [array] Providers with custom additions
@mattwiebe
mattwiebe / responsive-images.php
Created September 21, 2011 23:02
Mobile First Responsive Images for WordPress
<?php
/*
Plugin Name: Mobile First Responsive Images
Description: Serve up smaller images to smaller screens.
Version: 0.1.1
Author: Matt Wiebe
Author URI: http://somadesign.ca/
*/
/**
@mattwiebe
mattwiebe / post-numbers.php
Created March 16, 2011 18:21
Post numbering function for WordPress
<?php
/**
* Display a post count on WordPress posts
* Just use mw_post_number() inside the loop and you'll get a post number count
* @author Matt Wiebe
* @link http://somadesign.ca/
* @license GPL v2 {@link} http://www.opensource.org/licenses/gpl-2.0.php
* @copyright 2011
*/
@mattwiebe
mattwiebe / checkPerf.js
Last active March 2, 2016 15:45
Check performance up to a certain point in the page's load, multiple times
/**
* To use: call the function at the point in the load you want to check performance for.
* The page will then reload for @var iterations times to provide multiple measures
*/
function checkPerf() {
var mean;
var iterations = 10;
var times = localStorage.getItem( 'perf' ) ? JSON.parse( localStorage.getItem( 'perf' ) ) : [];
times.push( performance.now() );
localStorage.setItem( 'perf', JSON.stringify( times ) );
@mattwiebe
mattwiebe / filter-out.php
Last active December 15, 2015 18:09
Filter out posts according to permissions and categories
<?php
add_action( 'pre_get_posts', 'mw_post_limiter' );
function mw_post_limiter( $wp_query ) {
// only modify for the main query - if we're not there, bail.
if ( ! $wp_query->is_main_query() )
return;
// category_slug => permission
$filtration_pairs = array(
jQuery( document ).ready( function( $ ) {
// Local vars.
var $masthead = $( '#masthead' ),
timeout = false,
$siteInfoClone,
$headerImageClone,
$socialLinksClone,
ajaxRequest = false,
$clickedModule;
@mattwiebe
mattwiebe / exclude-cat.php
Created June 26, 2012 23:40
exclude category from home
<?php
function mw_exclude_cat_from_home( $query ) {
// this is the category ID(s) you want to exclude.
$to_exclude = array( 3 );
if ( $query->is_main_query() && $query->is_home() ) {
$query->set( 'category__not_in', $to_exclude );
}
}
add_action( 'pre_get_posts', 'mw_exclude_cat_from_home' );