Skip to content

Instantly share code, notes, and snippets.

@Mr2P
Mr2P / jQuery-plugin-boilerplate
Created March 1, 2012 00:53
jQuery plugin boilerplate based on Jeffrey Way's work
// polyfill for unsupported browsers
if( Object.create !== 'function'){
Object.create = function (o){
function F(){};
F.prototype = o;
return new F();
}
}
(function($, window, document, undefined){
@Mr2P
Mr2P / css-slideshow-without-page-jump.css
Created June 4, 2012 14:15
CSS Slideshow without Page Jump
/**
* Pure CSS3 Slideshow Without Page Jump by Taufik Nurrohman
* 26 April 2012
* http://hompimpaalaihumgambreng.blogspot.com
*/
body {
background-color:black;
height:2000px;
color:#999;
@Mr2P
Mr2P / gist:2905971
Created June 10, 2012 14:39
Common css classes from Twitter Bootstrap
/*
Reset
Adapted from Normalize.css http://github.com/necolas/normalize.css
------------------------------------------------------------------------
Display in IE6-9 and FF3
-------------------------
*/
article,
aside,
@Mr2P
Mr2P / gist:3081898
Created July 10, 2012 07:50
background size cover polyfill for IE (6, 7, 8)
!function ($) {
"use strict"; // jshint ;_;
var BGCover = function (element, options) {
this.$element = $(element);
this.options = options;
this.init();
}
@Mr2P
Mr2P / rAF.js
Created July 25, 2012 00:23 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller
// fixes from Paul Irish and Tino Zijdel
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
// find out what prefix this browser supports.
// usage: gimmePrefix('transform') // 'WebkitTransform'
// returns false if unsupported.
function gimmePrefix(prop){
var prefixes = ['Moz','Khtml','Webkit','O','ms'],
elem = document.createElement('div'),
upper = prop.charAt(0).toUpperCase() + prop.slice(1);
@Mr2P
Mr2P / gist:3176712
Created July 25, 2012 15:15
Detect CSS3 Support
//Jeffrey Way
//http://net.tutsplus.com/tutorials/html-css-techniques/quick-tip-detect-css-support-in-browsers-with-javascript/
var supports = (function() {
var div = document.createElement('div'),
vendors = 'Khtml Ms O Moz Webkit'.split(' '),
len = vendors.length;
return function(prop) {
if ( prop in div.style ) return true;
@Mr2P
Mr2P / gist:3486040
Created August 27, 2012 05:59 — forked from remy/gist:350433
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@Mr2P
Mr2P / gist:3522184
Created August 30, 2012 03:57
check a boolean variable is true or not
// javascript: check a condition variable is set to true or not
x = !!( 'undefined' != typeof x && x);
@Mr2P
Mr2P / Wordpress: Append span tag to each "tag item" returned from get_the_tag_list()
Created November 4, 2012 17:18
Wordpress: Append span tag to each "tag item" returned from get_the_tag_list()
$tags_list = get_the_tag_list( 'Tags: ', __( ', ', 'text_domain' ) );
preg_replace_callback('/<a\b[^>]*>(.*?)<\/a>/',create_function('$matches','return "$matches[1]";'),$tags_list);
preg_replace('/(<a\b[^>]*>)(.*?)(<\/a>)/', '$1<span class="tag-label">$2</span>$3', $tags_list);