Skip to content

Instantly share code, notes, and snippets.

View AlexAegis's full-sized avatar
🦔
ʕ•ᴥ•ʔ

Sandor AlexAegis

🦔
ʕ•ᴥ•ʔ
View GitHub Profile
@AlexAegis
AlexAegis / environment.interface.ts
Created April 8, 2021 12:56
Angular Generic Environment Setup
/**
* Environment shape
*/
export interface Environment {
/**
* Application version, straight from the package.json
*/
version: string;
/**
@AlexAegis
AlexAegis / parse_args.sh
Last active June 16, 2021 21:02
POSIX compliant argument parsing
#!/bin/sh
expand_single_args() {
var="${1#-}" # cut off first, and only dash
while [ "$var" ]; do
next="${var#?}"
first_char="${var%$next}"
echo "-$first_char"
var="$next" # next
done
@AlexAegis
AlexAegis / retrieve_npm_packages.sh
Created June 28, 2021 18:05
Recursively pack all dependencies of an npm project
#!/bin/sh
# This script will run npm pack on every dependency and dependencies of a dependency
# on 8 threads. It's useful if you want to then upload everything to a private registry.
mkdir packages
cd packages || exit 1
# There is some unwanted garbage in the output of `npm ls` hence the inverted greps
npm ls --all --registry https://registry.npmjs.org 2> /dev/null |
@AlexAegis
AlexAegis / finite-progress.operator.ts
Last active June 21, 2022 07:49
RxJS Loading and progress tracking pipeline operator with finite sources!
import { Observable, OperatorFunction } from 'rxjs';
import { tap, map, flatMap, mergeScan, reduce, finalize } from 'rxjs/operators';
/**
* This loader-manager pipeline should be attached to an observable that contains
* a finite amount of observables (preferrably using an of(), like here.)
*
* Loading starts when the source completes!
*
* These observables should be expected to complete, as the pipeline will
@AlexAegis
AlexAegis / convert_1money_to_wallet.sh
Last active July 30, 2022 11:39
A script to convert a 1Money CSV export into Wallet imports.
#!/bin/sh
# Converts a 1Money export to be used at Wallet
# Converts one Account at a time, places all found accounts into a folder
# called output
# Usage:
# ./convert_1money_to_wallet.sh 1moneyexport.csv
# Import settings:
# Go to https://web.budgetbakers.com/imports
@AlexAegis
AlexAegis / angular-megalistener.ts
Created April 22, 2019 21:50
Angular Megalistener - When you want to hear everything
@HostListener('abort', ['$event'])
@HostListener('afterprint', ['$event'])
@HostListener('animationend', ['$event'])
@HostListener('animationiteration', ['$event'])
@HostListener('animationstart', ['$event'])
@HostListener('beforeprint', ['$event'])
@HostListener('beforeunload', ['$event'])
@HostListener('blur', ['$event'])
@HostListener('canplay', ['$event'])
@HostListener('canplaythrough', ['$event'])
@AlexAegis
AlexAegis / buffered-all-settled.ts
Last active August 4, 2023 08:09
buffered-all-settled.ts
const task = (i: number): Promise<number> =>
new Promise((res, rej) => {
setTimeout(
() => {
if (i % 12 === 0) {
console.log('task reject', i);
rej('nope');
} else {
console.log('task resolve', i);
res(i);