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 / FlieList-mock-creator.ts
Created Sep 13, 2020
Create a mock FileList to test file upload components.
View FlieList-mock-creator.ts
/** list of mock File elements to pass the input[file] */
export function getBrowsedFiles(): FileList {
return fileListFromArray([
mockFileCreator({ name: 'file-one.png', type: 'image/png', size: 234 * 1000 }),
mockFileCreator({ name: 'file-two.gif', type: 'image/gif', size: 56 * 1000 }),
export function mockFileCreator({
name = 'file.txt',
baamenabar /
Last active Oct 15, 2019
Installing Docker, setting it up for Jenkins, and installing Jenkins.
# Copied from:
# Updated with :
# this script is only tested on ubuntu xenial and bionic
# sudo is only if you are not on root (you should not be on root)
# Uninstall previous versions of docker
sudo apt-get remove docker docker-engine containerd runc
sudo apt-get update
baamenabar /
Last active Jan 7, 2019
Don't forget how to build and start Flyimg in windows 10 home environment with Cmder (conEmu)
# Windows only: Don't forget how to build and start Flyimg in windows 10 home environment with Cmder (conEmu)
# Must have virtualbox installed, ideally through docker toolbox
# do this only once
docker-machine create --driver virtualbox default
# all the subsequent times, only this
docker-machine start default
# hook the virtual env to docker
baamenabar / stat-is-folder-comparison.js
Created Jul 11, 2018
Compare different approaches and node 10.x APIs to stat a directory or folder, and by extension do many fs operations. Includes experiment with fs promises
View stat-is-folder-comparison.js
const fs = require("fs");
const fsPromises = require("fs").promises;
* Util function we will reuse to check if the caught error is simply a "not found" error
* @param {*} err
* @returns {boolean}
function isErrorNotFound(err) {
View md5-hash-in-node.js
const fileHash = crypto.createHash('md5').update(fileContents).digest('hex');
baamenabar / get-docs-from-chrome-har-file.js
Created May 21, 2017
Get network data only for docs from Chrome .har file
View get-docs-from-chrome-har-file.js
// you can load the har however you like.
var har = 'paste json har content here';
har.log.pages.forEach(item => { = har.log.entries.find(element => {
return element.request.url == item.title;
baamenabar / extractor-de-vehiculos.js
Last active Jun 30, 2017
Un script scraper, para extraer listas de vehículos de las estadísticas de el registro civil de Chile.
View extractor-de-vehiculos.js
// 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 / do-flyimg-cloud-config.yml
Last active Mar 7, 2017
Cloud Config for flyimg in DIgitalocean
View do-flyimg-cloud-config.yml
- name: leopold
groups: sudo
shell: /bin/bash
package_upgrade: true
- git
baamenabar /
Last active Mar 7, 2017
Provisioning script for flyimg on digital ocean
# 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:
# Original Gist at:
# Author B. Agustin Amenabar L. @iminabar
baamenabar / async-consecutive.js
Created Mar 17, 2016
async each for an array
View async-consecutive.js
* 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];
if(typeof item === 'undefined') {