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.

7 October 2013

GeekDesk

I have had my height adjustable GeekDesk v3 for about two months now, and I love it.

GeekDesk

GeekDesk lets me work standing up for most of the day, but when I feel inclined to rest my legs or feet, I can easily adjust it to a sitting height by pressing a button that operates a small internal motor drive.

Why bother standing anyway?

Two reasons.

Firstly, and mainly, because I have a bit of a crook back. Other people have described this condition as Programmer’s Back, and I think that is apt. My theory is that moderating the amount of time I spend sitting will lead to a healthier back.

Secondly, because sitting is quite bad for you.

Why a GeekDesk?

As usual, I did a fair amount of research before making this purchase.

Initially, I started searching for desks available locally in Adelaide, but I was disappointed by the range, and in particular, I was disappointed by the lack of information and reviews available for the products.

So I expanded my search, and I found that there are some top products available in the US. After reading various reviews, I narrowed the list down to three products: the GeekDesk v3, a Mod-E, or the NextDesk Terra. If price was not a factor, I would get the NextDesk. But price is a factor, and $US1500 + delivery to Australia was just too much.

So that left the GeekDesk or the Mod-E. They both seemed like top notch products, so I didn’t think I could go wrong with either. I settled on the GeekDesk because I liked that it had a low cross bar for stability, and because it ended up being cheaper, once the delivery quote was factored in. I decided to get the large frame, rather than the small frame, as I think a desk top width of 1.5 metres is the minimum for my purposes.

GeekDesk also offers a more expensive “Max” model, which adds extra lift capacity and programmable height presets. However, the v3’s capacity of 125 Kg is plenty for my purposes, and programmable height presets are simply not very useful. One of the advantages of a height adjustable desk is fine tuning the height for your comfort, for different users, and even for when you are wearing shoes with a different sole depth; presets just get in the way.

Getting a desk top

I didn’t get a top with my GeekDesk purchase, because shipping that from the US to Australia is just too pricey. I had to source one myself.

Initially I considered making a desk top out of timber myself. But after realising that I didn’t have all the required tools, or the time, I thought better of it, and decided to look for a pre-made one.

The dimensions of the medium size top sold by GeekDesk is 160 x 80 cm, so that was the ball park size I was looking for.

We are lucky to have an IKEA in Adealide, so I investigated what they offer:

  • LINMON table top. A 150 x 75 cm particle board table top for the miserly sum of $49. But it is $49 for a reason, and on inspection, I was not at all impressed. It was a bit too cheap any nasty for my taste. The table on display had lots of chips around the edge of the top, showing the fibre board colour underneath. I hate that. Also, the dimensions were a little smaller than I was looking for.
  • NUMERAR kitchen bench top. A 186 x 62 cm solid Beech timber top for only $260. This would have been great, except that 62 cm is not deep enough; 75 cm was my minimum.
  • GERTON table top. This looked perfect. A 155 x 75 cm solid Beech timber top for only $189. I really wanted this one! But when I enquired with IKEA about stock, this is what they said: “Unfortunately I’m unable provide you any information of when this arriving. Possibly looking at 7–8 weeks till we get shipment date.” Very noncommittal, and not very promising at all. A shame.
  • GALANT table top. A 160 x 80 cm particle board top with Ash timber veneer for $149. Its a perfect size, as it exactly matches the size sold by GeekDesk. It is quite good quality. It is available in a black/brown stain, which happens to match our other furniture. I had found my desk top!

So I got the GALANT, and I am very happy it. The GERTON would have been perfect, but the GALANT was a very close second anyway.

Ordering, delivery and setup

The GeekDesk staff were very helpful in quoting for delivery to Australia, and I thought that the $US236 delivery cost was quiet fair.

Delivery of the desk took a little more than two weeks. Pretty impressive, given that it came from the US!

Setup was straight forward, and the instruction booklet is well written and easy to follow.

Cable management

As you can see in the photo, there is a bit of a mess of cables on the floor, and I even have my ADSL modem sitting there. However, I have plans to tidy all that up by adding a hidden shelf underneath the desk. I’ll be able to place the modem, router, USB hub and power adapters there.

Conclusion

I really dig my new GeekDesk. I love the solid quality, the simple understated look, the stability at standing height, and the fast, smooth and quiet motor operation.

What’s more, I really enjoy standing at it. I have the desk at home, and I find that I tend to stand around ninety percent of the time. It is actually very comfortable. It is easy to ergonomically sort your body out with a straight back and neck, and correctly angled elbows. Standing seems to even help me concentrate, I think. Importantly, standing at home compensates for the fact that I sit all day at work.

I have a few photos here.

If you’re a programmer, a height adjustable desk is very worthy investment, in my opinion. And you won’t go wrong with a GeekDesk! But if you’re rich enough, maybe get the NextDesk; it looks like the bee’s knees :-).