Skip to content

Instantly share code, notes, and snippets.

View johndwells's full-sized avatar

John D Wells Jr johndwells

View GitHub Profile
if($.browser.msie && parseInt($.browser.version) < 7) { ... }
@johndwells
johndwells / jQuery - Attach load event to image
Created February 26, 2011 11:56
This snippet includes all of the boilerplate code to attach a load event to an image. Provisions are included for an image already loaded into browser's cache.
var img = new Image();
$(img)
// set the src attribute of the new image to our image
.attr('src', '/path/to/image.jpg')
// once the image has loaded, execute this code
.one('load', function () {
// remember to place into DOM first if you need access to width & height
// access width & height with this.width and this.height
@johndwells
johndwells / gist:943989
Created April 27, 2011 09:46
Resolve "out of date" error when attempting to recursively delete a bunch of SVN
// once folders are selected to delete, terminal into the folder and run these two commands:
svn update
svn resolve --accept working -R .
@johndwells
johndwells / normalise_param.php
Created July 22, 2011 13:34
A clever way to succinctly normalise a parameter passed to EE
// Found within the guts of Stash: https://github.com/croxton/Stash
// set default value in 2nd param passed to TMPL::fetch_param()
$my_param = (bool) preg_match('/1|on|yes|y/i', $this->EE->TMPL->fetch_param('my_param', 'yes'));
@johndwells
johndwells / eecms_plugin_static.php
Created July 22, 2011 13:36
Allow EE plugin to be called statically from PHP
// Taken from the guts of Stash: https://github.com/croxton/Stash
// is this method being called statically from PHP?
if (func_num_args() > 0 && !(isset($this) && get_class($this) == __CLASS__))
{
$this->EE->TMPL->tagparams['name'] = $name;
$this->EE->TMPL->tagparams['type'] = $type;
$this->EE->TMPL->tagparams['scope'] = $scope;
// as this function is called statically,
// we need to get an instance of this object and run get()
@johndwells
johndwells / gist:1168123
Created August 24, 2011 13:55
Publish Layout Break Debug
<?php
// place this snippet at line 61 of system/expressionengine/views/content/publish.php
if(! array_key_exists('field_visibility', $field)) {
var_dump($name);
var_dump($field);
die;
}
?>
@johndwells
johndwells / gist:1171300
Created August 25, 2011 17:56
Interset & merge an array of settings, discarding invalid keys
<?php
$default_settings = array(
'setting1' => '',
'setting2' => ''
);
// assuming $settings has been passed
// interset & merge with defaults
$settings = array_merge($default_settings, array_intersect_key($settings, $default_settings));
@johndwells
johndwells / gist:1325702
Created October 30, 2011 08:19
Standard .gitignore for Wordpress
# OS Files
######################
.DS_Store
# Files that change depending on server
######################
.htaccess
.htpasswd
wp-config.php
@johndwells
johndwells / gist:1325707
Created October 30, 2011 08:25
Standard .gitignore for ExpressionEngine
# OS generated files #
######################
.DS_Store
# Change depending on server
######################
.htaccess
.htpasswd
# Backups, caches and logs #
@johndwells
johndwells / htmlemailboilerplate.html
Created December 19, 2011 12:28
HTML Email Boilerplate
<html><head><title></title><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
/*
* ========================================================================
* Some cross-device, client-specific styles, courtesy of CampaignMonitor
* ========================================================================
*/
#outlook a { padding: 0; } /* Force Outlook to provide a "view in browser" button. */
body { width: 100% !important; }