Latest Event Updates

STM32 development on MacOS

Posted on

Installation

brew install gcc-arm-embedded --cask
brew install opened

Citation Error on VScode Latex

Posted on Updated on

Introduction

It is because the pdflatex compiler didn’t run the bibitex. By default you need to run the bibitex to process the .bib file before compiling the latex.

To solve this problem, add the bibiTex tools to the code latex-workshop plugin and define a now recipe for compiling the latex file.

Solution

Add the `bibiTex` to the latex-workshop tools

"latex-workshop.latex.tools": [
    {
        "name": "pdflatex",
        "command": "pdflatex",
        "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOCFILE%"
        ]
    },
    {
        "name": "bibtex",
        "command": "bibtex",
        "args": [
            "%DOCFILE%"
        ]
    }
],

Add the new recipe on the vscode setting.json

"latex-workshop.latex.recipes": [
    {
        "name": "pdflatex",
        "tools": [
            "pdflatex"
        ]
    },
    {
        "name": "pdflatex (w/ bib)",
        "tools": [
            "pdflatex",
            "bibtex",
            "pdflatex",
            "pdflatex"
        ]
    }
],

Force Mac output colour in RGB instead of YPbPr

Posted on

Introduction

Some of the people said RGB color space is better than YPbPr color space. By default, mac is using the YPbPr color format. To use RGB color format, we need to modify the EDID display setting.

Here is my computer and monitor model.

Mac: Macbook pro 2018 – macOS 11.1
Monitor: Dell U2720Q

Procedure

Follow this guide.

sudo mkdir -p /Library/Displays/Contents/Resources/Overrides
cd /Library/Displays/Contents/Resources/Overrides
sudo curl -O https://gist.githubusercontent.com/ejdyksen/8302862/raw/patch-edid.rb
sudo ruby patch-edid.rb

Then, restart your Mac.

After that, your display name will become Display with forced RGB mode (EDID override) at System Information

Reference

patch-edid.rb

A script to fix EDID problems on external monitors in macOS.

Instructions

  1. Connect only the problem display.

  2. Create this directory structure (if it doesn’t already exist):

    sudo mkdir -p /Library/Displays/Contents/Resources/Overrides
  3. Download this ruby script in that directory:

    cd /Library/Displays/Contents/Resources/Overrides
    sudo curl -O https://gist.githubusercontent.com/ejdyksen/8302862/raw/patch-edid.rb

    Note: You may want to use adaugherity’s version of the script instead.

  4. Run the script we just downloaded (as root again). This creates a new display override plist file.

    cd /Library/Displays/Contents/Resources/Overrides
    sudo ruby patch-edid.rb
  5. Unplug and replug in the problem display.

Additional reading/acknowledgements

  • The original forum thread
  • An improved version of the script by adaugherity
  • An explaination of the problem from Atomic Object’s blog
  • Thanks so much to @stackrainbow for pointing out that this can be done without disabling SIP.
  • This version appears to work in Catalina and Big Sur. See earlier revisions for what worked (with disabling SIP) in earlier versions of macOS, which require the override plist to be in a different directory.

view raw

patch-edid.md

hosted with ❤ by GitHub


