Skip to content

Instantly share code, notes, and snippets.

@dialex
dialex / Default%20%28OSX%29.sublime-keymap
Last active January 13, 2024 16:52
Sublime Text 3 Settings
[
{ "keys": ["super+t"], "command": "new_file" },
]
@dialex
dialex / python.md
Last active August 1, 2021 14:19
setup scripting enviroments
brew install pyenv
pyenv init
(reload terminal)
pyenv install 3.9.6
pyenv global 3.9.6
pyenv versions
python3 -V
pip3 -V
@dialex
dialex / pair-with.sh
Last active June 24, 2020 14:52
co-author commits
#!/bin/bash
# How to use this little dev tool
#
# You need to add the following snippet to .git/config
# [commit]
# template = .git/.gitmessage
#
# And this is how you should run it
# ./pair-with.sh will simply empty the .gitmessage file
@dialex
dialex / code.sh
Last active September 11, 2019 08:08
check if tool is installed before running command
check_file_exists () {
local what=${1:-}
if [[ ! -f "$what" ]]; then
>&2 echo "Error: Could not find '$what'" # stderr
exit 1
fi
}
check_tool_exists () {
local what=${1:-}
@dialex
dialex / get-npm-package-version
Created September 9, 2019 09:14 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
echo $PACKAGE_VERSION
@dialex
dialex / services-healthcheck.sh
Created August 8, 2019 15:05
Check health of services through APIs
#!/bin/bash
############
# Functions
############
function is_api_healthy() {
local api_endpoint=${1}
local api_name=${2}
local status_code=$(/usr/bin/curl -sL --max-time 5 -w "%{http_code}\n" "$api_endpoint" -o /dev/null)
@dialex
dialex / brew-upgrade.sh
Last active July 3, 2025 10:10
Upgrades everything that was installed using brew. Cleanups at the end.
#!/bin/sh
brew update;
brew upgrade;
brew upgrade --cask;
brew cu -fy --cleanup;
# brew upgrade --cask --greedy;
brew cleanup;
brew autoremove;
read -p "Finished. Press Enter to continue..."
@dialex
dialex / .zshrc
Last active July 3, 2025 10:15
macOS bash_profile
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# If you come from bash you might have to change your $PATH.
# PYTHON: uncomment this to fix version of pip3 https://stackoverflow.com/a/64240143/675577
export PATH=$HOME/bin:/usr/local/bin:$PATH
@dialex
dialex / dir-pull-repos.sh
Last active September 28, 2018 16:55
My purpose is to pull (rebase) all git repositories in the current directory
#!/bin/bash
#set -e #fail on first error
echo -e "🤖 My purpose is to pull (rebase) all your git repositories in this directory.\n"
for d in */ ; do
echo -e "\n>> Pulling git repo... ${d%?}"
cd $d;
#git pull -r;
git pull -r --autostash;
# list total size of directories, sorted on CLI
du -sh * | gsort -r -h
# GDrive find files that were deleted but are still using up space https://support.google.com/drive/thread/16475518?hl=en&msgid=16485580
owner:me is:unorganized
# upgrade yarn dependency and update package.json
yarn upgrade PackageNameHere@^
# when maven doesn't want to prepare release