Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env sh
target_boot_name='Windows Boot Manager'
windows_boot_id="$(efibootmgr --unicode | grep "$target_boot_name" | sed 's/Boot\([0-9a-fA-F]\{4\}\)\*\? .*/\1/')"
if [ ${#windows_boot_id} -ne 4 ]; then
echo "$0: Could not find boot id for Windows."
exit 1
fi
@shello
shello / zfs_snapshot.hook
Created June 13, 2021 10:30
Pacman hook: Take a snapshot of the root dataset before any operation
# ZFS Root Snapshot Pacman Hook
# 2021 Filipe Rodrigues<shello@shello.org>
#
# Take a snapshot of the root dataset before any pacman operation.
# See: https://man.archlinux.org/man/alpm-hooks.5
# Depends on: pacman, zfs, coreutils
# Location: /etc/pacman.d/hooks/zfs_snapshot.hook
[Trigger]
Operation = Install
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shello
shello / README.md
Last active February 1, 2019 04:14
syncthing.sh: Syncthing + tmux control

syncthing.sh: Syncthing + tmux control

This is a simple script to control syncthing. It is possible to also source this script in 'sh'-like shells (tested in dash, bash and zsh). When used as a script it accepts a number of subcommands; if sourced, a number of syncthing_* functions are defined.

Functions / subcommands

# Via: https://sts10.github.io/2018/11/27/syncthing-and-tmux.html
# Changes to `ss` and `se`:
# - Start session with command on `new-session`: avoids creating a shell
# session just for `syncthing`; also use only `kill-session` instead of
# sending keys.
# - Test if the sessions exist (or don't exist) before creating/killing them.
# in ~/.bash_profile or ~/.bashrc
function ss {
if tmux has-session -t synct 2>/dev/null; then
@shello
shello / README.md
Last active May 13, 2022 23:43
HIBP Pwned Passwords splitter

This Awk script splits pwned-passwords-1.0.txt.7z (and updates) into 256 files xz compressed files, by hash prefix (2 digits).
The script assumes the format of the input file is one hash per line.

It can be ran for more than one pwned-passwords-*.txt.7z file, such as pwned-passwords-update-1.txt.7z as long as Troy keeps the format consistent.

Requires 7z (p7zip), and GNU Awk (tested with

#!/usr/bin/env bash
# Interactively capture a screenshot (using the cursor), and decode any 1D or 2D
# barcodes in the image (such as QR Code, EAN-13, etc...)
#
# OS X / macOS only
# Requires:
# - zbar (http://zbar.sourceforge.net/, `brew install zbar`)
# - screencapture (included with the system)
function screenqr() {
<?php
/**
* `password_hash`/bcrypt cost benchmark script
*
* Usage:
* $ php bcrypt_cost_benchmark.php <lower cost> <higher cost> <n_tries>
*
* Example: Run 100 tries of costs 8 through 12
* $ php bcrypt_cost_benchmark.php 8 12 100
@shello
shello / vncssh.sh
Last active November 10, 2015 01:17
Connect to VNC using TigerVNC Viewer through an SSH tunnel. OS X only.
#!/usr/bin/env bash
# Connecto to VNC using TigerVNC Viewer through an SSH tunnel. OS X only.
# Requires osx_app_path: https://github.com/shello/osx_app_path
# Tested with bash 3.2 and zsh 5.1.1
vncssh () {
local SSH_HOST VNC_PORT LOCAL_PORT TIGERVNC
local TIGERVNC_BIN="Contents/MacOS/TigerVNC Viewer"
@shello
shello / WikiEmoji.md
Last active June 16, 2016 13:40
Wiki Emoji