Ric W

The RRR: Random Ramblings & Rants

Read this first

Django Model Choices using Python Enum

Python 3.4 introduced enums types which seem tailor made for use with django model choices. For some reason there seemed no examples to do this, but it’s relatively simple with some tricks (you may call them warts, django needs to enable this better). These have been back ported to prior python versions via the enum34 package (“pip install enum34”).

In this example, we’ll use an IntEnum to associate a variable with an integer value. For django, this means that the database contains integers, though we have a descriptive text for each choice. This is desirable, as we can abstract the name of the variable from the actual value. If you change / refactor the name, the existing values will simply remain the same.

Here’s the model definition:

from enum import IntEnum, unique

def django_enum(cls):
    # decorator needed to enable enums in django templates
    cls.do_not_call_in_templates =

Continue reading →


Apple removing outdated iPads and iPhones

After Apple’s presentation on March 21st 2016 it seems as if they have listened to my previous post on their line-up, at least with regards to the internals. All iPhones and all apart from one iPad now have the latest or previous generation CPU and camera on board. Only the $279 iPad mini 2 still has a 2013 CPU. Nice! Having said that, their naming is still seemingly getting worse and worse.

iPhone names: 6S, 6S Plus, 6, 6 Plus, SE
iPad names: 12.9 Pro, 9.7 Pro, Air 2, mini 4, mini 2

This is obviously all over the place and still does not seem particularly logical. The iPhones are simple generation numbers or random letters. The iPad is slightly more clear with the Pro range including their respective sizes (as I recommended). Other than that, iPads are named Pro (pencil support?), Air (which it isn’t made of) and mini (it is smaller). This still needs some cleaning up though it’s

Continue reading →


Deploying to heroku using mercurial & bitbucket

Very neat and straightforward guide to use mercurial & bitbucket to deploy to heroku, which only supports git. In short: create another repository on bitbucket that hosts git, and push all the existing code to it. Then maintain the same in parallel, force pushing to the git repository.

http://www.fantomfactory.org/articles/using-mercurial-and-git-in-harmony

View →


Apple Watch’s Digital Crown Mess!

apple-watch-digital-crown-2.jpg

In my short period with the Apple Watch, I noticed how confused people are when clicking on the digital crown, including Apple Store employees. The digital crown is Apple Watch’s primary button, akin to the iPhone’s home button. Being curious as to why people were confused, I started mapping out the principal interface states of the watch (which took ages!).

Clicking the digital crown allows you to inconsistently reach three different screens using two actions (single and double clicks). You can sometimes reach the watch face, the home screen, as well as the last used app, depending on what screen you were previously on. Sometimes and depending are bad attributes for a user interface. Here is the state diagram that maps the interface behaviour when clicking the digital crown button:

apple_watch_buttons.jpg

The problem stems from the app as well as home screen behaving differently depending on what screen

Continue reading →


Initial Apple Watch Experience

Early in the day, I’m mildly giddy with anticipation. I’ve ordered the space grey sports watch. It finally arrives around midday, when I’m in the middle of a call with my bank who have screwed up. This obviously makes the phone conversation even harder, as it’s not at all my point of focus anymore. The shrink wrap on the packaging is so snug that it’s impossible to open by hand. Frustration is taken out on the lovely bank lady on the other end of the line. I barely manage to put the watch onto my wrist, while on the call as it’s not the easiest of tasks. It needs tools and some mental work to open the watch packaging and put it on.

The watch feels good on the wrist and does not itch or annoy me, as other watches have in the past. Setting up the phone is straight forward, but takes far too long for my liking. You’re not allowed to use the watch while it syncs your data for approximately

Continue reading →


Arduino string / password keyboard emulator using reset button

Arduino has a nice Keyboard library that allows it to pretend to be a keyboard to any host it is connected to. This allows you to automatically “type” passwords or strings, eliminating a potential source of error (though this still obviously exists while programming the arduino). Unlike other examples, this does not require you to have an external button or the like. The reset button will simply act as the activator.

To start the “typing” of the string, either plug the arduino into the USB port or if already connected to the USB port, simply press the arduino’s reset button and it will print the programming string. On the Arduino Due, you will have to connect the USB cable to the “native USB” port, rather than the programming port.

Here’s the code arduino code:

void setup() {
  // do not remove this delay or you will brick the arduino
  delay(1000);
  Keyboard.begin();

Continue reading →


How did Apple forget to focus its product line-up?!

When Steve Jobs returned to Apple he famously trimmed the line-up to only a few products, thereby focussing the company and presenting a coherent set of options to consumers. As Apple has grown over the last couple of years, its product line-up has become increasingly confused and bloated. To me this became apparent when Apple continued selling its iPad 2 as well as the iPhone 4S for a staggering 3 years. But it’s not just tablets where this can be seen. The incoherent product offering has slowly crept up throughout the entirety of its line-up to a comedic proportion with regards to the naming schemes. Three aspects are particularly wrong: 1. the age ranges from the cutting edge to embarrassingly outdated products, 2. the screen size and quality is confusing and 3. the naming schemes are meaningless and incoherent.

 Analysing the line-up

A quick look at screenshots from the Apple store

Continue reading →


Ramblings and rants

I finally managed to sign up to a blog that I can dump my random Ramblings and rants that keep me up at night, or rather anytime I find to write something I find sensible enough to out onto the interwibbles. It also has the advantage of keeping me writing, which I don’t do anywhere near enough since leaving academia.

Most topics will be either related to tech, startups and software engineering, or politics and other current affairs I find troubling. Let’s hope I can motivate myself to write more than once a month..

View →