Skip to content

Instantly share code, notes, and snippets.

View dfadler's full-sized avatar

Dustin Fadler dfadler

View GitHub Profile
@dfadler
dfadler / prevent-css-transition.css
Created May 8, 2012 16:20
Prevents css transitions on page load
// http://css-tricks.com/transitions-only-after-page-load/
.preload *
-webkit-transition: none !important
-moz-transition: none !important
-ms-transition: none !important
-o-transition: none !important
@dfadler
dfadler / youtube-controls.js
Created May 8, 2012 19:03
Iframed YouTube Javascript Controls
//http://jsfiddle.net/vYb72/1/
/*
* @param String frame_id The id of the div containing the frame
* @param String func Desired function to call, eg. "playVideo"
* @param Array args (optional) List of arguments to pass to function func*/
function callPlayer(frame_id, func, args){
/*func: playVideo, pauseVideo, stopVideo, ... Full list at:
* http://code.google.com/apis/youtube/js_api_reference.html#Overview */
if(!document.getElementById(frame_id)) return;
args = args || [];
@dfadler
dfadler / email_obfuscation.php
Created May 16, 2012 15:42 — forked from ivuorinen/email_obfuscation.php
Email Obfuscation Shortcode for WordPress
<?php
/*
Plugin Name: Email Obfuscation Shortcode
Plugin URI: https://gist.github.com/1424515
Description: Shortcode for including emails into content and keeping spambots clueless. [obf email="email@example.com" noscript="what's shown to bots/people without javascript"]
Version: 0.1
Author: Ismo Vuorinen
Author URI: http://github.com/ivuorinen
*/
@dfadler
dfadler / wp-config.php
Last active October 5, 2015 06:37
Wordpress Environment Configuration
$server_url = $_SERVER['HTTP_HOST'];
$site_url = 'http://';
$env;
switch ( $server_url ) {
// Prod
case 'example.com':
$env = 'prod';
@dfadler
dfadler / parse-youtube-url.php
Created May 21, 2012 22:35
Parse a YouTube Url returns a video id
<?php
// Expects a YouTube URL. Returns the video ID
function ob_parse_youtube_url($url) {
parse_str(parse_url($url, PHP_URL_QUERY), $url_array);
return $url_array['v'];
}
@dfadler
dfadler / print_array.php
Created May 22, 2012 20:32
Prints Formated PHP Array
<?php
// https://github.com/welaika/wordless/blob/master/wordless/helpers/log_helper.php
/**
* Prints the specified variable inside <pre> tags.
*
* @param string $var
* The variable to be printed
*
* @ingroup helperfunc
@dfadler
dfadler / navigation-helper.php
Created May 22, 2012 20:48
Wordpress Navigation Helper
<?php
// Registers Navigation
function register_navigation() {
register_nav_menus(
array(
'main-nav' => __('Main Nav'),)
);
}
@dfadler
dfadler / frequently-asked-questions.js
Created June 7, 2012 19:04
CSS3 Accordion With jQuery Fallback
// Sets gets the initial height of the question and sets it to the alt tag
$('#frequently-asked-questions .question .content')
.each(function(i){
$(this)
.attr('alt', $(this).height() );
});
// Sets all the questions height to 0
$('#frequently-asked-questions .question .content')
.css({
@dfadler
dfadler / placeholder.js
Last active October 6, 2015 15:58
Cross Browser Placeholder Fix
// Stores a reference to all input with a placeholder attribute
var $inputs = $('input[placeholder]');
if (!Modernizr.input.placeholder) {
$inputs.each(function(i, el) {
var $el = $(el),
placeholder = $el.attr('placeholder');
// Sets the input value to be the same as the placeholder
$el.attr('value', placeholder);
@dfadler
dfadler / parseCSS.js
Created July 6, 2012 18:16
Parse linked css with javascript
// Need to abstract this into a plugin
for(var i = 0; i < document.styleSheets[0].rules.length; i++) {
var selectorText = document.styleSheets[0].rules[i].selectorText;
if( selectorText === 'h1') {
console.log(document.styleSheets[0].rules[i].style.marginBottom);
}
}