#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
#
# Update 2013-06-24: added -w0 option to prevent truncated lines
require 'base64'
data=`ioreg -l -w0 -d0 -r -c AppleDisplay`
edid_hex=data.match(/IODisplayEDID.*?<([a-z0-9]+)>/i)[1]
vendorid=data.match(/DisplayVendorID.*?([0-9]+)/i)[1].to_i
productid=data.match(/DisplayProductID.*?([0-9]+)/i)[1].to_i
puts "found display: vendorid #{vendorid}, productid #{productid}, EDID:\n#{edid_hex}"
bytes=edid_hex.scan(/../).map{|x|Integer("0x#{x}")}.flatten
puts "Setting color support to RGB 4:4:4 only"
bytes[24] &= ~(0b11000)
puts "Number of extension blocks: #{bytes[126]}"
puts "removing extension block"
bytes = bytes[0..127]
bytes[126] = 0
bytes[127] = (0x100-(bytes[0..126].reduce(:+) % 256)) % 256
puts
puts "Recalculated checksum: 0x%x" % bytes[127]
puts "new EDID:\n#{bytes.map{|b|"%02X"%b}.join}"
Dir.mkdir("DisplayVendorID-%x" % vendorid) rescue nil
f = File.open("DisplayVendorID-%x/DisplayProductID-%x" % [vendorid, productid], 'w')
f.write '<?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"&gt;
<plist version="1.0">'
f.write "
<dict>
<key>DisplayProductName</key>
<string>Display with forced RGB mode (EDID override)</string>
<key>IODisplayEDID</key>
<data>#{Base64.encode64(bytes.pack('C*'))}</data>
<key>DisplayVendorID</key>
<integer>#{vendorid}</integer>
<key>DisplayProductID</key>
<integer>#{productid}</integer>
</dict>
</plist>"
f.close

view raw

patch-edid.rb

hosted with ❤ by GitHub

Fixing the External Monitor Color Problem with My 2018 MacBook Pro


https://forums.macrumors.com/threads/m1-mac-external-display-fuzzy-fonts-colors-ypbpr-vs-rgb.2276345/

Subscribe multiple holiday calendar from official iCloud

Posted on Updated on

Introduction

In the Apple iCloud system, a holiday calendar is subscribed automatically depends your Region setting. Only one holiday calendar can be displayed at the same time. To subscribe more holiday calendars through the official iCloud system, we can add the calendar manually from the icloud website.

Method

Type the link https://p20-calendars.icloud.com/holidays/AA_BB.ics in safari will auto-subscribe the holiday’s calendar into your iCloud calendar.

Modify the filename located at the end of the web-link to subscribe to the holiday calendar in different countries. The filename must be in AA_BB.ics format which AA is the country code and BB is the language code.

Here are the examples of holiday calendar in different countries:

# Hong Kong holiday in Cantonese
https://p20-calendars.icloud.com/holidays/hk_zh.ics

# Hong Kong holiday in English
https://p20-calendars.icloud.com/holidays/hk_en.ics

# British holidays
https://p20-calendars.icloud.com/holidays/gb_en.ics


# United States holiday 
https://p20-calendars.icloud.com/holidays/us_en.ics

Reference:

brew update hangs

Posted on Updated on

Introduction

I update the Mac from macOS 10.15 to macOS 11.0, I found out that the homebrew hangs after running brew update. Running brew update --verbose said the brew update software hangs when fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

Running brew doctor said my CommandLineTools is not updated. To fix this problem, we need to upgrade the CommandLineTools.

Since I upgraded the homebrew-core with an OLD CommandLineTools, the homebrew-core is also contaminated. I need to use brew update-reset to reset the homebrew-core module.

# Full script of fixing homebrew update error

# Reset
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install

# Reset homebrew-cask
brew untap homebrew/homebrew-cask
brew reinstall cask

# Reset homebrew-core
brew update-reset -d -v


Reference

https://github.com/Homebrew/homebrew-cask/issues/50586

brew upgrade cask that mark as auto-upgrade

Posted on

brew cask outdated --greedy --verbose | grep -v '(latest)' | awk '{print $1}' | xargs brew cask reinstall

Reference

https://stackoverflow.com/questions/31968664/upgrade-all-the-casks-installed-via-homebrew-cask

Disable auto-switching desktops on mac

Posted on Updated on

In VScode Arduino add-on, the Arduino logo will pop-up when you compiling or uploading your code. When you turn on the full-screen mode or you VScode, your desktop will switch to another mac finder desktop page automatically. It is very annoying when you reading your code during that moment. To disable the auto-switching behavior of the mac, you need the following command.

defaults write com.apple.dock workspaces-auto-swoosh -bool NO
killall Dock

Reference:

https://discussions.apple.com/thread/4995042

Fix ubuntu sound delay problem

Posted on Updated on

Introduction

These are the quick fix for 2 second delay when playing audio sound on ubuntu linux system

Methods

1. Disable the audio idle mode

Go to /etc/pulse/default.pa and
comment on this line

### Automatically suspend sinks/sources that become idle for too long
#load-module module-suspend-on-idle

Find module-udev-detect & module-detect and insert tsched=0 to the back of them.

#enable the interupt based timing
load-module module-udev-detect tsched=0
load-module module-detect tsched=0

Restart your computer to apply the new configuration.

2. Create a dummy sound generator

If method 1 is not working, proceed to this step

This is a systemd service to generate a silent sound to occupy the sound channel.

Create a systemd file as /etc/systemd/system/audio_non_stop.service

#audio_non_stop.service
[Unit]
Description="Create a silent sound to keep the audio HDMI digital output running"
After=sound.target

[Service]
ExecStart=/usr/bin/aplay -c2 -r48000 -fS16_LE /dev/zero
#Restart=on-failure
ExecStop=/bin/kill -INT $MAINPID
KillSignal=SIGINT
#TimeoutStopSec=10

[Install]
WantedBy=graphical.target

After resuming the computer on hibernate mode, you need to restart the audio_non_stop.service and make it occupy the HDMI digital sound module again.

Then create another systemd service as /etc/systemd/system/audio_non_stop_resume.service

#audio_non_stop_resume.service
[Unit]
Description="Restart the audio_non_stop.services after resume from hibernate"
After=suspend.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl --no-block restart audio_non_stop.service

[Install]
WantedBy=suspend.target

Reference

https://askubuntu.com/questions/218444/sound-output-starts-delayed
https://unix.stackexchange.com/questions/362223/short-audio-playback-is-muted-requires-warming-up-or-secondary-audio-in-backgro

Solving the 2-second sound delay with XBMC and HDMI


https://bbs.archlinux.org/viewtopic.php?id=183447
https://askubuntu.com/questions/1033405/crackling-and-delayed-sound-after-upgrading-to-18-04
https://askubuntu.com/questions/371595/for-pulseaudio-what-does-tsched-do-and-what-are-the-defaults

Minecraft Performance Boost

Posted on Updated on

You can use the methods listed below to boost your performance on Minecraft. For Minecraft Version = 1.15, you can use OpenJDK 11 and try ZGC.

JVM

Java 14 (OpenJDK 14)

#Java 14 G1 GC Arguments

-server -Xmx4G -Xms4G -XX:+UnlockExperimentalVMOptions -XX:+UseNUMA -XX:ParallelGCThreads=3 -XX:+DisableExplicitGC -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=2048m -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true
#Java 14 ZCG Arguments

-server -Xmx4G -Xms4G -XX:+UnlockExperimentalVMOptions -XX:+UseNUMA -XX:+UseZGC -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=15 -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=2048m -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true

Java13 (openjdk 13)

openjdk 13 is not compatible with for 31.1.63

Java 11 (openjdk 11)

#Java 11 CMS GC Arguments

-server -Xmx4G -Xms4G -XX:+UnlockExperimentalVMOptions -XX:+UseNUMA -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=3 -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:MaxTenuringThreshold=15 -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=2048m -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true
#Java 11 ZCG Arguments

-server -Xmx4G -Xms4G -XX:+UnlockExperimentalVMOptions -XX:+UseNUMA -XX:+UseZGC -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=15 -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=2048m -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true

Java 8 (Launcher Built-In version)

#Java 8 G1 GC Arguments

-server -Xmx4G -Xms4G -XX:+UnlockExperimentalVMOptions -XX:+UseNUMA -XX:ParallelGCThreads=3 -XX:+DisableExplicitGC -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=2048m -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true
#Java 8 CMS GC Arguments

-server -Xmx4G -Xms4G -XX:+UnlockExperimentalVMOptions -XX:+UseNUMA -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=3 -XX:+DisableExplicitGC -XX:+CMSParallelRemarkEnabled -XX:MaxTenuringThreshold=15 -XX:SurvivorRatio=8 -XX:TargetSurvivorRatio=90 -XX:MaxGCPauseMillis=30 -XX:GCPauseIntervalMillis=150 -XX:+UseAdaptiveGCBoundary -XX:-UseGCOverheadLimit -XX:+UseBiasedLocking -XX:+UseFastAccessorMethods -XX:+UseCompressedOops -XX:+OptimizeStringConcat -XX:+AggressiveOpts -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=2048m -Dfml.ignorePatchDiscrepancies=true -Dfml.ignoreInvalidMinecraftCertificates=true

use GPG key on git

Posted on Updated on

Introduction

Here is the way to use GPG key on git

 

Procedure

 

1. Create GPG key

gpg --full-generate-key

Recommend Setting:

Field Value
Key type RSA (1)
Key length 4096
Expire Date 0
Real Name Your Name in .gitconfig
Email Your Email in .gitconfig & GitHub verified email
Comment github

 

2. Check your GPG key information

# List selected key
gpg --list-ley KEY_ID
# List all key with long format
gpg --list-keys --keyid-format LONG

 

3. Export the Public key to

Copy the output to your github account

gpg --armor --export KEY_ID

 

4. Edit your .gitconfig

Command:

git config --global --edit

Insert the following information

[user]
  name = YOUR_NAME               # Should be same as your commit name
  email = YOUR_EMAIL             # Should be same as your GitHub verification email and GPG uid email
  signingkey = YOUR_SIGNING_KEY  # your KEY_ID that you want to use
[gpg]
  program = GPG_BINARY_PATH      # usually in "/usr/local/bin/gpg"
[commit]
  gpgsign = true

 

5. Setting on your shell

Insert this line to your shell

export GPG_TTY=$(tty)

 

Useful command

 

Edit the existing GPG key

gpg --edit-key KEY_ID

gpg> adduid   #Add a new uid on your key
gpg> uid 1    #Select the uid 1
gpg> revuid   #Revoke the selected uid from the key
gpg> save.    #Save the modification

 

Test you GPG key

You may run this command first before using github desktop to commit anythings. Since github desktop CANNOT pop-up the GPG key passphase input dialog to the user, you need this command to unlock the GPG key first. After that the github deskop can package you commit with your GPG key without the passphase.

echo "test" | gpg --clearsign

 

Reference

https://help.github.com/en/github/authenticating-to-github/generating-a-new-gpg-key
https://help.github.com/en/github/authenticating-to-github/telling-git-about-your-signing-key#telling-git-about-your-gpg-key-1

GPG signing – git github-desktop

Here is a short guide that will help you setup your environment to create signed commits or signed tags with Git locally. This has been extensively tested on Windows with Git and the Github Desktop application: I use it every day for my professional development projects.

I you face any issue, feel free to leave a comment below.

Summary

  1. Sign commits or tags
  2. Key passphrase
  3. Disable signatures
  4. Renew a GPG key

Sign commits or tags

  1. Generate a GPG key and add it to Github: https://help.github.com/articles/generating-a-new-gpg-key
    (if you don’t want to type a passphrase on every commit, you need to press “Enter” when the console will prompt you to type a passphrase)

  2. Open the .gitconfig configuration file by typing git config --global --edit in a terminal (since this file can exists in different places depending on your operating system, the command line will prompt git binary and open your default editor)

  3. Configure Git by replacing GITHUB_EMAIL, SIGNING_KEY and GPG_BINARY_PATH with your own data:

[user]
  name = Xavier Foucrier
  email = GITHUB_EMAIL
  signingkey = SIGNING_KEY
[gpg]
  program = GPG_BINARY_PATH
[commit]
  gpgsign = true
