Skip to content

Instantly share code, notes, and snippets.

View cmcculloh's full-sized avatar

Christopher McCulloh cmcculloh

View GitHub Profile
@cmcculloh
cmcculloh / The CoolGuyLoop
Created January 14, 2011 19:58
By Paul Irish. This one is fun....
for(var i = -1; ++i < Obj.length; ){}
@cmcculloh
cmcculloh / The CoolGuyLoop++
Created January 14, 2011 19:59
A slight speed improvement over the CoolGuyLoop
for(var i = -1, ii = Obj.length; ++i < ii; ){}
@cmcculloh
cmcculloh / window namespaced vars not recognized by jshint
Created March 8, 2011 20:24
JSHint says that namespace is undefined, however, I defined it on the first line.
window.namespace = window.namespace || {};
namespace.blah = "something";
@cmcculloh
cmcculloh / escape JSHint
Created March 8, 2011 20:32
allowing escape in JSHint
/*global escape: true */
var string = "blah";
string = escape(string);
@cmcculloh
cmcculloh / Array Literal
Created May 26, 2011 14:28
Array example, terse/readable
window.MyNamespace = {
something:[
["t","h","i","s"],
"that",
"the other"
],
another:function(){
return MyNamespace.something[0].join('');
}
};
@cmcculloh
cmcculloh / Array Object
Created May 26, 2011 14:31
Array example, fully qualified object name, less readable
window.MyNamespace = {
something:new Array(
new Array("t","h","i","s"),
"that",
"the other"
),
another:function(){
return MyNamespace.something[0].join('');
}
};
@cmcculloh
cmcculloh / full_example.php
Created November 23, 2011 05:50
Full Example
$thumb_sizes = array(
'breaking' => array( 'breaking', 80, 80, true ),
'slider1' => array( 'slider1', 390, 280, true ),
'slider1-wide' => array( 'slider1-wide', 450, 320, true ),
'slider1-thumbnail' => array( 'slider1-thumbnail', 120, 72, true ),
'slider2' => array( 'slider2', 710, 385, true ),
'slider2-wide' => array( 'slider2-wide', 880, 385, true ),
'slider3' => array( 'slider3', 455, 430, true ),
'slider3-wide' => array( 'slider3-wide', 630, 430, true ),
@cmcculloh
cmcculloh / gist:1387972
Created November 23, 2011 05:52
add action
add_action('admin_init', 'your_init_function');
@cmcculloh
cmcculloh / gist:1387974
Created November 23, 2011 05:52
init function
function your_init_function(){
//you will add stuff here later
}
@cmcculloh
cmcculloh / gist:1387976
Created November 23, 2011 05:53
add section
function con_register_section($section, $title){
add_settings_section('your_prefix_' . $section,
$title,
'your_prefix_'.$section.'_callback_function',
'dashboard page');
}