Code Blog

Displaying 6-10 of 17 results.
2016/11/22 MacOSX

I had some problems getting a Fuji-Xerox DocuPrint to print from my Mac, I tried multiple drivers but it still only printed garbage (see photo below). Turns out that the Mac requires the printer to support postscript. It's a bit confusing as this printer (FX DocuPrint 2065) says it supports Mac and it also gets autodetected when I try to add the printer. Problem is, the printer I tried to add doesn't have the postscript module (it's actually an optional addon!) so in order to get it to print correctly I need to install a non-ps printer driver! This is quite tricky to find out, and also not so easy to find where to download this driver. 

Links for downloading the non-ps driver at 

Printer output using postscript driver when printer doesn't support postscript! 

Note that the autodetected driver says "PS", but if the printer doesn't have the postscript module this will not work.

Need to click "View All" to show the download link for the "Non PS" driver.

After installing the downloaded "Non PS" driver, you need to manually select it when adding the printer.

2016/09/28 MacOSX

I started to get some battery warnings in Mac OS X and before long the battery was not working at all (when I unplugged the power cable the computer turned off immediately even though the battery should have been fully charged). I bought a Llano replacement battery online from TMall for 279 RMB. It has a 7150 mAh capacity. The price included shipping and the two torx screwdrivers needed for changing the battery.

To make sure I got the correct battery I checked the model number on the back of my Macbook Air (mid-2013) (mine says "Model A1466" on the back).

There's a good step-by-step instruction on Youtube for changing battery in a Macbook Air:

2016/09/19 MacOSX,Xcode

The Apple developer download page normally redirects to the Apple Store for downloads, but the link below is quite handy to get direct links for downloading (you need to be logged in as developer first)

I often have trouble in China downloading Xcode as the network usually gives up before the download is completed (Xcode 8 is 4.1 GB).

The latest Xcode 8 is right now only available as a .xip file (not .dmg). The .xip file format contains an archive (xar containing a gzip archive and metadata) and a signature of the archive. You can open/extract it with the Archive in finder. If you want to investigate whether the .xip is validly signed you can use pkgutil:

pkgutil --check-signature Xcode_8.xip
2016/09/19 MacOSX

To list all USB devices (with device information) run the following command in terminal window:

system_profiler SPUSBDataType

Another way is to use the "ioreg" that is a command line tool to show I/O kit registry. By default it clips to the window's width (i.e. 80 chars) so you may add the -w0 flag to get a full-width display.

ioreg -p IOUSB -w0

Adding the -l flag will show full details about each devices.
If you only want to list the device names, you can filter away all other information with this line:

ioreg -p IOUSB -w0 | sed 's/[^o]*o //; s/@.*$//' | grep -v '^Root.*'

Information from post by Gordon Davisson (

2016/09/19 MacOSX

Tip 1: Change screenshot file type:

defaults write type jpg

Tip 2: Encrypt and decrypt file using openssl:

openssl enc -aes-256-cbc -e -in {path-in} -out {path-out}
openssl enc -aes-256-cbc -d -in {path-in} -out {path-out}

Tip 3: Set updates check to daily (or any other value you would like)

defaults write ScheduleFrequency -int 1

Tip 4: Hold down option key when clicking on volume icon to quickly switch between audio input and output devices.

Tip 5: Prevent computer to sleep / install updates:

caffeinate -i -t 3600