Skip to content

Instantly share code, notes, and snippets.

View chapmanjacobd's full-sized avatar
🥅
goal_net

Jacob Chapman chapmanjacobd

🥅
goal_net
View GitHub Profile
# https://old.reddit.com/r/pushshift/comments/ajmcc0/information_and_code_examples_on_how_to_use_the/
with open("filename.zst", 'rb') as fh:
dctx = zstd.ZstdDecompressor(max_window_size=2147483648)
with dctx.stream_reader(fh) as reader:
previous_line = ""
while True:
chunk = reader.read(2**24) # 16mb chunks
if not chunk:
break
import itertools
subcommand_abbrevs = []
def consequtive_combos(s):
combos=[list(itertools.combinations(s,x)) for x in range(1,len(s))]
combos=set([''.join(e) for e in sum(combos,[]) if e[0] == s[0] and ''.join(e) not in subcommand_abbrevs])
subcommand_abbrevs.extend(combos)
return combos
q=consequtive_combos('merge-online-local')
def youtube_dl_id(file) -> str:
if len(file) < 15:
return ""
# rename old youtube_dl format to new one: cargo install renamer; fd -tf . -x renamer '\-([\w\-_]{11})\.= [$1].' {}
yt_id_regex = re.compile(r"-([\w\-_]{11})\..*$|\[([\w\-_]{11})\]\..*$", flags=re.M)
file = str(file).strip()
yt_ids = yt_id_regex.findall(file)
if not yt_ids:
return ""
@chapmanjacobd
chapmanjacobd / list_dict_filter_bool.py
Last active October 1, 2022 22:39
removing some dead code
def dict_filter_bool(kwargs) -> dict:
return {k: v for k, v in kwargs.items() if v}
def list_dict_filter_bool(media: List[dict]) -> List[dict]:
return [dict_filter_bool(d) for d in media if len(dict_filter_bool(d)) > 0]
@chapmanjacobd
chapmanjacobd / add_virtual_monitor.sh
Created September 21, 2022 18:52
unfortunately this script does not help me
#!/bin/bash
if [ -z "$(xrandr --listactivemonitors | grep 'HDMI-A-0')" ]; then
xrandr --addmode HDMI-A-0 1920x1080
xrandr --output HDMI-A-0 --mode 1920x1080 --right-of eDP
xrandr --output eDP --fb 5760x1080 --panning 5760x1080
else
xrandr --output HDMI-A-0 --off
xrandr --delmode HDMI-A-0 1920x1080
xrandr --output eDP --fb 1920x1080 --panning 0x0
fi
function lt-stop
/bin/rm /tmp/catt_playing &
pkill -f "python.*xklb.*lt" &
pkill -f .local/bin/lb
pkill -f '.local/bin/lt'
pkill mpv &
catt pause
catt -d "Xylo and Orchestra" set_default
end
function nextSongDelete
if test -f /tmp/catt_playing
set song (string unescape (cat /tmp/catt_playing))
else
set song (echo '{ "command": ["get_property", "path"] }' | socat - /tmp/mpv_socket | jq -r .data)
end
# if not test -f /tmp/catt_playing
echo 'playlist-next force' | socat - /tmp/mpv_socket
# end
catt stop &
function tabs-monthly
set day_of_month (date "+%d")
set day_of_year (date "+%j")
set temp_file (mktemp)
cat ~/mc/monthly.cron ~/mc/reddit.monthly.cron >$temp_file
set file_len (cat $temp_file | count)
while test $day_of_month -lt $file_len
echo $day_of_month
set url (sed "$day_of_month""q;d" $temp_file)
@chapmanjacobd
chapmanjacobd / mrvideo.fish
Created August 16, 2022 03:04
move 24 random portrait videos
is_vertical_video (fd -tf --max-results=1 -eWEBM -eMKV -eMP4 -eMOV -eAVI . src/ -E '*keep/*' -E '*gifs/*' -E '.nomedia') # random_choice
set want_vertical $status
set -l chosen
while test (count $chosen) -lt 24
for video in (fd -tf --max-results=500 -eWEBM -eMKV -eMP4 -eMOV -eAVI . src/ -E '*keep/*' -E '*gifs/*' -E '.nomedia' )
is_vertical_video "$video"
set is_vertical $status
@chapmanjacobd
chapmanjacobd / __fish_print_pipestatus
Created August 5, 2022 02:47
less dumb __fish_print_pipestatus
function __fish_print_pipestatus
set -l last_status
if set -q __fish_last_status
set last_status $__fish_last_status
else
set last_status $argv[-1] # default to $pipestatus[-1]
end
set -l left_brace "["
set -l right_brace "]"
set -l separator "|"