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 / special-char-by-eu-lang.md
Created May 6, 2015 08:28
Special caracters by European Language
/**
* 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{
/**
* 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
@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');
@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 / async-consecutive.js
Created March 17, 2016 13:43
async each for an array
/**
* for each item in the array, call a function, but only after the previous has called the callback.
**/
function consecutive (list, task) {
var count = 0;
function step() {
var item = list[count];
//console.log(count++);
if(typeof item === 'undefined') {
@baamenabar
baamenabar / udus.sh
Last active March 7, 2017 21:47
Provisioning script for flyimg on digital ocean
#!/bin/bash
#
# Commented provisioning script for a flyimg server
# Created for Ubuntu 16 but works with 14 and possibly with other distributions
# This script is intended to be used as a root user
# This script should be ideally invoqued by a Cloud-init script
# Read more at: https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting#run-arbitrary-commands-for-more-control
#
# Original Gist at: https://gist.github.com/baamenabar/2a825178318d27fc20abfe5a413b45eb
# Author B. Agustin Amenabar L. @iminabar
@baamenabar
baamenabar / do-flyimg-cloud-config.yml
Last active March 7, 2017 21:19
Cloud Config for flyimg in DIgitalocean
#cloud-config
users:
- name: leopold
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
package_upgrade: true
packages:
- git
- docker.io
@baamenabar
baamenabar / extractor-de-vehiculos.js
Last active June 30, 2017 13:46
Un script scraper, para extraer listas de vehículos de las estadísticas de el registro civil de Chile.
// script para scrape de registro civil
var elAno = '2017';
var request = new XMLHttpRequest();
var nuevoLin = undefined;
var saltarLin = undefined;
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
//console.log('volvió! con:',request.responseText)
var eldiv = document.createElement('div');
var laMarca = request.responseURL.split('/PrimerasBUS_').pop().split('_'+elAno+'.')[0];
@baamenabar
baamenabar / get-docs-from-chrome-har-file.js
Created May 21, 2017 08:44
Get network data only for docs from Chrome .har file
// you can load the har however you like.
var har = 'paste json har content here';
har.log.pages.forEach(item => {
item.data = har.log.entries.find(element => {
return element.request.url == item.title;
});
console.log(JSON.stringify(item.data));
})