Running 'nweb' on Mac OS X

For some time I've admired the simple web server code called nweb, which can be found here. It's written in C and shows how you can build a nice simple little HTTP server without scary amounts of code. The code even runs on the Raspberry Pi.

It's written for Unix and Linux systems, but I wanted to see if it would work on my MacBook (which runs Mac OS X, obviously). Since Mac OS X has a Unix heritage, I hoped it would work without too much trouble...

So I fired up Xcode and created a blank "Command Line" application in C, then I just pasted in the nweb source code. It gave just one compilation error.

All I needed to do was replace SIGCLD with SIGCHLD in one line of code. Then it worked! Nice.

So that's awesome, a very handy little command line web server for Mac OS X.

I'm sure I will find a use for that. The old brain cogs are whirring as I type this in fact.

Some apps for the hudl

After owning a hudl (an Andriod tablet made by Tesco) for a little while, I have found a few useful Apps. So here are some of the ones I've found to be quite good (they have all come from the Google play store):

ePub reader: Moon+ Reader

A nice ePub reader, with good abilities for highlighting. So it's useful for study purposes.

Document editor: Kingsoft Office

Quite an impressive document editor for MS Office documents, especially considering it's free. This is what I often use when I'm taking notes.

C/C++ IDE (woo-hoo): C4driod

OK, you have to pay for this one, but it means I'm never too far away from a C compiler. This is the feature I always wanted on my iPad...

I'm still quite impressed by the hudl, and I use it often. I'm planning to post some more of my thoughts on the hudl another time, watch this space.

Switching to decaf

I like coffee. But I drink too much of it, so I've mainly switched to decaf at the moment. My objections to most decaffeinated coffees are 1) they don't taste the same, and 2) I'm worried that they're full of other chemicals left over from the process of removing the caffeine.

So I've been experimenting. Or rather, my wife has been experimenting and I have been the tester/victim. Actually, it's not been too bad, she has chosen wisely.

So far the winners are...

Ground coffee: Grumpy Mule Organic Sumatra

Instant coffee: Clipper Super Special Organic Decaf

Both are organic and fairtrade. Both use a water process to remove the caffeine, so no nasty chemicals. And both taste OK, IMHO (I think they're pretty nice actually).

Sometimes I mix them with a regular coffee to make a 50/50 blend, just to get a little caffeine. Just occasionally.

They are worth checking out, if you're looking for a nice cup of decaf.

The Hudl from Tesco

I'm becoming increasingly reliant on having some kind of tablet type computing device with me. My favourite is still the iPad mini, which works brilliantly as far as I'm concerned. It's one of those things that just works. Shame you can't actually do any programming on it though. A decent lightweight C IDE on the iPad would be nice... but I digress.

However, the iPad is not the type of thing I want to chuck in my bag and drag round Cambridge all day. If I damaged my iPad I would be very upset indeed.... they are not cheap to replace.

So I have been looking for a cheaper tablet, something where I would not be quite so upset if I dropped it or scratched it. As long as I can get online and run a couple of apps I'll be OK. But this would be slightly more expendable than an iPad.

So I've decided to try out the Hudl from Tesco. It seems to have a very decent spec for the price, and if you buy it online and use your Clubcard points you can get further discounts.

I went into a Tesco store to try one out... but the demo machine was locked down and would do little more than play some promotional videos. I wanted to fire up the browser, look around in the Google Play store and that kind of thing. Unfortunately, the demo machines don't let you. Boo...

So you need to buy one to have a proper play. I've bought one now, and will report back if there are any important developments.

Some nice autumn mornings in Cambridge

It has been a beautiful autumn - my favorite time of the year. Yes, we've had a few storms too, but we've also had some absolutely fantastic days where the sky has been clear and blue.

Recently, I've been starting early in the mornings, so when I've walked through the streets of Cambridge in the early morning sunshine I've snapped some pictures on my phone.

The picture quality isn't great (I have an iPhone 3GS which is quite old now), but hopefully you'll get an idea of the sights I have been enjoying.

Here is a view along the river Cam ... looking along the backs:

Here's Kings College, looking nice in the early morning sunshine:

And this is the Senate House, which is also near Kings:

....it's certainly no hardship to walk around these streets, even if it is before 8am. In fact, it might be the best time of day to experience it.

Freddinos, Puerto de la Cruz

We went on holiday to Tenerife recently. It was nice, but very hot - the on-street temperature displays were reading 39°C on the day we arrived. So it was a real shame that the air conditioning was not working in our hotel :-( Actually, it's the first time in over a decade that we've felt let down by Thomson holidays (TUI). The hotel was just not up to their usual standard. But apart from that, we had a nice time.

Anyway, when on holiday I'm extra-happy if I can find a decent cup of coffee.. Most of the Spanish coffee is not to my personal taste, so I have pretty low expectations when I go to the Canary Islands. I mostly prefer the Italian style of caffeinated beverage of course...

But we actually found this place, which did nice 'Italian-style' coffee and was also extremely cheap:

Result! So look out for Freddinos if you're in Puerto de la Cruz and want a nice coffee.

But I have to say their ice cream and cheesecakes were awesome too, look at this beauty:

We had to go back several times, just to make sure...

Extra speedy H2D2 on the Mac

I remember there was a time I was very happy because H2D2 was running my Mandelbrot test program in about 650 milliseconds (whereas the original proof of concept, DALIS, took nearly 12 seconds to do the same thing).

Since moving over to my new MacBook and compiling the H2D2 source using Xcode, just look at the result now:

Whoa! 72 milliseconds! Now that's impressive. This new MacBook is pretty fast, but I'm sure the Apple LLVM compiler is also playing its part in achieving that level of speed. I have done some optimisation work in H2D2 recently, but I don't think I can take the credit this time.

It really pays to do this type of 'system level' programming in C (plus I enjoy it of course). Right, I'm off to work on parsing string expressions now...

H2D2 … now on Mac OS X

OK, first of all, I've bought a new laptop, and it's a Mac - a 13" MacBook Pro to be precise, the one with the Intel Core i7 processor, 8Gb of RAM and 750Gb hard disk. After having great success with running things as VMs at home, I've decided to do the same on my laptop. But the old Toshiba T130 was just not powerful enough to do that (it seemed like quite a powerful laptop when I bought it, but that was over 4 years ago I think). Besides, the Toshiba was feeling quite slow anyway.

But I came to realise that if I was going to run all my stuff as a VM, then I didn't need Windows as the host OS. And getting a new shiny Apple piece of kit seemed like a pretty good choice. I've virtualised the old (Windows) laptop and now it's running happily as a VM in VirtualBox on my new MacBook. Pretty seamless really.

But, I then went and downloaded Xcode (Apple's IDE) and quickly realised that it will happily support plain old C programs. So I copied the H2D2 codebase from Pelles C on Windows into Xcode on the Mac. It compiled and ran first time - even I was surprised. But that is what is supposed to happen when you write portable C code - you can run it natively on just about any platform.

So, I'm going to carry on developing H2D2 in Xcode for a while and see how that goes. My initial impression is good, I'm still learning the keyboard shortcuts … but then I'm still getting used to the new Mac keyboard as well. I was surprised to realise that there is no hash (#) key, at least not on the UK Mac keyboard. Maybe twitter isn't as popular amongst Apple users as I had thought. Or maybe that's just because I think of Steven Fry when I think of a typical Mac user :-)

Anyway, I'm still finding my way round the IDE at the moment. It's probably too soon to draw any final conclusions. Maybe I should buy a book on Xcode...

Conway's Game of Life as a C# console app

Since my school days, I've always liked the Game of Life, invented by mathematician John Conway. It nicely demonstrates how complex behaviour can come about from just a few simple rules.

Anyway, when I was reading up on the I2C interface recently, I accidentally found this code on the Wiring Pi website (which is a GPIO interface library for the Raspberry Pi). It looked like a nicely written bit of code so I decided to write something similar in C#. There's no real reason why I should, but it just seemed like a fun thing to do...

In terms of my example (with black and white cells), the rules go like this:

  • a black cell with less than 2 black neighbours goes white
  • a black cell with 2 or 3 black neighbours stays the same
  • a black cell with more than 3 black neighbours goes white
  • a white cell with three black neighbours becomes black

Here is the result:

This console app version demonstrates a glider gun, which is some pretty impressive behaviour from those four simple rules.

Oh, and if you're really interested, and would like to see my code, it's here (as a text file).

Lenovo IdeaCentre K430 Desktop PC

So my wife needs to run a bunch of different Virtual Machines for her work. Doing that means she can easily clone an existing VM, mess about with stuff and throw it away afterwards if needs be. Then she doesn't need to worry about having left her computer with lots of weird settings at the end of the day.

So she really needed a fast machine with loads of storage for all those VM virtual disk images, and a decent amount of RAM as well.

We looked around, and she went for the Lenovo IdeaCentre K430. It has a 4TB hard disk, a intel Core i7 processor and 12Gb RAM. So there's lots of space for VM disk images there and a nice amount of RAM to run them. We've created a separate partition just for the VMs to be stored on. All that RAM means you can easily dedicate 4Gb of memory to a VM without any worries.

When I got my hands on the machine, there was loads of rubbish pre-installed by Lenovo, so I erased the entire disk, set up my own set of partitions and reinstalled from scratch. But it was a pretty smooth process. I didn't even need the Lenovo driver disk, everything seems to have been detected by Windows 8 automatically.

I was tempted to suggest she tried Linux as the host Operating System, but in the end I decided she'd be happier with Windows.

Using VirtualBox, when you set your VM to run full screen it seems just as fast as the old PC running natively, you don't really notice. So that's pretty good. But I will upgrade to Windows 8.1 as the host OS when it's released, I've been using the Windows 8.1 preview on my tablet and I like the tweaks that have been made.

... and I've virtualised the old PC so I can keep it as a VM, just in case there's something left on it that we need. Yet again Disk2VHD comes to the rescue.