Skip to content

Instantly share code, notes, and snippets.

@daaimah123
Last active February 14, 2025 02:53
Show Gist options
  • Save daaimah123/5ffa3495837474c1935f35672a9944ae to your computer and use it in GitHub Desktop.
Save daaimah123/5ffa3495837474c1935f35672a9944ae to your computer and use it in GitHub Desktop.
# All geos, all languages
language IN ["in", "en", "gb", "da", "nl", "fi", "fr", "de", "it", "ja", "ko", "no", "pt-br", "ru", "es", "sv",  "tr", "zh-tw"]

# Do NOT include Portuguese
language != "pt-br"

# English-only
language IN ["en", "gb"]

✅ Industry, Git, & Command Line

git commit --no-verify

make test-php

npm run build:types && npm run lint # typescript build and check lint

npm run lint && npm run test -- -u # run lint tests and update snapshots

npm run eslint-fix # auto-fix lint errors

git pull origin main # pull all latest from main

git reset --hard origin/main # reset entire branch to main removing any local changes

npm install --no-optional --no-audit

npm run clean:cache

npm run build

# update dependencies in package.json to latest
npm i -g npm-check-updates
ncu -u
npm install

Add path to Paths

sudo nano /etc/paths

Force clear npm cache

sudo npm cache clear --force

Find all merged branches

git branch --merged | grep -v \* | xargs

Delete all merged branches

git branch --merged | grep -v \* | xargs git branch -D

Delete all excluding main

git branch | grep -v "main" | xargs git branch -D

Retrieves failed commit messages

git commit -e --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG

Git stash

Try git stash apply instead of git stash pop to avoid losing saved changes

git stash save <message>
git stash apply stash@{#}

Remove git from project / directory

rm -rf .git*

Print $PATH variable pretty

echo $PATH | tr ":" "\n"

Update Node and NPM

sudo npm cache clean -f
sudo npm install -g n #install latest version of node
sudo n vX.XX.XX #install specifc version of node
sudo n stable

Add ssh-key to ssh-agent

ssh-add -K

Remove file / directory from entire tree history

You know when you accidentally commit "." files this will take a while but it will walk through every committed instance of the file and directory on your branch and remove it, your will have to force the push to see results on remote. USE WITH EXTREME CAUTION

git filter-branch --tree-filter 'rm -rf <file-or-directory-to-be-removed>' HEAD

Quick version, does not check the tree

git filter-branch --index-filter 'rm -rf <file-or-directory-to-be-removed>' HEAD

Rewrite a commit

Rebase, then replace pick with reword, save/exit, the commit window will open for editing, save and force push

git rebase -i <commit_hash>^ OR git rebase -i HEAD~N // N = number of commits back
reword <commit_hash>
:wq

Node Modules or Package Consistency Acting Up?

Remove and reinstall node_modules

rm -rf node_modules
npm install

Good Reads

An incomplete list of skills senior engineers need, beyond coding

Docker

Which docker containers are running on the host: docker ps
See all docker containers: docker ps -a
Restart a docker container: docker restart <container-id>
Stop a docker container: docker stop <container-id>
Start a docker container: docker start <container-id>

VirtualBox won't start up

Shut down VirtualBox, restart, in CLI enter sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart, then vagrant up

If this doesn't work, you will need to go to System Preferences > Security & Privacy Then hit the “Allow” button to let Oracle (VirtualBox) load.

React Props & DefaultProps Resources

Adding GPG on M1 Mac

Resources

# determine if a gpg-agent is running
gpg-agent --default-cache-ttl 2629800

# [Correct Correct GnuPG Permission](https://gist.github.com/oseme-techguy/bae2e309c084d93b75a9b25f49718f85)
#!/usr/bin/env bash

# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/

# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg


# ensure the following is in ~/.gnupg/gpg-agent.conf
# remember the password longer (1 hour since last usage, 5 hours max)
default-cache-ttl 3600
max-cache-ttl 18000

allow-preset-passphrase
allow-loopback-pinentry


# ensure the following is in ~/.gnupg/gpg.conf
pinentry-program /usr/local/bin/pinentry-mac

use-agent
pinentry-mode loopback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment