A common purpose

June 19th, 2008

Ian Robinson posted a callout to any Cocoa developers in Northern Ireland (and wannabees, I presume). He wants to form a group to get together in order to dicuss Mac and iPhone development. Great stuff.

However, there’s another fledgling group of misfits meeting under the banner of Xcake.

Let’s get together, and code ! (You kinda have to sing that so it doesn’t sound *too* silly)

So many books, so little … attention

June 18th, 2008

I’m a geek and a coder. It’s inevitable, then, that I’ll collect a huge number of books about every geeky, coding subject going. I have countless books on Java, Python, C, testing, framework-this, framework-the-other. A new batch is adding another layer of veneer on my desk at home: the Mac development books.

The issue is, though, that I seem incapable of picking up one book and working through it to the end. I’m time-slicing my scant resources over countless books. This leads to an unfortunate outcome: I learn nothing from any of them (another side effect being the sizable amount of money that I’ve basically wasted over the years).

Reading has become a wholly mechanical activity. I open the book, scan it for all the pictures (being turned off immediately if the word/picture ratio is too high … I like to think of myself as a visual learner, rather than shallow), and then follow the steps in all the programming examples. I end up with lots of example applications, but ask me how they work, or ask me to build one of them from scratch without the aid of the book, and I’d probably struggle.

This is not the fault of the books themselves (although, there are some decidedly sub-par tech books on the market, and most of those have red covers), it’s just that I have an awful lack of attention and focus. So, I’ve decided to take the bull by the horns, and force myself to abide by these rules from now:

  1. Only one tech book on the go at once
  2. Start a project in parallel with the examples in the book (the best books, I find, are those that build a single application incrementally as you progress)
  3. Find others reading the same book and discuss it with them

The book at the top of the stack is Aaron Hillegass’ Cocoa Programming for MacOSX, 3rd edition. The author builds a little application throughout the book, and my plan is to write another little application in parallel, only referring to the book as reference where necessary. That’s rules 1 & 2 covered. For rule 3, if anyone is also reading through this book, get in touch.

Cover me, I’m going in

June 11th, 2008

One of the deciding factors on whether I go for the new iPhone 3G (only one of them, mind you) is, of course, what coverage is like where I live. So I followed Matt’s lead and checked the O2 HSDPA coverage maps.

Not good news.

There’s currently no HSDPA coverage in Ballymena.

Of course, I spend 5 days a week in Belfast, and coverage is bound to improve. Isn’t it?

Push it.

June 11th, 2008

So, Monday saw the official announcement of the iPhone 3G. We all knew it was coming, and most of us had started budgeting in anticipation. It turned out that the budgeting may have been unnecessary, as Apple have tried to address the affordability of the device. They also announced MobileMe, the replacement for the aging .Mac service (I say aging when I really mean decrepit). That, again, had been widely predicted.

There was one announcement that was made that I didn’t hear anyone predicting; the push notification service. This is Apple’s proposed fix to the background applications problem (at least, Apple see it as a problem).

As you probably know, appplications written using the official iPhone SDK cannot be run in the background. You cannot write background tasks, servers or daemons that run concurrently on the device. Apple have continually cited battery life and dropped calls as the reasons why they would not support background tasks. That hasn’t stopped developers asking (nay, demanding) it though. So, Apple have listened, thought about it, and come up with a cool (read, over-engineered) approach, that is scalable (read, controllable) and goes most of the way (read, half-way) to meeting the requirements of developers.

The Push Notification Service (or whatever they eventually call it) is, essentially, an proxy service that accepts notifications from developers’ servers that are pushed to iPhones that have installed the developers’ applications. The developer can push badges (those cure little number thingies that tell you how many mails and texts you have waiting), notification sounds and dialogs (I guess that’s actually the ‘description’ of a dialog, along with buttons to be displayed etc.).

A couple of things to note:

  1. The notifications are tied to users.  By necessity, the notifications must be linked to users as they will only be sent if you need to receive them, i.e. you have installed an application from a developer that requires notifications. That’s going to give Apple the opportunity to collect a lot of data about users and the applications they are using. If you trust Apple, that’s not a problem.
  2. The system is only one way. OK, so full details haven’t been released yet, and I may have misunderstood what little is known, but there’s no way for the device to reply to any notifications.

