Skip to content

Instantly share code, notes, and snippets.

@vxavictor513
Last active June 17, 2025 07:35
Show Gist options
  • Save vxavictor513/5139324d1605a2ceecf03ac9474d5eab to your computer and use it in GitHub Desktop.
Save vxavictor513/5139324d1605a2ceecf03ac9474d5eab to your computer and use it in GitHub Desktop.

macOS Setup

Apps

What I use

Command-line Tools

General

Backend Development

Other Recommendations

Productivity Notes

Shortcut for Screenshot

Command + Control + Shift + 4 to snap, at the same time copy.

Read more here.

Make app switcher displays on both multiple screens

defaults write com.apple.Dock appswitcher-all-displays -bool true
killall Dock

Ref: https://superuser.com/a/1625752

Temporarily disable Gatekeeper to allow third party app installs that are not allowed by Apple

sudo spctl –-master-disable # disable
sudo spctl --master-enable # re-enable

Ref: https://osxdaily.com/2015/05/04/disable-gatekeeper-command-line-mac-osx/

Open project in Xcode from command line

At the directory where your xcworkspace or xcodeproj is, run the following command.

xed .

Ref: https://stackoverflow.com/a/52739630/5366727

Open project in IntelliJ from command line

In IntelliJ, go to Tools > Create Commandline Launcher for one-time setup.

At the directory where your Java project is, run the following command.

idea .

Ref: https://stackoverflow.com/a/49819015/5366727

Known Issue: k9s cannot resolve host name through VPN

When connected to VPN, k9s might not be able to resolve private host names.

This happens when k9s is installed via Homebrew, where Cgo is disabled by default.

To overcome this, we can compile and install k9s from source using go install.

Ref: derailed/k9s#780

Docker Setup

Colima as Docker Daemon

In case Docker Desktop cannot be used (e.g. due to licence limitation), can consider using Colima to replace Docker Daemon, then Docker CLI can still be used.

Sample command to start Colima

colima start --cpu 4 --memory 8 --disk 100

Install Docker buildx for Colima

See official doc here or discussion colima#273

brew install docker-buildx

mkdir -p ~/.docker/cli-plugins
ln -s $(which docker-buildx) ~/.docker/cli-plugins/docker-buildx

colima restart
docker buildx version

Adding insecure registries to Colima

See official docs here.

Using Dive with Colima

See wagoodman/dive#462 (comment)

export DOCKER_HOST=$(docker context inspect -f '{{ .Endpoints.docker.Host }}')

How to inspect files in a container image without running it

See https://stackoverflow.com/a/53481010

# Create
docker create --name="tmp_$$" image:tag
docker export tmp_$$ > output.tar
tar -xvf output.tar
# Clean up
docker stop tmp_$$
docker rm tmp_$$
docker ps -a

MySQL: MySQL 9 fails to start

There is a known issue at Homebrew#5539 where the introduction of MySQL 9 causing the database fails to start.

When troubleshooting, try the steps mentioned in brew info mysql

Upgrading from MySQL <8.4 to MySQL >9.0 requires running MySQL 8.4 first:
 - brew services stop mysql
 - brew install [email protected]
 - brew services start [email protected]
 - brew services stop [email protected]
 - brew services start mysql

MySQL: Reset password to empty string

mysqladmin -u root -p'password' password ''

Ref: https://serverfault.com/questions/103412/how-to-change-my-mysql-root-password-back-to-empty

MapStruct: Delegate IDE build/run actions to Maven in IntelliJ

Sometimes local build in IntelliJ does not work when a Java project has MapStruct.

Consider doing the following:

  1. Navigate to: File > Settings > Build, Execution, Deployment > Build Tools > Maven > Runner
  2. Check the option: Delegate IDE build/run actions to Maven
  3. Apply the changes and restart IntelliJ IDEA if necessary.

Ref: mapstruct/mapstruct#2802

Protobuf: Cannot compile on Apple Silicon machines

On Apple Silicon machines, when building the application using Maven command, we always needed to specify -Dos.arch=x86_64 otherwise the Protobuf could not be successfully compiled.

An alternative is to specify the Protobuf version in the Maven plugin configuration.

<configuration>
    <protocVersion>${protoc.version}</protocVersion>
</configuration>

Ref: os72/protoc-jar-maven-plugin#129

@KhyeK
Copy link

KhyeK commented Aug 31, 2022

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment