24 March 2016

iCloud for iBooks

With the release of OS X 10.11.4 and iOS 9.3 a couple of days ago, iBooks now syncs your own PDF and ePub books (ones not from the iBooks Store) via iCloud. This is fantastic! I’ve been wishing for this capability for a long time.

The first time you open iBooks on your updated device, you’re asked if you want to use “iCloud for iBooks”. After that is turned on, any books added to iBooks are automatically uploaded to iCloud, making them available for download on your other devices.

To test it out I added a couple of PDF documents to iBooks on my Mac, and shortly after I had them available on my iPhone with the familiar iCloud icon overlay. With a couple of taps on the iCloud icons, I had the PDF documents on my phone. Love it.

Books was the last media type to still need old fashioned iTunes syncing, so with this update, I don’t need to use iTunes for syncing at all! The only reason I plug my phone into my Mac now is to create a local backup. I backup my phone to iCloud too, but having a local copy is a fail-safe.

Syncing books over iTunes never worked right either. It would often refuse to sync some books, and it was slow. In contrast, my experience with the new iCloud for iBooks has been flawless, so far.

Thanks Apple!

30 November 2014

SystemC on OS X

Aren't you tired of logging into a Linux server, or resorting to a virtual machine to use SystemC? Wouldn't you rather be using your shiny Mac and the awesome Clang C++ compiler? This is how you can do it.

Install Apple's "Command Line Tools". You have two options: install Xcode (a big download), or just the command line tools (a much smaller download). If your goal is simply building SystemC applications at the command line, then I recommend the latter.

Install Apple's "Command Line Tools" by launching Terminal, entering

$ xcode-select --install

then clicking Install. After that, you'll have make, clang and more available at the command line.

Build and install Accellera's SystemC implementation. Download the latest release from the Accellera Downloads page (annoyingly, you'll have to provide a few personal details) and extract the contents of the .zip file.

I like to keep a copy of the SystemC source code available, because it can be useful for debugging or understanding how something works. Therefore, I move the extracted folder (systemc-2.3.1) into ~/Work/Other. That's where I keep source code for third party libraries. However, you can put it wherever you like.

Open Terminal, change into the extracted folder (systemc-2.3.1), and execute:

$ mkdir build  
$ cd build  
$ export CXX=clang++  
$ ../configure --with-arch-suffix=  
$ make install

The --with-arch-suffix= option prevents a -macosx64 suffix being add to the lib folder name, allowing your build scripts to be simpler.

After that process, the salient include and lib folders should be available within the systemc-2.3.1 folder.

Configure your build environment. There are many ways you can do this; I have a simple approach that I believe is close to what the SystemC maintainers envisioned. I define two environment variables in my .bash_profile (executed for every new Terminal session on OS X):

export CXX="clang++ -fcolor-diagnostics"  
export SYSTEMC_HOME=~/Work/Other/systemc-2.3.1

Build a SystemC application. You could use Make, the quintessential build tool, which you get with Apple's "Command Line Tools", or any one of the plethora of other options. I use SCons with SConstruct files that look something like this:

import os  
env = Environment(CXX=os.environ["CXX"],  
                  SYSTEMC_HOME=os.environ["SYSTEMC_HOME"],  
                  CPPPATH="$SYSTEMC_HOME/include",  
                  LIBPATH="$SYSTEMC_HOME/lib")  
env.Program("main.cpp", LIBS="systemc")

View trace (VCD) files. Scansion is a nice tool for this. GTKWave is another option, but it's a bit clunky.

Now you're rocking!

28 September 2014

No sleep for you Mac mini

Our Mac mini (a late 2012 model running the latest OS X 10.9.5) has just decided that it doesn’t want to wake from sleep anymore. It would normally wake when accessed from my MacBook for Screen Sharing, or from our Apple TV for streaming with iTunes Home Sharing, which we use all the time (Peppa Pig!). My feelings: frustration with a tinge of déjà vu.

This was all working fine before Apple’s recent round of software updates: iOS 8, OS X 10.9.5 and Apple TV 7.0.0. I don’t know which of those updates is the culprit, if any.

I spent the morning looking for a solution. I tried playing with network settings, resetting all the devices, and even resetting the Parameter Memory (PRAM) in the Mac, all to no avail. And I definitely have the salient “Wake for network access” preference set in Energy Saver Preferences. I’ve submitted a bug report to Apple, but who knows what will come of that.

This isn’t the first time we have had this type of issue. If I remember correctly, the first version of OS X Mountain Lion (10.8) broke “wake from sleep” for us, and it wasn’t fixed until 10.8.2. I vaguely remember other issues when running Lion too. There is a smell of unreliability around this “wake from sleep” stuff.

After a wasted morning, I started wondering: why do I even care about this? I can just prevent the Mac mini ever going to sleep and be done with it. Sure, it’ll cost a bit more in electricity usage, but compared to all my other expenses, not a big deal.

I think part of the reason that I persist with this folly is that I just feel like it should work; it’s the correct solution! Apple has a cool technology with its Bonjour Sleep Proxy service, which has been around for a while, and should “just work”. And I’m using all modern Apple hardware, with the latest software, so there should be minimal compatibility issues; why doesn’t it work! And it feels wrong to waste electricity, when I don’t have to.

But that’s all wishy-washy thinking; I should be looking at the facts:

  • I measured the Mac mini’s power usage: 1 Watt when sleeping, 8 Watts when fully awake. It would be even less when the hard drives aren’t spinning (but, I didn’t measure that). At $0.35 per kWh (my highest tariff), it costs about $25 to run the Mac mini at full power for an entire year. That’s not much.
  • The time to wait for the Mac mini to wake from sleep can range from a few seconds (fine), to tens of seconds (not so fine). However, when the Mac is fully awake, access is instantaneous; bonus!
  • Sometimes we see flaky behavior with Home Sharing, and I usually fix it by restarting the Apple TV, or by restarting iTunes on the Mac mini. I don’t know if “wake from sleep” comes in to play here, but it might.
  • I can schedule the Mac to completely shutdown overnight for at least six hours, which will save energy (and $6 a year, pffft). Resetting iTunes every night probably doesn’t hurt either.

Considering the above facts, the course of action is clear: no sleep for you Mac mini!

25 April 2014

Paprika

We bought the recipe management app Paprika a few months ago. It's mainly for my wife, but we both think it’s great.

We have it on all our devices: our two Macs, our iPad and our two iPhones. So we have easy access to all of our recipes from anywhere. We use the iPad on a stand as a recipe book in the kitchen, and editing recipes is best done on the Mac. Theoretically, the iPhone version could be useful when out shopping, but we have a different app for that.

Nina had amassed a small collection of favourite recipes, and she had each one stored as an individual Pages document. I hacked together a Python script to extract the contents from the Pages documents – luckily she had a fairly regular format – and translated it into the YAML import format supported by Paprika. After importing those YAML files into Paprika, we almost instantly had access to over 150 recipes on all of our devices.

These are the things we like about Paprika:

  • Simple, intuitive and easy to use interface. Its easy to find the recipes you are after, and the recipes are presented in a clean, easy to follow manner.
  • Fast and reliable sync across devices. We haven’t had a sync issue yet. Paprika uses a custom sync mechanism – not iCloud or Dropbox – which makes it easy to share recipes across multiple devices and users.
  • Scaling ingredients based on how many serves you need prepared. Very handy!
  • Running multiple timers concurrently, and timers are automatically detected in your recipe directions. For example, if you have the text “2 minutes” in your directions, you can click on that to start a 2 minute timer.
  • Assigning Categories (which are basically tags) to recipes, making it easy to browse your recipes for ideas, based on the type or style of meal you need to prepare. Here are some of the categories we use: Breakfast, Lunch, Dinner, Biscuits and Soups. A recipe can be assigned to any number of categories.
  • Import recipes from web-sites. This works great! Nina has used it with taste.com.au a few times, and it has worked perfectly every time.

Other features include a meal planner and a grocery list manager, neither of which we have used yet. We’d need to put some effort in to come up with a “work flow” that incorporates those features; maybe one day. But anyway, I consider those peripheral features for us.

Highly recommended!

16 January 2014

Modific Sublime Text Package

I recently started using the Modific Sublime Text package. It highlights (with a subtle icon in the gutter) lines changed since your last commit. It supports Git, Subversion, Bazaar and Mercurial.

It also has some other useful features: view a file diff, preview committed code for the current line, revert a specific change, and cycle through changes.

By default, it uses the svn binary on PATH. For my Windows machine I configured it to use svn.exe out of my Cygwin install:

{
    "vcs": [
        ["svn", "C:\\cygwin\\bin\\svn.exe"]
    ]
}

On my Mac, I had to set this option to true:

{
    "svn_use_internal_diff": true
}

I’m finding it pretty useful.

11 December 2013

It's the future: spare parts online

The microwave had just beeped. Nina went to pop it open and get out the hopefully warm bottle of milk… but there was no pop. The button just flopped there, and the door didn’t budge. It was busted! My initial thought was: expensive repair job or expensive new microwave purchase. My second thought was: maybe I can fix it.

Getting the microwave cover off was a cinch, and finding the problem was easy too: a plastic lug had been sheared off the door button lever. How do I fix that, I thought? Maybe I could jury rig something using a screw in place of the lug, but that would probably be sub-optimal, even if I could pull it off.

Then I thought: hey, it’s 2013, nearly 2014, surely I can find this part online. I wasn’t optimistic, but I located what appeared to be a part number (5Y00AP) on the broken part and chucked it into Google, and was surprised to find this place: Big Warehouse spares.

They had my part listed, a “PANASONIC NNSD686S DOOR OPENING LEVER”, complete with multiple photos from different angles (great for piece of mind that you are ordering the right part). It was $19.04; maybe a little pricey for a single piece of plastic, but I’m not complaining because that it a lot cheaper than having to pay someone else to fix it. Delivery was $5.95.

The part arrived in a couple of days. The photo below shows the broken part on the top, and the new one on the bottom. Spot the difference?

Untitled

Fitting the new part was easy enough, and the microwave was as good as new.

The morale of the story is: Big Warehouse spares is awesome, with stacks of spare parts (they claim a million!), so check them out.