Skip to content

Instantly share code, notes, and snippets.

View ethangardner's full-sized avatar

Ethan Gardner ethangardner

View GitHub Profile
@ethangardner
ethangardner / GoogleCDNfallback.html
Created October 5, 2010 17:43
code snippet to offer fallback to local file if google's ajax api is unavailable
<!-- From http://github.com/paulirish/html5-boilerplate -->
<!-- Grab Google CDN's jQuery. fall back to local if necessary -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>!window.jQuery && document.write('<script src="js/jquery-1.4.2.min.js"><\/script>')</script>
@ethangardner
ethangardner / yql_flickr.php
Created December 21, 2010 02:02 — forked from avinashbangar/yql_flickr.php
using yql to access flickr photos via api
<!-->
Following code gets information about photos from Flickr via YQL for the given search term
Author : avinash
Email : [email protected]
<-->
<h2>Using YQL to Access the Flickr API</h2>
<form name='upcoming_form'>
@ethangardner
ethangardner / Mootools-1.2-XML-parsing.js
Created January 11, 2011 22:21
Mootools 1.2 XML sitemap parsing
new Request({
url: '/sitemap.xml',
method: 'get',
onSuccess: function(responseText, responseXML) {
responseXML.getElements('url').each(function(url) {
alert(item.getElement('loc').get('text'));
});
}
}).send();
@ethangardner
ethangardner / MooTools-1.3-XML-parsing.js
Created January 11, 2011 23:03
MooTools 1.3 XML parsing with Slick
//XHR to retrieve an atom feed and parse the result
//with MooTools Slick selector engine
new Request({
url: '/index.php?format=feed&type=atom',
data : 'xml',
method: 'get',
onComplete: function(responseText, responseXML) {
console.log(Slick.search(responseXML, 'entry > title'));
}
}).send();
@ethangardner
ethangardner / combine-files-from-command-line.txt
Created January 28, 2011 19:37
Combine Multiple Files using Linux or Cygwin command line
#code from article at http://beardscratchers.com/journal/compressing-css-and-javascript-with-yui-compressor
JSDIR="./www/js"
echo "1. Combining Javascript"
# Combine all the javascript to a single temporary file
cat $JSDIR/mootools-1.2-core.js \
$JSDIR/mootools-1.2-more.js \
$JSDIR/functions.js \
@ethangardner
ethangardner / prevent-IE-console-errors.js
Created January 30, 2011 18:18
Prevent console errors from IE if left in JS
// Prevents web inspector and firebug console errors from appearing in IE
// if a debugging flag is accidentally left in somewhere.
// originally from twitter.com
if (!window.console) {
(function() {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
@ethangardner
ethangardner / XML-attributes-to-elements.xsl
Created March 2, 2011 21:54
XML attributes to elements
<?xml version="1.0" encoding="UTF-8"?>
<!-- original source is http://diggintojava.blogspot.com/2011/02/converttransform-xml-attributes-to.html -->
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:strip-space elements="*" />
<xsl:template match="*">
<xsl:copy >
<xsl:if test="@*">
@ethangardner
ethangardner / jquery-wp-footer.php
Created April 7, 2011 13:39
Load jQuery in the footer of Wordpress.
@ethangardner
ethangardner / yql-twitter-dashboard.php
Created June 28, 2011 23:39
YQL Twitter Dashboard
<table id="social-media" class="tablesorter">
<caption>Twitter Dashboard with YQL</caption>
<thead>
<tr>
<th>Account Name</th>
<th>Followers</th>
<th>Following</th>
<th>Last Tweet</th>
</tr>
</thead>
@ethangardner
ethangardner / xsl-restaurant-menu-1.xml
Created June 28, 2011 23:44
XSL Restaurant Menu 1
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="menu.xsl"?>
<menu>
<section name="Appetizers">
<summary>Start your meal with something hot and fresh</summary>
<item>
<title>Appetizer Title 1</title>
<description>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</description>
<price>7</price>
<img></img>