Skip to content

Instantly share code, notes, and snippets.

View rachelbaker's full-sized avatar

Rachel Baker rachelbaker

View GitHub Profile
@rachelbaker
rachelbaker / copyr.php
Created September 2, 2012 22:30
PHP method to copy a single file or recursively copy an entire directory
/**
* Copy a single file or recursively copy a directory along with all contents
* @param string $source Source path
* @param string $dest Destination path
* @return bool Returns TRUE on success, FALSE on failure
*/
function copyr($source, $dest)
{
// if only one file
if (is_file($source)) {
@rachelbaker
rachelbaker / get_project_cpt_template.php
Created September 2, 2012 18:53
Display WordPress plugin template file for custom post type
public function get_project_cpt_template($project_template) {
global $post;
if ($post->post_type == 'projects') {
$single_template = dirname( __FILE__ ) . '/views/single-project.php';
}
return $project_template;
}
add_filter( 'project_template', array( &$this, 'get_project_cpt_template' ) );
@rachelbaker
rachelbaker / unplugged-plugin.php
Created August 24, 2012 19:27
Load a different WordPress theme for mobile visitors
<?php
/*
Plugin Name: Unplugged Mobile Theme
Plugin URI: http://www.rachelbaker.me
Description: A plugin and theme for WordPress that automatically reformats your blog's content for optimized viewing on Apple's <a href="http://www.apple.com/unplugged/">unplugged</a> and <a href="http://www.apple.com/ipodtouch/">iPod touch</a>.
Author: Rachel Baker
Version: 0.1
Author URI: http://www.rachelbaker.me
# Special thanks to Imthiaz Rafiq and the wp-pda Plugin (http://imthi.com/wp-pda/) which this plugin is derived from.
@rachelbaker
rachelbaker / matchMedia.js
Created August 24, 2012 17:38
jQuery matchMedia event handler for mobile
jQuery(document).ready(function($) {
// load touchdown resposnive nav
$('#site-navigation .menu').Touchdown();
// check window size
if (matchMedia) {
var mq = window.matchMedia("(min-width: 769px)");
mq.addListener(WidthChange);
WidthChange(mq);
}
@media only screen and (max-width : 321px) and (orientation : portrait) {
.box {
width:200px;
height:200px;
background:red;
}
}
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</html
@rachelbaker
rachelbaker / responsive-boilerplate.css
Created August 23, 2012 15:12
boilerplate for CSS media queries on responsive sites
// Option 1 - for sites with a max-width of around 1140px
// --------------------------------------------------
//
@media (max-width: 640px) {
}
@media (max-width: 1024px) {
}
@rachelbaker
rachelbaker / fitrespondizr.js
Created August 23, 2012 14:59
fitrespondizr.js - FitVid.js, Respond.js and Modernizr.js
/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
* Contains: fontface | backgroundsize | boxshadow | hsla | multiplebgs | rgba | textshadow | cssanimations | generatedcontent | cssgradients | csstransforms | csstransitions | inputtypes | iepp | cssclasses | teststyles | testprop | testallprops | prefixes | domprefixes
*/
;window.Modernizr=function(a,b,c){function F(){e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)l.setAttribute("type",f=a[d]),e=l.type!=="text",e&&(l.value=m,l.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&l.style.WebkitAppearance!==c?(g.appendChild(l),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(l,null).WebkitAppearance!=="textfield"&&l.offsetHeight!==0,g.removeChild(l)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=l.checkValidity&&l.checkValidity()===!1:/^color$/.test(f)?(g.appendChild(l),g.offsetWidth,e=l.value!=m,g.removeChild(l)):e=l.value!=m)),r[a[d]]=!!e;return r}("search tel url email datetime date month week time datetime-loc
@rachelbaker
rachelbaker / php.sublime-build
Created August 17, 2012 20:43
Sublime Text 2 PHP Build Script. Lints php files
{
"cmd": ["/usr/bin/php", "-l", "$file"]
, "selector": "source.php"
, "file_regex": "^Parse error: .* in (.*?) on line ([0-9]*)"
}
@rachelbaker
rachelbaker / st2-config.json
Created August 16, 2012 15:15
SublimeText2 User Configuration File
{
"auto_complete_commit_on_tab": true,
"auto_complete_size_limit": 1194304,
"auto_complete_with_fields": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Color Scheme - Default/Cobalt.tmTheme",
"default_line_ending": "unix",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": false,
"file_exclude_patterns":