Skip to content

Instantly share code, notes, and snippets.

@pjeby
pjeby / shelldown-demo
Last active May 28, 2025 08:18
"You got your markdown in my shell script!" "No, you got your shell script in my markdown!"

Mixed Markdown and Shell Scripting

: By the power of this magic string: ex: set ft=markdown ;:<<'```shell' #, this file is now both a markdown document and an executable shell script. chmod +x it and try running it!

The above line does just what it says. More specifically, when placed within in the first 5 lines and preceded only by blank lines or #-prefixed markdown headers:

  1. The first part of the magic string makes github and various editors (e.g. atom with the vim-modeline packge) treat the file as having markdown syntax (even if the file doesn't have an extension)
  2. The second part (if run in a shell), makes the shell skip execution until it encounters the next ```shell block.

(The line also has to start with a : so that it's valid shell code.)

@eugene-babichenko
eugene-babichenko / Makefile
Created September 28, 2019 13:33
Makefile for building version strings from Git data and including that version numbers into go programs
TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell git log -1 --format=%cd --date=format:"%Y%m%d")
VERSION := $(TAG:v%=%)
ifneq ($(COMMIT), $(TAG_COMMIT))
VERSION := $(VERSION)-next-$(COMMIT)-$(DATE)
endif
ifeq $(VERSION,)
VERSION := $(COMMIT)-$(DATA)
@3isenHeiM
3isenHeiM / MDNS_jail_FreeNAS
Last active July 27, 2022 21:26
Enable MDNS on a FreeNAS/BSD jail. That will allow a Avahi name resolution of the jail in the local network.
freenas# jls
JID IP Address Hostname Path
...
5 - etherpad /mnt/basin/jails/etherpad
...
freenas# ./mdns.sh 5
Updating FreeBSD repository catalogue...
[etherpad] Fetching meta.txz: 100% 944 B 0.9kB/s 00:01
[etherpad] Fetching packagesite.txz: 100% 6 MiB 5.9MB/s 00:01
@ScribbleGhost
ScribbleGhost / Privacy links you might want to check out.md
Last active August 13, 2024 16:50
👀 Privacy links you might want to check out...
@lrvick
lrvick / github-troll.md
Last active May 24, 2025 01:11
Trolling Github's DMCA repo with their own security flaws.
@idelem
idelem / titleUrlMarkdownClip.js
Last active May 31, 2025 01:01 — forked from bradleybossard/titleUrlMarkdownClip.js
Bookmarklet to copy current page title and url in Markdown format to clipboard, like [title](url) - Usual for posting links to resources in README.md files
javascript:(function() {
function copyToClipboard(text) {
if (window.clipboardData && window.clipboardData.setData) {
/*IE specific code path to prevent textarea being shown while dialog is visible.*/
return clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var textarea = document.createElement("textarea");
textarea.textContent = text;

Plex file hierarchy example

📂 ROOT
	┣📂 MOVIES
	┃ ┣ 📂 The Shawshank Redemption (1994)
	┃ ┃ ┣ 🎬 The Shawshank Redemption (1994).mkv
@ScribbleGhost
ScribbleGhost / Check a video file for subtitles, subtitle language and subtitle format
Created April 12, 2021 12:47
Check a video file for subtitles, subtitle language and subtitle format with ffprobe
ffprobe -loglevel error -select_streams s -show_entries stream=codec_name,index:stream_tags=language -of csv=p=0 %input%
@ScribbleGhost
ScribbleGhost / subtitle_extractor.bat
Last active January 26, 2023 03:24
Extract all subtitles from MKV video file, and make a copy of the video file without subtitles. Requires mkvmerge and subtitleedit CLI in PATH
@echo off
FOR %%A IN (*.mkv) DO (
echo %%~nxA
FOR /F %%I IN ('mkvmerge -i "%%A" ^| FIND /C "SubRip"') DO (IF %%I GTR 0 (echo SRT found in file) & (subtitleedit /convert "%%A" SubRip) else (echo SRT not found in file))
echo.&echo.
FOR /F %%I IN ('mkvmerge -i "%%A" ^| FIND /C "SubStationAlpha"') DO (IF %%I GTR 0 (echo ASS found in file) & (subtitleedit /convert "%%A" SubStationAlpha) else (echo ASS not found in file))
echo.&echo.
FOR /F %%I IN ('mkvmerge -i "%%A" ^| FIND /C "VobSub"') DO (IF %%I GTR 0 (echo. &echo. &echo. &echo. & echo VobSub - SUB/IDX found in file. You should use SubtitleEdit to convert the subtitles to a text-based format such as SRT) else (echo VobSub not found in file))
echo.&echo.

Some handy MKVToolNix commands

Extract chapter XML files for all MKVs:

for /r %i in (*.mkv) do (mkvextract "%i" chapters "%~ni".xml)

Remove all chapters from MKVs:

for /r %i in (*.mkv) do (mkvpropedit "%i" --chapters "")