Skip to content

Instantly share code, notes, and snippets.

View NinoScript's full-sized avatar
🎩
Working my way to FI/RE

Cristián Arenas Ulloa NinoScript

🎩
Working my way to FI/RE
View GitHub Profile
export function groupBy<T, K>(array: T[], getKey: (value: T) => K): Map<K, T[]> {
return array.reduce(
(groups, item) => {
const key = getKey(item);
const innerArray = groups.get(key);
if (innerArray === undefined) {
groups.set(key, [item])
} else {
innerArray.push(item)
}
@NinoScript
NinoScript / EnumNSCoding.swift
Last active December 2, 2019 10:47
NSCoding a Swift Enum
//: Playground - noun: a place where people can play
import Cocoa
enum Enum {
case SimpleCase
case AssociatedValue(String)
case AnotherAssociated(Int)
}
extension Enum {
@NinoScript
NinoScript / randomColorGenerator.js
Last active November 28, 2021 15:57
You can use this generator to get nicely distributed color with the same saturation and lightness.
// TIL that a `function *` in JavaScript makes a generator.
// Generators "yield" values and their execution is paused until next() is called.
function * randomColorGenerator(initialHue, saturation, lightness) {
const phi = 0.618033988749895;
let hue = initialHue;
while(true) {
yield `hsl(${Math.round(hue)}, ${saturation}, ${lightness})`;
hue = (hue + phi * 360) % 360;
}
@NinoScript
NinoScript / APV.md
Created December 28, 2021 15:06
Explicación sobre el Ahorro Previsional Voluntario (APV) en Chile

Ahorro Previsional Voluntario (APV)

El APV es un instrumento para incentivarte a ahorrar más de lo que ahorras en la AFP.

Este incentivo tiene dos regímenes, el A y el B. Ambos te incentivan de maneras distintas, a veces conviene uno más que el otro, a veces conviene tener los dos. Y el incentivo tiene un tope combinado de 600UF de ahorro al año.

APV régimen A