Skip to content

Instantly share code, notes, and snippets.

View rc1's full-sized avatar

Ross Cairns rc1

View GitHub Profile
// add js-clear class to input to enable
function defaultInputs(className) {
$('input.' + className).each( function () {
$(this).bind('focus', function () {
$this = $(this);
if($this.val() == this.defaultValue) {
$this.val('');
}
});
$(this).bind('blur', function () {
@rc1
rc1 / Single Checkbox example
Created December 10, 2010 19:16
uses the html-field extension
// for illustration only. need refactoring as it shows a non-exsistant defined group by sending an empty string to show
// add groups
ADMIN_SHOW_HIDE.addFieldGroup('Gallery Images', ['Images']);
function debugField (selector) {
objectForSymphonyLabel(selector).addClass('debug');
}
// actions
@rc1
rc1 / App.h
Created February 21, 2011 11:56
added orientationChange(int) to Cinder
/*
Copyright (c) 2010, The Barbarian Group
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that
the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and
the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
@rc1
rc1 / expandingMenus.js
Created March 2, 2011 18:02
One open at a time
/* Expanding Menus for Indexhibit
* uses jquery
*
* -- Version: One open at a time --
*
* Created by RossCairns.com
*/
var last;
@rc1
rc1 / .bash_aliases
Created March 3, 2011 18:39
Bash! Aliases for Git, Tar, ...
# Aliases
# tar
alias targz="tar -cvzf"
# git
alias gc="git commit -m"
alias gca="git commit -am"
alias gs="git status"
alias ga="git add"
@rc1
rc1 / Makefile
Created October 1, 2011 15:14
JavaScript Makefile with concatenation, minimiser
# description: build script for project libraries, external libraries including jslint
# used on The Big Art Mob web app
#
# usage: `make all` or `make lint`
#`
# requirements: node + npm for uglify-js, jslint.
# App.js
#
# From http://winhelp2002.mvps.org/hosts.htm
#===============================================================================
# [Start of entries generated by WinHelp2002]
#
# [Misc A - Z]
127.0.0.1 fr.a2dfp.net
127.0.0.1 m.fr.a2dfp.net
@rc1
rc1 / gist:2172730
Created March 23, 2012 16:54
Retina Display Image Sources
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script>
$(function () {
$("img[data-lowres]").each(function (index, el) {
$(el).attr({src: (window.devicePixelRatio) ? $(el).data("highres") : $(el).data("lowres") });
});
});
</script>
@rc1
rc1 / gist:2320760
Created April 6, 2012 15:25
Underscore body mixin. Returns the middle part of an Array (between last/tail and first/head)
_.mixin({
body : function(array, fromHead, fromTail) {
fromHead = (_.isUndefined(fromHead)) ? 1 : fromHead;
fromTail = (_.isUndefined(fromTail)) ? 1 : fromTail;
if (array.length < 2) return [];
return array.slice(fromHead, array.length-fromTail-1);
}
});
@rc1
rc1 / clean.sh
Created April 26, 2012 20:28
cleaning hacked files on dream host with node
#!/usr/bin/env node
var walk = require("./node-walk/lib/walk.js"),
fs = require('fs'),
path = require('path');
walker = walk.walk("./../", { followLinks: false });
var counter = {
clean : 0,