Welcome ! This is the personal site / blog of Graham King. Most people come for the credit card generator, but I think the Categories (top right) are more interesting.

May 2, 2013

We are all polyglots

Posted in Software at 17:24 by graham

I used to know two programming languages at any one time; what I called a serious language and a what I called a scripting language. My initial serious language was C, my scripting language was Perl. The serious language was for client work, it paid the bills. The scripting language was for tools and toys (which is why many early web-apps were Perl CGI scripts).

We’ve been replacing C as our serious language since the 70s. C++ mostly succeeded, and became the official language of Microsoft Windows. Objective-C got a solid niche when Apple chose it for OSX, and later iOS. Java, became the serious language of web apps, and is now the language of Android. The two recent exciting developments here are Go and Rust.

In scripting-language world, Perl was largely replaced by Python and Ruby, and for web-app work by PHP.

So by now my serious language was Java, and my scripting language Python. But then three interesting things happened.

Read the rest of this entry »

April 26, 2013

Rust: What I learnt so far

Posted in Software at 22:58 by graham

Rust is an open-source programming language being developed mostly by Mozilla. It’s goal is the type of applications currently written in C++ (such as Firefox). Details at the Rust Wikipedia page.

I’ve been learning bits of it the past few days, and whilst Rust is still rough around the edges there’s a lot to enjoy. Rust is only at v0.7pre and changing daily, so you may have to adjust some of the code here.

Rust is a big language, and unless you come from C++ it will probably make your head hurt. In a good way :-)

The two most helpful introductions I have found so far are:

I’d encourage you to run through both of those, starting with Rust for Rubyists. When you get stuck reading one of them (and you will), switch back here.

Contents:

Install

At time of writing Rust is v0.7pre:

Read the rest of this entry »

March 26, 2013

PyCon 2013: My two favorite talks

Posted in Software at 16:41 by graham

PyCon is an annual gathering of Python programmers. All the talks are recorded and distributed freely on the web. My two favorite talks were:

March 5, 2013

Chapter books for a three / four year old

Posted in Misc at 23:32 by graham

Starting in summer 2012, when my son was 3.5, I started reading chapter books to him, a chapter or two a night. Before we started chapter books, it was always easy to find good books to read to them (from board books upwards). Now though, I struggled finding good chapter books for this age group.

I’ve collected a list of the ones we tried, in order, with notes if appropriate. I’m linking all the books to Amazon to be clear which book it was, but we got most from our local library.

Jason’s Quest – A lovely book to start with. A wonderful adventure, which never gets too frightening, or too hard to follow, and the good folks win in a good way.

Fantastic Mr. Fox – Might have been a little too frightening at the beginning, with the mean farmers trying to kill the fox. In retrospect I would have saved it till he was a few months older.

Mr. Popper’s Penguins

Read the rest of this entry »

February 23, 2013

Google World

Posted in Society at 05:54 by graham

First thing in the morning, I check my gmail on my Google Nexus 7 tablet, or my Nexus 4 phone, whichever is nearest. I have a conference call so I fire up my Chromebook. Google’s browser, Chrome, uses Google’s public DNS servers (8.8.8.8) and Google network’s protocol (SPDY), to connect to gmail.

In the Google Calendar invite, I click the Google Hangouts link and video conference. I’m lucky to live in Kansas City, with it’s super-fast Google Fiber internet connection. We update a Google Doc, stored on Google Drive, with notes during the meeting.

I tell the team that the next version of our web app, written in Go (Google’s server language) was just uploaded onto Google App Engine (their app hosting platform). The client side is in Javascript, but we might update it to use Dart (Google’s client-side language), when that’s ready.

We’ve already got Google Checkout payment integrated, which makes measuring our Google Ads conversions with Google Analytics easy. We’re hoping to rank highly in Google Search, or no-one will find us. We’ve just started promoting it on our G+ page (we migrated from Blogger), and our Youtube demo video seemed popular.

Who knows, if the product goes really well, Google might acquire us.


It’s just a silly story. Move along. :-)

January 15, 2013

Keyword arguments in C

Posted in Software at 06:03 by graham

This is valid C nowadays:

my_func(.username="Bob", .is_admin=true);

I found it in 21st Century C. It requires a macro and a structure, and relies on three features introduced in C99.

#include <stdio.h>      // printf
#include <stdbool.h>    // bool - there's a bool type now

// Macro that turns the kwargs into an struct
#define my_func(...) my_func_base(\
    (struct user){.is_admin=false, __VA_ARGS__});

struct user {
    char *username;
    bool is_admin;
};

// The actual function - and yes there's single line comments too
void my_func_base(struct user u) {
    printf("Hello %s\n", u.username);
}

int main(int argc, char *argv[]) {
    my_func(.username="Bob", .is_admin=true);
}

The three new features introduced in C99 that make this possible are:

  • Compound literals which allow my_user = (user) {"Bob", true}.
  • Designated initializers which give us struct user my_user = {.username="Test", .is_admin=true}
  • Variadic macros which allow #define‘s to take ... as a parameter and have it substituted wherever __VA_ARGS__ appears in that macro.

All the keyword arguments are optional, because compound literal rules state that any unspecified arguments are set to zero / null of the appropriate type.

We even have default arguments, like the .is_admin=false in the macro above, because designated initializer rules state that if the argument is repeated, the last argument wins.

December 31, 2012

How will you measure your life? – book notes

Posted in Society at 19:37 by graham

How Will You Measure Your Life?, by Clayton M. Christensen is life advice for M.B.A. graduates. It dispenses valuable career, relationship, and ethics advice in business-school language.

High-achieving individuals (he’s a Harvard business-school professor) often over-invest themselves in their career and under-invest themselves in their family, and regret this later in life. This book is his attempt to correct that.

Read the rest of this entry »

Why I prefer Android to iOS

Posted in Software at 18:53 by graham

Our house has two iOS devices (an iPad and and iPod Touch), and two Android devices (Nexus 7 tablet, Samsung Galaxy phone). The Androids are newer than the iOS. So far, I prefer the Android devices for these reasons:

  • Android is multi-user. Just swipe down, select a different account. iOS seems designed for individuals living alone.
  • Widgets on the home screen. Just by glancing at my Nexus 7′s screen I can check my email, my calendar, and the weather. iOS’s home screen is just a list of all your apps.
  • AdBlock Plus. Android has an AdBlock app, which tries to block in-app adverts.
  • Internal access – Terminal, Disk usage, RAM usage, etc. I feel more comfortable with a device that gives me that level of knowledge. Android holds it’s users in higher regard than iOS.

October 23, 2012

Tools for Change, Social Change Conference 1995 notes

Posted in Behaviour at 05:31 by graham

In these months of American politicians trying to influence you, I thought it interesting to look at ways of using the same tools for positive change.

In May 1995, Canadian academic, broadcaster and environmental activist David Suzuki invited marketers, scientists, media educators, and activists to Vancouver for a Social Change Conference. The goal was for social change organisations to learn about effective marketing and behaviour change from professionals and each other.

The proceedings were published in Tools for Change, which is available at the Vancouver Pubic Library, and AFAIK basically nowhere else. Here’s what I found interesting:

Read the rest of this entry »

David Suzuki on television

Posted in Behaviour at 02:11 by graham

David Suzuki tells of making television science programs. He thought people would turn on TV to watch his program, then turn it off and discuss.

Of course people don’t watch television that way at all. They come home, they turn it on, and it’s there. And they tune in and out, assaulted by a barrage of images. By the time they go to bed at night, their brains are mush. They retain bits and pieces with no idea where it came from.

(From the highlights of Social Change Conference, 1995).

When confronted with the negative effects of television, people often claim “I only watch the Discovery / History / Nature channel”. Your brain still turns to mush. Put the TV in a cupboard.

« Previous entries Next Page » Next Page »