[tag]
  gpgsign = true
  • GITHUB_EMAIL: the email address used to login on Github

  • SIGNING_KEY: the GPG key identifier used to sign commits (should follow the GPG key ID convention, like this example: https://help.github.com/articles/telling-git-about-your-signing-key/#telling-git-about-your-gpg-key-1)

  • GPG_BINARY_PATH: the GPG binary file path depending on your Git install and your operating system:

    • Windows: gpg, gpg.exe or C:\\Program Files\\Git\\usr\\bin\\gpg.exe
      (can be found using where gpg in a terminal)

      Some system may contain multiple gpg binaries, in this case you can execute the following command line with PowerShell to use the more appropriate one: git config --global gpg.program $(Resolve-Path (Get-Command gpg | Select-Object -Expand Source) | Select-Object -Expand Path)

    • Mac or Linux: gpg or /usr/local/bin/gpg
      (can be found using which gpg in a terminal)

  1. Enjoy signed commits with your favorite code editor, Github Desktop application, and even command line using git commit -S -m "Commit message" 🎉

Key passphrase

In order for GPG to automatically store your key passphrase (even empty), so you don’t have to enter it every time you sign a commit, Github recommend using the following tools:

This is necessary to let GPG launch the gpg-agent as a system daemon when signing commits.

Disable signatures

If you want to temporarily pause GPG signatures for your commits or tags, just set gpgsign = false in your .gitconfig configuration file with git config --global commit.gpgsign false (for commits) or git config --global tag.gpgsign false (for tags).

Renew a GPG key

If the key you have defined in the .gitconfig configuration file has expired, you can’t sign commits anymore. You can easily renew it by following these steps:

  1. list the secrets keys with gpg --list-secret-keys

  2. edit the key you want to renew with gpg --edit-key SIGNING_KEY
    (the GPG key used to sign commits, as defined in your .gitconfig configuration file)

  3. gpg prompt is ready: you should see gpg>

  4. type expire to select a new expiration delay and confirm

  5. type trust to trust the selected key as “ultimate”
    (this step is not needed if your current key is already trusted as an “ultimate” key)

  6. type quit and confirm you wish to save changes

  7. enjoy a fresh renewed GPG key!

Thanks everyone for reading! 👀

view raw

gpg-signing.md

hosted with ❤ by GitHub

https://stackoverflow.com/questions/51504367/gpg-agent-forwarding-inappropriate-ioctl-for-device


For troubleshooting, two things to first try:
run `git config –global gpg.program gpg2`, to make sure git uses gpg2 and not gpg
run `echo "test" | gpg2 –clearsign`, to make sure gpg2 itself is working
If that all looks all right, one next thing to try:
run `brew install pinentry` to ensure you have a good tool installed for passphrase entry
If after that install and you re-try git commit and still get the "failed to sign the data" error:
run `gpgconf –kill gpg-agent` to kill any running agent that might be hung
If that says gpgconf isn’t installed or doesn’t have a `–kill` option, you might try this:
`cp ~/.gnupg ~/.gnupg-GOOD` to save a copy of your `~/.gnupg` to revert to later if needed
`brew install gnupg21` to install `GnuPG 2.1`
The reason for saving a copy of your `~/.gnupg` dir is that GnuPG 2.1 potentially creates/changes some key data in way that isn’t backward-compatible with GnuPG 2.0 and earlier, so if you want to go back later, you can do `mv ~/.gnupg ~/.gnupg21 && mv ~/.gnupg-GOOD ~/.gnupg`.
Otherwise there are some basic steps to run to check you’ve got a working GnuPG environment:
run `gpg2 -K –keyid-format SHORT`, to check that you have at least one key pair
If the output of that shows you have no secret key for GnuPG to use, then you need to create one:
run `gpg2 –gen-key`, to have GnuPG walk you through the steps for creating a key pair
source: https://stackoverflow.com/a/41054093/4902448

view raw

gpg_fix.txt

hosted with ❤ by GitHub