Skip to content

Instantly share code, notes, and snippets.

View piotrlewandowski's full-sized avatar

Piotr Lewandowski piotrlewandowski

View GitHub Profile
@piotrlewandowski
piotrlewandowski / 0_reuse_code.js
Created December 26, 2013 18:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
var TrafficModule = (function (module) {
var newPercentIsValid = function (newPercent) {
var intPercent = parseInt(newPercent);
return (intPercent <= 100) && (intPercent % 20 === 0);
};
module.updateTraffic = function (newPercent) {
window._eventLog = (function(longTime, important) {
var eventLog = [];
eventLog.getLongEvents = function(time) {
time = time === undefined ? longTime : time;
return this.filter(function(el) {
return el.time > time;
})
}
// Should we filter mousemove?
(function() {
var method;
var noop = function noop() {};
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
var length = methods.length;
var console = (window.console = window.console || {});
while (length--) {
method = methods[length];
if (!console[method]) {
console[method] = noop;
//Google Map Skin - Get more at http://snazzymaps.com/
var myOptions = {
zoom: 14,
center: new google.maps.LatLng(43.493184, -1.495102),
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
styles: [
{
"featureType": "water",
"elementType": "geometry.fill",
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
@piotrlewandowski
piotrlewandowski / ie11-only.md
Last active August 29, 2015 14:26 — forked from mgol/ie11-only.md
How to easily not serve JS and/or CSS to IE<11

Here's how to make your site not load CSS and/or JS in IE older than 11:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=8,9,11">
        <title>Page title</title>
        <!--[if !IE]>-->
 
@piotrlewandowski
piotrlewandowski / tiny-pubsub.js
Created September 7, 2015 11:47
jQuery Tiny Pub/Sub
/*! Tiny Pub/Sub - v0.7.0 - 2013-01-29
* https://github.com/cowboy/jquery-tiny-pubsub
* Copyright (c) 2013 "Cowboy" Ben Alman; Licensed MIT */
(function($) {
'use strict';
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@piotrlewandowski
piotrlewandowski / mediator.js
Created September 7, 2015 13:15
JS Mediator Pattern Implementation
var mediator = (function() {
'use strict';
var
subscribe = function(channel, fn) {
if (!mediator.channels[channel]) {
mediator.channels[channel] = [];
}
mediator.channels[channel].push({ context: this, callback: fn });
@piotrlewandowski
piotrlewandowski / index.html
Last active September 21, 2015 18:30 — forked from mszynka/index.html
CSS stylesheet lazyloader
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>LazyLoader</title>
<noscript>
<link href="style.css" rel="stylesheet">
</noscript>
</head>
<body>