Skip to content

Instantly share code, notes, and snippets.

View pazguille's full-sized avatar

Guille Paz pazguille

View GitHub Profile
(function (window, n) {
'use strict';
var storage = window.localStorage;
var count = parseInt(storage.getItem('gkcounter'), 10) || 0;
if (count >= n) {
alert('Create a new instance of gesturekit');
return;
}
@pazguille
pazguille / index.html
Created March 21, 2014 18:08
Conditional Comments (jQuery or Zepto)
<!--[if lte IE 9]><script src="http://code.jquery.com/jquery-1.11.0.min.js"></script><![endif]-->
<!--[if gt IE 9]><!--><script src="http://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.3/zepto.min.js"></script><!--<![endif]-->
@pazguille
pazguille / index.html
Last active August 29, 2015 13:57
Conditional comments
<!doctype html>
<!-- Conditional comment for mobile ie7 http://blogs.msdn.com/b/iemobile/ -->
<!--[if IEMobile 7 ]><html class="iem7"><![endif]-->
<!--[if IE 8]><html class="ie8 lt-ie10"><![endif]-->
<!--[if IE 9]><html class="ie9 lt-ie10"><![endif]-->
<!--[if gt IE 9]><!--><html><!--<![endif]-->
var fileInput = document.getElementById('file');
fileInput.addEventListener('change', function () {
var img = document.createElement('img');
img.width = "200";
img.src = URL.createObjectURL(fileInput.files[0]);
document.body.appendChild(img);
});
@pazguille
pazguille / parseScript.js
Last active January 3, 2016 03:09
This function can be used to execute the JavaScript code received in the Ajax response.
function parseScript(code) {
var script = document.createElement('script');
// script.insertAdjacentText('beforeend', code); Don't work on FF
script.innerHTML = code;
document.body.appendChild(script);
}
@pazguille
pazguille / dabblet.html
Created November 4, 2013 13:40
Untitled
<!-- content to be placed inside <body>…</body> -->
@pazguille
pazguille / modular.js
Last active December 26, 2015 21:09
Modular Pattern
/*
* Component
*/
(function (win) {
'use strict';
/**
* Component definition
*/
@pazguille
pazguille / index.html
Last active April 26, 2024 08:23
Simple JavaScript Templating by John Resig
<script type="text/html" id="item_tmpl">
<div id="<%=id%>" class="<%=(i % 2 == 1 ? " even" : "")%>">
<div class="grid_1 alpha right">
<img class="righted" src="<%=profile_image_url%>"/>
</div>
<div class="grid_6 omega contents">
<p><b><a href="/<%=from_user%>"><%=from_user%></a>:</b> <%=text%></p>
</div>
</div>
</script>
/**
* Singleton Pattern
*/
function Singleton(options) {
if (!(this instanceof Singleton) && Singleton.getInstance === undefined) {
Singleton.getInstance = new Singleton();
return Singleton.getInstance;
}