Skip to content

Instantly share code, notes, and snippets.

View trustin's full-sized avatar
πŸŒ„
β–‚β–ƒβ–…β–‡β–ˆβ–“β–’β–‘Ϋ©ΫžΫ©β–‘β–’β–“β–ˆβ–‡β–…β–ƒβ–‚

Trustin Lee trustin

πŸŒ„
β–‚β–ƒβ–…β–‡β–ˆβ–“β–’β–‘Ϋ©ΫžΫ©β–‘β–’β–“β–ˆβ–‡β–…β–ƒβ–‚
View GitHub Profile
@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 / git-checkout-pr.sh
Last active July 22, 2024 13:14
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() {
#!/bin/bash -e
HEAD_COMMIT_ID=$(git rev-parse HEAD)
if [[ -n "$HEAD_COMMIT_ID" ]]; then
git commit --amend --reuse-message="$HEAD_COMMIT_ID"
git push --force
fi
@trustin
trustin / bash_prompt.sh
Last active July 27, 2018 09:40
Trustin's Bash prompt
#!/bin/bash
# Git-aware bash command prompt
#
# Put this script at $HOME/.bash_prompt and add the following to your .bashrc:
#
# if [[ -f "$HOME/.bash_prompt" ]]; then
# if [[ -z "$PROMPT_COMMAND" ]]; then
# PROMPT_COMMAND="$HOME/.bash_prompt"
# else
# PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND ;} $HOME/.bash_prompt"
@trustin
trustin / git-trigger-build.sh
Last active April 4, 2025 05:46
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
@trustin
trustin / ffmpeg-1080p.sh
Last active July 5, 2021 07:25
ffmpeg-1080p.sh: Scales down and transcodes a video file into HEVC with ffmpeg + CUDA
#!/bin/bash -e
if [[ $# -gt 1 ]]; then
while [[ $# -gt 0 ]]; do
"$0" "$1"
shift
done
exit 0
fi
@trustin
trustin / logid.cfg
Last active April 4, 2025 14:51
logiops settings for Logitech MX Anywhere 3 and 2 (/etc/logid.cfg)
devices: ({
name: "MX Anywhere 3";
hiresscroll: {
hires: true;
invert: false;
target: false;
up: {
mode: "Axis";
axis: "REL_WHEEL_HI_RES";
@trustin
trustin / karabiner.json
Created September 10, 2021 02:45
Trustin's Karabiner-Elements settings
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@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"
#!/usr/bin/env bash
set -Eeuo pipefail
echo_and_run() {
echo "> $*"
"$@"
}
setup_sudo() {
# Ask for the administrator password upfront