Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

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.

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!

Thursday, July 12, 2012

Reader Page Customization in Safari

The style of the Reader page can be customized by modifying this file:

/System/Library/PrivateFrameworks/Safari.framework/Resources/Reader.html

To change the font size for the .page, the "important" keyword has to be added.

More information can be found on this page.

Friday, May 25, 2012

Aquamacs + Emacs (HomeBrew) + site-lisp

The site-lisp directory for Emacs is:
/usr/local/share/emacs/site-lisp

So to share this site-lisp directory with Aquamacs:
sudo mkdir /Library/Application\ Support/Emacs
cd /Library/Application\ Support/Emacs
sudo ln -s /usr/local/share/emacs/site-lisp


I used this so that I can use the same version of ESS for Emacs (installed by HomeBrew) and Aquamacs.

Monday, July 25, 2011

Local Backup on Lion (Mac OS X 10.7)

Local backup is a new feature in Lion. Once the time machine is setup, the local backup will be enabled. When a laptop is disconnected to the time machine drive, the local backup starts to take snapshots on the computer periodically (I still haven't figured out how often it will take).

This poses one problem. If the local drive runs low on storage, the local snapshots will take up much of the scarce space. Deleting files doesn't help -- not until the local snapshots have been pruned. One way to remove the snapshots immediately is by disabling the local snapshots. This can be done by typing the following command on the Terminal:

sudo tmutil disablelocal

Once this command has been issued, the system will start to prune the local snapshots. It may take some time (maybe a few minutes) before the disk space occupied previously by those snapshots can be recovered.

Monday, September 06, 2010

Blocking Flash

I have recently found an extension to Safari, which allows me to block the Flash content of a webpage. The Flash content, which is often annoying and consumes quite much CPU, can be enabled only after I click on it, so that I can load only those I want.

The extension is called ClickToFlash. Have a try.

Thursday, August 12, 2010

Changing Default Fonts on Mac OS X

To change the default (Traditional Chinese) fonts on Mac OS X, one may edit the following file directly:

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework/Resources/DefaultFontFallbacks.plist

Also note that to be able to modify this file, you need superuser right. So one can "sudo vi" to edit this file. I used STSong for monospace and san-serif, while STFangsong for serif. These fonts look better to me than those Hei type fonts.

A simpler way to do this is to use TCFail. Indeed, I noticed the path to the above file by reading the source code of TCFail.

Update 2010-11-16: To make this works, the order of the languages has to be changed, so that Chinese has to be put in front of other languages (e.g. Japanese). This can be done in the Language pane of the Language & Text panel under System Preferences.

Saturday, July 31, 2010

Calibre + Stanza

Recently I have finally found a way to read on my iPod Touch, using two free applications: Calibre (for Mac OSX) and Stanza (for iPhone). I guess they have been used by others for a while. This combo should work on platforms other than Mac OS X, and it doesn't require jailbreak to transfer e-books to my iPod Touch. I can now download some webpages, convert it to a better format for reading on iPod Touch, and read them in dark using my iPod Touch. Calibre also supports fetching webpages from some free news sources (or paid news sources, requiring proper authentication).

A good way to read on iPod Touch. Highly recommended!

Thursday, July 23, 2009

Locking the Dock on Mac OS X

To lock the dock and prevent any accidental drag & drop to move the dock icons, type the following commands in the terminal:

> defaults write com.apple.dock contents-immutable -bool true
> osascript -e 'tell application "Dock" to quit'


To unlock it, change the value from 'true' to 'false' in the first line of command.

Source: http://forums.macosxhints.com/showthread.php?t=67085

Thursday, May 28, 2009

Convert rmvb to avi on Mac OS X

A quick note on how to convert video in rmvb to avi so that it can be further processed by Handbrake.

1. Follow this nice guide: "How to convert .rmvb to .avi (on PowerPC and Intel Macs)?"
2. If in some case it fails with "bus error" in the log, rename the extension from rmvb to rm, as suggested here.

Saturday, May 02, 2009

Jailbreak iPod Touch?

I know programming, though I don't know Cocoa programming and Objective-C. But I still want to try to develop some programs on a iPod Touch. Good news is that the iPhone SDK is free to download. The bad news is, I found that if I want to use/test my application on iPod Touch, I need to join the standard iPhone Developer Program for US$99. It seems that the only way for me to deploy an application to the iPod Touch for free is to jailbreak it. Yet doing so may lose the warranty by Apple.

Perhaps I have been spoiled by many open-source software for some time. For example, the GNU/Linux is a free OS, along with many free applications like OpenOffice, GIMP, Firefox, etc, and the programming tools of Eclipse and Java. Now I have moved to a Mac OS X, perhaps I should accept that fact that I will soon become a slave to Apple. For example, if I want to sync my calendar to any handheld devices, the likely choice is a iPhone/iPod Touch. And then if I want to write any real iPhone applications, I have to pay Apple for distributing it through Apple store.

Well, I don't mind using Apple products. The MacBook, iPod Touch, OS X are great. They have some very nice features. In particular, I like the Spotlight and the Spotlight comment feature from Leopard, along with the backup functionality.

But Apple products also have some weakness. One is that the it has to pay for the software. And there is a major weakness of Leopard that it is slow, compared with Ubuntu, I believe. The startup time is ok, but when I launch a few applications like Mail, Calendar, Firefox just after startup, it can take a few minutes until the computer has proper response again! It didn't happen when I use Ubuntu on a much older notebook. Fortunately, the MacBook sleeps properly most of the time, so that I don't have to launch these applications everyday, except that after one or two weeks it may require a reboot due to some non-responding process (e.g. Finder!).

In short, I hope I can find a way to better utilize the Apple hardwares without paying extra money. And now I have to consider whether to jailbreak the iPod Touch......

Thursday, March 26, 2009

Spotlight Index Not Updated

This was my problem on Mac OS X Leopard. I changed some tags using Quicksilver, but some of my smart folders depending on the tags were not updated with the new files. I did some search and thought I needed to rebuild the index using the mdimport command. However, the real cause of problem was that the index was somehow made read-only.

The normal status of the spotlight index can be shown using "mdutil -sa", as

/:
Indexing enabled.

which shows that the indexing is enabled. However, last time I had this problem, the status was something like:

/:
Index is read-only.

As the index was read-only, the mds couldn't update the index, and so the changes on the tags were not reflected in the smart folders. To solve this, I used the naive method: reboot. After that, the indexing was enabled again. And the files tagged appeared appropriately in the smart folders again. (If not, the mdimport command might be used to update the index.)

It seems that I need to reboot my MacBook more often from now on.

Friday, August 08, 2008

Backup files on Mac OS X with metadata

I found that the metadata of a file (e.g. Spotlight comment) on Mac OS X is not preserved by the traditional backup utilities such as tar or zip.

Here is one way to do it. First create a DMG file using the Disk Utility. Then copy those files that need to be archived into the drive to which the DMG file is mounted. Next we can compress the DMG file using any compression programs like zip. In this way, the metadata is preserved while the disk space use is reduced by compression.