Skip to content

Instantly share code, notes, and snippets.

View remy's full-sized avatar
🐹
Always hacking

Remy Sharp remy

🐹
Always hacking
View GitHub Profile
/*!
* jQuery ie6ize: Emulate IE-6 rendering - 11/13/2009
* http://mankzblog.wordpress.com/2009/11/13/ie6-frame-to-battle-chrome-frame/
*
* Created by Mats Bryntse
*
* Plugin-ified by "Cowboy" Ben Alman
* http://benalman.com/
*/
function Foo(name) {
this.type = 'foo';
}
Foo.prototype = {
name: function (name) {
if (name) {
this._name = name;
} else {
return this._name;
function Foo(name) {
this.type = 'foo';
}
Foo.prototype = {
name: function (name) {
if (name) {
this._name = name;
} else {
return this._name;
function isPrime( num ) {
if ( isPrime.cache[ num ] != null )
return isPrime.cache[ num ];
// everything but 1 can be prime
var prime = num != 1;
for ( var i = 2; i < num; i++ ) {
if ( num % i == 0 ) {
prime = false;
break;
var e = "touchstart touchmove touchend".split(' '),
i = e.length,
method = '';
while(i--) {
$.fn[method = e[i]] = function (fn) {
return fn ?
this.bind(method, fn) :
this.trigger(method);
};
var e = "touchstart touchmove touchend".split(' '),
i = e.length,
method = '';
while(i--) {
(function (method) { // method is now private
$.fn[method] = function (fn) {
return fn ?
this.bind(method, fn) :
this.trigger(method);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>Lazy Eval Technique</title>
</head>
<body>
<script id="lazy">
/*
alert('lazy module loaded');
@remy
remy / gist:256811
Created December 15, 2009 09:40
getQuery
function getQuery(s) {
var query = {};
s.replace(/\b([^&=]*)=([^&=]*)\b/g, function (m, a, d) {
if (typeof query[a] != 'undefined') {
query[a] += ',' + d;
} else {
query[a] = d;
}
});
@remy
remy / gist:259520
Created December 18, 2009 14:39
onorientationchange
// jQuery based patch for onorientationchange
(function () {
var w = window.innerWidth, h = window.innerHeight, el = $('body')[0];
if (!('onorientationchange' in el)) {
if (el.setAttribute) {
el.setAttribute('onorientationchange', 'return;');
if (!typeof element[eventName] == 'function') {
// patch support for the onorientationchange event via onresize
$(window).resize(function () {
// because I just needed the function to run once, then assign it -
// I knew that I'd never need to run it manually again, so here I
// extended the Function prototype :)
Function.prototype.runReturn = function () {
this.call();
return this;
};
// for example: