Category Archives: Blog

Main blog category, I’m too lazy to manage multiple categories so this blog has only one category.

Mac mini 10GbE Packet Loss Issue with Energy Efficient Ethernet (EEE)

64 bytes from 10.0.1.2: icmp_seq=772 ttl=64 time=2.401 ms
64 bytes from 10.0.1.2: icmp_seq=773 ttl=64 time=2.958 ms
Request timeout for icmp_seq 774
Request timeout for icmp_seq 775
Request timeout for icmp_seq 776
Request timeout for icmp_seq 777
Request timeout for icmp_seq 778
64 bytes from 10.0.1.2: icmp_seq=779 ttl=64 time=2.457 ms
64 bytes from 10.0.1.2: icmp_seq=780 ttl=64 time=2.173 ms
64 bytes from 10.0.1.2: icmp_seq=781 ttl=64 time=2.325 ms
64 bytes from 10.0.1.2: icmp_seq=782 ttl=64 time=2.803 ms

If you got packet loss issue with 10GbE Mac mini. Try to disable Energy Efficient Ethernet on your Network pane in System Preferences:

Network pane in macOS System Preferences

You have to manually configure your Ethernet with full-duplex only. Then your network should be back to normal.

GitHub Actions – Cross Repository Event Triggering with Repository Dispatch

What repository_dispatch can do in this post: When some tasks finish processing in repository A. Send a webhook payload to trigger GitHub Actions in repository B.

In .github/workflows/build.yml from repository A:

    - name: Notify project-b
      if: github.event_name != 'pull_request'
      run: |
        curl -X POST -H "Accept: application/vnd.github.v3+json" \
          -H "Authorization: Bearer ${{ secrets.PAT_SPARANOID }}" \
          https://api.github.com/repos/sparanoid/project-b/dispatches \
          -d '{"event_type":"webhook"}'

In .github/workflows/build.yml from repository B:

name: Build

on:
  # ... other options
  repository_dispatch:
    types:
      - webhook

# ...
jobs:
  build:
    # do your staff...

Custom VS Code Activity Bar Color Scheme for Light Color Mode

Search for workbench.colorCustomizations in your VS Code settings.json and add the following:

  "workbench.colorCustomizations": {
    "[Default Light*]": {
      "activityBar.background": "#ededed",
      "activityBar.activeBorder": "#222",
      "activityBar.activeBackground": "#22222210",
      "activityBar.activeFocusBorder": "#007acc",
      "activityBar.border": "#ddd",
      "activityBar.dropBorder": "#222",
      "activityBar.foreground": "#222",
      "activityBar.inactiveForeground": "#888",
      "activityBarBadge.background": "#007acc",
      "activityBarBadge.foreground": "#fff",
    },
  },

Result:

Global Homebrew PATH Prefix for macOS

Based on Homebrew’s FAQ you can set prefix in PATH for all GUI apps which is not enabled by default:

user$ sudo launchctl config user path "$(brew --prefix)/bin:${PATH}"
Configuration applied. You must reboot for changes to take effect.

According to this answer. The sudo launchctl config user path <...> command updates /private/var/db/com.apple.xpc.launchd/config/user.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>PathEnvironmentVariable</key>
	<string>/opt/homebrew/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
</dict>
</plist>

You can query launchd‘s current settings via:

launchctl getenv PATH

Related: You can also query the default PATH by executing:

sysctl user.cs_path

Test script with clear environment:

env -i git commit

Remove/Uninstall Rosetta 2 from Apple Silicon Macs

  1. Obtain a list of files/directories and LaunchAgents with: pkgutil --files com.apple.pkg.RosettaUpdateAuto
  2. Save them in a way that you can access them in the recovery
  3. Boot into recovery mode: Press and hold the power button on your Mac until “Loading startup options” appears.
  4. Open Terminal in recovery mode
  5. Run csrutil disable and confirm (temporary disable SIP)
  6. Reboot
  7. Delete the files listed at step 1 (in my case it was enough to delete /Library/Apple/usr/share/rosetta and /Library/Apple/usr/libexec with all their contents)
  8. Remember to empty the Trash
  9. Reboot back to recovery
  10. Run csrutil enable and confirm

Sample pkgutil output:

$ pkgutil --files com.apple.pkg.RosettaUpdateAuto
Library
Library/Apple
Library/Apple/usr
Library/Apple/usr/lib
Library/Apple/usr/lib/libRosettaAot.dylib
Library/Apple/usr/libexec
Library/Apple/usr/libexec/oah
Library/Apple/usr/libexec/oah/debugserver
Library/Apple/usr/libexec/oah/libRosettaRuntime
Library/Apple/usr/libexec/oah/runtime
Library/Apple/usr/libexec/oah/translate_tool
Library/Apple/usr/share
Library/Apple/usr/share/rosetta
Library/Apple/usr/share/rosetta/rosetta

Migrate Homebrew from Intel Macs to Apple Silicon Macs

Dump all your existing Homebrew packages:

brew bundle dump

If you’re using custom shell installed by Homebrew (ie. fish), change it back to bash temporarily:

chsh -s /bin/bash

You may also need to change this in System Preferences – Users & Groups (right click on your avatar and choose Advanced Options…)

Uninstall existing Homebrew (and all its packages):

curl -fsSL -o /tmp/uninstall.sh https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
/bin/bash /tmp/uninstall.sh --path=/usr/local
Continue reading

Nginx Notion Proxy

What these configs do:

  • Proxy all traffic from Notion to your custom domain notion.example.tld and deliver it to your clients
  • WebSocket proxy support
  • Image local disk caching support
  • Correct URL rewriting
  • Get access logs from real request IPs

This post is a proof of concept proxying a general XaaS without using any vendor-locked FaaS such as Cloudflare Workers or AWS Lambda.

Continue reading