The first one may not be a problem. Apple could use the data collected to simply track the most successful applications and developers. No bad thing. The second point, I see as more of an issue.

I have an idea for an application on the iPhone that requires the device to report it’s location every now and then (”Yea, you and everyone else mate”). Now, I could simply ask the user to click a button on a dialog pushed from a notification, which, at least, gives the user the option *not* to update their location if they choose. But, from a usability point of view, it blows. I’d much rather give the user a preference to turn off automatic location updates when they want some privacy, rather than bother them with periodic notifications flashing up every now and again. And I can’t have anything running to respond to notifications that come from the server, because that’s just a background task, and I’m not allowed those.

(I could, of course, just develop my app with the unoffical toolchain.)

What about a small service, running on the iPhone as a client side addition to the push notification system,  with which developers could register bundles to respond to notifications from their servers? That way, developers would effectively delegate the handling of notifications on the client side to an Apple process, keeping Apple in control, yet giving developers some of the flexibility of developing their own background services.

The full details of the service have not been disclosed, and I’m not at WWDC to hear if any further details are given. I’ll be interested to see how they deliver this one.

It’s count(), you idiot.

May 22nd, 2008

I had an interview the other day. You know the kind of thing, sitting at one side of a boardroom table with a firing squad on the other, ready-aim-firing technical questions for an hour. Like most, sane, interviewess, I prepare for these. I read. I code. “What questions would ‘I’ ask?” This time was no different. Sort of.

The job in question required knowledge of PHP. Now, it feels like half a lifetime since I’ve used in PHP in anger (that’s how I remember coding in PHP, at least), so I thought I had a little more preparing to do than usual. I spent a couple of evenings reading, coding, “What questions would ‘I’ ask?”-ing and felt I’d more or less covered everything I’d need. Security, database access, objects in PHP etc.

I was ready. Confident. Wrong.

First question was about the difference between GET and POST. Ok. Next, retrieving values that have been GETted or POSTed to your application. Fine. How to you find the size of an array in PHP? The exchange went something like this:

“Mmmm … in Python that would be the len function … mmmm” (Inner voice - Good start cretan.)

“Erm, there’s a method on an array ….” (Inner voice - They’re laughing at you now)

“length?” “No” “len?” “No” “size?” “No, it’s count” (Inner voice - It’s count, you idiot)

This was the prelude to a series of basic PHP questions upon which I poured huge buckets of FAIL. You see, I’d forgot to go over the basics. In all my preparation, I had neglected to take even a cursory glance over the fundamentals of the language. The very things that will leave you if you don’t code in a language for a while. I spent that part of the interview being able to answer all those questions in Python and Java. Big help.

Lesson learned? Keep a hand in everything that’s on my CV as much as possible. That’s scary, because over the past 11 years, I’ve been in contact with a *lot* of technologies. I know that I’ll never remember everything I’ve ever done, but surely I should be able to remember the basics. Some of them.

BTW, I got the job.

VirtualHost at Localhost

April 23rd, 2008

So, once I got mod_python running, the next task was to get a Django app up and running on the machine. Which led to my next question, how to I set up an Apache VirtualHost on my local machine. Up to this point, I had deployed all my mod_python apps to the Linux VM running, making it trivial to set up VirtualHosts for all my projects. The answer, as always, was simple.

Simply add your VirtualHost as always, then add it’s name to your hosts file. Talk about a Duh moment.

So I set up a name-based VirtualHost in apache called, for instance, ‘project.local’ (ServerName project.local), then I add a line to my hosts file

127.0.0.1   project.local

Now, I can browse to project.local on my local machine, and everything works.

I don’t think I’ll be looking for any sysadmin jobs in the short term.

Snakes and cats

April 22nd, 2008

I have a VM running Linux on my MacBook. The main reason being that I could never get mod_python to install into Apache on Leopard. I followed all the instructions I could online. I could always get it compiled, but Apache would always puke when I tried to restart it with the module loaded.

