Skip to content

Instantly share code, notes, and snippets.

View emlautarom1's full-sized avatar
⛓️

Lautaro Emanuel emlautarom1

⛓️
View GitHub Profile
@emlautarom1
emlautarom1 / restore-set.ts
Last active April 17, 2023 17:44
A Set with checkpoints and restore functionality
/**
* Opaque type used by `RestoreSet<T>` to handle restoration.
*/
class Checkpoint {
constructor(public _value: number) { }
}
/**
* A set-like object that stores arbitrary `T` elements. At any point in time,
* the user can create a `Checkpoint` which then can be used to restore the state of the structure.
@emlautarom1
emlautarom1 / infinite.ts
Created January 29, 2022 01:05
Depaginate & share infinite stream
import { defer, from, Observable, of } from 'rxjs';
import { take, expand, mergeMap, tap, concatWith } from 'rxjs/operators';
interface Result {
page: number;
items: number[];
}
// Assume that this does a real HTTP request
function fetchPage(page: number = 0): Observable<Result> {
@emlautarom1
emlautarom1 / Windowing.md
Created November 4, 2021 20:11
Windowing Problem

Windowing Problem

[...] you may [...] be stuck with data containing two-digit year fields. You have tried to get it expanded to four digits at the source, but it simply cannot be done.

In this case, you need to adopt a technique called "windowing". Windowing means taking the two-digit year and applying common sense to determine the century that it belongs in.

Obviously, windowing cannot be used for data that might span a period greater than 100 years. For instance, the birth years of people in the general population. There have always been a number of people living beyond the age of 100, and as health care improves that number can only increase. If you code a birth year as "96", that could be either 1996, which would indicate a two-year-old, or 1896, which could indicate a 102-year-old. For a short time after the year 2000, there will be people alive who were born in three different centuries!

Source: https://www.uic.edu/depts/accc/software/isodates/fixing.html

@emlautarom1
emlautarom1 / youtube-audio-increase.js
Created August 23, 2021 15:32
Increase Youtube volume
const video = document.querySelector('video');
const audioCtx = new AudioContext();
const mediaSource = audioCtx.createMediaElementSource(video);
const gainNode = audioCtx.createGain();
mediaSource.connect(gainNode);
gainNode.connect(audioCtx.destination);
// Increase this value for higher volume
gainNode.value = 50.00;
@emlautarom1
emlautarom1 / youtube-fix.js
Created August 13, 2021 18:14
Fix Youtube single-channel audio
/*
* Fix playback of videos where audio is playing from just one side.
* Just copy-paste into your browser console and run the code.
*/
var context = new AudioContext();
var videos = document.getElementsByTagName("video");
var audioElement = context.createMediaElementSource(videos[0]);
context.destination.channelCount = 1;
audioElement.connect(context.destination)
@emlautarom1
emlautarom1 / launch.bat
Created June 1, 2021 15:20
SFX Batch Java Launcher
@echo off
Set ExecutablePath=%~dp0
For %%A in ("%sfxname%") do (
Set AssetsPath=%%~dpA
)
cd %AssetsPath%
echo AssetsPath: %AssetsPath%
echo ExecutablePath: %ExecutablePath%
newtype State s a = State { runState :: s -> (s, a) }
instance Functor (State s) where
-- fmap :: (a -> b) -> State s a -> State s b
fmap g (State f) = State (\s ->
let (s', a) = f s
in (s', g a))
instance Applicative (State s) where
-- pure :: a -> (State s a)
@emlautarom1
emlautarom1 / GUIDE.md
Last active November 23, 2019 22:41
My Hackintosh Configuration Guide/Snippet

My Hackintosh Configuration Guide/Snippet

Important

These are the steps I followed in order to get Mac OS High Sierra 10.13.6 running in my PC. These may not work (and probably won't) on your machine if your build contains different components (like a different motherboard). This is not a proper guide or tutorial, just a reference for me or for anyone facing issues with a build like mine. You will need to read a bit about Hackintosh in order to get the most out of these notes.

My Build

  • CPU: Ryzen 5 3600 (Stock)
  • Motherboard: ASUS Crosshair VI Hero - BIOS v7601
@emlautarom1
emlautarom1 / add_alacritty_to_context_menu.reg
Last active November 12, 2021 09:05
Add alacritty to Windows context menu
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\alacritty]
@="Open Alacritty here"
"Icon"="C:\\programdata\\chocolatey\\bin\\alacritty.exe"
[HKEY_CLASSES_ROOT\Directory\Background\shell\alacritty\command]
@="\"C:\\programdata\\chocolatey\\bin\\alacritty.exe\" \"--working-directory\" \"%V%\""