Skip to content

Instantly share code, notes, and snippets.

View mattmccray's full-sized avatar

Matt McCray mattmccray

View GitHub Profile
#
# Titanium Rakefile
#
# Contains the following tasks:
#
# build:all # Build all source files
# build:auto # Autobuild all source files
# build:compress # Compresses and munges output JS using YUI Compressor
# build:css # Build CSS files from SASS source
# build:js # Assemble output javascript file(s)
// ads.js v0.1 by M@ McCray, find the source at http://gist.github.com/252391
var Ads=(function(B){function A(D){var C=B.location.search.substring(1);var G=C.split("&");for(var E=0;E<G.length;E++){var F=G[E].split("=");if(F[0]==D){return F[1]}}return""}return{Google:function(D,F,E,C){B.google_ad_client=D;B.google_ad_slot=F;B.google_ad_width=E;B.google_ad_height=C;document.write('<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js"><\/script>')},ProjectWonderful:function(J,G,D,F){var I=document,H=new String(Math.random()*9999).substr(0,5),E='<script src="http://www.projectwonderful.com/gen.php?',C=A("pw_highlight_code");E+="id="+J+"&";E+="type="+G+"&";E+="r="+H+"&";if(I.referrer){E+="referer="+escape(I.referrer)+"&"}if(I.location){E+="location="+escape(I.location);+"&"}if(D){E+="fg="+D+"&"}if(F){E+="bg="+escape(F)+"&"}if(C!=""){E+="hl="+escape(C.match(/[0-9]+/g))}E+='"><\/script>';I.write(E)}}})(this);
/* View Builder for JavaScript with support for CommonJS (and therefore Node.js)
By M@ McCray - 01/31/2010
Usage Example:
View.register('_footer', function(content){
return div({ cls:'footer'},
div({ cls:'footer-content' },
content
)
@mattmccray
mattmccray / gist:295342
Created February 5, 2010 00:53
Bash script for showing/hiding desktop icons in OSX
# Goes in your .bash_rc or .profile
# Hides the icons from your desktop
desktop_hide() {
defaults write com.apple.finder CreateDesktop -bool false
killall Finder
}
# Show the icons from your desktop
desktop_show() {
@mattmccray
mattmccray / jquery.anim8.js
Created April 25, 2010 08:19
platform.js -- Memoize functions base on browser type.
// (Simple example of using platform.js in a jQuery plugin.)
// Usage: $('#block').anim8({ top:50, left:350 }, 250);
$.fn.anim8 = (function($){ return platform({
// For Webkit browsers it will use CSS animations
webkit: function(props, speed, transition) {
return this.each(function(){
var elem = $(this),
transition = transition || 'ease-out',
@mattmccray
mattmccray / core.js
Created April 27, 2010 20:54
Tiny JS module/class framework.
/*
Version 0.2
module("Boldr", function(ns) { with(ns) {
module("Hello", function() {
def("hello", function() {
alert("hello " + this.name);
});
});
Class.extend({
callback: function() {
if(arguments.length == 0 || typeof arguments[0] != "string") { throw "You must specify a method name (as a String)"; };
var self = this,
args = Array.prototype.slice.call(arguments),
name = args.shift(),
meth = self[name];
if (typeof meth === 'function') { return function curriedMethod() {
return meth.apply(self, args.concat(Array.prototype.slice.call(arguments)));
};
person: {
name: 'matt'
age: 34
}
ok 'name' of person # OF tests object property names
ok 'matt' in person # IN tests object values (CURRENTLY FAILS)
brothers: ['matt', 'dan', 'sam']
@mattmccray
mattmccray / Cakefile
Created August 9, 2010 06:23
Cakefile for compiling Coffee and LESS files, optionally compressing them with YUIC
###
Web Toolkit v0.4 (by M@ McCray)
http://gist.github.com/515035
NOTE: This is meant to be used as a Cakefile (Coffee's RAKE equivalent).
###
COFFEE_SRC="source/coffee"
@mattmccray
mattmccray / sudo.sh
Created September 27, 2010 03:03
Some (somewhat) useful shell scripts
# Wrap sudo to handle aliases and functions
# Wout.Mertens@gmail.com
#
# Comments and improvements welcome
sudo ()
{
local c o t parse
# Parse sudo args