Skip to content

Instantly share code, notes, and snippets.

View OliverSpeir's full-sized avatar

Oliver Speir OliverSpeir

View GitHub Profile
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC6cpSs4O35Es2BPR2x9S0m8lP759AkXwN6G+Z0FDZqoIwOx/G2v/4m/N38FhqJIu9Ke5E/aMT28F3nzzAx8rtSRIQLclyMBSuaGQWawQ5cYMqmaW6pNI++qu6OWlzM/NVyGgkQWwukicp36JKZi/OBECFi9IqzdLC6EUz5bFHHHx9gsYSgOcz2/99kv7Fgkb3/fRjPeWam2SEgnxBl4TA7RdDhk+MaAH0pYSPIqIcsTj6T7m/DDmM+ZWuQdc8RQDWrxbQ5GYmtKwFviVuWa+bmbVQ8SfQpwlWmZQSyxn0GtPmMpy9P8v38J+m4E+RHSd1gCoIlHEE1VhzrmSt6Tn9f5kIdpnLbre7Xa4JS/qH4kELAvri5RSocPLvM33/YI8oq8lXlyTeVBT/k4RtfvRK4onNZLiY5+nW7gwzKI4Cwo/TxbId/SVfc3HgsBsprJddC2/RwO10tg6XGWKINrOCdUU770gZB7MBcssHMd07H4AsbaXlTknOq8H4HvP9vcvRCqM+PlM9A0iX8/mcUkDILlwRpKm3tdC0x4G6+0OToQYvkgaZQPM/6s46I1pg/onR9BZEqGKbRuVYmS205crrcg818/V0lEkzQZdFxI0utfBJMWS/n+cafJD1c6nV1T4iLDqkiz7mUdLOGJw2H4ikF5LUdaoMrAjTxKqKcB72K4w== oliverspeir9@gmail.com
-----BEGIN PGP PUBLIC KEY BLOCK-----
mDMEZt+nIxYJKwYBBAHaRw8BAQdAg/NnFUA+0w9JlFtbDg9csmy2ZmXZwIWpLj1V
/dBrf1q0JW9saXZlciBzcGVpciA8b2xpdmVyc3BlaXI5QGdtYWlsLmNvbT6IkwQT
FgoAOxYhBAoczh/8vhfCaQIIwTln9ThkyCCkBQJm36cjAhsDBQsJCAcCAiICBhUK
CQgLAgQWAgMBAh4HAheAAAoJEDln9ThkyCCk+UoBAO
@OliverSpeir
OliverSpeir / view-on-github.svg
Last active May 22, 2024 06:47
View on Github svg styled like Open in StackBlitz button
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@OliverSpeir
OliverSpeir / .zshrc
Last active May 31, 2024 03:44
Automatically install and use the correct Node version and enable corepack
# Automatically install and use the correct Node version
autoload -U add-zsh-hook
load-nvmrc() {
# Fail early if .nvmrc file is not present
if [ ! -f .nvmrc ]; then
return
fi
local required_version
@OliverSpeir
OliverSpeir / killport
Last active February 18, 2024 06:35
Killport
killport() {
if [[ -z "$1" ]]; then
echo "Usage: killport <port>"
return 1
fi
local port=$1
local pids=$(lsof -ti tcp:"$port")
if [[ -z "$pids" ]]; then
echo "No processes found on port $port."
return 1
@OliverSpeir
OliverSpeir / publishnotes
Last active February 18, 2024 06:38
Function to auto deploy obsidian notes
publishnotes() {
rsync -av --exclude=".*" --delete "/path/to/obsidian/notes" "/path/to/repo/src/content/notes/" >/dev/null 2>&1
cd
cd /path/to/repo
# acp is function that adds commits and pushes https://gist.github.com/OliverSpeir/6842787f67680a1844c718e09eacb169
acp >/dev/null 2>&1
cd
# find .md files, convert spaces to hyphens, convert to lowercase, remove extension
find "/path/to/repo/src/content/notes/" -name "*.md" | sed 's/\/path\/to\/repo\/src\/content\/notes\///' | sed 's/.md$//' | awk '{print tolower($0)}' | tr ' ' '-' | while read line
do
@OliverSpeir
OliverSpeir / timestamp
Last active February 18, 2024 06:37
timestamp command that will print readable date format from unix timestamp or difference between two timestamps
timestamp() {
# Define colors and styles
local BLUE="\e[1;36m"
local GREEN="\e[1;32m"
local RESET="\e[0m"
local NEWLINE="\n"
local RED="\e[1;31m"
if [ $# -eq 1 ]; then
# Split the date and time into two variables
@OliverSpeir
OliverSpeir / ginit
Last active May 31, 2024 03:47
git init remote repo with .gitignore and README.md zsh command using gh cli
ginit() {
local repo_name="."
local visibility="public"
if [[ -n "$1" ]]; then
if [[ "$1" == "private" || "$1" == "priv" ]]; then
visibility="private"
else
repo_name="$1"
fi
@OliverSpeir
OliverSpeir / acp
Last active February 18, 2024 06:35
git add commit push all in one command zsh
acp() {
message="$*"
branch=$(git rev-parse --abbrev-ref HEAD)
git add -A
git commit -m "$message" --allow-empty-message
git push origin $branch
}
#
# ADD TO ~/.zshrc
#