Skip to content

Instantly share code, notes, and snippets.

@spyesx
spyesx / yq-command-full-path-from-key-name.md
Last active October 27, 2025 09:36
yq command to find the full path by a key name (using the go implementation by mikefarah/yq)

yq command to find the full path by a key name – (using the go implementation by mikefarah/yq)

TL;DR

yq '.. | select(tag != "!!map" and tag != "!!seq" and (parent | key) == "<keyname>") | path | join(".")' \
 <filename.yaml>

Example

@spyesx
spyesx / MP4-total-duration-in-hours.md
Created October 6, 2025 08:27
MP4 total duration in hours

MP4 Total Duration in Hours

Calculate the total duration (in hours) of all MP4 files in the current directory and its subdirectories.

Requires the ffprobe utility (part of FFmpeg) to be installed.

find . \
  -type f \
 -iname "*.mp4" \
@spyesx
spyesx / readme.md
Last active October 5, 2025 14:41
Synology drive download unsynced due to invalid file name or attribute

Synology drive download unsynced due to invalid file name or attribute

Usage:

chmod +x syno_check.sh
./syno_check.sh /path/to/your/synology/sync/folder
@spyesx
spyesx / git-report.sh
Last active February 24, 2025 13:29
Standalone Bash script to recursively scan directories and identify Git repositories with unpushed changes or local modifications.
#!/usr/bin/env bash
# Standalone Git Repository Report Script
# Configuration (can be modified here directly)
DEFAULT_GIT_CLONE_PATH="$HOME/repositories" # Default path to search for git repos
# --- Helper Functions (Standalone implementations) ---
# For standalone, let's use simple echo with prefixes instead of log_warning/log_info
@spyesx
spyesx / images-crawler.sh
Created October 31, 2022 08:13
Download all images listed in list.txt then make it a PDF
#!/usr/bin/env bash
# Download all images listed in list.txt then make it a PDF
wget --input list.txt -O $1.jpg
convert *.jpg output.pdf
@spyesx
spyesx / readme.md
Last active May 2, 2025 12:23
Clean up old linux kernels

Remove old linux kernels

Script way

# Dry run to check
bash remove-old-kernels.sh

# Run
bash remove-old-kernels.sh exec
@spyesx
spyesx / array-functions.js
Created March 21, 2022 10:25
Common array functions in javascript
[1, 2, 3].push(4)
// [1,2,3,4]
[1, 2, 3].pop()
// [1,2]
[1, 2, 3].shift()
// [2,3]
[1, 2, 3].unshift(0)
@spyesx
spyesx / mark6.js
Created January 6, 2022 13:40
mark6 lazy generator in javascript
const options = {
n6 : { price: 10, columns: 6 },
n7 : { price: 70, columns: 7 },
n8 : { price: 280, columns: 8 }
}
const opt = 'n7'
const rows = 10
const columns = options[opt].columns
@spyesx
spyesx / esm-package.md
Created November 21, 2021 10:13 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@spyesx
spyesx / netlify.toml
Created September 27, 2021 15:54 — forked from DavidWells/netlify.toml
All Netlify.toml & yml values
[Settings]
ID = "Your_Site_ID"
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.
[build]
# This is the directory to change to before starting a build.
base = "project/"
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
# This is the directory that you are publishing from (relative to root of your repo)