Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View baamenabar's full-sized avatar
:octocat:
yeah, that

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

:octocat:
yeah, that
View GitHub Profile
@baamenabar
baamenabar / rename-with-md5sum.sh
Last active September 23, 2022 09:13
in shell bash: Read a file, get the md5 checksum, save it in a variable, make a copy of the file with the hash,
#!/bin/bash
# http://stackoverflow.com/questions/3679296/only-get-hash-value-using-md5sum-without-filename
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
baamenabar / WebPageTest Scraper.js
Created November 25, 2015 14:18
Little bookmarklet scraper to get test results from a webpagetest.org into a table.
// 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');
/**
* Localstorage for webfonts
* WIP
*
* 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
/**
* 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 ){
alert('supported');
}else{
@baamenabar
baamenabar / special-char-by-eu-lang.md
Created May 6, 2015 08:28
Special caracters by European Language
@baamenabar
baamenabar / n-of-m-columns.scss
Created March 12, 2015 19:07
Column percentage calculator SASS mixin
/**
* 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
baamenabar / clearfix-snippet.css
Created March 12, 2015 13:51
Simple clearfix for > IE8
.clearfix:after {
content:"";
display:table;
clear:both;
}
/*
From:
http://cssmojo.com/latest_new_clearfix_so_far/
*/
@baamenabar
baamenabar / importer.php
Created October 1, 2014 19:29
Download and deflate a ZIP file from a remote address.
<?php
$url = 'http://g.m0.cl/sistema/ci_assaabloy.zip';
$path = 'importado.zip';
$fp = fopen($path, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$data = curl_exec($ch);
@baamenabar
baamenabar / move.php
Created September 25, 2014 19:02
PHP move all files and folders from one directory to a new directory
<?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;
<?php
/**
* Ú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