Skip to content

Instantly share code, notes, and snippets.

View andrewheins's full-sized avatar

Andrew Heins andrewheins

View GitHub Profile
@andrewheins
andrewheins / gist:3091591
Created July 11, 2012 16:36
JS - For Loop
// JS for loop
for (var i = 0, len = DEF; i < len; i++) {
}
@andrewheins
andrewheins / gist:3091589
Created July 11, 2012 16:35
WP - Meta Content Retrieval
// Retrieve metabox content
global $DEF_mb;
<?php $DEF_mb->the_value('DEF'); ?>
@andrewheins
andrewheins / gist:3091582
Created July 11, 2012 16:34
WP - Meta fn call
// Place in functions.php
require_once('library/metaboxes/DEF-spec.php');
@andrewheins
andrewheins / gist:3091578
Created July 11, 2012 16:33
WP - Meta Spec
/*
* WordPress MetaBox Spec
*/
<?php
$DEF_mb = new WPAlchemy_MetaBox(array(
'id' => 'DEF',
'title' => 'DEF',
'types' => array('page'),
'context' => 'normal', // defaults to "normal"
@andrewheins
andrewheins / gist:3091540
Created July 11, 2012 16:24
WP - Meta Field
/*
* Meta control for WordPress Pages
*
*/
<div class="my_meta_control">
<div>
<?php $mb->the_field('DEF'); ?>
<label for="<?php $mb->the_name(); ?>">DEF</label>
<input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/>
<span>DEF</span>
@andrewheins
andrewheins / obxdesignworks
Created June 25, 2012 18:18 — forked from williamdodson/obxdesignworks
Track PDF files in Google Analytics with jQuery
/**
* Place this code after your Google Analytics scripts
*/
$(function() {
/* any links to PDFs are tracked with GA */
$('a[href$="pdf"]').click(function(e){
/* grab only the file name without the full path */
var fullpath = $(this).attr('href');
var filename = fullpath.substr(fullpath.lastIndexOf("/")+1, fullpath.length);
_gaq.push(['_trackPageview', '/'+filename]);
@andrewheins
andrewheins / qs_to_hash.rb
Created December 7, 2011 17:29
QueryString to Hash in Ruby
# Today's little useless tidbit converts a url's query string into a hash
# set of k/v pairs in a way that merges duplicates and massages empty
# querystring values
def qs_to_hash(querystring)
keyvals = query.split('&').inject({}) do |result, q|
k,v = q.split('=')
if !v.nil?
result.merge({k => v})
elsif !result.key?(k)