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.

Travelling between fromValue and toValue

April 3rd, 2008

Last night at XCake showed me just how much catching up I have to do if I’m going to be an active (useful) member of the MacHack community here.

So, I started with Bill Dudney’s Core Animation for OS X tonight.

I’ve only got through the first chapter so far, and one very tiny code example, but already I’m looking forward to getting deeper into the book and the subject.

The very first code example shows the way things are going. The author provides a little project that moves a picture from one point in a window to a new point, on a keypress. Then, with one change in the code, the image is animated along the path, rather than simply disappearing from one and appearing in another.

Like most things that Apple dream up, it’s all magic, and yet all perfectly logical. Instead of dealing directly with the thing you want to animate, you request it’s animator proxy. Then, instead of telling the window to move, you tell its proxy, and it’s the proxy’s job to interpolate everything from the start position to the end within the time alloted to the animation. Simple!

Actually, the animator proxy delegates (it’s amazing how often that word crops up in Mac development) the actual interpolation to an implementation of CAAnimation. The animator proxy looks up the implementation for the specific action you’re attempting (setFrame: for instance) and it does the interpolation between the fromValue (usually the current position) and the toValue (the argument passed to setFrame: in this case). Brilliant!

The intriguing part will come later when the book goes on to talk about how you write your own CAAnimation implementations are make them available to the animator proxies.

We’ll see how it goes from here (to there).

Update: Isn’t amazing how boring I can make such an exciting subject sound? Maybe I should’ve followed a career in higher education.

All I know is that I know nothing.

April 2nd, 2008

I’ve just come from the inaugural meet of XCake, here in Belfast. The plan is to get together and discuss Mac and iPhone coding over cake and coffee.

The only problem with getting together with smart people is that you can come away feeling that, no matter how much you think you’ve picked up in the last two weeks, you really know very little. I suppose it’s how you react to the realisation that you know nothing: give up on the idea that you’ll ever learn anything ever, or get the head down and start learning …

I’ve just bought the Core Animation book from Pragmatic Programmers.

So, you’re a Mac fanboy now?

March 26th, 2008

It’s been a little over a week since my MacBook Pro arrived. I knew, more or less, what to expect. It’s not my first Mac, and the week has thrown up no surprises so far. It’s all good. The PC is being reformatted and donated to the Receiver of All Tech Handmedowns, my mum.

This machine is primarily a development machine. That’s the plan anyway. It gives me the chance to finally dive into the iPhone SDK (the other Mac in the house is a G5 iMac, a no-go for the Intel only SDK). I’m also interested in looking at the unofficial toolchain. Hopefully more posts will follow regarding my many coding adventures in both.It was great to see the latest Python installed along with setuptools, which really surprised me. I’ve lost all interest in following Java developments, so, it’s of no real concern to me that the version of the JDK installed is a little behind the times.

I’ve installed Linux in a VM to have a local mirror of my VPS. Other than that, it’s a still a pretty vanilla OSX install. That’s bound to change.

The big question now, of course, is should I buy a Time Capsule? The bug has bitten. 

(BTW - the title comes from the first thing a friend said when he heard I’d bought the notebook. Why do people have reactions like that to Apple hardware? Would he have said “So, you’re a Dell fanboy now?”)

The idiot gene

March 20th, 2008

I know there is one because I have it. Some have diagnosed me as having a particular mutation: A55-H0-L3.

This particular gene mutation manifests itself in an almost Tourette-like inability to stop myself from issuing forth whatever inane utterance hits the frontal lobe, all the while believing myself to be funny, sincere or intelligent. The ease of use, and high availability of outlets like Twitter and blog comments only serve to spread the stupidity further, multiplying its effects.

I suppose I’ll come to terms with it. In the meanwhile, I’ll continue to make enemies of those I admire, annoy those I like, and talk my way out of opportunities to work with clever people.

The parable of the paint roller

March 18th, 2008

As I mentioned, I spent the remainder of last night painting the nursery (or what will become the nursery). I must’ve been getting really tired, or, more likely, it’s the result of a Baptist upbringing, but I started to draw parallels to my day job (writing software). I spent most of my time taping up skirting boards and windows. In fact, the majority of my time was probably spent preparing to paint, rather than actually getting anywhere near the walls with the roller. But, all this preparation meant two things happened: the actual painting went much quicker; and it was a neater job in the end. And that got me to thinking about testing, specifically, test driven development, which, coincidentally, I’ve just given a presentation on at work a couple of weeks ago. Why write your tests before you write any code? The reasons are the same as my painting job: you’ll end up with neater, smaller code written faster with less mess to clean up afterwards. You’d think I’d learn my own lesson, but I’m still in the habit of getting down to coding instead of testing. Maybe I should paint more rooms in the house to drive home the lesson.