Tuesday, March 19, 2024

Monitor Apple M1/M2 CPU performance

 MacBook Air with Apple Silicon CPU is very efficient but it comes with a cost -- reduced CPU performance during heavy-duty jobs. This is due to the lack of cooling fan so the CPU needs to reduce clock speed to prevent overheating.

To monitor this performance change, there are two handy tools:

  • asitop: use simple ASCII graphics to show CPU/GPU frequency and power usage.
  • influxDB dashboard: if you like nice-looking GUI, this is your choice.

To overcome this bottleneck, there are a few ways shown by Max Tech on youtube.

Monday, July 03, 2023

Optimize Java JVM for Matlab


Matlab UI has been very slow and buggy on MacOS due to the default JVM. A fast JVM can be used to fix this: 

1. Download and install Azul JDK 8
    NOTEJDK 11 would also work on latest version of Matlab. Newer version doesn't work with Matlab.

2. Set the new JVM to Matlab using matlab_jenv command:
/Applications/MATLAB_R2021b.app/bin/matlab_jenv /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/
    NOTE: can also run jenv command in Matlab to assign the path of new JVM.
    NOTE: for JDK 11, use /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/

3. Run Matlab and confirm the new JVM by 'version -java'

4. To reset to default JVM, use:
/Applications/MATLAB_R2021b.app/bin/matlab_jenv factory

Sunday, June 11, 2023

 Useful software on Mac (with native Apple Silicon ARM64 support):

1. Homebrew

2. Mounty: to r/w NTFS.

    * install Mounty by homebrew as it will automatically install ntfs-3g and macfuse: 

brew install gromgit/fuse/mounty

3. Skim: lightweight tab PDF reader
* Use "defaults write -app Skim AppleWindowTabbingMode -string always" to enable opening in tab by default.  

4. CloudFlare WARP: secure wifi access

5. BBEdit: all-round free editor. 

* Add this to make BBEdit as the default editor in command-line:

export EDITOR="/Applications/BBEdit.app/Contents/MacOS/BBEdit"

6. ToyViewer: lightweight image viewer (App Store)

7. RealVNC


Scientific software:

1. FSL: If the installer didn't stop after 100% complete, just kill it by Ctrl+C. It will be ready to use.

2. ANTs (need to compile for ARM64)

* Set the following in .bashrc to enable multicore support:

export ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=8
export ITK_GLOBAL_DEFAULT_THREADER=Pool

3. Visual Studio Code: powerful IDE for almost any coding.

4. Julia: super fast Matlab-like software.

* Set the following for multicore support:

export JULIA_NUM_THREADS=8

5. MRIcroGL: powerful Nifti viewer/converter.

6. Xcode command line tools: for compile. Install by "xcode-select –install".


Thursday, December 02, 2021

Replace with formatted words in M$ Word

1. Copy the desired formatted words.
2. Open Find and Replace tool in Word.
3. Type "^c" in the Replace box (note lowercase). This tells Word to replace whatever in the clipboard.

Monday, April 26, 2021

M$ Office High Memory on MacOS

MS Office (especially Outlook and Word) usually use a few GB ram on MacOS. A simple solution is to run them using Option+Command keys. The ram usage immediately reduces by 10 folds. See other tips here.

Friday, June 19, 2020

Faster DNS

用ping實測新的DNS,1.1.1.1比Google快一倍!

Google DNS (8.8.8.8 and 8.8.4.4) has been very useful but sometimes still not quick. CloudFlare provides public DNS (1.1.1.1 and 1.0.0.1) claiming faster than Google. Just tested by ping, 1.1.1.1 has shorter than 15ms delay while 8.8.8.8 takes longer than 25ms. So it's time to make a change!

Solve WiFi timeout for Apple devices

最近換了router,結果所有的Apple裝置都上不了網,反而Windows好得很。查了半天原來是Apple不支援舊的wifi,只要把2.4G wifi模式設定成只用802.11g/n就好了。 Recently changed to a new ISP and new router. All of sudden, all the Apple devices (Mac, iphone, ipad) cannot connect to internet. Using ping to a DNS (eg, 8.8.8.8), it turns out that the requests are all timeout. However, Windows didn't have this problem. Tried changing wifi channel didn't help at all. It turns out Apple doesn't support old wifi mode. So just changing 2.4G wifi mode from "b/g/n" to "g/n" solves this issue.