Western Digital Black² in a Apple Macbook Pro 13″

UPDATE:
The method described below worked before Western Digital official supported the drive on a Mac. They now have both the firmware update tool and software to run as either a dual drive of a fusion drive on a Mac:
http://support.wdc.com/KnowledgeBase/answer.aspx?ID=11750
http://support.wdc.com/downloads.aspx

The Western Digital Black² is a 120GB SSD with a 1TB 7200rpm regular hard drive in a single 2.5″x9.5mm case. I thought it would be ideal for both expanding and speeding up my MacBook Pro 13″ without needing to use a hard drive caddy and remove the DVD drive, which I still use from time to time.

I went ahead and got one without realising it wasn’t compatible with a Mac. Since the move to Intel almost everything is these days, so I just assumed it would be. Not wanting to give up, I did some Googling and found that AnandTech reports that once partitioned using Windows, it is readable on a Mac.

Annoyingly you have to install the Black² as an internal drive in computer, otherwise the automatic partitioning tool won’t recognise it. I din’t have a Windows PC I could put this in, so I had to install it in my Mac first, install windows just to use the partitioning tool, and then copy back over my Mac OS. This is all the steps I did to get it working:

1) Backup your existing drive, its important to do this often anyway, but especially since this is not supported, I or Western Digital will not be responsible for any damage or loss suffered to you, your hardware, or your files.

2) Remove your old hard drive and install the Black² in its place.

3) Install Windows (I used Windows XP, so I also had to remove a ram chip to leave it with only 4GB RAM).

4) If on Windows XP SP2, install Windows Installer 3.1, download it onto a USB drive first so you don’t have to install the bootcamp drivers to get the WiFi working.

5) Run the WD Black² partitioning tool.

6) Hold the Alt key while booting and boot onto your backup or original hard drive on USB.

7) The Black² should now have two visible partitions. Erase existing partitions so that you’re left with one big one.

8) Create 2 partitions, the first one 119.8GB, and the rest for the remaining. I experimented with different sizes, but 119.8GB left the right block sizes (see appendix).

9) (Recommended) Add an additional partition of 1GB to the end of the first (SSD) partition you just created. I then cloned by old recovery partition using the instructions here. Update: I’ve changed this from optional to recommended, since when I tried to upgrade to OSX 10.10 Yosemite it couldn’t install because it wasn’t able to create the Recovery HD. I also tried to create it with Carbon Copy Cloner as a 650MB partition and that failed too. I don’t know if its because my partitions weren’t quite right and were overlapping the SSD/HD but when I created the Recovery HD as a 1GB partition it worked, and Yosemite installed.

10) Clone less than 120GB of your original or backup hard drive onto the SSD. If you have more data, you may need to clone your home folder on to the magnetic hard drive bit.

11) (Optional) If you have too much data for the 120GB, clone your home folder to the magnetic hard drive partition, and after booting up, move your home folder location.

12) (Recommended) Enable Trim. You can use Trim Enabler (paid) or what I used Chameleon SSD Optimizer (free). If anyone is interested, there seems to be an extra hardware controller in between the SATA and the drives to make sure trim command only effect the SSD not the magnetic partition.

Notes:
There has been one or two settings that have changed on my Mac. I’m not sure if this is a result of moving my user home folder, cloning the hard drive, or something else. It seems unlikely that it would be because of using the Black², but I’ll report back as I’ve spend more time using the system. The settings changed were:
– Custom screenshot location overridden
– Mac gatekeeper changed from “All” to “Trusted”

Also strangely Western Digital do have a firmware update tool for the Black2 that does work on a Mac. I haven’t tried it, and not sure if I will yet.

Updates:
– I just tried to update to Yosemeti and realised it won’t install if the partitioning scheme is master boot record instead of guid. I updated above to include these steps.
– In searching to fix the partitioning scheme problem I found that someone else has done this before, and also turned it into a full fusion drive!
– I also found this article helpful for how to check out the partition sizes in detail.
– Also since doing this upgrade I’ve noticed I get the the “Disk too slow (recording) -10004” error when using GarageBand. I’m not sure if its the hard drive, or making the upgrade to Yosemite on an older Mac, but now I have to record to an external hard drive (not the one that the OS is on. I used to be able to do this when I had a normal hard drive. The disk isn’t slow, my boot times are at leas 6-10 times faster, but it maybe “glitchy” in a way that GarageBand doesn’t like.

Appendix:
Partition Block Sizes using sudo gpt show /dev/disk0

After WD Black2 Tool on Windows + Converting to GPT. I really should have done this before converting to GPT for it to be more accurate. From this you can see that the last block of the 1st partition should of the 120GB SSD partition should be at most 234420417 + 63 = 234420480 to be sure its on the SSD. In addition the start of the 2nd block should be at least 234442752.

start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 29
63 234420417 1 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
234420480 22272
234442752 1953523712 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
2187966464 319
2187966783 32 Sec GPT table
2187966815 1 Sec GPT header

After deleting original partitions and formatting to two partitions using Disk Utility and the first set to 119.8GB. Apple creates the EFI partition at index 1, so now index 2 is the 120GB we will store the OS on. The last block of this partition 233984376 + 409640 = 234394016 which is < 234420480. Apple also intentionally creates a large gap after any user partitions. This makes the first block of the normal hd partition start at 234656160 which is > 234442752.

start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 233984376 2 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
234394016 262144
234656160 1953048472 3 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
2187704632 262151
2187966783 32 Sec GPT table
2187966815 1 Sec GPT header

After I used Carbon Copy Cloner to create the recovery partition on the SSD, this is what I get:

start size index contents
0 1 PMBR
1 1 Pri GPT header
2 32 Pri GPT table
34 6
40 409600 1 GPT part - C12A7328-F81F-11D2-BA4B-00A0C93EC93B
409640 231887224 2 GPT part - 53746F72-6167-11AA-AA11-00306543ECAC
232296864 262144
232559008 1835008 3 GPT part - 426F6F74-0000-11AA-AA11-00306543ECAC
234394016 262144
234656160 1953048472 4 GPT part - 48465300-0000-11AA-AA11-00306543ECAC
2187704632 262151
2187966783 32 Sec GPT table
2187966815 1 Sec GPT header

Ikea Standing Desks

While I was at Onoko I did a standing desk for a while. While it was really good, I found doing it 100% gave be cramps in my legs. Now that I work at home a smaller desk (in additional to sit down desk) that would take up less room and also allow me to move it around the house or even to the garden to work! I had some GERTON legs so I got a £1 piece of wood from the bargain bin and built my own. There are lots of fancy options at Ikea Hackers, but here are the other ideas I looked at:

At a height of 105cm the BILSTA Bar table would make a perfect standing desk. Its also available as just the base so you can add your own top from a piece of wood the bargain bin or any of: TROFAST / INREDA / ALGOT / KOMPLEMENT / BILLY / BILLY / FJÄLKINGE / IVAR / EKBY LAIVA or even the top off a LACK coffee table
Another bar table that works is BJÖRKUDDEN. Its quite deep so do can fit too people with laptops facing each other.
Get the GERTON legs extendable up to 107cm:
http://www.ikea.com/gb/en/catalog/products/60261626/

Get any of the compatible desks, or a piece of wood from the bargain bin or one of the tops mentioned above.

There are also the BILLSTA desk legs, but they’re more expensive and less flexible in terms of tops.

Use one of the wall mounted leaf desks:

Select an item from the various wall shelves available. If you want something bigger, buy the sturdiest brackets and again get a piece of wood from the bargain bin or one of the tops mentioned above.

I hope that’s helpful. Sorry the links are to the UK store if you live somewhere else. I’m still wondering if I should eventually get a Cycle Desk!

Disable Git in Eclipse

I use the excellent Source Tree as a visual Git client, and really dislike messages about versioning when I’m coding. Eclipse’s Git colours and overall intrusiveness seem to be particularly bad. I couldn’t find which plugin to remove but I did find the following settings:

This setting will stop Eclipse from automatically attaching its Git functions:

disablegit

Update: Newer versions of Eclipse seem to use this setting:

disablegiteclipse

If you’ve already loaded some projects before disabling the above setting, you can disconnect those individual projects from Eclipse’s Git functionality here:

disconnectproject

iPhone Push Notifications with JavaPNS on Google App Engine

There have been several issues with getting JavaPNS working on Google App Engine. These included:
1) GAE didn’t support sockets or SSL
2) GAE doesn’t support signed jars, the BouncyCastle cryptography library is signed
3) GAE is transitioning to Java 7, and Java 7 has issues reading .p12 certificates

These instructions are for JavaPNS 2.2 and GAE 1.7.7, things may change on both fronts to make things either easier or harder.

1) GAE didn’t support sockets or SSL

With the arrival of GAE 1.7.7 sockets and SSL are now fully supported:
http://googleappengine.blogspot.com/2013/04/app-engine-177-released.html

2) GAE doesn’t support signed jars

Remove META-INF/MANIFEST.MF from the latest BouncyCastle jar or download my modified jar of BouncyCastle 1.48

3) Java 7 has issues reading .p12 certificates

a) Generate your .p12 certificate as per Apple’s instructions

b) Install Java 6 JDK

c) Use Java 6’s keytool to convert the .p12 to a .jks

keytool -importkeystore -destkeystore CERTIFICATES.jks -srckeystore CERTIFICATES.p12 -srcstoretype PKCS12

d) Configure JavaPNS to use the .jks format instead of .p12

boolean production = false;
String device = "DEVICE_ID";
String keystore = "CERTIFICATES.jks";
String password = "PASSWORD";
String message = "Hello JKS";

AppleNotificationServer jksServer = new AppleNotificationServerBasicImpl(keystore, password, ConnectionToAppleServer.KEYSTORE_TYPE_JKS, production);
PushNotificationPayload payload = PushNotificationPayload.alert(message);
PushNotificationManager pushManager = new PushNotificationManager();
pushManager.initializeConnection(jksServer);
List<PushedNotification> notifications = pushManager.sendNotifications(payload, Devices.asDevices(device));

Thanks to Palomino Labs Blog for the hints about Java and .p12 files:
http://blog.palominolabs.com/2011/10/18/java-2-way-tlsssl-client-certificates-and-pkcs12-vs-jks-keystores/

List Apps To Update After Moving iTunes App Store Countries

I moved my iTunes account from one country to another recently as I am about to move. An annoying thing is iTunes doesn’t know how to update apps that you’ve downloaded from a different country, even though if you download it manually again you get the app for free. It works on the iPhone/iPad, so its really something they should fix in iTunes.

If you have OCD like me it can be very annoying to constantly have a (1) or something by the Apps, meaning you have Apps to update. I recently worked out where this information was stored, and came up with a relatively quick way to update these apps.

1) Open Terminal.app

2) Run the following command:

