Category Archives: Blog

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

GMMK Pro Restores to Original Firmware from VIA

Minimal guide how to flash GMMK Pro keyboard from factory firmware to VIA firmware and vice versa.

Factory firmware to VIA firmware

  • Download VIA firmware
  • Download QMK Toolbox
  • Unplug your keyboard and reconnect it while holding the spacebar and B at the same time
  • You should see a message in the QMK Toolbox that indicates that your board is in STM DFU Bootloader Mode.
  • Load the VIA firmware and press Flash

VIA firmware to facttory firmware

  • Download factory firmware
  • Unplug your keyboard and reconnect it while holding the ESC (The official guide is wrong that tells you to hold spacebar and B)
  • You should see a message in the QMK Toolbox that indicates that your board is in STM DFU Bootloader Mode.
  • Load the factory firmware and press Flash

NPM Publish Error 402 Payment Required – You must sign up for private packages

When publishing public scoped packages you might get the following errors:

npm ERR! code E402
npm ERR! 402 Payment Required - PUT - You must sign up for private packages

This happens when trying to publish public scoped packages. The default access level is private. To resolve this you can either set npm config set access public or add the following to your package.json:

"publishConfig": {
  "access": "public",
  "registry": ""

Microsoft 365 Excel Performance Hack for UHD Displays in Windows

If you have a large spreadsheet to edit (ie. 10k+ columns) with your UHD display (ie. 4K or higher resolution) in Microsoft 365 Excel you may have some performance issues when scrolling.

I just found an easy hack that works for me:

  1. Check Disable hardware graphics acceleration in Excel under File – Options – Advanced – Display section
  2. Exit Excel
  3. Change your display resolution to 1920×1080
  4. Change text scale to 100%
  5. Open the spreadsheet you need to edit with Excel
  6. Change your display resolution back to native resolution
  7. Change text scale back to your original option (ie. 200%)
  8. See magic happens

This hack works until you exit your Excel. So you have to redo step 3-8 when openning new documents.

Download Bilibili 4K Videos. The Hard Way


  • Google Chrome installed
  • Get cookies.txt extension installed
  • youtube-dl installed
  • FFmpeg installed
  • Active bilibili membership (to get 4K streaming perk)
  • Basic JSON and Bash knowledge


  • Open the video page you want to download with Google Chrome
  • Open Web Inspector and refresh the page
  • Change video quality to some lower ones (like 480p) and change back to 4K
  • Search for player/playurl in Inspector
  • You should get a JSON payload returned:

Then select one of the most recent requests with accept_quality that has 120 in array:

Then select down to the[0].baseUrl and[0].baseUrl. Remember these URLs:

Open Get cookies.txt extension and download your current cookies.

Download video and audio with youtube-dl:

youtube-dl --cookies bilibili.com_cookies.txt --referer '' ''

Then you will get two files like the following:

  • 20210510 336676712-1-30280 [336676712-1-30280].m4s
  • 20210510 336676712-1-30120 [336676712-1-30120].m4s

Rename the video extension to mp4 and audio to m4a. Play them to check if everything works.

Combine these two with FFmpeg:

ffmpeg -i 20210510\ 336676712-1-30120\ \[336676712-1-30120\].mp4 -i 20210510\ 336676712-1-30280\ \[336676712-1-30280\].m4a -c copy output-combined.mp4

Fix Invalid Package Name “.DS_Store” for Node.js NPM Global Update on macOS

If you got the following error message when run npm update -g:

$ npm update -g
npm ERR! Invalid package name ".DS_Store": name cannot start with a period

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/sparanoid/.npm/_logs/2021-04-28T13_59_32_013Z-debug.log

Simply run if you installed your Node.js via Homebrew:

find /usr/local -name '.DS_Store' -type f -print -delete

Using Motion Sensor as Occupancy Sensor for HomeKit with Homebridge


  • A HomeKit enabled motion sensor. I use Aqara Motion Sensor Hue Motion Sensor
    • The update interval of Hue Motion Sensor exposes to HomeKit is 10 seconds. Far better than Aqara Motion Sensor (120 seconds). And seems more stable after testing for months.
  • A HomeKit enabled accessory to be controlled
  • Homebridge with homebridge-delay-switch plugin installed


  • You want to stick with local automation instead of configuring automations in vendor specific apps
  • Trigger an open/turn on/start event when motion detected
  • When no motion for specific minutes. Trigger another event to close/turn off/stop

Why? This method no longer depends on the buggy HomeKit built-in “Turn Off” and Stops Detecting Motion feature. Common HomeKit motion sensors only update the motion state every n seconds. When Stops Detecting Motion triggers. It won’t be canceled or delayed when it detects another motion during the n detection interval. That causes your accessory to be turned off even motion detects during the time you set.

With my method. Your accessory won’t be turned off if your motion sensor detects motion during the specific time you set. Make your motion sensor work more like an occupancy sensor.

First. Add a delay switch in Homebridge:

    "name": "Living Room Delay Switch",
    "delay": 300000,
    "disableSensor": false,
    "startOnReboot": false,
    "accessory": "DelaySwitch"

The delay time is in milliseconds so 300000 equals 6 minutes here.

In your Home app. Create the following automations:

First Automation

  • When: Living Room Motion Sensor – Detects Motion
  • Accessories:
    • Turn on your accessory
    • Turn on your Living Room Delay Switch

Second Automation

  • When: Living Room Delay Switch Trigger – Detects Motion
  • Accessories:
    • Turn off your accessory

Third Automation

This automation is important. It can ensure your accessory can still be turned off at a specific time if the accessory was opened/turned on/started manually.

  • When: Living Room Sensor – Stops Detecting Motion
  • Accessories:
    • Turn on your Living Room Delay Switch

How to Install LineageOS on OnePlus 3T with GApps

This is the minimal guide for installing LineageOS 17.1 on OnePlus 3T abtracted from LineageOS offical guide. It works at the time of writing so no gurantee for further updates.

  1. Enable OEM unlocking and USB debugging on your phone with developer mode.
  2. Download latest Android platform tools for Windows, for Linux, or for macOS from Google. The full guide can be found at Using ADB and fastboot.
  3. Connect your phone into your computer with USB mode.
  4. Install the built-in OnePlus USB Drivers or use UniversalAdbDriver.
  5. cd to the platform-tools directory, run adb devices to see if your phone is connected.
  6. Run adb reboot bootloader to boot your phone into bootloader mode.
  7. Run fastboot devices while in bootloader mode to see if your computer still connects to it.
  8. Run fastboot oem unlock. Your phone should be reset and reboot automatically.
  9. Setup your phone. Then re-enable USB debugging.
  10. Download latest custom recovery from TWRP.
  11. Run adb reboot bootloader to boot your phone into bootloader mode. Also make sure your phone can be find in fastboot mode by re-typing fastboot devices.
  12. Run fastboot flash twrp-3.4.0-0-oneplus3.img to flash custom recovery.
  13. Run fastboot boot twrp-3.4.0-0-oneplus3.img to boot into new recovery mode.
  14. Download the LineageOS installation package.
  15. Download Google Apps using the arm64 architecture. Choose the packages you prefer (I recommend nano package).
  16. In recovery mode, tap Swipe Format Data
  17. Return to the previous menu and tap Advanced Wipe, then select the Cache and System partitions and then Swipe to Wipe.
  18. Sideload the LineageOS and Google Apps packages:
    1. On your phone, tap AdvancedADB Sideload, then swipe to begin sideload
    2. On your computer, sideload the package using adb sideload
    3. Then sideload the Google Apps using adb sideload
  19. Back to recovery main menu. Reboot your device.
  20. Setup your LineageOS.