Skip to content

Instantly share code, notes, and snippets.

View jmatsu's full-sized avatar
🏠
Working from home

Jumpei Matsuda jmatsu

🏠
Working from home
View GitHub Profile
@jmatsu
jmatsu / parse_vector_pathData.rb
Created September 3, 2023 04:27
Just a snippet to parse vector drawable's pathData for VectorImage in Compose
# ruby parse_vector_pathData.rb "<pathData>"
#
# @example ruby parse_vector_pathData.rb "M2...Z"
#
# <pathData> is a pathData attribute of path node.
pathData = ARGV[0]
kotlinPathNodeChunks = []
@jmatsu
jmatsu / created a repository
Last active June 19, 2022 07:41
Docker .env compatible Bash function to export them
https://github.com/jmatsu/export-docker-dotenv
@jmatsu
jmatsu / .zshrc
Created December 10, 2021 03:12
Force me to set advanced messages to git stash
proxy-git() {
if ! type command > /dev/null 2>&1; then
git "$@"
elif let "$# > 0"; then
# git git git git... :)
while [[ "$1" == "git" ]]; do
shift 1
done
if [[ "$1" = "stash" ]]; then
@jmatsu
jmatsu / script-template.sh
Created June 29, 2021 04:27 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
# Register a filter command for Git commands
git config --system --add mine.filter fzf
# Show checked-out branches in reflog (distinct, and not sorted by the checked-out time)
git config --system --add alias.head-history "\!f() { git reflog HEAD | grep 'checkout:' | awk '\$0=\$NF' | sort | uniq; }; f"
# Select and switch HEAD to the branch
git config --system --add alias.switch-to "\!f() { local -r ref=\"\$(git head-history | \$(git config --get mine.filter))\"; [[ -n \"\$ref\" ]] && git switch \"\$ref\"; }; f"
@jmatsu
jmatsu / packaged
Last active February 9, 2021 08:20
https://github.com/jmatsu/mc-migration
@jmatsu
jmatsu / get_default_branch_name.sh
Last active August 1, 2020 06:37
To avoid default branch name chaos
# get the default branch of the current repository. NOTE that this will requires the network connection
git config --global alias.default-branch "\!f() { git ls-remote --symref \$(git remote get-url origin) HEAD | grep 'refs/heads' | awk '\$0=\$2' | sed 's/refs\/heads\///'; }; f"
# then run git default-branch
# BAD
export ANDROID_HOME="$HOME/sdk"
curl -o sdk-tools.zip "https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip"
unzip "sdk-tools.zip" -d $ANDROID_HOME
$ANDROID_HOME/tools/bin/sdkmanager <package>...
# GOOD
export ANDROID_SDK_ROOT="$HOME/sdk"
mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
curl -o sdk-tools.zip "https://dl.google.com/android/repository/commandlinetools-linux-6514223_latest.zip"
export ANDROID_HOME="$HOME/sdk"
curl -o sdk-tools.zip "https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip"
unzip "sdk-tools.zip" -d $ANDROID_HOME
$ANDROID_HOME/tools/bin/sdkmanager <package>...
die() {
echo "$*" >&2
exit 1
}
warn() {
echo "$*" >&2
}
if [[ ! -d ".git/hooks" ]]; then