Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block dalethedeveloper

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dalethedeveloper / .htaccess
Created May 15, 2014
WordPress .htacces redirect to shift to new domain but allow wp-admin access
View .htaccess
# Drop at the end of your base .htaccess or virtualhost, hooray for negative lookaheads
RedirectMatch ^\/(?!wp\-admin)(.*)$$1
dalethedeveloper / gist:0ce24d86cf4c4a12e277
Created Oct 1, 2014
Poor Mans Image Rotator (multiple slides, minimal jquery)
View gist:0ce24d86cf4c4a12e277
<!DOCTYPE html>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="//"></script>
var rollem = function() {
var si = $('#slide ul.current');
dalethedeveloper / gist:460e7c72c1d1e9f55a94
Created Dec 12, 2014
Check the Google Tag Manager dataLayer for an Ecommerce transaction and do something only once (cookie enforced)
View gist:460e7c72c1d1e9f55a94
if (typeof (window.dataLayer) !== 'undefined' && window.dataLayer.length) {
for (var d = 0; d < window.dataLayer.length; d++) {
var obj = window.dataLayer[d],
keys = Object.keys(obj);
for (var k = 0; k < keys.length; k++) {
var key = keys[k],
val = obj[key];
dalethedeveloper / gist:cc1f482f5ebdf07ccf26
Last active Aug 29, 2015
Prepare a Tab Delimited flat file for SQL Import where text fields contain newlines that cause records fall to the next line
View gist:cc1f482f5ebdf07ccf26
# Assumes a tab delimited flat file and the first field being a numeric key
FS = OFS = "\t";
p = "";
# Strategy is to readline, check for key in first field, store to print
# on next readline if the next record has a key in first field, otherwise
# append our fragmented line to the stored line
sub(/\r/,""); # also scrub those pesky carriage returns
dalethedeveloper / gist:8bbc30e847543fac088b
Created Jan 12, 2015
Plain Javascript to normalize target attribute for External Links
View gist:8bbc30e847543fac088b
// I needed to trigger a non-interactive Google Analytics Event on external link click in
// Google Tag Manager v2. This is a hacky workaround for targeting external links on using
// a trigger like this:
// Event Type: Link Click [element: target] [starts with] ["_"]
// This is used as a HTML tag in Google Tag Manager v2 to normalize all external <A> links
// to have a "target" attribute. Priority 100, Triggered on All Pages and Event = gtm.dom
View JavaScript - DOM Ready(ier)
* Works in Chrome, Firefox, MSIE, Opera and Safari.
function onDOMContentLoaded( event ) {
if( event ) {
document.removeEventListener( event.type, onDOMContentLoaded, false );
document.onreadystatechange = null;
// For testing purposes.
alert( "DOM Content Loaded" );
dalethedeveloper / gist:965036
Created May 10, 2011
Wordpress + Facebook Done Right: Load FBConnect asynchronously for XFBML and handle the channelUrl
View gist:965036
* A class-based approach to bring in Facbook Connect asynchronously on every
* frontend page load. Also handles side-loading channelURL when using
* Facebook's FB.init() method.
* This fits nicely in any functions.php, or can be dropped in to a standalone
* php file to use as a plugin.
* @link
dalethedeveloper / gist:1093962
Created Jul 19, 2011
Mimic a static HTML file from Wordpress using functions.php
View gist:1093962
/* When an html page like URL is accessed, return some static content,
In this case, a verification page for Google Apps
In the current theme functions.php:
if( !class_exists('google_verify') ) {
class google_verify {
public function __construct() {
add_filter('rewrite_rules_array', array($this,'gv_rewrite') );
if( !is_admin() ) {
dalethedeveloper / gist:1123968
Created Aug 3, 2011
Timestamp to a plain words description of elapsed delta (great for Twitter timestamps)
View gist:1123968
// Adapted from jQuery TimeAgo plugin:
// Update, check out performance:
function timetowords(timestamp) {
var words = {
"seconds": "less than a minute",
"minute": "about a minute",
"minutes": "%d minutes",
dalethedeveloper / gist:1126105
Created Aug 4, 2011
Minimalist post-load of Twitter Statuses to a page using jQuery (with bonus relative time description + Wordpress wraps!)
View gist:1126105
jQuery(document).ready(function($) {
$.getJSON('', function(data){
var relative_time = function(datetime) {
var delta = parseInt(( - Date.parse(datetime)) / 1000, 10);
var r = '';
if (delta < 60) {
r = delta + ' seconds ago';
} else if (delta < 120) {
r = 'A minute ago';
} else if (delta < (45 * 60)) {
You can’t perform that action at this time.