Skip to content

Instantly share code, notes, and snippets.

yeah, that

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

yeah, that
View GitHub Profile
baamenabar /
Last active Jan 7, 2020
in shell bash: Read a file, get the md5 checksum, save it in a variable, make a copy of the file with the hash,
md5HASH=($(md5sum www/app/js/bundle.js| cut -d ' ' -f 1))
cp www/app/js/bundle.js www/app/js/bundle-$md5HASH.js;
# store in variable in file
echo "<?php define('HASH_EXT', '$md5HASH'); ?>" > www/app/inc/hash-bundle.php;
baamenabar / WebPageTest Scraper.js
Created Nov 25, 2015
Little bookmarklet scraper to get test results from a into a table.
View WebPageTest Scraper.js
// this is a Bookmarklet
// this must go in the url part of a browser bookmark (without the comments)
javascript: (function() {
var recoveredNumbers = [];
var toPrint = '';
var elementsSelectorList = ['#fvVisual', '#rvVisual', '#fvTTFB', '#rvTTFB', '#fvStartRender', '#rvStartRender', '#fvRequestsDoc', '#rvRequestsDoc', '#fvBytesDoc', '#rvBytesDoc' ];
var tableContainer;
var dateElement;
recoveredNumbers.push(document.querySelector('#header_data h2 span').innerHTML);
dateElement = document.querySelector('.heading_details .jsdate');
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
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 ){
baamenabar /
Created May 6, 2015
Special caracters by European Language
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){
baamenabar / clearfix-snippet.css
Created Mar 12, 2015
Simple clearfix for > IE8
View clearfix-snippet.css
.clearfix:after {
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 / move.php
Created Sep 25, 2014
PHP move all files and folders from one directory to a new directory
View move.php
$dir = ".";//"path/to/targetFiles";
$dirNew = "viejo2014";//path/to/destination/files
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo '<br>Archivo: '.$file;
//exclude unwanted
if ($file=="move.php")continue;
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