Skip to content

Instantly share code, notes, and snippets.

View FiXato's full-sized avatar

Filip H.F. "FiXato" Slagter FiXato

View GitHub Profile
@FiXato
FiXato / .profile_term_session_history
Last active January 21, 2021 17:44
Save bash history into separate files based on iTerm2 session id.
#TODO: support WSL's $WT_SESSION and tmux panes ($TMUX_PANE?)
if [ "$TERM_SESSION_ID" != "" ]; then
if [ "$HISTFILE" != "" ]; then
OLD_HISTFILE="$HISTFILE"
else
OLD_HISTFILE="~/.bash_history"
fi
HISTFILE_DIRECTORY="${HOME}/.histories/bash_histories"
mkdir -p "$HISTFILE_DIRECTORY"
@FiXato
FiXato / download_studio_ghibli_promo_pics.sh
Last active January 6, 2021 13:31
Shell script to download freely released Studio Ghibli images
#!/usr/bin/env bash
#encoding: utf-8
#Shell script to download freely released Studio Ghibli images (http://www.ghibli.jp/info/013344/)
film_names=( "marnie" "kaguyahime" "kazetachinu" "kokurikozaka" "karigurashi" "ponyo" "ged" "chihiro")
for film_name in "${film_names[@]}"; do
mkdir -p "./${film_name}" && curl "http://www.ghibli.jp/images/${film_name}.jpg" -o "./${film_name}/${film_name}.jpg" && curl "http://www.ghibli.jp/gallery/${film_name}[001-050].jpg" -H "Referer: http://www.ghibli.jp/works/${film_name}/#frame" -o "./${film_name}/${film_name}-#1.jpg"
done
@FiXato
FiXato / launcher.py
Last active December 16, 2020 05:02
[OBSOLETE] A TUI-based launch app written in Python for kelbot
#!/usr/bin/env python3
# encoding: utf-8
# NOTE: THIS VERSION HAS BEEN MADE OBSOLETE BY THIS REPOSITORY: https://github.com/FiXato/tui_launcher
from math import floor
import argparse
import urwid
import asyncio
urwid.set_encoding("utf8")
arg_parser = argparse.ArgumentParser(description='Launch tools via buttons.')
arg_parser.add_argument('--term-width', nargs=1)
@FiXato
FiXato / MorseMedium.py
Last active November 23, 2020 22:28
Read Medium.com article through Morse code pulsed via your ScrollLock light, and on Windows via Winsound.beep() too
import pyautogui
pyautogui.FAILSAFE = False
from pyautogui import press, FAILSAFE
from morse3 import Morse as m
from bs4 import BeautifulSoup
import urllib.request
from time import sleep
URL = "https://medium.com/risan/upgrade-your-ssh-key-to-ed25519-c6e8d60d3c54"
req = urllib.request.Request(
@FiXato
FiXato / comics_tweaks.user.js
Last active November 10, 2020 01:50
Tweaks for various comics, such as visible alt and title texts, adding ctrl+left/right keyboard shortcuts for previous and next comic, prefetching prev/next link documents, and a kioskmode. Currently supported: xkcd and the (NSFW) comic "Oglaf".
// ==UserScript==
// @name Comics tweaks
// @author Filip H.F. "FiXato" Slagter
// @namespace http://code.fixato.org/userscripts
// @description Some tweaks for various comic sites, such as visible alt text, and kiosk mode. Currently supports: Oglaf, xkcd.
// @match https://oglaf.com/*
// @match https://www.oglaf.com/*
// @match https://xkcd.com/*
// @match https://www.xkcd.com/*
// @version 2.1
@FiXato
FiXato / autopause.tcl
Created October 26, 2020 17:50
autopause script for openMSX
namespace eval autopause {
proc autopause {} {
message "pause: [set ::pause]"
::set ::pause true
};
after realtime 0.1 autopause::autopause
};
@FiXato
FiXato / LICENSE
Last active September 25, 2020 13:56
A proof-of-concept script based on a conversation over on #Mastodon at mastodon.social/@FiXato/104738706980490091, It tries to provide a CLI solution to copying the music referenced in an M3U8 playlist to a separate directory so it can be more easily synced to another device such as an Android phone, while retaining the playlist order.
MIT License
Copyright (c) 2020 Filip H.F. "FiXato" Slagter
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@FiXato
FiXato / 7z-list-duplicates.awk
Last active February 28, 2020 05:01
Get an overview of likely byte-for-byte duplicates in a zip file, using 7z, gawk and grep, based on CRC+filesize
function process_group(name, body) {
size = gensub(/.+\nSize = ([0-9]+)\n.+/, "\\1", "G", body);
crc = gensub(/.+\nCRC = ([A-F0-9]{8})\n.+/, "\\1", "G", body);
packed = gensub(/.+\nPacked Size = ([0-9]+)\n.+/, "\\1", "G", body);
modified = gensub(/.+\nModified = ([A-F0-9]{8})\n.+/, "\\1", "G", body);
id = crc "-" size;
uniques[id]++;
data[id]["size"] = size;
@FiXato
FiXato / openMSX_lets_play.tcl
Created February 25, 2020 21:22
A script to help automate recording of reverse replays.
namespace eval lets_play {
set debug_log 1
proc log {args} {
variable debug_log
if {$debug_log != 1} { return }
puts "DEBUG: $args"
}
proc position_to_time {position} {
if {[string is double $position] == 1} {
@FiXato
FiXato / toot_media_viewer_cygwin_irfanview.sh
Last active January 10, 2020 16:18
Wrapper scripts to open each passed URL as an image in various environments (such as Termux on Android, and IrfanView on Cygwin for Windows), meant to be used with the `toot` CLI Mastodon client.
#!/usr/bin/env bash
PATH_TO_IRFANVIEW="${HOME}/iview454_setup/i_view32.exe"
tmpfilelist="$(mktemp "${TMP}/toot_media_viewer.XXXXXX.filelist.txt")"
tmpfilelist_win="$(mktemp "${TMP}/toot_media_viewer.XXXXXX.win.filelist.txt")"
# Loop through all arguments passed to the script, assuming they are all URLs
for url in "$@"
do
basename="$(basename "$url")"
# Get the extension from the URL's basename. Default to 'png' if basename has no period