Skip to content

Instantly share code, notes, and snippets.

View aaronmcadam's full-sized avatar
🎉
Having fun!

Aaron McAdam aaronmcadam

🎉
Having fun!
View GitHub Profile
@aaronmcadam
aaronmcadam / cycle-example
Created February 2, 2010 22:54
jQuery cycle plugin example with pause and resume controls
<script type="text/javascript" src="/site_assets/js/cycle.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#featured_slideshow").hover(
function() { $("#slides").cycle("pause"); $("#controls").stop().fadeTo("normal", 1); },
function() { $("#slides").cycle("resume"); $("#controls").stop().fadeTo("normal", 0); }
);
$("#slides").cycle({
var $pagination = $("#demo1 ul");
$pagination.delegate('.jPag-current', 'click', function() {
var $$this = $(this);
$$this.closest('li').addClass('cached');
$pagination.find("#currentPage").removeAttr('id').wrapInner($('<a>', {'class':'pagenumbers', 'href':'book_data.php?keywords='+keywords}));
$$this.closest('li').attr('id','currentPage').html( $$this.text() );
$.ajax({
type : "GET",
cache : false,
@aaronmcadam
aaronmcadam / ee_categories_number.php
Created May 13, 2010 00:20
Expression Engine Number of posts under Categories
{!--
This script is useful for grabbing the number of entries under a category
--}
{exp:weblog:categories weblog="faq" style="nested" show_empty="yes"}
<h2>{category_name}</h2>
{exp:query sql="SELECT count(exp_category_posts.entry_id) AS post_count FROM exp_category_posts WHERE exp_category_posts.cat_id = {category_id}"}
<h4>{post_count} Question(s)</h4>
{/exp:query}
@aaronmcadam
aaronmcadam / lg_better_meta_implementation.php
Created May 13, 2010 00:23
LG Better Meta Sitemap implementation
<?php
global $IN;
// Getting the last segment of the URL
if (sizeof($IN->SEGS) > 1) {
$last_seg = ($IN->QSTR == 'index') ? $IN->SEGS[sizeof($IN->SEGS)-1] : $IN->QSTR;
} else if (sizeof($IN->SEGS) == 0) {
$last_seg = "home";
}
@aaronmcadam
aaronmcadam / grabbing_real_clicks.js
Created May 13, 2010 01:56
A way to tell if the click is actually a user-made click and not a triggered one
$.fn.trigger = function (type) { if (type == 'click') return false; return this.trigger (type); }
@aaronmcadam
aaronmcadam / yql_jquery.js
Created May 16, 2010 00:05
Small function for easier YQL
$.YQL = function(query, callback) {
if (!query || !callback) {
throw new Error('$.YQL(): query or callback are undefined');
}
var encodedQuery = encodeURIComponent(query.toLowerCase()),
url = 'http://query.yahooapis.com/v1/public/yql?q='
+ encodedQuery + '&format=json&callback=?';
$.getJSON(url, callback);
};
@aaronmcadam
aaronmcadam / jquery_cdn_fallback.html
Created May 16, 2010 19:18
Fallback in case CDNs go down for serving jQuery
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/js/jquery-1.4.2.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
@aaronmcadam
aaronmcadam / ee_disqus_exporter.rb
Created May 27, 2010 19:26 — forked from shapeshed/ee_disqus_exporter.rb
import ee comments to disqus
# Copyright 2009 Michael Ivey, released to public domain
# Disqus guts lifted from http://github.com/squeejee/disqus-sinatra-importer/tree/master
# I wanted it to run from MySQL and command line, instead of a Sinatra app
require 'rubygems'
require 'rest_client'
require 'json'
require 'sequel'
disqus_url = 'http://disqus.com/api'
@aaronmcadam
aaronmcadam / gist:432808
Created June 10, 2010 10:37
bookordersystem array manipulation
//EXAMPLE CODE FROM MY BOOK PROJECT:
$data = array();
foreach ($entries->rows as $index=>$e) {
if(array_key_exists('title', $e['value'])){
// checking if the id of the book has already been met
if ( isset($data[$e['id']]) ) {
<div class="coda-slider-wrapper" id="sliderContainer">
<div class="backgroundWrapper">
{exp:weblog:entries weblog="{embed:section}" disable="categories|member_data|pagination|trackbacks" dynamic="off"}
<div class="coda-slider preload slider" id="coda-slider-{count}">
{if gallery_images != ""}
{gallery_images}
{if image != ""}
<div class="panel">