Skip to content

Instantly share code, notes, and snippets.

@madrobby
madrobby / gist:30223
Created November 29, 2008 10:34 — forked from dhh/gist:29752
config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
// pure JS
function shuffle(array) {
return array.sort(function(){
return .5 - Math.random();
});
}
// with Prototype.js you can do
function shuffle(array){
return array.sortBy(Math.random);
function(s,k){k=s.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);return new Date(Date.UTC(k[1],k[2]-1,k[3],k[4],k[5],k[6]))}
@madrobby
madrobby / LICENSE.txt
Created May 19, 2011 12:06 — forked from 140bytes/LICENSE.txt
Email validation
Copyright (c) 2011 Thomas Fuchs, http://mir.aculo.us
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@madrobby
madrobby / webkitRequestAnimationFrame.html
Created April 5, 2012 06:40 — forked from jeremyckahn/webkitRequestAnimationFrame.html
An example of requestAnimationFrame (webkit version)
<b id=a>X<script>e=document.getElementById('a'),i=0;(function u(){e.style.marginLeft=++i+'px';webkitRequestAnimationFrame(u)})()</script>
@madrobby
madrobby / penner_beziers.js
Created June 24, 2012 19:32 — forked from jeremyckahn/penner_beziers.js
Penner beziers
var beziers = {
easeInQuad: '.55,.085,.68,.53',
easeInCubic: '.55,.055,.675,.19',
easeInQuart: '.895,.03,.685,.22',
easeInQuint: '.755,.05,.855,.06',
easeInSine: '.47,0,.745,.715',
easeInExpo: '.95,.05,.795,.035',
easeInCirc: '.6,.04,.98, .335',
easeInBack: '.6,-.28,.735,.045',
easeOutQuad: '.25,.46,.45,.94',
@madrobby
madrobby / penner_beziers.js
Created June 24, 2012 19:46 — forked from insin/penner_beziers.js
Penner beziers
var beziers={easeInQuad:".55,.085,.68,.53",easeInCubic:".55,.055,.675,.19",easeInQuart:".895,.03,.685,.22",easeInQuint:".755,.05,.855,.06",easeInSine:".47,0,.745,.715",easeInExpo:".95,.05,.795,.035",easeInCirc:".6,.04,.98, .335",easeInBack:".6,-.28,.735,.045",easeOutQuad:".25,.46,.45,.94",easeOutCubic:".215,.61,.355,1",easeOutQuart:".165,.84,.44,1",easeOutQuint:".23,1,.32,1",easeOutSine:".39,.575,.565,1",easeOutExpo:".19,1,.22,1",easeOutCirc:".075,.82,.165,1",easeOutBack:".175,.885,.32,1.275",easeInOutQuad:".455,.03,.515,.955",easeInOutCubic:".645,.045,.355,1",easeInOutQuart:".77,0,.175,1",easeInOutQuint:".86,0.07,1",easeInOutSine:".445,.05,.55,.95",easeInOutExpo:"1,0,0,1",easeInOutCirc:".785,.135,.15,.86",easeInOutBack:".68,-.55,.265,1.55"}
b=[".55,.085,.68,.53$.55,.055,.675,.19$.895,.03,.685,.22$.755,.05,.855,.06$.47,0,.745,.715$.95,.05,.795,.035$.6,.04,.98, .335$.6,-.28,.735,.045$.25,.46,.45,.94$.215,.61,.355,1$.165,.84,.44,1$.23,1,.32,1$.39,.575,.565,1$.19,1,.22,1$.075,.82,.165,1$.175,.885,.32,1.275$.455,.03,.515,.955$.645,.045,.355,1$.77,0,.175,1$.86,0.07,1$.445,.05,.55,.95$1,0,0,1$.785,.135,.15,.86$.68,-.55,.265,1.55"].split('$')
@madrobby
madrobby / penner_beziers.js
Created June 24, 2012 20:04 — forked from jeremyckahn/penner_beziers.js
Penner beziers
b=".55,.085,.68,.53$.55,.055,.675,.19$.895,.03,.685,.22$.755,.05,.855,.06$.47,0,.745,.715$.95,.05,.795,.035$.6,.04,.98, .335$.6,-.28,.735,.045$.25,.46,.45,.94$.215,.61,.355,1$.165,.84,.44,1$.23,1,.32,1$.39,.575,.565,1$.19,1,.22,1$.075,.82,.165,1$.175,.885,.32,1.275$.455,.03,.515,.955$.645,.045,.355,1$.77,0,.175,1$.86,0.07,1$.445,.05,.55,.95$1,0,0,1$.785,.135,.15,.86$.68,-.55,.265,1.55".split('$')
@madrobby
madrobby / LICENSE.txt
Created May 19, 2011 12:44 — forked from 140bytes/LICENSE.txt
Functional array sorting
Copyright (c) 2011 Thomas Fuchs, http://mir.aculo.us
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions: