All posts now have Send To Kindle functionality

Amazon recently released their “Send to Kindle” plugin, allowing users of Kindles (whether on iOS/Android or owning a physical Amazon Kindle device) can now send any post on this blog directly to their device over the air or whispernet (depending on device) without having to manually copy and paste content. A little convenience method for those who wish to read offline / on the go. For those who don’t… simply ignore it 🙂

Enjoy offline reading! (go into the posts to see “Send to Kindle” buttons

 

The __block specifier in Objective-C and Why its so mis-understood

I’ve seen a lot of source code recently where people are mis-using the __block “specifier” that ships with modern Objective-C runtimes. I’ve always had the opinion that if you are to use __block for an Object then you should design around it and avoid, reserving its use for primitives. Regardless of that, here is a summary of my understanding of __block to share with any other keen readers who may be interested.

__block is used as variables outside the scope of a block become readonly once inside a block. For example

 int num=1;
void (^someBlock)(void) = ^{
num = 2;
};
someBlock();

Would cause a compiler error asking for the __block specifier to be used. so in this case you can try:

 __block int num=1;
void (^someBlock)(void) = ^{
num = 2;
};
someBlock();

and num will contain the correct value after block execution.

Straight forward right? So what about the following example:

 __block NSMutableArray *someArray = @[@"Hello",@"World"];
void (^someBlock)(void) = ^{
[someArray addObject:@"Goodbye"];
};
someBlock();

It’s wrong… you don’t need __block in this case… why? because you’re not assigning a value to the captured “variable” someArray, rather you’re just sending a message. I often see this and wonder why.

The __block specifier is actually a storage-class specifier, to give you an idea of what this means, the following are also storage-class specifiers in C. extern, typedef, static and so on.

Why don’t I like __block a great deal then? Read on for more…

… 

 

Manage your KVM Hypervisor Remotely on your iPhone / iPad

Recently I began experimenting with KVM virtualisation in the Linux Kernel. Its a great technology that if your CPU supports VT-x / AMDV offers almost (really, almost) bare metal level performance inside Virtual Machines. It works on most Linux flavours and has a couple of handy management tools such as virsh and virt-manager. However, one thing I thought was always lacking and annoying me was of course, the ability to manage my Hypervisor from my iPhone / iPad when on the move! Time for an experiment I thought; then out came “KVM Remote”

KVM Remote on the iPad and 3 Different Remote Hypervisors

Its universal so works on both the iPhone and iPad and is extremely bleeding edge right now, but works! and is incidentally the first App i’ve made that doesn’t have selfish fiscal intentions, so theres another great reason to download it from the AppStore now!

P.S. i’ll be updating it regularly adding more features as requests come in.

 

Overclocking & Optimising the Raspberry PI

My Raspberry PI

Out the box the Raspberry PI comes with a ARM1176JZFS Core (armv6 with hard float aka armhf arch) running at 700 Mhz as part of the Broadcom SoC. Additionally the memory frequency is also limited. In recent firmwares however… tinkerers have had the ability to “overclock” the Raspberry PI to squeeze some extra juice out of it. Mine’s currently running at 1Ghz at a solid 48C temperature when under load. So the first question that springs to mind is… why doesn’t everyone overclock their Raspberry PI? Well… there have been (well founded) reports of SD card corruption, heat/power issues and instability. The idea of this post is to show the user how to safety squeeze every last bit, cycle and IOP out of their PI safely’ish and without being an astrophysicist. Read on for the know-how. … 

 

Installing Linux on a Late 2012 Mac Mini

So in the last post I discussed why the Mac Mini is the perfect machine for Linux and for Datacenters in general! One frustration some readers may be finding is that the networking chipset used by Ivy Bridge platform in Late 2012 Mac Mini’s doesn’t have native support in the Linux Kernel (as of now anyway). So its required to install a kernel module from the manufacturer/vendor (broadcom).

On their website they provide the “tg3” drivers for Linux kernels, however these are only good if you are running a Linux kernel < 3.5.x. If you take Ubuntu for example, 12.04 uses the 3.2.x stream, whereas 12.10 uses the 3.5.x stream and isn’t immediately compatible with the drivers on the broadcom page. This is due to the deprecation in 3.x and removal in 3.5.x of the asm/system.h header.

Read on for the fix, more and downloads. … 

 

Why use a Mac Mini in a Datacenter environment, even without Mac OS X?

I recently changed from having Dedicated Servers to renting co-location rackspace directly in a datacenter. What this meant was that the “density” of CPU:Power ratio was important. Say for example you rent 1U of rackspace, that will come with some amount of power, measured in FLOOR(0.9*(AMPS=(WATTS / VOLTS)) during “peak” or “boot” power usage… with a total allocation of say 0.4 amps, along with bandwidth etc.

So why a Mac Mini for this purpose? Take for example a Dell Poweredge 1U Server… fits perfectly in the 1U of space provided and can consume a lot of power, 0.5+ so really, you can only squeeze 1 of these in without paying over-ages… at a push. What it does give you over a Mac Mini though, is the possibility to have 128GB RAM and 4 HDD bays in a single chassis, but at a much higher power cost. Lets take for example the Mac Mini… I’m colocating 4 Late 2012, Core i7 Mac Mini’s with 16GB RAM and 2TB hard drive space in EACH. Due to the way in which the Mac Mini was engineered, these consume around 0.19 AMPS each. Making the “density” increase, so in my 0.4 allocation, I can place 2 Mac Mini’s without incurring additional charges… thats 8 Physical Core i7 Cores… 32GB RAM and 4TB Hard drive space… in a piece of metal that is easily and readily available/replaceable and modular…

Those datacenter savvy people amoung you will now be thinking… ah, what about cooling, what about remote reboots etc… well there are solutions to all of that also, see my guide on Ubuntu 12.04 and 12.10 on a Late 2012 Mac Mini for a detailed howto.

The end result, you’re reading this blog post on a Centos VM hosted on a Debian KVM Based Hypervisor running on a Late 2012 Mac Mini! all setup and configured to be at a lower cost than any competitor and offering a really high density in a datacenter environment.

Wanna discuss, tweet me @italoarmstrong

 

How to turn off Auto Layout Automagically on Xcode 4 post iOS 6

I’m sure i’m not the only one who is annoyed at the fact that, even though my project Deployment Target is set as iOS 5.0… Xcode finds it neccesary to enable Auto Layout on all newly created XIB’s regardless… causing Runtime exceptions that can be pesky and hard to find if not testing looking. So I started thinking how to disable this once and for all…

After monitoring the state of my disk, before and after ticking the infallable box in IB, I realised that Xcode is actually using some xml files to enable/disable this feature, however, there are a few locations and its a little pesky… i’d document it all here, but I don’t have it to hand and can’t remember… so maybe later… but until then, here is a little tool I made that performs a simple regexp on some of your Xcode installation files to make sure Auto Layout is disabled 🙂 NOTE: You’ll have to re-run this tool if you update/re-install Xcode.

Download: AutoLayoutAnnoysMe.zip

 

 

New Job New Posts New Fangled Things

Well… I’ve recently resigned from a nice role I had as a Mobile Architect at a large well known online company. Moving on to being an Independent Contractor working on different kinds of Mobile Projects. What this means is I’ll have a little more freedom to write about… whatever I want! So expect some more of the usual + some interesting and intricate iOS and Android posts. Of course as always, don’t judge me too badly 😉 feel free to tweet me @italoarmstrong with any comments.

P.S. if you read a post over 1 month old… I can’t guarantee the quality of it 😉