Archive for development

Optus iPhone Tethering – For FREE!

// June 18th, 2009 // 15 Comments » // General ramblings, Hacks, iPhone

Please note: This hack was patched by Apple in Firmware 3.1.1 and no longer works.

With the official release of the iPhone 3.0 firmware today there has been much talk about the leaked Optus pricing which indicates Tethering will be an account add-on which will cost $9.99 to enable and will require the additional purchase of a data pack ranging from $25 – $45/month. I decided this probably doesn’t need to be so, I mean its not the case in all countries, and most likely not going to be the case with all carriers in Australia either, and why would I pay to use Optus wireless internet when my previous experience has been a total fail.

So here’s the thinking behind this hack, Apple ships the same iPhone to all carriers around the world, when the end user syncs with iTunes their sim code tells iTunes which carrier to load onto the phone, so iTunes contacts Apple’s secret download server (http://phobos.apple.com/version) requesting in this case the Optus carrier profile which contains everything from the Voicemail number, email settings, Optus Zoo URL and internet access point names and passwords.

None of these details are really worth changing, unless you don’t want the Optus Zoo mess on your phone, except the access points (apns), there’s one of these for Internet, MMS, and Visual Voicemail, we need to add one for Tethering or you’ll see this message
img_0441

The Hack

Prerequisites:

  • An iPhone 3G.
  • Firmware 3.0 loaded onto said iPhone.
  • iTunes 8.2 +
  • xCode/iPhone SDK (Optional, but preferred)
  • Ability to follow instructions (Optional, but preferred)

This hack is somewhat technical, and you will need to have the xCode developer tools installed on your Mac, or a good XML editor if your on Windows.

You should be able to pull this off in less than 10 mins, just follow these simple instructions.

Step 1

Download the latest Optus carrier profile from Apple, here’s a link

Decompress it and you should end up with a folder called Payload, if your browser didn’t decompress it and your left with Optus_au.ipcc, change the extension to .zip and then decompress.

Inside Payload you’ll find Optus_au.bundle, this is just another folder, if you right click and select ‘Show Package Contents’ we’ll be in business.

Step 2

Inside Optus_au.bundle there is 5 files, the only one we care about is carrier.plist, open this with Property List Editor on OS X or your favourite text editor.

Step 3

Locate the ‘apns’ Array and open it by clicking the disclosure triangle next to the name. Now there should be 4 items inside, the first item is the phones internet settings, we want to duplicate this so that the iPhone thinks we have another profile for Tethering. So copy and paste it into ‘apns’

picture-5

Now this part is crucial, to force your phone to use this profile over all others, change the ‘type-mask’ attribute on Item 2 from 17 to -2

I’m not sure who came up with the -2 but I found it in an ATT profile and it seems to do the job just fine.

Save this file

Step 4

Close ‘Optus_au.bundle’ and re-compress ‘Payload’ folder

picture-6

Now rename the output zip file to ‘OptusHacked.ipcc’ make sure you have no trace of the .zip extension or this won’t work.

Step 5 – Load it into iTunes

Open Terminal (Located in Applications/Utilities) and run this command (Copy + Paste it then press enter)

defaults write com.apple.iTunes carrier-testing -bool TRUE

This will tell iTunes to allow custom carrier profiles to be loaded from your hard drive.

Connect your iPhone to iTunes and alt-click (Option + Click) on ‘Check for Update’, this will open a file selection window, locate the OptusHacked.ipcc file we created and open it.

picture-8

picture-9

And your done. Restart your iPhone and your in business, you should now see this option when you go into Settings/General/Network on your iPhone if you did it right.

img_0442

If it still says ‘Setup Internet Tethering’, I’d say you stuffed up on step 3.

I should take this time to point out that this will greatly reduce your battery life, as well as use a lot of data from your plan, if you don’t have much of this data stuff then you could get hit with a pretty big bill from Optus, and unless you live for really big bills, that’s something to worry about.

Ivan Vanderbyl on Rails – Interview

// May 28th, 2009 // Comments Off // General ramblings, Ruby on Rails, Site launches

I was recently interviewed by EngineActive’s Michael Troy for their new blog about everything, including the web development scene in Newcastle. So if you would like to learn a bit more about me, have a read.

How to unbrick iPhone 3.0 beta

// April 4th, 2009 // 26 Comments » // General ramblings, development

I was recently faced with a bit of a problem, I had upgraded my iPhone to the new 3.0 beta, but I forgot to create a provisioning profile for the device from within my newly activated Developer Portal before the upgrade, this resulted in what pretty much resembled a brick.

The iPhone 3.0 upgrade also includes a baseband update which is not compatible with previous versions of the iPhone firmware, and as the download site warns, there is no turning back.

Apple pre-install advisery

Apple pre-install advisery

So back to the brick, if I connected my now bricked iPhone to iTunes it displayed a message saying I needed to be a developer and add my device to my development device list. This however was not as straight forward as they said, because Xcode didn’t recognise the phone so there was no way to get the phones UDID which is required to add the phone to my developer portal. After digging around the file system for a while I stumbled upon a file in ~/Library/Lockdown which had a 40 character file name followed by .plist (Property List File), the filename looked like a SHA1 hash, and knowing the device UDID was 40 characters decided to type that into the developer portal and kick it in the guts, sure enough it worked.

Developer provisioning assistant

Developer provisioning assistant

I downloaded the provisioning profile and dragged it onto the iTunes icon in my dock, reconnected my phone and it activated without a problem.

Update:
As Marc mentioned in the comments, you can also get the UDID from the USBProber that comes with the Apple dev tools.
USB Prober

How to programmatically keep your job, the Rails way

// January 27th, 2009 // 1 Comment » // General ramblings, Ruby on Rails

Read the following code carefully, I found it in the Rails API docs for ActiveRecord transactions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class BooksController < ActionController::Base
    def create
      Book.transaction do
        book = Book.new(params[:book])
        book.save!
        if today_is_friday?
          # The system must fail on Friday so that our support department
          # won't be out of job. We silently rollback this transaction
          # without telling the user.
          raise ActiveRecord::Rollback, "Call tech support!"
        end
      end
      # ActiveRecord::Rollback is the only exception that won't be passed on
      # by ActiveRecord::Base.transaction, so this line will still be reached
      # even on Friday.
      redirect_to root_url
    end
  end

Exceptional exception handling

// November 25th, 2008 // 3 Comments » // Ruby on Rails, development

For the best part of the last 2 years I had been using the Exception Notification plugin for Rails, however recently I found that it was actually causing some of the errors in the application and not reporting them, so I went in search of an alternative, and to my luck found Exceptional, the exception tracking and managing utility for Rails, which was in BETA release, I have now been using it with all my production applications for nearly 2 months and its doing great.

Exceptional has great integration with Twitter, Lighthouse and Campfire, I would like Unfuddle integration but you can’t have everything can you.

Exceptional also groups exceptions which occur more than once so you don’t get bombarded every 10 seconds when something does go wrong.

Give it a try for free

Displaying Flash’s in Rails easily

// October 31st, 2008 // 2 Comments » // CSS, Design, Ruby on Rails, development

In all my Rails applications I make use of the Flash method for displaying simple messages about system changes to the user, such as “Welcome back Ivan” when they login, or “Your details have been saved successfully” when the user saves their profile.

Rails can handle multiple Flash states in the flash hash, e.g. :notice, :error, :success. But how do you display these messages in a no nonsense fashion? with this simple display_flashes helper method I’ve written.

1
2
3
4
5
6
7
8
9
10
11
12
module ApplicationHelper
 
  def display_flashes
    return if flash.blank?
    flash_type = flash.keys.first.to_sym
 
    return content_tag(:div, :id => "flash_box", :class => "flash-wrapper") do
      content_tag(:div, flash[flash_type], :class => "flash #{flash_type}")
    end
  end
 
end

(more…)

Return of the Beer.new

// July 6th, 2008 // 3 Comments » // General ramblings, Ruby on Rails, Uncategorized

Yes that’s right, last month when I was visiting the Sydney Ruby on Rails monthly meetup I was introduced to the Beer model, not the type of model your thinking about, something more along the lines of:

class Beer < ActiveRecord::Base
  CAT_PISS = 2
  named_scope :drinkable, :conditions => ['quality > ?', CAT_PISS]
  # ...
end
 
Beer.drinkable
 
#=> [#<Beer id: 25, name: "Tooheys New", quality: 4, rating: 7.1, best_served: "cold">, 
#<Beer id: 17, name: "Corona", quality: 7, rating: 9.0, best_served: "cold with lime" >]

(Its a Rails thing)