Skip to content

Instantly share code, notes, and snippets.

@jbenner-radham
Last active August 5, 2025 22:19
Show Gist options
  • Select an option

  • Save jbenner-radham/c2cecfa55894c00c6e24d44646b60122 to your computer and use it in GitHub Desktop.

Select an option

Save jbenner-radham/c2cecfa55894c00c6e24d44646b60122 to your computer and use it in GitHub Desktop.
Assorted notes.

Assorted Notes

Character Reference

CSS

Docker Commands

  • Prune system volumes: docker system prune --volumes
  • Delete all images: docker rmi $(docker images -a -q)

Git Commands

  • Auto-setup remote branch with tracking: git config --global push.autoSetupRemote true.
  • Amend a commit with a message that starts with an octothorpe: git commit --amend --cleanup=scissors.
  • Checkout the last locally used branch: git checkout -.
  • Create an empty branch: git switch --orphan <BRANCH>.
  • Create an empty commit: git commit --allow-empty --message='<MESSAGE>'.
  • Delete a local tag: git tag --delete <TAG>.
  • Delete a remote branch: git push --delete <REMOTE> <BRANCH>.
  • Delete a remote tag: git push --delete <REMOTE> <TAG>.
  • Delete all local branches which have been merged into main: git branch --no-contains main --merged main | xargs git branch -d
  • Diff staged files: git diff --staged or git diff --cached.
  • List all the commit hashes in a branch: git rev-list <BRANCH>.
  • List all the local branches in a "very verbose" manner (branches which once had a remote version on origin will have a "gone" tag): git branch -vv
  • Move/rename the current local branch: git branch --move <NEW BRANCH>.
  • Set default branch name: git config --global init.defaultBranch <NAME>
  • Reset all tracked files and delete all untracked files and directories: git reset --hard && git clean -d --force.
  • Reset the last commit and unstage the changes: git reset HEAD~.
  • Rebase to squash commits interactively, using <BRANCH> as a starting point: git rebase --interactive <BRANCH>.
  • Show the working tree status; including files that are ignored: git status --ignored.
  • Set a global Git ignore file: git config --global core.excludesFile '<PATH_TO_GITIGNORE>'

Homebrew

  • Create a Brewfile of your currently installed Homebrew packages. Targets $HOME by default: brew bundle dump [--file=/path/to/Brewfile] [--force] [--describe]
  • Install from a Brewfile. Searches $HOME by default: brew bundle install [--file=/path/to/Brewfile]

HTML

Image Optimization

IntelliJ Keyboard Shortcuts (macOS)

  • Add or remove carets at selected locations using a mouse: ⌥ Option + Click
  • Add selection for next occurance: ^ Control + G
  • Duplicate Line: ⌘ Command + D
  • Select all occurrences of a word or a text range: ⌘ Command + ^ Control + G
  • Select multiple occurrences of a word or a text range: ^ Control + G
  • Surround Code: ⌘ Command + ⌥ Option + T
  • Move Line Down: ⇧ Shift + ⌥ Option + ↓ Down
  • Move Line Up: ⇧ Shift + ⌥ Option + ↑ Up
  • View Quick Documentation: ^ Control + J
  • View Valid Parameters (in parentheses of a method call): ⌘ Command + P

IntelliJ Keyboard Shortcuts (Windows)

  • Add Selection for Next Occurrence: Alt + J
  • Extract Variable Refactoring: Ctrl + Alt + V
  • Surround Code: Ctrl + Alt + T
  • View Quick Documentation: Ctrl + Q
  • View Valid Parameters (in parentheses of a method call): Ctrl + P

Npm Commands

  • Set default package initialization author email: npm config set init-author-email <EMAIL>.
  • Set default package initialization author name: npm config set init-author-name <NAME>.
  • Set default package initialization author URL: npm config set init-author-url <URL>.
  • Set default package initialization license: npm config set init-license <SPDX LICENSE>.
  • Set default package initialization scope: npm config set scope @<SCOPE NAME>.
  • Set default package initialization version: npm config set init-version 0.0.0.
  • List configuration: npm config list.
  • View a package's published version: npm view <PKG NAME> version.
  • List a package's distribution tags: npm dist-tag ls [PKG NAME].
  • ...: npm help package.json

Sublime Text Keyboard Shortcuts (macOS)

Open file at a specified position: Cmd + P -> $FILENAME:$LINE:$COLUMN

UNIX-like Commands

  • Determine a file's type: file $FILE
  • Determine a file's type (without prepending the filename to the output): file --brief $FILE
  • Get current shell PID: echo $$
  • Get current year: date +"%Y"
  • Get the ISO 8601 date: date --iso-8601 (not on macOS) or date +"%Y-%m-%d"
  • Get Debian version: cat /etc/debian_version
  • Get Linux version (and other metadata): cat /etc/os-release
  • Get OS type: uname ("Darwin" for macOS and "Linux" for, well... Linux)
  • Get Ubuntu version: lsb_release -a
  • Get most recent exit code: echo $?
  • Get shell name: ps hp $$ -o cmd
  • List all actively listening TCP ports on localhost: [sudo] lsof -PiTCP -sTCP:LISTEN
  • Make a directory and cd into it (without re-typing the directory name): mkdir $DIRECTORY_NAME && cd $_
  • Rebuild font cache: fc-cache -fv (Maybe Linux only? Not on macOS 15.5 at least.)
  • Remove extended attributes (macOS): xattr -c $FILENAME
  • Run a command repeatedly a finite amount of times: for _ in {1..$DESIRED_RUN_COUNT}; do $COMMAND; done
  • ...: netstat -ant | grep LISTEN equivalent to netstat -anp tcp | grep LISTEN

Visual Studio Code Keyboard Shortcuts (macOS)

  • Add column: (Command) + \
  • Add cursor(s) to line end(s): ⇧ Shift + ⌥ Option + I
  • Copy line down: (Shift) + (Option) + (Down)
  • Copy line up: (Shift) + (Option) + (Up)
  • Move line down: (Option) + (Down)
  • Move line up: (Option) + (Up)

Yarn Commands

  • Set default package initialization author email: yarn config set init-author-email <EMAIL>.
  • Set default package initialization author name: yarn config set init-author-name <NAME>.
  • Set default package initialization author URL: yarn config set init-author-url <URL>.
  • Set default package initialization license: yarn config set init-license <SPDX LICENSE>.
  • Set default package initialization version: yarn config set init-version 0.0.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment