Fix broken miredo in El Capitan

OSX 10.11 introduced System Integrity Protection feature protecting the /usr/sbin folder, which will break existing miredo functionality to connect teredo tunnels.

Steps to fix it:

  1. Copy/move upgrade-migrated miredo command line tools from /Library/SystemMigration/History/Migration-XXX/QuarantineRoot/usr/sbin/ to /usr/local/sbin
  2. Edit /Library/LaunchDaemons/miredo.plist to use new /usr/local/sbin/miredo instead of /usr/sbin/miredo
  3. Re-enable miredo in prefpane

Since El Capitan also force kernel driver signing, if your tun/tap driver has problem to load, install the latest ones from here.

MX Master bluetooth pair problem with Yosemite

Just bought the latest Logitech MX Master mouse, which is quite powerful for Yosemite to natively support Mission Control and Spaces with its mouse gesture button, together with the interesting Smart Shift scrolling feature.

But also encountered the problem of pairing it with my MBP Retina on Yosemite 10.10.3. One discussion thread in the logitech forum suggested to delete all existing bluetooth devices to fix the connection. However, some hidden devices remain in the bluetooth paired list for Alt-Click menu. In this case, a complete bluetooth plist delete will finally help to pair the mouse with MBP.


Yosemite Bluetooth sometime freezes after wakeup, which then cannot be turned on/off and receive connections until reboot. If you want to manually restart it, do it by command line:

sudo kextunload -b

sudo kextload -b

Or you can use my Bluetooth Restart Alfred Workflow or similar AppleScript.

El Capitan UPDATE:   Above bluetooth kext restart method will make the bluetooth driver unusable in 10.11, so restart your mac seems the only way to fix bluetooth freeze.

Fix safari or chrome scroll lagging in Yosemite

Just found some lagging when scrolling content in Chrome/Safari, especially after a few scrolls, the web page will pause about 0.5s then leap to the target position, which is quite annoying. After a few google around and testing, the Better Touch Tool v0.9995 is found to be the culprit. After disable it, all browsing returns smooth.

But as I use customized three finger swipes frequently, the magicprefs is now the alternative choice for gesture customization, which seems no conflict problem. But the system three finger swipe gesture must be disabled first in the trackpad preference pane, then the magic preference will enable the available gestures.


Just encounter a Yosemite system-wide problem of missing right click menu, but ctrl+click still works, which might be related to WindowServer process. Only reboot can get the right click back. After rebooting more than 10 times,  it seems to happen after drag & drop to secondary monitor by bluetooth mouse. Quite strange, not sure if it’s bluetooth problem or drag&drop problem. Revert to Better Touch Tool temporally. And BTT released 1.0 which seems no lagging problem now.

Fix Mac App Store An Error Has Occurred

Just encountered a frustrating problem when updating Numbers in the Mac App Store. There’s “an error has occurred” message in the Updates list as well as Purchased app list for Numbers after a seemingly success but actual fail update. Then, opening Numbers app will fail, showing an alert that the app is still updating. Go back to the MAS, the button for Numbers is now installed, so you cannot update/install the app ever again because App Store deems it alright.

Try deleting the in Application folder won’t help either. The “an error has occurred” is still there and the app status is always “installed” even the app is absent from my Mac. Logging out, and logging in to MAS several times, an error always occurred.

Now googling hundreds of pages. Try the interesting MAS debug mode solutions here, but the problem remains. Try the reset errors solution, still no hope. Even try the reset everything for app store cache solution and safari cache solution, both fails. And nothing going wrong for MAS in the Console even strongly suggested that it might be a MAS server problem, which would requires a bug report eventually. I supposed.

Finally, a non-sense post in somewhere in the piles of discussion threads on the web I’ve browsed gave a helpless cue and last resort action: changing the system language/location to English. The mysterious MAS problem is solved. The latest Numbers update showed and installed.

Now I advocate that a fallback App installer/updater mechanism should be there just in case that MAS goes wrong.

fix himedia player to add nas files into media library

My HiMedia 910a player doesn’t support adding nas files (samba/nfs) into its media library. Browsing thru folders is quite tedious for media enjoy time. And 900 series players seem auto overwrite some system files when booting. Therefore customize your own firmware is the choice. Following is the solution after two days of search and configuration:

  1. Make sure you have squashfs-tools installed, if you are on Mac, then build yourself with this code from vasi.
  2. Download your device’s latest firmware, which is named as install.img but actually a tar file. Use tar to extract img’s contents files, in the “packageN” (N=5 or other number) folder, find squashfs1.img
  3. use unsquashfs to extract squashfs files, in the output folder rtk_rootfs/etc/init.d, modify file rcS to uncomment this line:


  4. in rtk_rootfs/user/local/, modify file rcS to add a line at the end:


  5. make sure it is executable: chmod +x rcS
  6. use mksquashfs to create back squashfs1.img file, and use tar to create back install.img
  7. upgrade this new created firmware, then will be auto called when booting
  8. Insert a sdcard or usbdisk to player, so that himedia system will allow add to media library button from these “local files”. I use a sdcard, so following location will be /tmp/usbmounts/mmcblkop1
  9. telnet into himedia, go to /tmp/usbmounts/mmcblkop1, mkdir a folder like “nasfiles”
  10. go to /usr/local/etc, vi to mount nfs share after sdcard is ready:


    sleep 35

    if [ -d /tmp/usbmounts/mmcblk0p1/nasfiles/ ]; then

    mount -t nfs -o ro,nolock 192.168.xx.xx:/folder/ /tmp/usbmounts/mmcblk0p1/nasfiles


  11. make sure is executable
  12. Now when himedia player is starting, it will auto mount remote nfs files into sdcard folder, then go to storage card’s nasfiles folder, the system will allow you to add nas folders or files to media library!
  13. However, sometime the system media library handling will not work properly. You can also manually fix the media library database when some folder or file is grayed out. Take the sdcard out and insert into your PC.
  14. Go to the sdcard root folder, go into “.Theatter” hidden folder, there’s stx.db file, which is in sqlite format. use sqlite3 to open it. Backup if you don’t want risk library corrupt.
  15. Mostly the ExtHddFolder table is your target, check full_folder_name to be correct; change folder_type to 3 will show the folder in “My Movies”; if you just want folders shown, delete all files item.
  16. Insert back, reboot and wait some time for network up and mount up, browse into My Movies, you have a neat and direct display of Nas folders and movie files!

Setup Test Analytics on GAE with Google Apps Account

Test Analytics is a quite good project from Google for testing analysis practice. It is open sourced at However the documentation is quite limited and not straight forward for configuration and setup.

Just spend quite a few hours to make it run on GAE with Google Apps account. Here is the  steps:

  1. Create target GAE application in GAE ( with your Google Apps account, select user authentication to Google Apps and set your apps domain (i.e.
  2. In your Google Apps Administrator Homepage (, add services with GAE application id set to the created one
  3. Download or git clone the test analytics project code
  4. In the pom.xml at project dir, add following lines into the maven-gae-plugin <plugin> element:


  5. also change gae.version to latest version in pom.xml


  6. In ~/.m2/settings.xml add: (make sure <id>value is equal to <serverId> of maven-gae-plugin in pom.xml)

    <username>google apps account</username>
    <password>google apps password</password>

  7. In the appengine-web.xml under src\main\resources, change:

    value of frontend.url to your GAE application url

    value of frontend.localdomain to your Google Apps Domain

    value of frontend.whitelisting to true

  8. in terminal, go to project folder, run “mvn gae:unpack” to install latest gae java sdk to maven repository
  9. run “mvn gae:deloy”
  10. now maven will download all required plugins, compile project and upload it to GAE
  11. check if it works successfully by login with your Google Apps Account, you can enable accessing accounts in GAE application’s  permission settings

add route and dns for VPN connection in Mac

VPN now becomes a ubiquitous way for climbing over GFW in China. However, once the Mac is connected with VPN and sends traffic thru it , VPN’s dns and route setting will take priority over the default network settings, which sometimes is quite inconvenient for fast accessing local sites and using other dedicated network like ipv6.

There’s a combination of configurations to work around the dns and route table of VPN:

1) when connected to the VPN, in Terminal, use the way described to find which VPN’s dns you want modify

2) in Terminal, sudo vi /etc/ppp/scutil_vpn.txt, add following lines, replace the GUID with your target GUID:

get State:/Network/Service/E6592FF4-8A4F-4C86-B1A2-F865D658D4FF/DNS
d.add ServerAddresses *
set State:/Network/Service/E6592FF4-8A4F-4C86-B1A2-F865D658D4FF/DNS

4) in Terminal, sudo vi /etc/ppp/ip-up,(make it executable), add following lines, and modify the TARGET_IPADDR and MASK of which network subnet you want to go thru the VPN:

