Skip to content

Instantly share code, notes, and snippets.

Avatar
🥅
goal_net

Jacob Chapman chapmanjacobd

🥅
goal_net
View GitHub Profile
View gist:6fea40459f27f514156bd553e9d87422
fd -tf -S-1mb -E map . node_modules/package/ -E '*.map' -E '*.d.ts' -E LICENSE -x cat |less -FSRXc
View yt.ogg.fish
function yt.ogg
cd ~/Music/New
youtube-dl -i --youtube-skip-dash-manifest -f bestaudio --extract-audio $argv --exec \
"ffmpeg -hide_banner -loglevel panic -y -i {} -c:a libopus -ac 2 -b:a 128k -vbr constrained -filter:a loudnorm=i=-18:lra=17 \"`echo {} | cut -f 1 -d '.' | sed 's/\$/.opus/'`\" && rm {} "
or youtube-dl -i -f bestaudio --extract-audio $argv --exec \
"ffmpeg -hide_banner -loglevel panic -y -i {} -c:a libopus -ac 2 -b:a 128k -vbr constrained -filter:a loudnorm=i=-18:lra=17 \"`echo {} | cut -f 1 -d '.' | sed 's/\$/.opus/'`\" && rm {} "
end
@chapmanjacobd
chapmanjacobd / medium-contrast.vscode
Created Sep 13, 2020
medium-contrast vscode theme
View medium-contrast.vscode
{
"$schema": "vscode://schemas/color-theme",
"type": "light",
"colors": {
"activityBar.background": "#080808",
"activityBarBadge.background": "#007acc",
"badge.background": "#000000",
"button.foreground": "#000000",
"editor.background": "#d1bca7",
"editor.findRangeHighlightBackground": "#000824",
View keyboarst.xmodmap
keycode 24 = q Q
keycode 25 = w W
keycode 26 = f F
keycode 27 = p P
keycode 28 = b B
keycode 29 = j J
keycode 30 = l L
keycode 31 = u U
keycode 32 = y Y
View less_boring_jsonb_to_record.sql
do
$$
declare
keys_u text;
begin
drop view if exists v_flat_u cascade;
select
string_agg(distinct format('data_json ->> %L as %I',rc, rc), ', ') data_json
into keys_u
View file type statistics
fd -tf | awk -F'.' '{print $NF}' | sort | uniq -c | sort -g
@chapmanjacobd
chapmanjacobd / swimming.ts
Last active Aug 13, 2020
swimlanes.io to XState FSM
View swimming.ts
swimlaneToXState(`
idle -> loading: fetch
loading -> success: resolve
loading -> failure: reject
failure -> loading: retry
`);
export function swimlaneToXState(swimlane: string) {
const initial = swimlane.split("->")[0].trim();
const states = swimlane
View rename utf8 files.fish
for file in (fd -tf)
set newFile (echo $file | unidecode)
if [ $file != $newFile ]
/usr/bin/mkdir -p (dirname "$newFile")
mv -v "$file" "$newFile"
else
end
end
@chapmanjacobd
chapmanjacobd / character equivalent class.sh
Created Aug 7, 2020
Enumerate POSIX character equivalent class
View character equivalent class.sh
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=a=]]$' | sponge a &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=b=]]$' | sponge b &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=c=]]$' | sponge c &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=d=]]$' | sponge d &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=e=]]$' | sponge e &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=f=]]$' | sponge f &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=g=]]$' | sponge g &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=h=]]$' | sponge h &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a '^[[=i=]]$' | sponge i &
for((i=0; i < 0x110000; i++)) { printf "\U$(printf "%x" $i)\n"; } | grep -a
@chapmanjacobd
chapmanjacobd / gist:39eb7ae5a20b98cc1c4634c6d516f5a0
Last active Aug 7, 2020
iconv doesn't have a way to prevent ? from overwritting illegal characters so I want to keep invalid characters but still translit and remove diacritics
View gist:39eb7ae5a20b98cc1c4634c6d516f5a0
--most extreme (makes everything lowercase)
diff non-ascii (bat non-ascii | sed 's/[[=a=]]/a/g; s/[[=b=]]/b/g; s/[[=c=]]/c/g; s/[[=d=]]/d/g; s/[[=e=]]/e/g; s/[[=f=]]/f/g; s/[[=g=]]/g/g; s/[[=h=]]/h/g; s/[[=i=]]/i/g; s/[[=j=]]/j/g; s/[[=k=]]/k/g; s/[[=l=]]/l/g; s/[[=m=]]/m/g; s/[[=n=]]/n/g; s/[[=o=]]/o/g; s/[[=p=]]/p/g; s/[[=q=]]/q/g; s/[[=r=]]/r/g; s/[[=s=]]/s/g; s/[[=t=]]/t/g; s/[[=u=]]/u/g; s/[[=v=]]/v/g; s/[[=w=]]/w/g; s/[[=x=]]/x/g; s/[[=y=]]/y/g; s/[[=z=]]/z/g' | psub) | wc -l
96514
-- removes pretty much everything but has some weird stuff:
pip3 install --user unidecode
diff non-ascii (bat non-ascii | unidecode | psub) | wc -l
10924
--only removes diacriticals (this one is the most technically correct)
You can’t perform that action at this time.