Tuesday, October 11, 2011

He who learns but does not think is lost; he who thinks but does not learn is in danger.

I've been in Australia for a 6 weeks now. The majority of that time has been spent bitching about how cold it was, and coding like beast to help get mChat ready for its next big release.

As a result I haven't really done any sightseeing, or at least I hadn't.

As a preparation exercise for when I go to South America I decided to take a bus from Sydney to Melbourne via Canberra. Total journey time came in at seat warming 15 hours.

I love having time to think, and I love to learn so the Confucius quote I used for the title of this post seemed perfect.

So what have I learnt?
Australia is huge and almost infinitely vast. At the moment I'm a hour and half into the Canberra, Melbourne leg. And all I've seen is grasslands. They extend for as far as the eye can see.

Having spent so much time in relatively small countries, buried in a mountain of technology you begin to think that the world is a small place. But in fact the "small" part is the series of interconnected hubs that form the major population centres. Outside of these you can find the "real world". One devoid of fibre, hi-speed rail, politics, and all the other assorted junk that we consider "modern civilisation".

So what do I think?
A good friend of mine what's to change the planet. Not in a "when I grow up" kind of way either. We often discuss how one would go about such a task. Perhaps to change the world what we need to happen is the reversal of the migration of people across the world to urban centres, in such of relatively low paid jobs.

Perhaps we need to allow people to return to the ways of the past, to build a better future.

In recent years anyone reading this would have seen slow destruction of society. As we have moved into the future we are slowly abandoning parts of our past that actually worked.

That's really insightful, so what can I do?
I haven't got a clue. If you'll excuse me I have another 8 hours on this bus. You never know, as I bridge the gap between these two centres of commerce and industry I might just discover the answer ...

Sunday, September 18, 2011

Brute forcing Router passwords

Someone in my house decided to change the password of the router. We share the access with about 10+ people, not all of whom i know so simply asking wasn't really an option. So like any normal person, i searched the internet and found a python script that does HTTP Auth brute forcing. The Indentation was out of whack, so once i fixed it, i thought i ought to share it with everyone.


If you do want to use it yourselves, you'll need a wordlist, which you can find with google's help.

Wednesday, September 07, 2011

Making UIImages with blocks

So i was going to post about something completely different today, but as i was typing i looked at my code, and thought it was verbose and a little bit ugly.

So i made it awesome, and as everyone knows to make your code awesome you add some blocks to it.

My problem was simple, i was faced with the need to create two CGBitmapContext, for the uniformed the following code is required to prepare a bitmap context for drawing.


So after a bit of thought, i decided what i really wanted was a method that did all of this for me, and meant that i didn't have to worry about constantly checking the code for leaks (DRY), and that was pleasant to look at and i came up with the above. The block that you pass in is given a fully formed CGBitmapContext, and the method returns a UIImage generated from that context. Almost like a UIView/CALayer.



So now your thinking, "Yeah, thats cool, but why the [INSERT FOUR LETTER WORD] would i want to use it ?" Well young grasshopper, have you ever wanted to mask a image in code? You know to do those trendy rounded corners ... well yes you can use CALayer's however the idea of using those off the main thread makes me uneasy, and we all know the cool kids do things in the background.


The above actually creates a rounded rect on the fly, and masks the image with it. It's made to be used in a category on UIImage. But look closer, yep thats right kids, no boiler plate, ZERO, NADA, 另, SQUAT (i think you get the point)!

I should take a moment to mention that the awesome code for the rounded rect comes from the awesome Oliver Drobnik, i have the utmost respect for this guy, not just for this snippet, but if you've ever seen his Rich text label and it's associated projects, you'll understand why real soon.

Friday, August 05, 2011

Tuesday, August 02, 2011

Waipo Valley Hike

While some people think i spend all my time on a perpetual vacation, it is sadly not the case. Everyday there is a little bit of something or another to be done.

However since i've been on the Big Island i've made an effort to try and relax, and actually have a vacation. Its not like i'll be having another one anytime soon. Being an iPhone developer and having loads of time off aren't compatible ideals.

So yesterday i started creaming myself on the prospect of visiting Waipo Valley, however it seemed so distance, and far from anywhere that it may as well have been on another planet. Initially i dismissed it, and decided instead to head for Akaka falls, a lovely 400ft waterfall only 20 minutes bus ride away.

However when my bus got to Akaka falls i didn't get off. It was a beautiful day, my camera was charged and my memory card was empty. I rode all the way to Waimea, in the north of the island, glimpsing the Towering Mount Kea, on the left and the steep coast to my right.



Though my consumption and research using the fantastic Offmaps i had learnt about a trail, just to the north of Waimea, that appeared to reach the valley. There is a more direct trek, that takes you to the head of the valley, however this is several Kilometers outside of town (READ not near the bus stop). So i decided to go a slightly different way, that allowed to me to go through town.


After walking though a residential neighbourhood to the north of the town. I found the entrance to the trail (above). Like all good hikers, i just ignored it and marched on.


After climbing the first hill, i got to what looked like a water treatment plant. Despite the signs at the gate, i vehicle from the Hawaii water department drove past me, but said or did nothing.


