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 / ordering a list of items not alphabetical order.sql
Created September 16, 2010 14:53
ordering a list of items but not in alphabetical order
SELECT `Name`, `Rating`, `City`, `Country`, `Displayed`, REPLACE(REPLACE(REPLACE(`Rating`,'Gold','1'),'Silver','2'),'Bronze','3') as `ratingNum` FROM `table` WHERE `Displayed` = 'Yes' ORDER BY `ratingNum`,`Name` ASC
// Banner Images:
// Dealing with the case of an image not existing for a given page, dealing with main section header images, stripping out sub page names too
$strippedName = substr($name, 0, strpos($name.'/', '/')); // stripping out sub page names
$imagePath=$root.'/images/header_images/' . $strippedName . '.jpg';
if ( file_exists($imagePath) === false) {
$dbXML.='<noBannerImage>No banner image exists for this page</noBannerImage>';
}
/*
@aaronmcadam
aaronmcadam / phonegap-android-create.txt
Created October 11, 2010 22:43
Command and instructions for setting up a new phonegap-android project
# IMPORTANT! Use Ruby 1.9.1
# command that works for creating a new phonegap-android project
ruby bin/droidgap classic "C:/android-sdk/android-sdk-windows" TestGap TestGap.com "C:/www" "C:/phonegap/projects/TestGap"
# Open Eclipse and File -> New -> Project. Then choose Android -> Android Project. Give your project a name, click the radio button for "Create project from existing source", and browse to your generated project folder.
# Don't forget to add the phonegap.jar to your project. Expand the libs folder and then right-click on phonegap.jar and choose "BuildPath -> Add to Build Path"
@aaronmcadam
aaronmcadam / jqueryDatepickerInit.js
Created October 12, 2010 15:48
Initialisation code for jQuery UI datepicker widget
$(document).ready(function() {
$('.datePicker').each(function(){
var $this = $(this); // cache the this object
$this.keydown( function(event){
if ( event.keyCode !== 9 ){ // If key is not Tab - for accessibility
event.preventDefault(); // Prevents user input, forces user to use Calendar Date Picker widget
}
})
.datepicker({
showOn : 'both', // displays Calendar widget on focus of input and on clicking the Calendar icon
@aaronmcadam
aaronmcadam / xslt_listoflinks_addingclasses.xslt
Created October 21, 2010 09:53
xslt element creation within list
@aaronmcadam
aaronmcadam / jquery_templating_example.html
Created October 21, 2010 18:13
jquery templating example
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script id="adminBarTemplate" type="text/x-jquery-tmpl">
<li><img src="${iconSrc}" alt="${area}" /><a target="_blank" href="${areaLink}">${area}<span></span></a></li>
</script>
<script type="text/javascript">
$(document).ready(function(){
var adminBarData = [
{ "iconSrc" : "src", "area" : "Page Text Manager", "areaLink" : "/admin/flex/bin/main.html" },
{ "iconSrc" : "src", "area" : "Menu Manager", "areaLink" : "/admin/flex/bin/menuManager.html" }
];
@aaronmcadam
aaronmcadam / resize-to-iphone-bookmarklet.html
Created November 10, 2010 10:40
bookmarklet to resize browser window to iPhone dimensions
javascript:open(location,'iPhone:portrait','innerWidth='+(320+15)+',innerHeight='+(480+15)+',scrollbars=yes');
@aaronmcadam
aaronmcadam / aniamteScrollBarBackUp.js
Created November 17, 2010 20:12
little snippet to animate scroll bars back up to a point on the page
$("html,body").animate({ scrollTop : $(".tabs").offset().top - 5 }, 500); // smoothly animate scrollbar back up to the tabs
@aaronmcadam
aaronmcadam / serializeForm.js
Created April 19, 2011 15:18
outputs form data as "{ username : 'abc', password : 'abc' ... } instead of "{ 'name' : 'username', 'value' : 'abc' ... }
var signUp = function () {
var signupData = $( '#competition_form' ).serializeArray(),
params = {};
// setup params data from signupData
signupData.map( function( value ) {
params[value.name] = value.value;
} );
// set required data
$.extend( params, {
@aaronmcadam
aaronmcadam / removeClassRegex.js
Created June 29, 2011 10:19
remove a class based on a pattern
$(slider).parent().find('.rating').removeClass(function(index, elementClass) {
matches = elementClass.match(/rating-[0-9]+/);
if( $(matches).length ) {
return matches.join(' ');
}
});