grep --binary-files=text -A 1 "<key>title" ~/Library/Preferences/*.iTunes.plist

3) Find those apps in iTunes and right click them -> “Show in iTunes Store”

4) Download the app again, if you bought it before it will say something like “This update is free because you have already purchases this app”.

5) After you’ve updated it once, it remembers that you’ve downloaded it from the new country and it can automatically find the update as per usual.

Note: Be careful because if an app has been removed from the App Store altogether, iTunes will sometimes redirect you to another app from the same publisher. This happened to me, I was redirected from the free (discontinued) app to the paid version, and thinking it was the same app I bought an app I didn’t mean to.

DynDNS via curl on Apple TV 2

1) Copy this script to /var/root/dyndns.sh

#!/bin/sh
if [ ${ip=$(curl -s ifconfig.me)} != ""$(cat ~/.dyndns.ip) ]; then
curl "http://USERNAME:[email protected]/nic/update?hostname=HOSTNAME&myip=$ip&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
fi
echo $ip > ~/.dyndns.ip

2) Edit USERNAME, PASSWORD and HOSTNAME for your DynDNS account

3) Check it runs /var/root/dyndns.sh

4) Copy this script to /Library/LaunchDaemons/dyndns.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>dyndns</string>
<key>ProgramArguments</key>
<array>
<string>/var/root/dyndns.sh</string>
</array>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>

5) Run launchctl load dyndns.plist

6) Run launchctl start dyndns

Notes:
– You can adjust the interval so that the script runs more frequently than every hour by modifying the 3600 seconds
– If you want to update multiple hostnames you can put them in a comma separated list
– For more information on DynDNS see:
http://dyn.com/support/developers/api/perform-update/

Google DFP with Appcelerator Titanium

I’ve been using Appcelerator’s Titanium to streamline mobile development for Android and iPhone. They have a module for doing Admob ads but there Double Click for Publishers (DFP) module is only available to enterprise customers.

However, as long as you don’t need the DFP’s multiple sizes and just want custom campaigns with Admob backfill, you can use their current free Admob module.

Initial set up
1) Get Titanium’s Admob module here:
https://marketplace.appcelerator.com/apps/795?1803788439

2) In DFP go to your inventory and create mobile ad units for each size of ad you want to server in your app.

3) In your app set the publisherId to the id of your DFP adunit (normally it’s the publisher id from Admob)

var Admob = require('ti.admob');
var adunit = '/123/App320'; //Get this from your inventory in (2)
var adview = Admob.createView({
adBackgroundColor:'black',
primaryTextColor:'blue',
secondaryTextColor:'green',
publisherId:adunit,
width:320,
height:50,
bottom:0
});

Admob backfill
4) If you haven’t already set up an Admob account at http://www.admob.com and create your app to backfill DFP with.

5) Go to your orders and create a new order and line item:
– Enter the inventory sizes you want to use in your apps
– Since you probably just want to back fill almost always, set an end time far in the future
– Likewise set the quantity of your impressions to really high
– Set a low non-zero CPM value so that your ads actually show up
– When you click save, if you need to check “overbook” then do, it just means no one is viewing your ads yet

6) Add the inventory items you created in DFP previously (2)

7) For each ad size add an Admob creative entering the publisher id you created in (4)

Custom campaigns (optional)
If you want to put your own ads in or run custom campaigns for clients

8) Create a new line item in DFP. This can be under the same order you created before since you can use a different CPM value, or you can create a new order to keep things separate.

9) Again select the ad sizes and and adunits you want to use

10) Set the CPM, impressions and time period that your client is paying for

11) Add a new creative with the images or HTML that you want to display

* Note, unlike backfill with Adsense, in backfill with Admob DFP doesn’t know how much advertisers are bidding, so if you run custom campaigns you’re competing with the manual price you entered in (5), not the price that Admob advertisers are paying. However normally this isn’t an issue since if you’re doing custom campaigns they are hopefully bidding quite a bit higher than Admob for it to be with it. See the link below:

https://support.google.com/dfp_premium/bin/answer.py?hl=en&answer=2549435

Alternatives to Google Apps

Google recently announced the very sad news that they were suspending the free version Google Apps for businesses. Here are some alternatives:

1) Microsoft’s outlook.com

Using domains.live.com you can map your domain and get up to 500 free email addresses.

2) Zoho mail

Zoho mail have a free version avaliable

3) Google Apps for Education / US Non-Profits

If you are an educational institution of US based Non-profit you can still get Google Apps for free

4) Google App Engine + Google Apps

Google App Engine still requires Google Apps to map domains. They’ve still kept a free version with which you can get a single account. You can probably still use multiple email addresses using catch-alls or with Google App’s “groups” feature, enabling anybody on the internet to post. You can sign up for that at the following link, but they check that your referrer is https://appengine.google.com

https://www.google.com/a/cpanel/standard/new3?refererName=AppEngine