Skip to content

Instantly share code, notes, and snippets.

View pazguille's full-sized avatar

Guille Paz pazguille

View GitHub Profile
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 / 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]-->
@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]-->
(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;
}
<link rel="shortcut icon" href="favicon.ico">

NodeList vs Array

A NodeList is a reference to a collection of objects, and if that collection changes (for example, elements are added or removed) the NodeList will automatically update to reflect that change; conversely our array is a static snapshot of the collection at one point in time, and so won’t update in response to changes in the DOM. Depending on your application, that could be significant.

Source: Sitepoint

function offline() {
document.body.innerHTML = 'You are offline :(';
}
function online() {
document.body.innerHTML = 'You are online :)';
}
window.addEventListener('load', function(e) {
if (navigator.onLine) {
@pazguille
pazguille / mango-token.html
Last active August 29, 2015 14:14
Mango: Obtener los datos de tarjeta y crear un token.
<!doctype html>
<html lang="es">
<head>
<meta charset="utf-8">
<title>Mango</title>
</head>
<body>
<form id="form" action="/your-server" method="POST">
@pazguille
pazguille / index.js
Created February 13, 2015 16:23
JavaScript Blocks
function test(printTwo) {
printing: {
console.log("One");
if (!printTwo) break printing;
console.log("Two");
}
console.log("Three");
}
@pazguille
pazguille / node-install
Created April 17, 2012 13:49
Install NodeJS - Amazon Fedora
Install base tools:
yum groupinstall "Development Tools"
Now install openssl-devel:
yum install openssl-devel
Esta instalado en sudo su -
Install+update NODE:
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.basic