Tonight, the breakthrough.

There are countless blog entries on building mod_python on Leopard, but why not add another one?

  • Get the source (3.3.1 is the newest at the time of writing)
  • When uncompressed, run
    ./configure --with-apxs=/usr/sbin/apxs
  • Open src/Makefile in your favourite text editor
  • Add “-arch x86_64″ to the end of line 27
  • Change line 49 to read “(APXS) $(INCLUDES) -c -Wc,”-arch x86_64″ $(SRCS) $(LDFLAGS) $(LIBS)”
  • Do the make/sudo make install dance
  • Root edit the file /usr/apache2/httpd.conf
  • Uncomment line 116 which should load mod_python.so, however, check that the module is loaded as ‘python_module’

(Update: I think line 116 was there from my last failed attempt at installing mod_python on this machine.)

The last point was the important one for me. There was a default of ‘mod_python_module’ there. Once I changed that, it all worked. I may be talking from my proverbial, but give it a go and tell me how it goes.

That way madness lies

April 15th, 2008

My copy of iPhone Open Application Development arrived the other day, and I was very excited by the possibility of actually seeing my code run on actual hardware, like an actual programmer.

I can’t get the flipping toolchain to build anything. The linker *will not* see anything in $HEAVENLY, the home from home for my iPod Touch (yes, that one) filesystem. I’ve installed the toolchain as per instruction, several times.

I know I’ve done something wrong. You now those moments of intelligence blindness you get, where you simply can’t see how you’ve done something wrong, but you’re absolutely convinced that you must have, because you’re the only one in the entire world seemingly having problems (that isn’t quite true).

Those pesky kids with their SDKs and Apple certificates may still be one step ahead … for now.

Update: I can get applications to build if I compile and link separately. I’m afraid I’m just a poor Python coder. Can anyone tell me why this would make a difference?

Why I hate my job

April 9th, 2008

Because something that’s 2% of my life takes up 80% of my time, and makes me forget that 98% of my life is fantastic.

Back from the brink

April 4th, 2008

I don’t know what it is, but I can never be satisfied with just having something, and using it, and leaving it alone, and being content. No, I have to mess.

My iPod touch has been jail broken several times. Every time it worked, eventually. Then came pwnage.

I can’t blame the tool for what happened next of course. It was my own fault. I didn’t pay attention to the firmware I had downloaded to use. It turns out your iPod touch can’t pretend it’s an iPhone, no matter what firmware you (try) to throw at it.

Anyway, I ran the tool and everything was going swimmingly. I knew as soon as it didn’t turn back on immediately that something had gone slightly awry. So, as the first wave of panic and nausea passed, I tried what I’ve always tried in situations like this, I tried the old two finger salute, hold own the home and power buttons for ten seconds and you’ll drop into DFU. iTunes will then tell you that you need to restore your iPod, and you go to bed saying a little prayer to his Jobness, repenting from your sins and promising you’ll never try anything like that again.

Not this time.

Nothing worked. The iPod showed no sign of life. No Apple. No reassuring ping. I’d have chewed an arm off just for a beachball. By this stage, I was trying to get my story straight for Apple. Would they believe that the iPod had played the Last Stand and simply keeled of its own volition?

All the forums were ablaze with people weeping and gnashing their teeth about how they had bricked themselves (some of them really had by the sound of it), and lots of other people telling the first crowd that they were idiots and should never breed.

The general consensus is that you cannot brick an iPod touch. But here I was with one that would not boot, which the computer could not see, and which consistently refused to acknowledge the two finger salute. Then, lo and behold, as I was now trying to get my story straight for Apple and the missus, a final stab at the TFS saw iTunes burst into life.

Now I know for sure that the iPod firmware has a built in idiot-cac-himself feature designed to stop the less gifted from messing and simply being happy with having a fully working iPod:

Get RANDOM_NUMBER
If how_many_tfs != RANDOM_NUMBER then ignore_tfs
Else oh_alright_then_but_dont_do_it_again_you_little_rascal

Dear Jobiness, forgive me, for I have sinned. No, I will never try it again.