Skip to content

Instantly share code, notes, and snippets.

View stefan-vatov's full-sized avatar
🦀
rock on

Stefan Vatov stefan-vatov

🦀
rock on
View GitHub Profile
@stefan-vatov
stefan-vatov / snippet.sh
Created January 20, 2023 22:00
yt-dlp windows
youtube-dl -i -r 3M -s --prefer-free-formats --embed-thumbnail --yes-playlist https://www.youtube.com/playlist?list=PLZ_57qANz90qDJS1MeqMrXtaR7y4hwhOC
yt-dlp -F https://www.youtube.com/playlist?list=PLZ_57qANz90qDJS1MeqMrXtaR7y4hwhOC
yt-dlp -f 299 --embed-thumbnail https://www.youtube.com/playlist?list=PLZ_57qANz90qDJS1MeqMrXtaR7y4hwhOC
https://www.youtube.com/watch?v=_9aUy56n-yI&list=
@stefan-vatov
stefan-vatov / snippet.sh
Created March 1, 2022 11:54
[Bash ternary] quick if-else in bash
# Source: https://stackoverflow.com/questions/3953645/ternary-operator-in-bash
[[ $b = 5 ]] && a="$c" || a="$d"
# or
a=$([ "$b" == 5 ] && echo "$c" || echo "$d")
@stefan-vatov
stefan-vatov / general.note.md
Last active January 16, 2022 01:38
[Obsidian templates]

<%* let title = tp.file.title if (title.startsWith("Untitled")) { title = await tp.system.prompt("Title"); await tp.file.rename(title); } tR += "---" %> Status: #inbox Title: <%* tR += title %>

@stefan-vatov
stefan-vatov / script.sh
Created January 6, 2022 12:01
[bash script user input] get user input from bash
read USERNAME
echo $USERNAME
# Hidden
read -s PASSWORD
echo $PASSWORD
@stefan-vatov
stefan-vatov / snippet.sh
Last active January 6, 2022 12:00
[std in user input bash] Re-enable user input in case stdin is already redirected
# Source: https://stackoverflow.com/questions/6561072/why-wont-bash-wait-for-read-when-used-with-curl
read git_name < /dev/tty # per-command I/O redirection
#read git_name < /dev/console # alternative
exec 0</dev/tty # script-wide I/O redirection
read git_name
@stefan-vatov
stefan-vatov / snippet.sh
Created September 28, 2021 11:53
[capture curl http code and result]
STATUSCODE=$(curl --silent --output result.txt --write-out "%{http_code}" --request GET URL)
cat result.txt
if test $STATUSCODE -ne 200; then
exit 1
fi
@stefan-vatov
stefan-vatov / script.sh
Created August 29, 2021 19:17
[ffmpeg flac to alac]
ffmpeg -i "<name>.flac" -acodec alac "<name>.m4a"
@stefan-vatov
stefan-vatov / script.sh
Created June 23, 2021 18:14
[Check exit code of last command] #bash #shell
if [[ $? -eq 22 ]];
then
// code
else
// code
fi
@stefan-vatov
stefan-vatov / index.ts
Created June 13, 2021 03:29
[Async Wrap]
export const asyncWrap = (promise: Promise<any>) =>
promise.then((res) => ({ res, error: null })).catch((error) => ({ res: null, error }));
@stefan-vatov
stefan-vatov / IValidators.ts
Created June 13, 2021 03:26
[Validation with folktale]
import { IBasicObject } from './objects';
export interface IValidator<T> {
run: IValidatorRun<T>;
concat: (other: IValidator<T>) => IValidator<T>;
}
export type ValidatorTypes = [] | undefined | string;
export type IValidatorRun<T> = (key: string, x: T, rec: IBasicObject) => IValidator<T>;