iPhone 3.0 OS helps you login to hotspots!

I had my iPod touch that has the 3.0 OS loaded with me yesterday. I thought I’d try it on the Panera WiFi. I often go there to work with my laptop and get something to eat. Often, I meet someone there and we socialize and work and eat.. it’s all good.
Back to the 3.0 OS thing. The neat thing I discovered was that when I selected the “Panera” hotspot, I was presented with a browser window so that I could authenticate right away! That was pretty cool! It saves me from having to go into Safari, just for the purposes of clicking the “login” button.

Alert showing available hotspots

Alert showing available hotspots

Login helper window

Login helper window

(It was hard to get a shot of the browser window… this is the best I could do)
So, I login via that browser window, click “done” and I’m able to go into what ever app I wanted to run in the first place. I’m impressed because I always felt that was a nuisance and this new way is much more streamlined. Thanks, Apple!!

Amazon announces Elastic MapReduce

I think this slipped out a day early, but here is what came across in the DevPay documentation;

On April 2, 2009, AWS announced the release of Amazon Elastic MapReduce, a web service that enables businesses, researchers, data analysts, and developers to easily and cost-effectively process vast amounts of data. It utilizes a hosted Hadoop framework running on the web-scale infrastructure of Amazon EC2 and Amazon S3. For more information, go to http://aws.amazon.com/elasticmapreduce.

Here is the link to the official docs: http://aws.amazon.com/elasticmapreduce

Amazon Elastic MapReduce is a web service that enables businesses, researchers, data analysts, and developers to easily and cost-effectively process vast amounts of data. It utilizes a hosted Hadoop framework running on the web-scale infrastructure of Amazon Elastic Compute Cloud (Amazon EC2) and Amazon Simple Storage Service (Amazon S3).

Using Amazon Elastic MapReduce, you can instantly provision as much or as little capacity as you like to perform data-intensive tasks for applications such as web indexing, data mining, log file analysis, machine learning, financial analysis, scientific simulation, and bioinformatics research. Amazon Elastic MapReduce lets you focus on crunching or analyzing your data without having to worry about time-consuming set-up, management or tuning of Hadoop clusters or the compute capacity upon which they sit.

I do wonder if they’re trying to move up the food chain a bit much. With this service, it is clear that they are walking over some people who have set up a business doing this for customers already. It feels l bit like what Microsoft used to do. They had special knowledge and APIs into the guts of the OS and could so things better than the competition once they decided to go there. Similar things could happen here. I feel better about Amazon in general, but it is a slippery slope!

Using UITextField on the iPhone

Coding on the iPhone is mostly a pleasant experience. XCode is a really nice IDE and I’ve come to like it (though I do fall back to Vim on occasion, see previous post about that). It’s the little things that really get you though! For instance, having the keyboard go away when it should. Another thing is when the text field is covered by the keyboard. Both are irritating and can be solved using the UITextFieldDelegate. Below is some code I’ve pasted into a few UIViewControllers! You can tweak that “100” number based on how much you want your view to move up to clear the keyboard.

#pragma mark UITextFieldDelegate
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[textField resignFirstResponder];
return YES;
}

- (void)textFieldDidBeginEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.25];
CGRect rect = [self.view frame];
rect.origin.y -= 100;
[self.view setFrame:rect];
[UIView commitAnimations];
}

- (void)textFieldDidEndEditing:(UITextField *)textField {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDuration:0.25];
CGRect rect = [self.view frame];
rect.origin.y += 100;
[self.view setFrame:rect];
[UIView commitAnimations];
}

To make sure these get called, you’ll want to do something like this in your “viewDidLoad” method.
[yourTextFieldUI setDelegate:self];

New iPhone 3.0 software has been announced!

Here are a few of my favorite things;
cut/paste
landscape keyboard
bluetooth peer-to-peer
in-app purchasing (think renewing subscriptions)
stereo bluetooth (A2DP)
search across all (or almost all) data in the phone

All in all, cool stuff! Developers can get their hands on 3.0 right now (or as soon as the dev site comes back!). To be released in “this summer”. Free to iPhone users, $9.95 for iPod touch (boo!!).

You can now buy “options” for Amazon EC2 instances!

They don’t call it options, They call it “Reserved Instances”. Let’s look at the details first.. then I’ll run some numbers.

Reserved Instances give you the option to make a low, one-time payment for each instance you want to reserve and in turn receive a significant discount on the hourly usage charge for that instance. After the one-time payment for an instance, that instance is reserved for you, and you have no further obligation; you may choose to run that instance for the discounted usage rate for the duration of your term, or when you do not use the instance, you will not pay usage charges on it.

Linux/UNIX One-time Fee  
Standard Reserved Instances 1 yr Term 3 yr Term Usage
Small (Default) $325 $500 $0.03 per hour
Large $1300 $2000 $0.12 per hour
Extra Large $2600 $4000 $0.24 per hour
High CPU Reserved Instances 1 yr Term 3 yr Term Usage
Medium $650 $1000 $0.06 per hour
Extra Large $2600 $4000 $0.24 per hour

