“Fixing” Slow Wake Up of MacBook Pro with Retina Display

My main machine I use throughout the day is a Macbook Pro (soon to be one with a Retina Display). I really love almost anything about this laptop except that sometimes it’s a little bit slow to wake up from sleep when I open up the lid.

After opening the lid, it instantly shows the password dialog box, but the shown ui is not real. What is shown immediately is a screenshot of what the screen looked like when it went to sleep. 
The ui, although visible, is not functional for almost 10 seconds. You can most likely tell that this is happening by watching the clock display in the upper right of the display. Right after opening the lid, it will show the incorrect time (the time when the laptop went to sleep). After 8-10 seconds, the time will become accurate and this is the signal that you can actually start typing your password to unlock the laptop.
What is actually happening is that these new MacBook Pro’s (and recent MacBook Air’s) have a new powersaving mode which Apple calls standby. Standby mode kicks in after the laptop has been in normal sleep mode for about an hour. When that happens, the content of the ram is written to the hard drive and the ram is powered down to further extend battery life. 
In theory, the laptop will last up to 30 days in standby mode. The trade off is that, when waking up, it takes a long time to reload 16 GB of RAM from the hard drive (even with an SSD).
Note that if the laptop sleeps for less than an hour, then it will wake up nearly instantly. I’ve seen this myself in cases where I close the lid briefly while walking between meetings. It turns out that this 1 hour delay is configurable.

I changed the standby delay for my machine from 1 hour to be 24 hours by running this command from a terminal window (86400 seconds = 24 hours):
sudo pmset -a standbydelay 86400
Given that I plug my laptop every night to charge up the battery, I don’t care as much about the standby feature keeping my battery alive for 30 days. 
In theory, I may go on a trip or something and standby mode may be more useful, so I didn’t disable it completely (which can be done by setting the delay to 0). By setting it to 24 hours, standby will almost never happen with my normal day to day usage patterns and I’ll almost always have instant wake times. 
It may be that 24 hours is unnecessarily long and 12 or 18 hours would have worked just as well while providing a little better balance between battery life and day to day convenience. Time will tell.
P.S. If you want to see what your current settings are, you can run this command from the terminal:
pmset -g

LibreOffice 4.0.3 on Debian 7 Wheezy

Debian Wheezy ships with Libreoffice 3.5.4 out of the box. However the newest version 4.0.3 offers numerous improvements over the previous version such as improved start up time etc.
Fortunately wheezy backports offer a way to install version 4.0.3 without “upgrading” your installation from stable to testing or even unstable.

Add the backports repository on Debian Wheezy:

$ sudo su  

# echo 'deb http://ftp.debian.org/debian/ wheezy-backports main contrib non-free' >> /etc/apt/sources.list

# echo 'deb-src http://ftp.debian.org/debian/ wheezy-backports main contrib non-free' >> /etc/apt/sources.list

Update package information:


# apt-get update

Install LibreOffice from backports repository


# apt-get -t wheezy-backports install libreoffice

Compile 3.9 Kernel on Debian 7 Wheezy for Lenovo X230

Reason for compiling your own kernel

Debian Wheezy out of the box installs the Linux 3.2 kernel which was released back in January 2012. The 3.2 kernel is marked as longterm by the kernel team and will be supported until 2016. That’s probably the reason why Debian chose to release Wheezy with the 3.2 Kernel. However most newer hardware (released after January 2012) will not properly be supported by this kernel. The Intel HD4000 graphics chip in my Lenovo X230 suffers from lock-ups while using the 3.2 kernel. These problems were fixed in the 3.4 kernel (Intel provided a new graphics chip driver). The following commands will compile and install the latest available kernel from kernel.org (v. 3.9.4 at the time of writing)

Prerequisites

The following packages are needed to compile your kernel

$ sudo apt-get install kernel-package fakeroot build-essential ncurses-dev

Download the new kernel from www.kernel.org

(replace 3.9.4 with current version number)

$ wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.9.4.tar.bz2

Extract the archive and cd into it

$ tar xvf linux-3.9.4.tar.bz2
$ cd linux-3.9.4/

Compile the kernel

Base the kernel config on your current configuration

$ cat /boot/config-`uname -r`>.config
## OR (depending on your current kernel)
$ cat /boot/config-3.2.0-4-amd64 > .config

$ make oldconfig

Remark: you’ll be asked quite a lot of questions (newer kernel contain more options and tweaks). If in doubt, choose the default answer.

Create the kernel related debian packages

$ make-kpkg clean

Compile the kernel

$ sudo time fakeroot make-kpkg -j4 --initrd kernel_image kernel_headers

replace 4 with the amount of available cpu-cores

Install the new kernel

$ sudo dpkg -i ../linux-image-3.9.4_3.9.4-10.00.Custom_amd64.deb ../linux-headers-3.9.4_3.9.4-10.00.Custom_amd64.deb

Reboot and select the new kernel in grub

Remove Applications from Location Services in Security & Privacy on OS X 10.8

After removing an application in OSX 10.8 it still showed up in location services under the security and privacy settings in system preferences. (see picture below)
The reason is that it saves the entries in a binary plist file. You could delete the file and OSX will automatically recreate it. However you would have to re-authorize all the apps that you previously had authorized.
The following process shows how to edit the file and just remove the single application.

Preparation

1. Start terminal and then sudo to a root shell

sudo -s

2. Navigate to /var/db/locationd

 cd /var/db/locationd

3. Make a backup of the clients.plist file

cp -p clients.plist clients.plist.save

4. The plist file is in binary format and to make it editable/readable you need to convert it to xml

plutil -convert xml1 clients.plist

Edit the file

5. Use vi (vim) to edit the clients.plist file and remove the application

vi clients.plist

6. The file will likely contain many application entries. Here is the format of a single application entry (Safari in this case). The entire entry needs to be deleted. (dd for deleting complete lines in vi)

com.apple.Safari  

Authorized

BundleId
com.apple.Safari
Executable
/Applications/Safari.app/Contents/MacOS/Safari
LocationTimeStopped
376348187.80421197
Registered
/Applications/Safari.app/Contents/MacOS/Safari
RequirementString
identifier "com.apple.Safari" and anchor apple
Whitelisted


7. Convert the clients.plist file back to binary format

plutil -convert binary1 clients.plist

8. Restart locationd daemon by force-killing it. Launchd will automatically restart the daemon

killall locationd

In case things go badly, then copy back the original file and restart locationd

cp -p clients.plist.save clients.plist
killall locationd

This should remove the invalid entries from the security and privacy tab in system preferences.