Skip to content

Instantly share code, notes, and snippets.

dalethedeveloper

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
dalethedeveloper / gist:1846552
Created Feb 16, 2012
Techniques for Anti-Aliasing @font-face on Windows
View gist:1846552

#Techniques for Anti-Aliasing @font-face on Windows

It all started with an email from a client: Do these fonts look funky to you? The title is prickly.

The font in question was Port Lligat Sans from Google Web Fonts.

The "prickly" is aliasing caused by lack of hinting

@dalethedeveloper
dalethedeveloper / gist:966848
Created May 11, 2011
Reorder a PHP array, moving items up or down
View gist:966848
<?php
/*
A quick set of functions to move items in a non-associative array
up or down by one, shifting the items around it appropriately.
Original usage was to for a set of UP and DOWN buttons to
manipulate the order of an array of items stored in Wordpress option.
*/
$a = array('a','b','c','d','e');
@dalethedeveloper
dalethedeveloper / gist:1503252
Created Dec 20, 2011
Mobile Device Detection via User Agent RegEx
View gist:1503252

#Mobile Device Detection via User Agent RegEx

Yes, it is nearly 2012 and this exercise has been done to death in every imaginable language. For my own purposes I needed to get the majority of non-desktop devices on to a trimmed down, mobile optimized version of a site. I decided to try and chase down an up-to-date RegEx of the simplest thing that could possibly work.

I arrived at my current solution after analyzing 12 months of traffic over 30+ US based entertainment properties (5.8M+ visitors) from Jan - Dec 2011.

The numbers solidified my thoughts on the irrelevancy of including browsers/OSes such as Nokia, Samsung, Maemo, Symbian, Ipaq, Avant, Zino, Bolt, Iris, etc. The brass tacks of the matter is that you certainly could support these obscure beasts, but are you really going to test your site on them? Heck, could you even find one?! Unless the folks that pay you are die hard Treo users my guess is "No".

Interestingly enough my research shows that /Mobile/ is more efficient than **/iP(

@dalethedeveloper
dalethedeveloper / gist:1246351
Created Sep 27, 2011
Wordpress functions.php snippet to add Google Analytics tracking to wp_nav_menu with Yoast's plugin
View gist:1246351
/*
For use in functions.php in combination with:
http://wordpress.org/extend/plugins/google-analytics-for-wordpress/
*/
add_filter('wp_nav_menu', 'menu_ga_tracking', 99);
function menu_ga_tracking($menu) {
if( class_exists('GA_Filter') and yoast_ga_do_tracking() ) {
$menu = preg_replace_callback(
@dalethedeveloper
dalethedeveloper / gist:2294765
Created Apr 3, 2012
WordPress: Popup YouTube Videos in Thickbox (via shortcode)
View gist:2294765
/**
* Add a custom shortcode to popup youtube videos in a thickbox overlay.
* Pastable to functions.php in a WordPress theme.
*
* Usage (in WP Editor):
* [ytp url="http://www.youtube.com/watch?v=xxxxxxxxxxxxx"]
*
* From: http://manchumahara.com/2010/03/22/using-wordpress-native-thickbox/
*/
@dalethedeveloper
dalethedeveloper / gist:3901835
Created Oct 16, 2012
WuFoo Form Javascript Embed Hack - Scroll to top on submit / error
View gist:3901835
<!--
This is the standard Javascript embed code for a WuFoo form with an
added var (iamnotscrolling) that delays a scroll to the top of the form
on submit or error.
We are hijacking the resizeDone function which fires after the form is
modified (this may have unintended consequences).
-->
@dalethedeveloper
dalethedeveloper / wpmybackup.sh
Created Dec 16, 2016
Extract a single WP Multisite Side DB Files
View wpmybackup.sh
#!/bin/bash
WPUSER="username"
WPDBNAME="wp_db"
if [ $# -ne 1 ]
then
echo "Enter a WPMU ID for the Database"
exit
fi
DBS=$(mysql -u $WPUSER -p -ss $WPDBNAME -e "SHOW TABLES LIKE 'wp_$1_%'" | tr "\n" " ")
$(mysqldump -u $WPUSER -p $WPDBNAME $DBS > wp_$1_sql)
@dalethedeveloper
dalethedeveloper / gist:968926
Created May 12, 2011
Encrypt a WordPress Option using MySQL ENCRYPT()
View gist:968926
/*
An example of using MySQL's ENCRYPT() and DECRYPT() functions to store
sensitive data in a Wordpress Option. In this case, a password.
This only provides a bare amount of security as your Key is likely stored somewhere
else in your code or database. Basically, its not plaintext.
http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html
*/
@dalethedeveloper
dalethedeveloper / sync_mail.sh
Last active Feb 21, 2017
Transferring to/from Gmail accounts to a Google Apps account with imapsync. Also good for GApps to GApps transfers, archives, or migrations.
View sync_mail.sh
#/!/bin/bash
# Most of the tweaks here are wrapped up in gmailmig
# https://code.google.com/p/gmailmig/
#
# Props to brave folks who figured this out before me
# http://imapsync.lamiral.info/FAQ
# http://www.thamtech.com/blog/2008/03/29/gmail-to-google-apps-email-migration
# http://seagrief.co.uk/2010/12/moving-to-google-apps-with-imapsync/
# http://blog.mcfang.com/tag/imapsync/
#
@dalethedeveloper
dalethedeveloper / gist:1042934
Created Jun 23, 2011
Backup bash script for Webserver DB + Site Files
View gist:1042934
#!/bin/bash
# http://www.ivorde.ro/How_to_backup_all_mysql_databases_with_one_command-51.html
# http://bash.cyberciti.biz/backup/backup-mysql-database-server-2/
# http://sgowtham.net/blog/2008/04/04/backing-up-and-restoring-mysql-databases/
# Requires: http://s3tools.org/s3cmd
MyUSER="YOUR-USERNAME"
MyPASS="YOUR-PASSWORD"
MyHOST="localhost"
You can’t perform that action at this time.