Skip to content

Instantly share code, notes, and snippets.

View j0yu's full-sized avatar
👌

Joe Yu j0yu

👌
View GitHub Profile
@j0yu
j0yu / null-args.bash
Created January 13, 2020 15:44
Storing and fetching cmd arguments using null as separator
#!/bin/bash
# Null separate arguments to retain newlines/whitespace
ARGS_FILE="$(mktemp)"
# WRITE/STORE -----------------------------------------
printf "%s\0" "$@" > "$ARGS_FILE"
# READ -----------------------------------------
#!/bin/bash
set -x
: Raw @ and *
: $@
: $*
:
: Quoted @ and *
: "$@"
: "$*"
:
@j0yu
j0yu / Dockerfile
Last active November 12, 2019 18:53
Running Maya after mounting install inside fresh CentOS 7 container
FROM centos:7
RUN yum install -y \
mesa-libGLU-9.0.0-4.el7 \
libgomp-4.8.5-39.el7 \
libXp-1.0.2-2.1.el7 \
libXmu-1.1.2-2.el7 \
libXpm-3.5.12-1.el7 \
libXi-1.7.9-1.el7 \
libtiff-4.0.3-32.el7 \
@j0yu
j0yu / deps-install
Last active November 14, 2019 11:16
Auto installs yum library dependencies
#!/bin/bash
set -euf -o pipefail
# Usage:
#
# deps-install CMD [ARGS ...]
#
# Execute a command, parsing and yum installing library dependencies
#
# Examples:
@j0yu
j0yu / bleeding-rez-hack.bash
Last active November 6, 2019 22:42
Run interactively in docker run --rm -it centos:7
########### ---- Results from running ----
########### curl -sSL https://bootstrap.pypa.io/get-pip.py | python -
########### pip install bleeding-rez
########### rez bind python
########### rez bind rez
########### cd $(mktemp -d)
########### curl -sSL https://github.com/mottosso/rez-pipz/archive/1.1.0.tar.gz | tar -xz --strip-components=1
########### rez build --install
########### rez env pipz -- chmod +x '$REZ_PIPZ_ROOT/bin/install'
########### rez env pipz -- PATH=$(dirname $(command -v python)) '$REZ_PIPZ_ROOT/bin/install' -y pip
@j0yu
j0yu / acb-patch.md
Last active March 28, 2020 22:58
Patch Steam Assassins Creed Brotherhood (flatpak)
#!/bin/bash
set -eufx -o pipefail
cd ~/.var/app/com.valvesoftware.Steam/.local/share/Steam
export WINEPREFIX=$(find steamapps/compatdata/ -mindepth 1 -maxdepth 1 -type d -print -quit)/pfx
# WINE_BIN="$(find steamapps -name wine ! -type d | sed 's/ /\\ /g')"
WINE_BIN="$(find steamapps -executable -name wine ! -type d)"
@j0yu
j0yu / centOS7_virtual_terminal.bash
Last active August 2, 2019 11:04
scancodes for Microsoft_Natural®_Ergonomic_Keyboard_4000 special buttons
# Ctrl+Alt+2 to log into virtual terminal
# Then run the below:
showkey -k > /tmp/keycodes.txt
showkey -s > /tmp/scancodes.txt
@j0yu
j0yu / docker_descendants.py
Last active May 7, 2019 15:36 — forked from altaurog/docker_descendants.py
Python 2 version of the Python3 script to find descendants of one or more docker images. Slightly different searching/print algorithm
#!/bin/python2
#
# usage: python2 docker_descendants.py <image_id> ...
import sys
from subprocess import check_output
from collections import defaultdict
def run(cmd):
@j0yu
j0yu / colorping
Created March 17, 2018 12:09
Check your internet connection
#!/bin/bash
ping www.google.com | while read LINE;
do
MS_STR=$(echo $LINE | grep -oP '[0-9\.]+(?= ms)')
MS_INT=$(printf '%.0f' "$MS_STR")
PRE_STR='\e[0;43m\e[30m'
[ $MS_INT -gt 100 ] && PRE_STR='\e[0;41m\e[30m'
[ $MS_INT -lt 30 ] && PRE_STR='\e[0;42m\e[30m'
for unknPlugin in (mc.unknownPlugin(query=True, list=True) or []):
try:
mc.unknownPlugin(unknPlugin, remove=True)
print('Unknown plugin removed : {}'.format(unknPlugin))
except RuntimeError as err:
print('({}) {} (Node types: {})'
''.format(unknPlugin, err,
mc.unknownPlugin(unknPlugin, q=True,
nodeTypes=True)))