Skip to content

Instantly share code, notes, and snippets.

View thingsiplay's full-sized avatar

Tuncay thingsiplay

View GitHub Profile
@thingsiplay
thingsiplay / thing.py
Last active June 22, 2025 23:17
Python Tutorial: argparse advanced-help with additional options
#!/usr/bin/env python3
import sys
import argparse
long_help = False
for arg in sys.argv:
if arg == "--":
break
if arg == "--long-help":
@thingsiplay
thingsiplay / history-print-paths.sh
Last active June 15, 2025 21:35
List all existing program paths from your Bash's history.
#!/usr/bin/env bash
# 1. history and $HISTFILE do not work in scripts. Therefore a direct path to
# the file is needed.
# 2. awk gets the first part of the command line, resulting in the command name.
# 3. List of command names is then sorted and duplicate entries are removed.
# 4. type -P will expand command names to paths, similar to which. But it will
# also expand aliases and remove functions from the list.
# 5. Final output is then sorted again.
#!/usr/bin/env bash
local="${HOME}/.config/retroarch"
repo='https://github.com/libretro/docs'
open='okular'
cd -- "${local}" || exit
if [[ "${1}" == '' ]]; then
mode="$(printf 'open\nupdate' | fzf)"
@thingsiplay
thingsiplay / txt2png-1.1.sh
Last active April 7, 2025 13:33
Convert Text files to Image format.
#!/usr/bin/env bash
# (This version is specific for my special use case of personal documents.)
# Version 1.1
# 2025-04-07
#
# Convert Text files to Image format.
#
# Usage:
# txt2png desc1.txt desc2.txt
@thingsiplay
thingsiplay / tocase
Last active February 7, 2025 12:58
tocase - Change the lower and upper case characters.
#!/usr/bin/env bash
if [ "${#}" -eq 0 ] ; then
cat << EOF
usage: tocase option...
options:
upper all uppercase
upper1 upper first character
@thingsiplay
thingsiplay / crc32sum
Last active April 18, 2025 15:22
crc32sum - Calculate CRC32 for each file (Bash using 7z)
#!/usr/bin/env bash
if [[ "${#}" -eq 0 ]] || [[ "${1}" == '-h' ]]; then
self="${0##*/}"
cat <<EOF
usage: ${self} files...
Calculate CRC32 for each file.
positional arguments:
@thingsiplay
thingsiplay / toarchive
Last active June 14, 2025 07:05
toarchive - Create one archive for each file or folder (Bash using 7z)
#!/usr/bin/env bash
supported_ext=("7z" "zip")
help() {
cat <<EOF
toarchive ext [options] files...
toarchive zip -f -k *.smc
Convert each file to an archive using 7z or tar, similar to gzip.
{
"version": "1.5",
"default_core_path": "/home/tuncay/.config/retroarch/cores/fbneo_libretro.so",
"default_core_name": "Arcade (FinalBurn Neo)",
"base_content_directory": "/home/tuncay/Emulation/Roms",
"label_display_mode": 0,
"right_thumbnail_mode": 2,
"left_thumbnail_mode": 0,
"sort_mode": 0,
"items": [
@thingsiplay
thingsiplay / ytvideo
Created May 19, 2024 13:07
ytvideo - YouTube video downloader wrapper to yt-dlp
#!/bin/sh
# Default values.
quality='bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4'
limit='4.8'
metaextras='--add-metadata --write-description --write-info-json --write-sub'
OPTIND=1
while getopts ':hbp:s:M' OPTION; do
case "$OPTION" in
@thingsiplay
thingsiplay / trim
Last active May 23, 2024 15:49
Remove surrounding whitespace from stdin.
#!/bin/sh
# echo -e ' \thello world ' | trim
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'