Reserved Instances can be purchased for 1 or 3 year terms, and the one-time fee per instance is non-refundable. Usage pricing is per instance-hour consumed. Instance-hours are billed for the time that instances are in a running state; if you do not run the instance in an hour, there is zero usage charge. Partial instance-hours consumed are billed as full hours. 

Reserved Instances are currently available for Linux/UNIX operating systems. We expect reserved Instances to be available for the EU region in the near future. Click here to see FAQs on using Reserved Instances.

As you can see the cents/hour figures have dropped a lot! How does that work if you factor in 1 or 3 years of “reservation” money?

For a small instance, a 1 year term is $325, so that’s $325/365/24 = $0.03710 per hr. Let’s add that up. You can now get a small instance for $0.0671 per hr instead of $0.10. That’s a savings of 0.0329 per hour, or $288.20 per year! If you bought into 3 years, $0.049 per instance per hour and $446.76 saved per year! That’ll pay a pretty nice sized Amazon S3 bill!

As they say, the savings scale with the instance size! To summarize;

Standard Linux/Unix

1 year 3 years
Small – $0.0671 per hr, $288.20 savings per year $0.049 per hour, $446.76 savings per year
Large – $0.2684 per hr, $1152.80 savings per year $0.1961 per hour, $1786.13 savings per year
XLarge – $0.5368 per hr, $2305.60 savings per year $0.3922 per hour, $3572.27 savings per year

High CPU

1 year 3 years
Medium – $0.1342 per hr, $576.40 savings per year $0.09805 per hour, $893.07 savings per year
XLarge – $0.5368 per hr, $2305.60 savings per year $0.3922 per hour, $3572.27 savings per year

 

If you run several instances all the time, this is a huge win! If you buy into 3 years, the savings is about 50%!

Nice work, Amazon!

Editing xib files for rapid UI building

I just decided to look at what a .xib file contained. The “x” should have been the clue that it just might be an XML form of a .nib file. If you’re lost, I’m talking about the files that the Apple Interface Builder tool uses to store interface definitions.

I needed to copy an existing interface, then make minor tweaks. Starting from scratch in Interface Builder isn’t so bad, but I’m really a Vim guy of old and being able to fly through a text file and make edits is 2nd nature to me. If you’ve ever edited XML manually, this won’t seem like a silly notion. For that matter, you could use any of the XML editors out there as well.

To start with, I copied the existing .xib to a new name. In Vim, I changed the references to the old name to the new one. So, now my new interface also references a new controller class, which I’ll probably copy/paste also. It’s pretty trival to change the button text and IBActions and IBOutlets the .xib points to. There are a lot of reference numbers within the XML, so I wouldn’t do too many changes for fear of messing up some relationships that Interface Builder requires. Also, don’t forget to add (existing file) to your project, so that you build with the new interface def.

Happy .xib editing!

Using “autorelease” can really bite you!

This will be a short post, but there was a lot behind it. Trust me!

A few times, I’ve run into cases where my code didn’t run as expected. I’d initialize an object (sometimes in viewDidLoad()). Later, maybe in viewWillAppear(), or in a button delegate, I’d try to access that object and use it. The debugger would show an EXC_BAD_ACCESS. I’d step through the code and sometimes, the object would appear normal in the inspector. Other times, the debugger would think it was of a different type!?!

The cause, it seems was that when I initialized the object, I set autorelease, like this;

memberVariable = [[[MyObject alloc] initWithParam:param] autorelease];

I thought I was being smart by allow the object to be cleaned up for me. In fact, I was causing a problem because I apparently don’t understand the behavior of autorelease. It turns out it can cause objects to be released early. I would say avoid autorelease! It has bitten me several times now!

Dismissing keyboard for UITextField

I found it frustrating that editable UITextFields don’t automatically dismiss the keyboard when editing is done. I think this should be the default behavior, but what do I know?
First thing you need to do is implement the UITextFieldDelegate in your UIViewController.

@interface MyViewController : UIViewController <UITextFieldDelegate> {

The next is to set the controller as the UITextField delegate (I do this in the viewDidLoad method).

- (void)viewDidLoad {

	[super viewDidLoad];

	[myTextField setDelegate:self];

}
Then, implement textFieldShouldReturn in your controller like this;
#pragma mark UITextFieldDelegate

- (BOOL)textFieldShouldReturn:(UITextField *)textField {

	[textField resignFirstResponder];

	return YES;

}

The keyboard is the "first responder", and this causes it to go away when the "done" button is pressed (assuming you have a "done" button on your keyboard). Can anyone tell me why the numeric keypad doesn't have a done button??

Scribus – Open Source DTP

I’ve just finished my first real Desktop Publishing project. Always looking to save some cash, I took a look at the open source project called Scribus. Like with any new software, it took a little bit of getting used to, but I managed to figure how to edit master pages, create bullet lists, hyperlinks and wrap text around images. Very cool (and really, standard) stuff for DTP. The results should be posted here soon. (click the Porthole link)