/sbin/route add TARGET_IPADDR/MASK $5
/usr/sbin/scutil < /etc/ppp/scutil_vpn.txt

5) install and use dnsmasq to direct wildcard dns resolving for target server names to the VPN dns server

6) in the VPN settings, uncheck “Send All Traffic” box

7) done.

Now when you are connected with the target VPN, you will only go through the VPN to visit target domain names and ip you’ve set, with all other network like ipv6 unchanged. Of course,  the settings could be reversed to send most traffic thru VPN, leaving a few sites accessing locally.

Fix TimeMachine on Buffalo LS-CHLv1

Since Lion, the TimeMachine support on the Buffalo LinkStation LS-CHL v1.0 was broken because the new Netatalk protocol is now used in Lion TimeMachine backup process which is not compatible with the old NAS firmware’s atalk version. With such a long time passing, Buffalo only updates a few products’ firmware (including LS-CHL v2.0) to support Lion’s TimeMachine, and leaves a lot of old NAS model unsupported. And according to this thread, there WILL NOT be any official firmware updates for my LS-CHL v1.0 in the future.

However, as user boing in the previous forum thread suggested, it could be done by self installing new netatalk protocol to your old NAS device. After two days of configuring, now my old LS-CHL v1.0 could successfully backup my MBP now. Here’s the detail steps:

1) use acp_command to allow telnetd on the LinkStation device, logon to it under root user

2) ipkg update, ipkg upgrade, and then ipkg install netatalk protocol, which should be version 2.2.0-2

3) stop old default atalk service by: /etc/init.d/ stop, and killall cnid_dbd and cnid_metad service

4) copy old /etc/atalk/*.* to /opt/etc/netatalk/, but don’t overwrite new installed uams folder (before copy, backup the new installed ones for reference if you wish)

5) remove .AppleDB .AppleDesktop .AppleDouble in the root folder under your time machine backup volume, the new cnid_dbd service will recreate these database upon the first access

6) modify file AppleVolumes.default, find the time machine backup volume line, append “options:tm” to it

7) modify AppleVolumes.default, afpd.conf, netatalk.conf to change MAC_CHINESE_SIMP to MAC_ROMAN if these ones contain such localization encoding before

7.5) because I use guest account to access NAS time machine volume, new in afpd.conf is added but not used and tested actually, try use old firmware’s uams if logon to your network volume fails

8) start /opt/sbin/cnid_metad , /opt/sbin/atalkd and /opt/sbin/afpd service, now TimeMachine on your mac should work to connect your old friend NAS backup volume. Try do a backup first, as the Lion will update the old backup sparsebundle a bit, and you could enter into the new Time Machine with all your old data out there!

9) if you want linkstation to have boot time new afp service, modify /etc/init.d/, copy or create symbolic link to use new installed atalk ones

10) if TimeMachine won’t connect but prompts you “must create new backups” dialog, try this method , it takes several hours but works.

It’s a bit tedious to figure out all the configure steps after trying with several different time machine failures, but it’s not so complicated after all, requiring no recompilation or coding. It’s a REAL SHAME for Buffalo to abandon its longtime users without giving any efforts and notice.

sunpinyin compile problem in Lion 10.7

Just encounter some build problem in 10.7 with latest sunpinyin git:

1)when compiling xib there’s a warning says TableViewColumns identifier expects NSString in 10.7, it could be fixed by manually set the TableViewColumn’s identifier to a string in Interface Builder. And note: manually set the english version xib, the zh_CN version will be auto generated

2)an build error suggest cp’s usage: in the build phrase, add quotation mark with the directory part, there could be space in the path

p.s. the diff file for the changes is here

Fix QSB Freeze with Lion

Google Quick Search Box will freeze in OS X Lion and alloc huge memory if you input long words in search box. Only forcing to kill the QSB process could free up the memory, which makes QSB almost unusable in Lion.

After a few trials and thoughts, I found that the issue seems related to spotlight integration, which is apparently upgraded in Lion. Try to deselect spotlight results and disable spotlight plugin in QSB preference to work around it.

Works for my QSB and freezes no more.