Skip to content

Instantly share code, notes, and snippets.

yeah, that

B. Agustín Amenábar Larraín baamenabar

yeah, that
View GitHub Profile
View Quick-fuzzy-search-jQuery.markdown
baamenabar / common.js
Last active Aug 29, 2015
Common useful functions for JavaScript
View common.js
var Common = {
addEvent : function(ele, evType, fn, useCapture) {
if (ele.addEventListener) {
ele.addEventListener(evType, fn, useCapture);
return true;
}else if (ele.attachEvent) {
var r = ele.attachEvent('on' + evType, fn);
return r;
} else {
ele['on' + evType] = fn;
baamenabar / gist:d1e44adb6fa9c0a6a13d
Last active Aug 29, 2015
Hoja de estilos sólo para IE8 o superior, más hoja de estilo sólo para ie7 e inferior
View gist:d1e44adb6fa9c0a6a13d
<!--[if lt IE 8 ]><link rel="stylesheet" href="/styles/legacy-ie.css" /><![endif]-->
<!--[if gt IE 9]><!--><link rel="stylesheet" href="/styles/styles.css" /><!--<![endif]-->
baamenabar / touch-detect.js
Last active Aug 29, 2015 — forked from nikoskip/gist:f6ee7b8191945b97adaf
Detect touch and no-touch devices.
View touch-detect.js
// It will add the appropriate class to <html> node
// This should only be used in combination with media queries detecting wide screens, because it is not reliable.
// Always use with a mobile-first approach
var root = document.documentElement;
if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
root.className += ' touch';
} else {
root.className += ' no-touch';
View gist:e1cf36c5882e71154710
* Útil cuando se necesita calcular el tamaño de un paquete a enviar en el cual
* dentro van N productos con distintas medidas.
* Con este algoritmo se puede obtener el tamaño de la caja contenedora final necesaria.
$dimensiones = array(0, 0, 0); // Largo, alto, ancho
baamenabar / importer.php
Created Oct 1, 2014
Download and deflate a ZIP file from a remote address.
View importer.php
$url = '';
$path = '';
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
baamenabar / clearfix-snippet.css
Created Mar 12, 2015
Simple clearfix for > IE8
View clearfix-snippet.css
.clearfix:after {
baamenabar / n-of-m-columns.scss
Created Mar 12, 2015
Column percentage calculator SASS mixin
View n-of-m-columns.scss
* MIXIN n-of-m-columns
* calculates the adequate percentage width and gutter percentage
* @param $n: number of columns to calculate
* @param $m number of total columns in the row
$gridGutter: 24px;
$defaultWidth: 984px;
@mixin n-of-m-columns($n:1, $m:3){
View JavaScript ES5 simple polyfills.js
* This is a simple list of ES5 JS polyfills and snippets I commonly need to add to code for it to run on IE8 or legacy JS engines.
* No particular order.
// Check for __proto__ support.
function a() {}
if ( (new a).__proto__ === a.prototype ){
View base64-font-loading-annotated.js
* Localstorage for webfonts
* This file should me minified/uglified and injected directly on the head.
* also absolute path to the static server should be used for the css files that get ajaxed.
(function () {
'use strict';
// once cached, the css file is stored on the client forever unless