Wednesday, January 09, 2019

Flickering / Disconnection with Target Display Mode using iMac

[Update: The Target Display Mode didn't work again after 2 months.]

I had an older iMac that supports Target Display Mode.  However, over the last year, it has become less reliable.  When connected with my MacBook Pro, the Target Display Mode might sometimes last only a short period of time (e.g. one hour or less) and then disconnect. I tried to update the macOS version to the latest one but it couldn't help.

I finally seem to have found a solution to this problem.  Since my iMac now mainly use as a display, I re-installed an older version of Mac OS X (10.8.5) on it.  The Target Display Mode has been working properly over the last two weeks. I hope this will continue to work in the future.

For reference, I installed also KeyRemap4MacBook 8.4.0 to allow using a PC keyboard to trigger the Target Display Mode on the iMac.

Thursday, July 31, 2014

Running R with Cocoa Emacs (ESS)

When I tried to run R in Cocoa Emacs on Mac, I encountered this error:

Searching for program: No such file or directory, R

It seems that I used to be able to run it properly.  Anyway, here is how I solved the problem after doing some search (see this page).  I just needed to add the following line to ~/.emacs:

(setq-default inferior-R-program-name "/usr/local/bin/R")

And then R could be run properly again.

Some other notes:
  • I could run R without the above line if I start Cocoa Emacs by running this command "open -a Emacs".  Probably Emacs inherits some environment variables with appropriate values.
  • I couldn't solve the problem by adding the path to R by (setenv "PATH" (concat "/usr/local/bin" ":" (getenv "PATH")))  as reported in some other posts.  I am not sure why.

Wednesday, May 21, 2014

Taking Screenshots on Mac OS X

The keyboard shortcut for taking screenshots of a selected area on Mac OS X is: Cmd-Shift-4.  You may press space after the shortcut to capture a window.
  1. To change the image format to PNG:
    defaults write com.apple.screencapture type png
  2. To change disable the shadow in the screenshot:
    defaults write com.apple.screencapture disable-shadow -bool true
  3. To take effect:
    killall SystemUIServer
More information can be found from Mac Guides.

Tuesday, February 25, 2014

Emacs on Mac OSX

I am using reStructuredText to format some documents.  However, the key binding [ctrl-=] for rst-adjust did not work when I used Emacs using Terminal on Mac OS X.  A workaround is to use the Cocoa version of the Emacs.  The shortcut [C-=] should be ok.

Saturday, October 26, 2013

Resetting Finder View Options on Mac OS X

To reset the Finder view options, you have to delete two kind of files:
  1. rm Library/Preferences/com.apple.finder.plist
  2. find ~ -iname .DS_Store -delete -print

[Warning: use at your own risk.]

Tuesday, October 22, 2013

Installing R with brew on Mac

I used to install R on Mac using brew.  However, recently, it seemed that the R package did not exist as a brew package anymore.  It turns out that I need to run the following command before maintaining the R installation with brew:

brew tap homebrew/science

After that R can be installed as before:

brew install R

Thanks for a comment on a blog post  for pointing this out.

Monday, September 02, 2013

Error in OpenESB: "MBeanServerConnection is null."

I was trying to learn about OpenESB following a tutorial.  When I was running the test for the composite application in Part 3, the test often took tens of seconds before it could complete.  It seemed that the test needed to wait due to the error below:

java.lang.RuntimeException: MBeanServerConnection is null. Make sure the App Server is running.

After some investigation, I found that the error could be fixed by entering a correct password to the GlassFish server, where the default password was "adminadmin".  With this fix, the test could be completed in two seconds on my computer.

Monday, April 08, 2013

「守護中環」有樣學樣?

今天讀《明報》見到「守護中環」人士的論點,真的嚇了一跳!

話說昨天「真普選聯盟」舉行政制研討會,但因「『守護中環』插言叫囂」(《明報標題》),令研討會腰斬。「愛港之聲」成員陳文廣解釋,「踩場」是因為建制派沒有代表發言。

也許他們認為之前有民主派人士衝擊政府舉辦的咨詢會合理,所以他們便有樣學樣。不過他們也許沒明白一點,就是政府應代表全港人民,但「真普選聯盟」只需要代表某些理念相同的人。

見到這些所謂愛港人士的言論,真的令人不寒而凜。

Sunday, April 07, 2013

Mac OS X 上的中文字體

一直認為,Mac 機上的預設中文字體不太靚。以前亦嘗試過去改善這問題,但總覺仍有所缺。直至最近見過iPhone上的中文字,發覺原來這非必然。

在這裏略略指出解決的方法:
  1. 在較新版本的Mac OS X, 附加了更多的中文字體。不過並非每一隻字體也適合做預設字體。尤其若果經常要處理正體和簡體的中文字,應該選一些字體能正常地同時顯示正簡字。我試過不同的字體,發現Heiti SC, Lantinghei SC和Hiragino Sans GB 效果較好。
  2. Heiti 和Lantinghei 有正體和簡體字的版本。兩者分別不大。但當顯示某些正簡字類似的字,例如「迎」字時,正簡字體便會顯示出相應的寫法。雖然我想用正體字版本,不過正體字體顯示簡體時會有較多間題,所以我選擇了簡體版。而我個人較喜歡Lantinghei SC,所以選了這個。而iPhone 上用的應該是Hiragino Sans GB.
  3. 選了想用的字體,便可用TCFall 去設定。不過該程式較耐冇更新,所以不能選用像Lantinghei SC等較新的字體。解決方法是下載source code, 自行加入新的字體。或直接更改:
    /System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist
  4. 在Lantinghei 字體中,我較喜歡Extralight.  所以設定字體時,可以選這個style.  不過縱使選了,有時系統仍會改用Demibold 版本。我相信原因是系統會自動選取較接近medium weight 的字體。
  5. 為了解決上一項間題,我用fontforge(可用brew去安裝)強將extralight 定為medium, 再將demibold定為bold。這樣,系統便會預定用本來Extralight 的版本去顯示中文,而需要顯示粗體時,便會使用Demibold版本。
經一輪修訂,終於轉了一隻自己接受到的中文字體(見下圖)!或者正如TCFall原作者所講,應該寫信到Apple 叫他們重視一下正體字用者的感受。


Adobe Reader Scrolling Slowly on Mac

I found that Adobe Reader scrolls slowly when reading a PDF file, compared to Preview.  After reading some search result, I found that this was caused by some unknown built-in plugins.

To see what plugins have been installed, from the menu click "Adobe Reader"->"About Adobe Plugins".

If you want to check whether the slow scrolling problem is caused by the plugins, you can disable all plugins temporarily by press the shift key when you start the Adobe Reader.

To fix the problem by disabling plugins:

  1. Look for the plugin folder.  It was /Applications/Adobe Reader.app/Contents/Built-in on my computer (Adobe Reader 11.0.02).
  2. Move those culprit plugins out of the folder.  In case, I removed "Checkers.acroplugin" and "PDDom.acroplugin" from the folder.  This may need more experiments to see which plugin really caused the problem.
  3. Restart Adobe Reader.  You should see that the scrolling becomes fast.  
Even disabling the plugins, I still felt that Preview performed faster than Adobe Reader in my case.  However, the latest version of Adobe Reader seems to support more features for commenting.  That's why I still needed to use Adobe Reader sometimes.

Thursday, October 25, 2012

Using USB thumb drive on Windows XP Guest with VirtualBox on Mac OS X Host

According to this post, to use a USB thumb drive on Windows XP guest in a VirtualBox machine on a Mac OS X host, one needs to use only one processor in the VirtualBox setting.  What a surprising setting!

Tuesday, October 09, 2012

NullPointerException When Creating New LibreOffice Database File

When I tried to create a new database file in LibreOffice (version 3.6.2 on Mac), I encountered the following error:

SQL State: S1000
Error code: -27

file input/output error java.lang.NullPointerException.properties

The reason was that I had added a newer version of hsqldb file in the classpath.  The one I added was hsqldb-2.2.6.  It seemed that LibreOffice expected a version of 1.8.0.

After removing those hsqldb files from the classpath, I could create a new database file again.