Skip to content

Instantly share code, notes, and snippets.

View alvaaz's full-sized avatar
🏠
Working from home

Álvaro alvaaz

🏠
Working from home
View GitHub Profile
@alvaaz
alvaaz / aberracion.ts
Created May 31, 2023 18:45
Aberración para relativeDate
export function calcDate(date1: any, date2: any) {
//new date instance
const dt_date1 = new Date(date1);
const dt_date2 = new Date(date2);
//Get the Timestamp
const date1_time_stamp = dt_date1.getTime();
const date2_time_stamp = dt_date2.getTime();
@alvaaz
alvaaz / registro-civil-hours.js
Last active August 25, 2022 20:56
Próximas horas del Registro Civil en JS
/*
Créditos a Sebastian Wilson
https://codepen.io/swilsont/pen/poLGxZe
Ayuda a buscar la próxima hora disponible en el Registro Civil.
Genera un archivo de texto plano donde las columnas son separadas usando $separator .
Este archivo puede ser cargado posteriormente en Excel, y al ordenar por la columna 'fecha_hora'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alvaaz
alvaaz / arrow.svg
Last active September 17, 2020 16:36
arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alvaaz
alvaaz / destructuringEnhacement.js
Created February 20, 2019 15:41
Destructuring and enhacement
const banda = 'Metallica'
const genero = 'Heavy Metal'
const canciones = ['Master of Puppets', 'Enter Sandman', 'Seek & Destroy']
//Object Literal Enhacement
const metallica = {banda, genero, canciones};
//Object Destructuring
const {banda, genero, canciones} = metallica
@alvaaz
alvaaz / tagged-templates.js
Created January 25, 2019 02:06
Tagged template
function highlight(strings, ...values){
let str = '';
strings.forEach((string, i) => {
str += `${string} <span class="hl">${values[i] || ''}</span>`;
});
return str;
}
const name = 'Snickers';
const age = 100;
@alvaaz
alvaaz / validarRUT.js
Created December 28, 2018 18:56
Validar RUT Vanilla JS
//Validar rut
function cleanRut(_value) {
return typeof _value === 'string' ? _value.replace(/[^0-9kK]+/g,'').toUpperCase() : '';
}
function formatRut(_value, _default) {
_value = cleanRut(_value);
if(!_value) return _default;
if(_value.length <= 1) return _value;
@alvaaz
alvaaz / ArrayTransformation.js
Created September 11, 2018 23:05
ArrayTransformation.js
const pasarAlturaACms = persona => ({
...persona,
altura: persona.altura * 100
})
let personasCms = personas.map(pasarAlturaACms)
@alvaaz
alvaaz / ArrayReduce.js
Created September 11, 2018 23:03
ArrayReduce.js
const reducer = (acum, { cantidadDeLibros }) => acum + cantidadDeLibros
let totalDeLibros = personas.reduce(reducer, 0)