Skip to content

Instantly share code, notes, and snippets.

View mpjura's full-sized avatar

Mike Pjura mpjura

  • Hearst Digital Media
  • NY
View GitHub Profile
@mpjura
mpjura / pixel-percent.js
Created October 24, 2012 19:58
PixelToPercent / PercentToPixel
/*jshint browser:true */
/*global _ */
//requires underscore.js for debounced function
(function(win, _){
"use strict";
var width = win.innerWidth,
handleResize;
win.pixelToPercent = function pixelToPercent(pixel){
@mpjura
mpjura / get-params.js
Created October 1, 2012 18:31
getParams
function getParams(key){
var url = window.location.href,
params = {}, i;
url = url.split('#')[0].split('?')[1];
if ( !url ) return undefined;
url = url && url.split('&');
while ( i = url.shift() ){
i = i.split('=');
params[ i[0] ] = i[1] || true;
}
@mpjura
mpjura / gist:3782195
Created September 25, 2012 14:16 — 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();
@mpjura
mpjura / to-dollars
Created August 26, 2012 20:25
Function that converts numbers to dollar amounts
/*jshint devel:true */
(function(){
"use strict";
var toDollarAmount = function toDollarAmout(amount, returnAsString){
var ret;
if ( 'number' !== typeof amount ){
return false;
}
ret = amount.toFixed(2);
return ( returnAsString ) ? '$' + ret : +ret;
@mpjura
mpjura / jquery-lazy-images.html
Created December 30, 2011 17:14
Lazy Loading Images w/ jQuery
<div class="lazyImage" data-src="http://baconmockup.com/200/200" data-width="200" data-height="200" data-title="Mmmm Bacon"></div>