Skip to content

Instantly share code, notes, and snippets.

View ethangardner's full-sized avatar

Ethan Gardner ethangardner

View GitHub Profile
@ethangardner
ethangardner / xsl-even-results.xsl
Created September 21, 2011 17:51
Applies an alternate class to even numbered results in XSL
<xsl:if test="position() mod 2 != 1">
<xsl:attribute name="class">alt</xsl:attribute>
</xsl:if>
@ethangardner
ethangardner / gist:1276957
Created October 11, 2011 00:25
Include jQuery and jQuery UI via Wordpress functions.php
// add this to the theme's functions.php
// file between the php tags
if(!is_admin()){
wp_deregister_script('jquery');
wp_register_script('jquery', ('https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'), false, '1.6.4');
wp_enqueue_script('jquery');
wp_deregister_script('jquery-ui');
wp_register_script('jquery-ui', ('https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js'), false, '1.8.16');
wp_enqueue_script('jquery-ui');
}
@ethangardner
ethangardner / gist:1277054
Created October 11, 2011 01:35
Create the structure for jQuery UI Accordion
// This goes in the functions.php file between the php tags
// to make wordpress render the markup needed for a jQuery UI
// accordion widget area
register_sidebar(array(
'name' => 'Accordion Widget Area',
'id' => 'accordion-widgets',
'description' => 'jQuery UI accordion enabled widget area',
'before_widget' => '',
'after_widget' => '',
'before_title' => '<h3><a href="#">',
@ethangardner
ethangardner / gist:1277100
Created October 11, 2011 02:09
Wordpress Accordion Widget Area
<?php
// Accordion widget area
if (is_active_sidebar('accordion-widgets')) : ?>
<div id="accordion" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'accordion-widgets' ); ?>
</div><!-- #accordion -->
<?php endif; ?>
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery Feature Box</title>
<link rel="stylesheet" href="assets/styles/momentum.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="assets/scripts/jquery.scrollTo-min.js"></script>
<script src="assets/scripts/featurebox.js"></script>
</head>
/**
* Add whatever reset you want to use here -
* I am using Eric Meyer's CSS reset
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dd, dl, dt, li, ol, ul, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
border: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
line-height: 1;
$(document).ready(function(){
var icons = $('.icons'),
icon = icons.find('li'),
numIcons = icon.length,
openIcon = Math.floor(Math.random()*icon.length),
iconContainer = $('.feature-box'),
expandedClass = 'expanded',
collapsedClass = 'collapsed';
$(icon[openIcon]).addClass(expandedClass);
@ethangardner
ethangardner / gist:1587281
Created January 10, 2012 05:52 — forked from wrboyce/gist:786460
pre-commit hook to automatically minify javascript/css
#!/usr/bin/zsh
COMPRESSOR=$(whence -p yui-compressor)
[ -z $COMPRESSOR ] && exit 0;
function _compress {
local fname=$1:t
local dest_path=$1:h
local min_fname="$dest_path/${fname:r}.min.${fname:e}"
$COMPRESSOR $1 > $min_fname
@ethangardner
ethangardner / gist:1991279
Last active November 17, 2020 06:18
Raphael JS Guitar Neck Diagram
/**
* @author Ethan Gardner
* @see: http://www.ethangardner.com/articles/drawing-with-raphael-js-plus-a-bonus-for-guitar-players/
*/
var paper = new Raphael(document.id("fretboard"), 1300, 300);
/**
* Set up a GTR object to be used for namespacing
* @see http://www.ethangardner.com/articles/javascript-namespace-strategy-for-large-applications/
@ethangardner
ethangardner / sql-order-by-random
Last active October 7, 2015 00:27
SQL - order by random
SELECT * FROM table ORDER BY NEWID()
-- mysql version
SELECT * FROM table ORDER BY uuid()