After the passing the water treatment facility i got to yet another gate, informing me that i was doing something or another wrong ... i ignored it and continued the march. With this particular gate i had to choices, jump it, or use the huge hole in the fence. It's always great to have options.


I was greeted by field full of cattle. I have to say that walking though a field of cattle by yourself is one of the strangest experiences i've ever had. They all just stare at you, and track your every movement silently. It reminded me a lot of when i was in China.


Climbing the hill further revealed a 50 million gallon reservoir, that was bone dry. I assume it fills up with rainwater run off over the winter, and then drains in the summer. This was one of three big reservoirs buried in the hills.


After another 5-10 minutes of walking a finally reached the Kohala Forest Reserve, at this point i knew it was on. I opened that gate and marched onward.


It went from grassy cattle pasture, to rainforest in the blink of an eye. The trail was easy to follow, but due to my naivety i was wearing trainers...


Trainers that got completely murked. There is a water pipe that runs along the trail, in several places it is leaking, which caused the mud trail to flood. Initially just walking on the grass was enough, but there were several places where this simply wasn't enough.

The landscape changed quite rapidly, going from rainforest to hilly plateau in a matter of minutes. While your at least 3 miles away from the nearest human being, you amazingly have 3 bars of AT & T service. I had turned data off to save battery. I'm not the worlds most amazing hiker so i didn't really want to be stranded in the middle of nowhere with half a sandwich, and Nutri-grain bar.
By this time i was almost 2 hours into the hike, I wasn't physically tired but the trail isn't scenic. There isn't much to see, and certainly no one to talk to. While i knew roughly how much further i had to go, the fact that i knew i had to retrace all my steps was beginning to depress the hell out of me. Especially as i was starting to consider if this dotted line that i had sacrificed my time to was actually a route to nowhere. I spotted a small hill up ahead, and made a deal with myself. If the canyon wasn't over the hill, then it was time to call it a day.


And there it was, 2000ft straight down, almost 4 miles in the middle of nowhere. I was at photographic "pay dirt". After about 10 minutes of this beautiful vista, i high tailed it out of there, rain clouds where all around, and this is the last place you want to be when it rains, especially considering that i wanted to salvage what was left of my trainers.

Overall i learnt a couple of things about my hike.

  • Never give up
  • Carry more food & water
  • Get hiking boots
  • Hawaii (Especially the Big Island) is beautiful.

Monday, August 01, 2011

Hawaii: Oahu & Hawai'i (aka The Big Island)

To be completely honest i knew very little about Hawaii as whole before i came here. But i've learnt a lot in the last 5 days. Mainly that i need to learn to drive. So thats definitely on the list for when i get home (finally).


Having flown into Oahu, i spent most of my time in Waikiki, Honolulu. As i was warned it was chock full of Japanese tourists showing off their Canon's and Nikons. I have nothing against my friends from the land of the Rising Sun, however i do suffer from a serious case of Lens envy.

After 6 days in the Japanese version of the Costa Del Sol, i've  flown to Hilo, on the big island, aka Hawai'i. Today, i felt like an idiot for even spending more than two days in Oahu.

Firstly the big island, is well, BIG. The road that runs around the entire coast is almost 300 miles long. I spent today in the car with some good people from Holland, we barely explored a quarter of the island. This place is huge.


What really stuck me is the differences in the flora in various parts of the island. In some places it looks like a Rain forrest, while in others it looks like the surface of Mars. The above is the beautiful rainbow falls.


This is an example of the rainforest like terrain. It even has a canopy that the Brazil Rainforest would be jealous of. Really makes me look forward to the day i finally set foot on the continent of South America, Un dia, un dia.


Then there is the black volcanic rocks. While i know the landscape was formed by magma, it almost seems as if it's been scared by it. I've been fortunate enough to see some amazing things. But this is truly fascinating.

Saturday, July 30, 2011

Auto incrementing version numbers in Xcode

Over the last month or so i've had to kick out a lot of betas for a project. Seeing as i use the fantastic Test Flight. I have to change the version number before i upload each build otherwise Test Flight will overwrite an existing build which is the last thing that we want.

I don't think anyone actually enjoys editing a plists, whether its in Xcode plist editor or the down and dirty XML. So has a result it was the perfect opportunity to get familiar with xcode's build process, and how to tie external scripts into it.

I use 3 segment version numbers (1.1.1), where the first digit is the major version, second digit is the minor version, and the 3rd digit is the build. For the benefit of the team, i wanted to have the latest commit hash in the build number so that people could quickly reference it and know whats going on.

With some direction from this post by Duane Sibilly i was able to hack together the below.

Friday, July 29, 2011

Wednesday, July 20, 2011

Goodnight San Francisco


The Mighty Pacific

When i'm not winning iOS Dev Camp, answering emails or writing code i like to take photos. Lots and lots of photos. As my time in the Bay Area comes to an end, i thought that it might be nice if i actually took the time to visit the Pacific Ocean.

Initially it was foggy (like it usually is) however it soon cleared up.


The birds came out...


As did the people ...


The sun shone ...


And everything was well with the universe (if only for today)