Skip to content

Instantly share code, notes, and snippets.

View LeZuse's full-sized avatar
🚀
Scaling productboard.com

Tomas Ruzicka LeZuse

🚀
Scaling productboard.com
View GitHub Profile
@LeZuse
LeZuse / psql.sh
Created April 4, 2023 13:43
Quickly start psql REPL with a fresh PostgreSQL instance
# 1. Launch Docker Desktop
# 2. Verify it is running:
docker ps
# 3. Start up a postgres instance and grab the container ID:
container_id=$(docker run -e POSTGRES_PASSWORD=mysecretpassword -d postgres)
# 4. Connect using psql:
docker exec -it "$container_id" psql -h localhost -U postgres
# 5. After doing your business, exit psql and shutdown the instance:
docker stop $container_id
# 6. Cleanup if you won't be using the instance anymore
@LeZuse
LeZuse / howto.md
Last active October 11, 2024 11:33
Disable Docker for Mac auto-update

Docker downloads all updates into a directory in /Users/$USER/Library/Caches/com.docker.docker/org.sparkle-project.Sparkle Let's make this directory inaccessible to the user under which Docker is going to run (you).

Switch to root user:

  sudo su

Change directory ownership and prevent access to other users:

@LeZuse
LeZuse / howto.md
Created March 30, 2021 13:31
Kubernetes context in iTerm status bar
@LeZuse
LeZuse / 00_README.md
Last active November 1, 2024 02:35
Install node on Apple Silicon M1 both ARM and x86 (Rosetta)

Node.js on Apple Silicon

Node Version Manager (https://github.com/nvm-sh/nvm) works perfectly across native node installations as well as emulated Rosetta installations. The trick I am using here is to install one LTS version of node under Rosetta and another stable version as native binary.

TODO

  • find a way how to run the same node version on both platforms
@LeZuse
LeZuse / analytics.bash
Last active November 16, 2020 17:32
Bash history logging into Google Analytics
#!/bin/bash
# Install
# Option 1: Install iTerm Bash integration
# https://www.iterm2.com/documentation-shell-integration.html
# Option 2: bash-preexec
# https://github.com/rcaloras/bash-preexec/blob/master/README.md#install
# Then source this file into your .bash_profile or equivalent:
# source "$HOME/analytics.bash"
@LeZuse
LeZuse / nx-completion.bash
Last active October 23, 2020 08:25
Bash completion for Nx – Extensible Dev Tools for Monorepos
#/usr/bin/env bash
# Bash completion for nx.dev project
# Inspired by https://github.com/jukben/fish-nx/blob/master/completions/nx.fish
# Prerequisites:
# brew install jq fzf
# Installation
# Source this file in your .bash_profile:
@LeZuse
LeZuse / tailscale
Created October 5, 2020 16:13
Tailscale CLI alias
#!/bin/bash
# Installation:
# Move this file into /usr/local/bin and make it executable:
# chmod +x /usr/local/bin/tailscale
# https://tailscale.com/kb/1080/cli#using-the-cli
/Applications/Tailscale.app/Contents/MacOS/Tailscale $@
@LeZuse
LeZuse / gitlab-env-copy.sh
Last active April 22, 2020 19:05
Copy ENV vars from one GitLab project to another
GL_TOKEN=xxxxxxx-xxxxxxx
ID_FROM=00001
ID_DESTINATION=00002
PREFIX=
[ "$1" == "--dry-run" ] && PREFIX=echo
download_page () {
DATA=`curl --header "PRIVATE-TOKEN: $GL_TOKEN" "https://gitlab.com/api/v4/projects/$ID_FROM/variables?per_page=100&page=$c"`
@LeZuse
LeZuse / mute.applescript
Last active April 17, 2020 14:53
Mac OS un/mute with notification using Automator
-- Credits: https://superuser.com/a/937488/44834
-- https://apple.stackexchange.com/a/346995/62041
set inputVolume to input volume of (get volume settings)
-- Zoom does not allow the input volume to drop to 0, so we check by "lower than"
if inputVolume < 10 then
set inputVolume to 100
set displayNotification to "Microphone Unmuted"
else
set inputVolume to 0
set displayNotification to "Microphone Muted"
@LeZuse
LeZuse / services.bash
Last active October 5, 2021 07:31
brew services list/start/stop fzf ui
function services() {
brew services \
`echo -e 'list\nstart\nstop' | fzf --header 'brew services'` \
`brew services list | tail -n +2 | \
fzf -d' ' --with-nth=1 --preview='brew services list | grep {}' --preview-window=up:1 | \
cut -d' ' -f1`
}