Skip to content

Instantly share code, notes, and snippets.

View anvanvan's full-sized avatar

An Van anvanvan

View GitHub Profile
@anvanvan
anvanvan / diff_dirs.bash
Last active January 21, 2026 04:12
diff_dirs - Quick directory comparison using rsync (bash/zsh/fish)
diff_dirs() {
local group=0
while [[ "$1" == -* ]]; do
case "$1" in
-g|--group) group=1; shift ;;
-h|--help)
echo "Usage: diff_dirs [-g] <folderA> <folderB>"
echo ""
echo "Quick directory comparison using rsync (compares by file size only)."
echo ""
@anvanvan
anvanvan / flexoki-light.js
Created January 17, 2026 01:36
Flexoki Light theme for Blink Shell iOS
// Flexoki Light for Blink Shell
// https://stephango.com/flexoki
black = '#100F0F'; // Flexoki black
red = '#AF3029'; // Red 600
green = '#66800B'; // Green 600
yellow = '#AD8301'; // Yellow 600
blue = '#205EA6'; // Blue 600
magenta = '#A02F6F'; // Magenta 600
cyan = '#24837B'; // Cyan 600
@anvanvan
anvanvan / lifecalendar.js
Last active January 2, 2026 01:44
Life Calendar Wallpaper Generator for Scriptable iOS app
// Life Calendar Wallpaper Generator for Scriptable
// https://waitbutwhy.com/2014/05/life-weeks.html
// https://x.com/luismbat/status/2006693230109176288
// https://x.com/pastabrian/status/2006756624246112619
// https://x.com/anvanvan/status/2006887614671106311
// Install instructions:
// 1. Download https://scriptable.app
// 2. Go to Shortcut app and create a new shortcut
// 3. Add `Run Inline Script` and `Set Wallpaper`
@anvanvan
anvanvan / toggle-app.scpt
Last active September 1, 2025 19:40
Universal App Toggle Script for macOS
#!/usr/bin/osascript
# Toggle macOS App Window State
#
# This script provides smart window toggling for any macOS application:
# - If app is not running → launches and activates it
# - If app is minimized → restores and brings to front
# - If app is in background → brings to front
# - If app is in foreground → minimizes to dock
#
@anvanvan
anvanvan / auto_timemachine.sh
Created May 31, 2025 01:01
Auto Time Machine Backup Script - Event-driven macOS backup automation
#!/bin/bash
#===============================================================================
# AUTO TIME MACHINE BACKUP SCRIPT
#===============================================================================
#
# DESCRIPTION:
# Automatically detects when an external SSD is connected, mounts the Time
# Machine sparsebundle, runs a backup, and safely ejects both volumes when
# complete. Uses event-driven architecture (no polling) for better power
@anvanvan
anvanvan / new safari window.scpt
Created November 20, 2023 00:12
Creates a new Safari window and bring it to the foreground
tell application "Safari"
make new document
activate
end tell
@anvanvan
anvanvan / Sort-Files.ps
Created November 17, 2023 05:50
This PowerShell script recursively sorts image and video files in a specified folder by their creation date or media date, placing them into new directories named after the year and month of their creation or media date.
param(
[Parameter(Mandatory=$true)]
[string]$FolderPath
)
function Sort-Files {
Get-ChildItem -Path $FolderPath -File -Recurse | ForEach-Object {
#Write-Host "File: $_"
$creationDate = $_.CreationTime -replace("[^0-9/\:\sapm]")
$fileName = $_.Name
@anvanvan
anvanvan / .vimrc
Last active September 1, 2020 13:33
.vimrc for working on remote server
" 1. performance settings
set synmaxcol=300
set noshowmatch
set lazyredraw
set ttyfast
set nocursorline
" leader key
let mapleader = "\<space>"
set timeoutlen=1000 ttimeoutlen=0
@anvanvan
anvanvan / newfiles
Last active October 20, 2018 19:41 — forked from renekreijveld/jnewfiles
Bash script to detect suspicious new and changed files last 3 hours. Skips cache directories.
#!/bin/sh
# newfiles
# Detects new and changed php and html files last xxx minutes
# (C) 2014 Rene Kreijveld, enail [at] renekreijveld [dot] nl
# Update 31-12-2013: only send email when changes are found
# Update 04-02-2014: check for new files last three hours
# Update 05-05-2014: check for new html files also
# Update 07-05-2014: filter out ju_chached and DirectAdmin stats folders in html files