Skip to content

Instantly share code, notes, and snippets.

@yyogo
yyogo / test_chmod_bug.sh
Last active January 30, 2022 16:15
script for testing Syncthing issue #7924
#!/bin/bash
set -e
# this script starts two ST instances, connects them, adds a shared folder,
# syncs a file, chmods it, and checks that the new permissions are synced
# within a reasonable time frame.
# Set to your local ST build
SYNCTHING=../bin/syncthing
@yyogo
yyogo / unzoom.py
Last active November 16, 2022 09:25
iTerm 2 unzoom on switch pane script
#!/usr/bin/env python3.7
# Put this script in ~/.config/iterm/Scripts or whatever, then enable in the Scripts menu
# Map switch keys to "Invoke Script Function...": `unzoom_and_switch(direction: "above/below/left/right")`
import iterm2
async def async_turn_off_menu_option(conn: iterm2.Connection, option: str):
state = await iterm2.MainMenu.async_get_menu_item_state(conn, option)
if state.checked:
await iterm2.MainMenu.async_select_menu_item(conn, option)
@yyogo
yyogo / style.sh
Last active August 15, 2023 08:16
easy ANSI styling in bash
#!/bin/bash
style() {
if [ $# -eq 0 ]; then
echo 'usage: style [[<color name>|[color] <index>|rgb R G B|#<rgb hex>] [fg|bg]]'
echo ' | bold | dim | italic'
echo ' | blink [fast|slow]'
echo ' | underline | invert | hide | strike | reset]]...'
return 1
fi
// Replace annoying tracking `http://t.co/...` links on Twitter ("X") with the actual target.
// Install as userscript or JSlet (prefix with `javascript:` and save as bookmark) or just run in console
document.querySelectorAll('a[href*="https://t.co"]').forEach(a => a.setAttribute('href', a.innerText.replace('…','')));
@yyogo
yyogo / extractObsidianSnapshots.js
Last active March 2, 2025 12:58
Extract file recovery snapshots from Obsidian
/**
* Obsidian Snapshot Exporter
* --------------------------
*
* This script helps you export snapshots (version history) from Obsidian's IndexedDB storage.
* It creates a ZIP file containing all your snapshots with proper file naming and organization.
*
* === HOW TO USE ===
*
* Step 1: Open Obsidian's Developer Tools