Monthly Archives: November 2011

Dear Posterous

A wonderful boquet of flowers.I’ve been using Posterous for a while now, as an alternative stream. I post pictures to Posterous indirectly through Instagram and text through, on occasion. I have a couple other weblogs that use Posterous exclusively, but I can’t quite move this weblog to Posterous, yet.

I have a couple requests. I believe these would get me a long way toward having the weblogging solution I’m after.

Request #1

I’d like to have the option to publish static HTML to an FTP site. A fully baked weblog. Why? A better question is, why not? I want a weblog minus a lot of dynamic content, it’s all about the content, the text, the post. I don’t need my pages rendered every time my site is hit. I’d like to generate static HTML when the “Publish” button is clicked. I was a Blogger user for years because of that feature, until it was removed. I’d love to see this feature.

Request #2

Give me different archive options. This request goes hand-in-hand with my prior request. If I move my weblog from WordPress to Posterous I need to make sure I don’t break links to my old posts. My posts are archived by YYYY/MM/DD/post, which, according to Posterous support, is not possible today. I asked support to pass that request to the development team. I hope it makes it out of the backlog.

That’s it. I believe, with these two changes, I could move my weblog to

Fingers crossed.

Potter, called it

Harry Potter, boy wizardMy Old Weblog: “Will Harry’s death save the world? I think we’ll have to wait for book seven to find out! I for one hope Ms. Rowling has some twisted scheme up her sleeve, one we can’t possibly guess, for the final chapter in Harry Potter’s life.”

We all know how it ended.

As an aside, I miss Harry Potter. I’d love to see J.K. Rowling write more about the Wizarding World of Harry Potter.


Readability Blog: “One of the more useful tools in the Readability toolbox has been our link shortener, The interesting bit about is simple: When an article is linked to through, it offers up the availability to view the content in a clean, readable view.”

Get to building! If you need some Objective-C to talk to, you’re in the right place.

Take a look at RFRddMe.

Asynchronous Unit Tests

AHHHHHH!When I created the project for RFRddMe I added Unit Tests. Every developer should do this today. They’re easy to create and Xcode does a great job getting you started. Everything is setup, you just need to write and run the tests. Really great stuff!

The only challenge for me was how to test asynchronous code? As far as I know it’s up to the developer to figure that out. That’s fine, I have a solution, but I thought I’d share it and see if anyone has an opinion about how I did it.

If you haven’t used the Unit Test Framework included with Xcode, you should. It’s a cut of SenTestingKit, and it does the trick.

It provides a couple of methods that allow you to setup and tear down a unit of tests and all you need to do is write test methods. Here’s an example test method, that does nothing.

- (void)test;
    STAssertTrue(true, @"test");

So, how in the world do you test asynchronous code? The way you write any other asynchronous code. You need a way to block until the code you’ve executed is finished.

The RFRddMe projects makes use of ASIHttpRequest, which runs in a thread. This project requires the implementation of an protocol, RFRddMeProtocol, which provides a mechanism for your application to receive results. This is all really cool because your application’s UI will remain responsive while you wait for results, but I digress.

The bottom line is we have to block while we wait on our results to return. So, here’s what I did to make this work. I created a method, I dubbed hackyRunLoopWait, that makes use of the default NSRunLoop to wait for completion of our asynchronous methods to complete. Here’s what it looks like.

// Introduced methods.
- (BOOL)hackyRunLoopWait;
    // Reset our _done flag.
    _done = NO;
    // Reset the _succeeded flag to NO.
    _succeeded = NO;
    // Get the current run loop.
    NSRunLoop* runLoop = [NSRunLoop currentRunLoop];
    // Spin until the _done is YES or we've waited for 90 seconds.
    // Yep, it's a complete hack, just to get this working.
    while ((NO == _done) && [runLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:90]]);
    // Need to deal with exiting the loop above because we timed out.
    return _succeeded;

Here’s how I used it to test methods on RFRddMe.

- (void)testShorten;
    RFRddMe* p = [[RFRddMe alloc] initWithDelegate:self];
    [p shortenUrl:@""];
    STAssertTrue([self hackyRunLoopWait], @"testShorten");
    [p release];    

Notice the STAssertTrue() statement, it contains [self hackyRunLoopWait], which blocks and waits on our shortenUrl method to complete.

Another thing to make note of is RFRddMeProtocol is implemented by the test class, see the [[RFRddMe alloc] initWithDeelgate:self]. When the request completes it will notify the shortenSucceeded method, which sets the values monitored in hackyRunLoopWait, which allows that method to return.

// RFRddMeProtocol Implementation
- (void)shortenSucceeded:(RFRddMeShortUrl*)shortUrl;
    _succeeded  = YES;
    _done       = YES;

Is this the best way? I don’t know, but it does what I need it to do, and it works as expected. If someone has a better idea I’d love to hear from you. Please, leave a comment, or send an email;

Dear Mr. President

The handling of the Occupy Movement by local authorities has gotten out of hand. Police, not the protesters, are getting violent. There’s no excuse for that type of behavior. Do you want to see it turn violent? Is that the idea? It’s ridiculous, step up and address this problem, you did it for the people of Egypt.

THE PRESIDENT: Good evening, everybody. My administration has been closely monitoring the situation in Egypt, and I know that we will be learning more tomorrow when day breaks. As the situation continues to unfold, our first concern is preventing injury or loss of life. So I want to be very clear in calling upon the Egyptian authorities to refrain from any violence against peaceful protestors.
The people of Egypt have rights that are universal. That includes the right to peaceful assembly and association, the right to free speech, and the ability to determine their own destiny. These are human rights. And the United States will stand up for them everywhere.

Maybe you could do the same for America?

Fresh Code: RFRddMe

Earlier this week Dave Winer pointed out some neat stuff Readability was up to. Part of the piece pointed out a new URL shortener. I marked it and came back to it today. Since I love writing code to talk to RESTful web services, why not write another one?

The Red Readability CouchThis afternoon I started on RFRddMe, an Objective-C library for the Readability Shortener Service. Late this afternoon I completed the library, and I checked it into my GitHub Repository tonight. Figuring out git submodules took a bit of time, but it works as advertised.

If you just happen to be looking for Objective-C code to shorten a URL, and add an article to Readability, look no further.

Get the code for RFRddMe on GitHub.

Please, drop me a line,, if you use the code.