Skip to content

Instantly share code, notes, and snippets.

View trustin's full-sized avatar
🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂

Trustin Lee trustin

🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂
View GitHub Profile
@trustin
trustin / setup-docker.sh
Created January 10, 2024 11:37
How to install Docker on macOS without using Docker Desktop
#!/usr/bin/env bash
set -Eeuo pipefail
# Install Docker CLI and Docker Compose, etc.
brew install docker docker-compose docker-credential-helper
# Configure Docker CLI.
mkdir -p "$HOME/.docker/cli-plugins"
ln -sfn '/opt/homebrew/opt/docker-compose/bin/docker-compose' "$HOME/.docker/cli-plugins/docker-compose"
echo '{
@trustin
trustin / git-trigger-build.sh
Last active January 22, 2024 05:14
git-trigger-build: Triggers a CI build by pushing an empty commit
#!/bin/bash -e
# Stash the staged files if any.
NEEDS_UNSTASH=0
if ! git diff --staged --exit-code >/dev/null; then
echo -ne '\033[1;32m'
echo -n 'Stashing the staged files'
echo -e '\033[0m'
git stash
NEEDS_UNSTASH=1
#!/usr/bin/env bash
set -Eeuo pipefail
echo_and_run() {
echo "> $*"
"$@"
}
setup_sudo() {
# Ask for the administrator password upfront
@trustin
trustin / logid.cfg
Last active November 22, 2023 08:36
logiops settings for Logitech MX Anywhere 3 and 2 (/etc/logid.cfg)
// /etc/logid.cfg
devices: ({
name: "MX Anywhere 3";
hiresscroll: {
hires: true;
invert: false;
target: true;
up: {
mode: "Axis";
@trustin
trustin / remove-mkv-tracks.sh
Created August 5, 2023 03:44
Remove the tracks that match certain criteria from MKV files (using jq)
#!/usr/bin/env bash
set -Eeuo pipefail
if [[ $# -lt 2 ]]; then
echo "Usage: $(basename "$0") <preset or jq condition> <files or directories...>"
echo 'Presets: subrip_only, anime'
exit 1
fi
JQ_COND="$1"
@trustin
trustin / git-checkout-pr.sh
Last active May 16, 2023 02:08
git-checkout-pr.sh - fetches a Git pull request from the remote and creates a local branch for it
#!/usr/bin/env bash
set -Eeuo pipefail
log() {
echo -en '\033[1;32m'
echo -n "$@"
echo -e '\033[0m'
}
choice() {
@trustin
trustin / smi2ass.py
Last active January 24, 2023 03:25
smi2ass.py - converts a SAMI (.smi) subtitle file to the SubStationAlpha (.ass) format.
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# Note: A newer version of this script is located at https://github.com/trustin/smi2ass
#
# Copyright (C) 2018 Trustin Heuiseung Lee and other contributors
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
@trustin
trustin / pf.conf
Created November 15, 2012 06:52
Trustin's /etc/pf.conf for Mac OS X
# 1. Put this file to /etc/pf.conf
# 2. Install init boot scripts using IceFloor then - http://www.hanynet.com/icefloor/
# I tried to use IceFloor to configure everything but it didn't work very well.
# 3. Once done, you can confirm the rules were loaded with 'sudo pfctl -sr'
# 4. At System Preferences -> Security -> Firewall -> Firewall Options,
# check 'Block all incoming connections' to prevent annoying per-app dialogs.
set skip on lo0
set block-policy drop
@trustin
trustin / bash_prompt.sh
Created April 27, 2011 11:37
Some useful git scripts I wrote - use with 'git config --global alias.<name> '!<script path>'
#!/bin/bash
# Git-aware bash command prompt
#
# Put this script at $HOME/.bash_prompt and add the following to your .bashrc:
#
# if [ "$PS1" ]; then
# if [ -f "$HOME/.bash_prompt" ]; then
# PROMPT_COMMAND="$HOME/.bash_prompt"
# if [ "$EUID" == "0" ]; then
# PS1="\n# "
@trustin
trustin / sjk.sh
Created March 7, 2022 07:10
SJK (Swiss Java Knife) launcher script
#!/usr/bin/env bash
set -Eeuo pipefail
if [[ -z "${JAVA_HOME:-}" ]]; then
JAVA='java'
else
JAVA="$JAVA_HOME/bin/java"
fi
SJK_VERSION='0.20'
SJK_PATH="$HOME/.local/opt/sjk/sjk-plus-$SJK_VERSION.jar"