Skip to content

Instantly share code, notes, and snippets.

Avatar
🥅
goal_net

Jacob Chapman chapmanjacobd

🥅
goal_net
View GitHub Profile
View badcode_alasql.js
export function obj2schema(obj: object | [], table: string, result = {}) {
if (obj) {
if (Array.isArray(obj)) return obj2schema(obj[0], table)
result[table] = Object.keys(obj).map(k => {
const v = obj[k];
if (Array.isArray(v)) obj2schema(v[0], k, result)
if (typeof v === 'object') return;
View GNU Parallel.md

Sequential jobs example:

tee example1.sh 
#!/bin/bash
printf 'cmd-to-run "%s"\n' "$@" | parallel -j1 --joblog p.log --resume --retries 3

Running this example1.sh taipeifilmcommission vihartvihart socallinuxexpo would start the following jobs and re-run them up to 3 times if they failed:

@chapmanjacobd
chapmanjacobd / mvl.fish
Created May 7, 2022
move lines of text
View mvl.fish
# requires moreutils
function mvl --description 'move lines'
argparse --min-args 2 'h/help' 's/search=' -- $argv
or return 1
set src $argv[1]
set dest $argv[2]
if set -q _flag_help
echo "Move lines of text from one file to another"
@chapmanjacobd
chapmanjacobd / reddit.fish
Last active May 10, 2022
yt-dlp tracking errors example
View reddit.fish
# requires fish shell, moreutils
# usage:
# 1. Create files with the subreddits you want to archive, one subreddit per line:
# echo "Wellington" >> ~/mc/WellingtonFolder-reddit.txt
# or use `reddit-add WellingtonFolder Wellington`
# 2. Run `reddit-links-update WellingtonFolder` to scrape links
# 3. Run `reddit-get-videos WellingtonFolder` to start yt-dlp
function ytUREs
string replace --all "
View bdfr+gallerydl+ytdl.fish
function reddit-photos-getter --argument dfolder url
cd $dfolder
gallery-dl --quiet --cookies ~/.local/cookies.txt --download-archive $HOME/.local/share/gallerydl.sqlite3 $url
if not test $status -eq 0 -o $status -eq 4 -o $status -eq 8 # https://github.com/mikf/gallery-dl/issues/1120
ytdl --quiet -f bestvideo[height<=576]+bestaudio/best[height<=576] --write-sub --write-auto-sub --sub-lang en --sub-format srt/sub/ssa/vtt/ass/best -- $url
end
end
function reddit-photos-get --argument dfolder subr
set tmpfile (mktemp)
View tabs_monthly.fish
function tabs-monthly
set file ~/mc/30_Computing-subreddits.monthly.cron
for ln in (seq (date +%d) (date +%d) (wc -l < $file))
echo $ln
set url (sed "$ln""q;d" $file)
open $url
end
end
View funcdel.fish
function funcdel --description 'Remove the current definition of all specified functions from session and file'
set -l options q/quiet h/help d/directory=
argparse -n funcdel $options -- $argv
or return
if set -q _flag_help
__fish_print_help funcdel
return 0
end
View fish_prompt.fish
# Defined via `source`
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
end
if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
end