Skip to content

Instantly share code, notes, and snippets.

@dalethedeveloper
dalethedeveloper / gist:1264836
Created October 5, 2011 16:07
jQuery InViewToo Plugin - Viewport Triggers
/*
jQuery InViewToo Plugin to add triggers for elements entering/leaving the viewport
Not entirely complete, fully featured, or documented...but functional!
Fiddle Away!
http://jsfiddle.net/dalesaurus/CkFUB/
Inspired by
http://www.appelsiini.net/projects/lazyload
@dalethedeveloper
dalethedeveloper / gist:1265499
Created October 5, 2011 19:53
Very Lazy Loading of Facebook Connect with jQuery
/*
Use jQuery to load FB Connect javascript asynchronously, then trigger manual parsing of individual XFBML tags
*/
window.fbAsyncInit = function() {
FB.init({channelUrl:'http://YOUR_SITE_URL.HERE/channel.html',xfbml: false,logging:false,status:false});
};
(function() {
jQuery(document).ready(function() {
jQuery.getScript('http://connect.facebook.net/en_US/all.js', function(){
var parseXFBML = function() {
@dalethedeveloper
dalethedeveloper / gist:1444480
Created December 7, 2011 20:26
Wordpress - Cross Taxonomy Tag List Query
<?php
/**
Echo a list of tags terms for posts that are also have a $where_tax of $where_slug
Queries added to transient cache for performance
Note: Using the slug for a Taxonomy in $where_slug for simpler query
Tested up to WP 3.3, drop it in your functions.php
Example: Get a tag list for Posts in the 'News' Category
tags_by_other_taxonomy('news');
@dalethedeveloper
dalethedeveloper / gist:1474525
Created December 13, 2011 23:54
Generic WP Plugin Admin Menu Implementation - with AJAX!
<?php
/*
Plugin Name: Generic Menu
Plugin URI: http://example.com/
Description: Move things
Author: dalethedeveloper
Version: 0.1
*/
new myadmin_generic();
@dalethedeveloper
dalethedeveloper / gist:1503252
Created December 20, 2011 21:00
Mobile Device Detection via User Agent RegEx

#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:1793789
Created February 10, 2012 22:55
Safely wrap jQuery when multiple versions are present on a page
<!--
For testing how multiple versions of jQuery interact on a page,
see http://jsfiddle.net/dalesaurus/5TgkG/
-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">window.jQuery || document.write('<script src="/js/jquery-1.7.1.min.js"><\/script>')</script></script>
<script type="text/javascript">
var jQuery171 = window.jQuery;
jQuery171(document).ready(function($){
// Do work, son!
@dalethedeveloper
dalethedeveloper / gist:1846552
Created February 16, 2012 17:18
Techniques for Anti-Aliasing @font-face on Windows

#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:2294765
Created April 3, 2012 19:05
WordPress: Popup YouTube Videos in Thickbox (via shortcode)
/**
* 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:3305558
Created August 9, 2012 16:12
RSVP button for Facebook Event using CSS / encoded image
<!-- http://tinkerbin.com/jkItQEwh -->
<a href="https://www.facebook.com/events/331218348435" class="fb_rsvp" target="_blank" title="RSVP on Facebook">RSVP</a>
<style type="text/css">
a.fb_rsvp {
background: #ECEEF5 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAC8AAAASCAYAAADLw4ffAAAAAXNSR0IArs4c6QAAA0ZJREFUSA3VVXtIk1EU/21q6h665ZypU9SgtEwt0hL6JyICiQgRiwgKCiPor/qjiKiECCIEA+lB2UOMgiyo6GVkLxMniuarfGe6pXNu6l5uPta9V78vc5u5CMwL+75zzj3n3N8953e+CfQGixOLdAkXKW4Ge1GD952r8rVftGhq00FnMOPo/k1zuS7InkfwLV16FNyt5EFRfWWsgtf/B0HgaWAPnHrkgq/wXKaLbaZhYmISjW39vEkq9kdMpBxCoYC3aXUj6NObEB+nhCjAj9m7tUMIkvhDHhTI+/X2DSOQ7FN7c7tuyk7SRIfLeL9/ynm7YxzXS6rR1j3IfmXqTpzML4XJYmeHXyqqwOuKdgLejPw7n1D5uYfZO74P4sWHVh44FW6QPDb7GKy2MRQ+nMrZSrp/5Z4axU/rmK9H2vyWyQtFIlqCrG2JfETxkzpUN2qwIkYBx9g49u1cx/bSU6Lx4GUDNiZHIXWNCrmXy7A7I4l1STdoxuSkE6qwYAybRkE7yOUcJ909kfcKmVtX468qTynljlY84mnBbHXgB6FIhFIKWVAANDoTq/CAwcJan5OdxjwpuKhlwfjaNcD0miYt0pJUs9MxnVKOLn8/H3isPOU3B1AmDUDe8QwW9KeHYdiKMwVvmJtx2Ia4KDmrukAgwOnDm0GpdPW+GqOEYrSaaxMimG96cjTU9T1YtVyJmiYNcrJT
@dalethedeveloper
dalethedeveloper / gist:3823530
Created October 2, 2012 21:48
WordPress fetch custom Taxonomy Terms with Posts
/**
Get all terms in a Taxonomy including associated posts
Like get_objects_in_term() for all terms or get_terms() that includes posts
@$tax string Taxonomy to fetch (Default "post_tag", must be a slug)
@$post_type string Post type to use (Default "post")
@$query_args string Additional Query Args to use when querying objects (Default: '', must be string form, eg 'order=ASC&post_status=published')
@$return_ids bool Return just Post IDs in $return->posts instead of complete post Objects (Default: false)
*/
function get_objects_in_taxonomy($tax = 'post_tag', $post_type = 'post', $query_args = '', $return_ids = false ) {