Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Pjura mpjura

  • Hearst Digital Media
  • NY
View GitHub Profile
@mpjura
mpjura / debug-console.js
Last active Aug 29, 2015
Overwrite console to only run when debug conditions are met
View debug-console.js
(function( window ){
var console = window.console;
var methods = ["log","dir"],
old = {};
//TODO - set this via query param or whatever you want
var debug = true;
View gist:d76cfb1ba2193c3d4ce4
/* Rule Id: 418180 */
/* Rule Id: 404574 */
(function doAdTargeting() {
//wait for jquery
if (undefined === window.$) {
setTimeout(doAdTargeting, 10);
return;
}
@mpjura
mpjura / debounced-scroll.js
Last active Aug 29, 2015
Debounced Scroll for Ads
View debounced-scroll.js
if ( !window.requestAnimationFrame ){
window.requestAnimationFrame = (function(){
return window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( callback ) {
window.setTimeout( callback, 1000 / 60 );
};
})();
View ae.js
var aeConfig = {
//URL of the Audience Engine end point
endpoint: "engine.hdmtools.com/get_teaser_block.json.php",
//Array of "blocks" (lists of stories) created in Audience Engine
blocks: [
{
//Each block has a name
name: "Smart Tout?",
//The container of the module being populated by Audience Engine
@mpjura
mpjura / jquery-lazy-images.html
Created Dec 30, 2011
Lazy Loading Images w/ jQuery
View jquery-lazy-images.html
<div class="lazyImage" data-src="http://baconmockup.com/200/200" data-width="200" data-height="200" data-title="Mmmm Bacon"></div>
@mpjura
mpjura / to-dollars
Created Aug 26, 2012
Function that converts numbers to dollar amounts
View to-dollars
/*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 / gist:3782195
Created Sep 25, 2012 — forked from remy/gist:350433
Storage polyfill
View gist:3782195
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();
View get-params.js
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 / pixel-percent.js
Created Oct 24, 2012
PixelToPercent / PercentToPixel
View pixel-percent.js
/*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 / _article.scss
Last active Dec 11, 2015
Typography/Layout Placeholders
View _article.scss
// base _article.scss
// ------------------
.article-hed {
@extend %layout-article-hed;
@extend %type-article-hed;
}
.article-dek {
@extend %layout-article-dek;
@extend %type-article-dek;
You can’t perform that action at this time.