Skip to content

Instantly share code, notes, and snippets.

🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂

Trustin Lee trustin

🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂
View GitHub Profile
@trustin
trustin / bash_prompt.sh
Last active Jul 27, 2018
Trustin's Bash prompt
View bash_prompt.sh
#!/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"
View git-repush.sh
#!/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 / git-checkout-pr.sh
Last active Oct 30, 2017
git-checkout-pr.sh - fetches a Git pull request from the remote and creates a local branch for it
View git-checkout-pr.sh
#!/bin/bash -e
if [[ $# -ne 1 ]] || [[ ! "$1" =~ (^[1-9][0-9]*$) ]]; then
echo "Usage: $0 <pull request ID>" 1>&2
exit 1
fi
ORIGIN='origin'
if git remote | grep -qE '^upstream$'; then
ORIGIN='upstream'
fi
@trustin
trustin / smi2ass.py
Last active Jun 7, 2018
smi2ass.py - converts a SAMI (.smi) subtitle file to the SubStationAlpha (.ass) format.
View smi2ass.py
#!/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 / reconfigure-display.sh
Created Mar 10, 2016
Trustin's single/dual monitor setup script for laptops with nVidia GPU
View reconfigure-display.sh
#!/bin/bash
if [[ $# -gt 0 ]]; then
CLONE=1
else
CLONE=0
fi
function get_max_resolution() {
xrandr | grep -A100 "^$1 " | grep -P '^\s+[0-9]+x[0-9]+\s+[0-9\.]+\s*\*?\+.*$' | head -1 | awk '{ print $1; }'
}
@trustin
trustin / noroaming.patch
Created Sep 12, 2015
broadcom-wl patch that fixes the crash on multi-AP environment
View noroaming.patch
diff -urN a/src/wl/sys/wl_cfg80211_hybrid.c b/src/wl/sys/wl_cfg80211_hybrid.c
--- a/src/wl/sys/wl_cfg80211_hybrid.c 2015-09-12 16:39:28.000000000 +0900
+++ b/src/wl/sys/wl_cfg80211_hybrid.c 2015-09-12 16:50:44.908084821 +0900
@@ -2150,8 +2150,12 @@
WL_DBG(("\n"));
if (status == WLC_E_STATUS_SUCCESS) {
- err = wl_bss_roaming_done(wl, ndev, e, data);
- wl->profile->active = true;
+ if (!wl_bss_roaming_done(wl, ndev, e, data)) {
View pants
#!/bin/bash -e
# Check if we can canonicalize a path with readlink.
HAS_NEW_READLINK=1
readlink -m / >/dev/null 2>&1 || HAS_NEW_READLINK=0
# Chdir up until we find ./pants
INITIAL_PWD="$PWD"
while true; do
if [[ -x 'pants' ]]; then
@trustin
trustin / gist:8552089
Last active Jan 4, 2016
A simple scripts that turns 'Ctrl' into 'Super' key in X. It also reverts the changes made by your desktop environment by monitoring xkbmap periodically.
View gist:8552089
#/bin/bash
# 0 - Init, 1 - Set XKBMAP
KBD_STATUS=0
while true; do
KBD_OPT='caps:super,terminate:ctrl_alt_bksp'
if [[ $KBD_STATUS -eq 1 ]]; then
setxkbmap -query | grep -qF "$KBD_OPT" || ((KBD_STATUS=0))
fi
@trustin
trustin / hintstyle.patch
Created Nov 1, 2013
Wine patch for saner font hinting configuration, which applies 'hintslight' for ASCII glyphs and 'hintnone' for others such as CJK glyphs. I hope Wine uses fontconfig to respect the hintstyle, lcdfilter, and rgba properties like other GTK apps do.
View hintstyle.patch
diff -urN wine-orig/dlls/gdi32/freetype.c wine-patched/dlls/gdi32/freetype.c
--- wine-orig/dlls/gdi32/freetype.c 2013-07-19 02:57:36.000000000 +0900
+++ wine-patched/dlls/gdi32/freetype.c 2013-11-01 11:05:11.998232947 +0900
@@ -6199,10 +6199,15 @@
}
if(format & GGO_UNHINTED) {
- load_flags |= FT_LOAD_NO_HINTING;
format &= ~GGO_UNHINTED;
}
@trustin
trustin / pavol.sh
Created Jun 13, 2013
Volume control script for PulseAudio
View pavol.sh
#!/bin/bash
SINK="`pactl info | grep -P '^Default Sink: ' | sed 's/[^:]\+:\s\+//'`"
[[ -z "$SINK" ]] && exit 1
if [[ "$SINK" =~ DragonFly ]]; then
INCR='24'
MIN_VOLUME=65050
MAX_VOLUME=65146
else
INCR='2%'
You can’t perform that action at this time.