Saturday, January 28, 2012

High Dynamic Range Imaging

High dynamic range imaging (HDR) is my favorite camera feature that was released in iOS 4.1, last year. HDR allows you to take a photo with a higher contrast between light and dark areas (i.e. dynamic range).

The basic principle is simple. When pressing the shutter button, three photos are taken. One photo is normally exposed, another is underexposed, and the third is overexposed. These three photos are combined, on the fly, to create a single image where the overexposed areas of the normal photo are replaced with the areas from the underexposed image and vice versa.

Instead of areas of a photo being too light or too dark, they come out just right.

One downside is that you can't photograph fast moving objects since there will be noticeable movement in the final HDR image. However, Apple's camera app cannot only compensate for this, sometimes, but it also has the ability to take an out-of-focus or blurry photo and, amazingly enough, correct it. Another downside is when you want high contrast in your photo, since the point of HDR is to reduce contrast.

The iPhone gives you the option to save the HDR image, only, or both the HDR and the normally exposed photo. I recommend always saving both to the camera roll so you'll have the option to pick the best one.

What Are Objects?

In computer science, there is the concept of objects as it relates to object-oriented programming (OOP) which is sometimes confused with basic data.

For example, Amazon's S3 web service has a concept of buckets which hold objects. But, there's no reason why these objects can't be referred to as files since that's all they really are. Files are a collection of data on a file system. Data can be structured to represent many different things such as records in a database, images on a hard drive, or music on an MP3 player.

What makes an object special is that it is not only data, but has behavior, too. In order to see or act on the data inside an object, it must be accessed through its methods. Generally speaking, this is the only (and preferred) way of reading, writing, and updating an object's data.

This may not seem like a big deal, but it is since, whenever an object is passed around, all of its behavior is passed along, too.

For example, in a non-object world, I could read data from a database, manipulate it, perhaps improperly like incorrectly calculating tax or interest, and then update the database with the bad data.

However, if I pass along an object representing that same data from the database, the methods (i.e. business logic) that wrap and act on that data, protect the data's integrity. How the data is manipulated can be private, like a black box, but how you can access it is publicly described by its application programming interface (API).

I don't need to know how my car engine works or how gasoline is made, all I need to do is plug the gas hose into my gas tank. If I try to stick the diesel hose into the my tank, it won't fit.

The beauty of objects is that they can be plugged into each other and the data just flows. This is very different from previous programming paradigms, such as procedural languages, like BASIC, where each step of the program must be followed in sequence; or declarative languages like SQL where the programmers don't describe the steps to take, rather they declare what is to be accomplished, such as, "show me all the people with the last name equal to Smith."

Special Relativity Time Dilation

I recently had a conversation where I was explaining why time slows down as you travel near the speed of light.

The explanation is rather simple if you think of light as particles, like bullets, called photons. One beauty of light is that it moves at a constant rate when traveling through a vacuum or medium. It doesn't move faster or slower unless you change the medium it's traveling in.

Thought Experiment
Imagine that you're standing at a fixed distance from a clock. As light reflects off the clock, it strikes your eyes at a fixed rate such that the clock's second hand sweeps at the same rate. Time is ticking away like normal.

Now, imagine if you are moving away from the clock at near the speed of light. Since the photos (bullets) are moving at a fixed rate, it will take longer and longer for each particle, reflected off the clock, to catch up with you. Therefore, you'll experience the sweeping of the clock's second hand at a slower rate. Hence, time appears to slow down - the clock looks as if it's running slower.

But, time isn't really slowing down. The watch on your wrist will mark time normally from your point of view. From the point of view of the clock, which is also marking time normally, it will look as if you're slowing down, too.

Further Reading
While this is a naive application of time dilation, since acceleration and deceleration must be taken into account, it really does appear that time slows down when traveling away from an observer at the speed of light. A more interesting observation is the twins paradox where one traveling twin ages slower than his other, non-traveling twin.

Sunday, January 22, 2012

Et Tu, iCloud

iCloud still has some critical bugs to work out.


In my mind, I considered Apple's iCloud akin to Amazon S3 for the consumer. S3 allows users to upload files which are stored on Amazon's servers in three different places, for redundancy. While Amazon Web Services have had occasional down time, they've never lost S3 files that I'm aware of.

Last Tuesday, my iPhone started running hot and the battery was running down very quickly. After troubleshooting the problem, over two days, by switching between WiFi and 3G, without any luck, I decided to reset my iPhone to original factory settings and restore it from iCloud.

iCloud Benefits
Launched this past October, iCloud stores a backup of your media and data on Apple's servers instead of iTunes. The beauty is multifold – at least in theory.

First is that you don't lose your iPhone backup if your computer's hard drive dies.

Second, is that it's very efficient in that iCloud doesn't actually store your apps or music, in your backup, since Apple already has a copy of these files on their servers. In other words, they don't count music and app backup storage against your allotment of 5, 20, or 50 GB.

Third is the fact that iCloud allows you to share and sync media and files across all of your devices – which happens automatically, in the background. Change a playlist on your desktop and, within seconds, you'll see the updated playlist on your Apple TV or iPad. Buy a song on your iPad, and it's immediately downloaded to iTunes on your desktop or iPhone.

My favorite iCloud feature is Photo Stream. Snap a photo on your iPhone and it's copied to your iPad or iPhoto automatically.

Backup Regrets
Unfortunately, I didn't take all the necessary precautions before resetting my iPhone to factory defaults, resulting in the loss of my iPhone's camera roll containing more than 12,000 photos that I've take, over the years, on my iPhones.

I forgot the 3-2-1 rule of backups: Three backups, on two different media, with one stored off site. In my case, I only had one current backup stored off site, in iCloud, but I failed to make two other backups.

Don't Give Up The Ship
Of course, I didn't go down without a fight. Over the course of several days, I tried every combination of restoring my iPhone that I could think of.

Some of my iPhone restorations required 30 hour sessions of updating and redownloading content in vain, followed by three trips to the local Genius Bar at Apple.

Two days in a row, I left my iPhone at home when I went to work so it could continue downloading, without interruption, on my speedy 50+ Mbps Internet connection since I thought that the 30 hour wait was due to my 19 GB camera roll download.

But, in the end, the final option was to replace my iPhone with a new one, in case it was defective. But, still no luck.

Postmortem
I have 25 GBs of iCloud storage. My backups where a little shy of 25 GB, but there were multiple iPhone backups in iCloud. Surely I would have expected at least one of my iCloud backups to succeed. But, alas, no.

Restore Incomplete
iCloud thought that my 12,000 photos were on its servers, but it just couldn't seem to download them to my iPhone.

After completing each restoration attempt, iTunes also thought that my 19 GB worth of photos where on my iPhone. But, were they really? It seems not.


Needless to say, it was very disconcerting to see the Restore Incomplete alert: Some items could not be restored from the iCloud backup.

Cupertino, We Have a Problem
It appears that there's a bug with the iCloud restore process which causes internal, repeated crashes. As my iPhone tried to restore apps, a process would crash, before the app finished installing, resulting in a repeated download and installation attempt. I suspect that a big chunk of the thirty hours spent restoring my iPhone was due to it redownloading the same apps over and over again. The internal iPhone diagnostics and usage data shows scores of crash logs, each about minute or two apart.

Saving Grace
So, did I really lose my 12,000 photos? Not exactly. While I'm highly disappointed that I can no longer have them on my iPhone's camera roll, nearly all of them are in iPhoto, which backs up to my Time Capsule. My most recent photos that weren't in iPhoto were, luckily, on my Photo Stream, so I copied them into iPhoto.

As a side note, my Photo Stream doesn't seem to go all the way back to when I first started using it. There only seem to be a few hundred photos in my Photo Stream – it's suppose to keep the last 1,000. Hmm.

Still, it's highly disappointing that I couldn't simply recover everything from my iCloud backup. The Apple iCloud team has some work to do.



Saturday, January 14, 2012

Life in a Day

It takes a lifetime to experience life.

But, what if you wanted to experience most everything that life has to offer in a single day?

Life in a Day, released a year ago, covers life around the world on July 24, 2010 in an amazing way.

This crowd sourced documentary, produced by Ridley Scott, opens during the pre-dawn hours where we see what some people experience before most of us wake up in the morning. It then takes you through that Saturday's seemingly mundane, yet, intimate and raw events from the point of view of anyone, rich and poor, young and old, sick and healthy, in developed and developing nations.

On this single day, one question is answered, "What was it like to be alive on July 24, 2010?", and three questions are asked:
1. What do you love?
2. What do you fear?
3. What's in your pocket?

The final moments of July 24, 2010
It's nearly midnight now and I'm running out of time…

The sad part is I spend all day long hoping for something amazing to happen, something great, something to appreciate this day and to be part of it and to show the world that there's something great that can happen every day of your life, in everyone's life.

But, the truth is that it doesn't always happen.

All day long nothing really happened.

I want people to know that I'm here. I don't want to cease to exist.

And today, even though nothing great really happened, tonight I feel as if something great happened.

YouTube
You can can watch the entire 95 minute production of Life in a Day embedded below or on Netflix streaming (turn on Closed Captioning to read the English translations).






Update: I was wondering what I did, myself, on July 24, 2010. Thanks to Facebook's new timeline feature, I figured out, in two clicks, that I had dinner at my father-in-law's.

PS - If you don't have time to watch the entire movie, but still want to experience life - and a great love story - then just watch the first four minutes of Up.

Wednesday, January 11, 2012

Job Satisfaction With Room Key

Nothing says job satisfaction like having the press cover your work.

Today, I was happy to see a number of news outlets cover the launch of a heretofore secret project that I've been working on: roomkey.com. While I only had a tiny part in this project, as the product manager, it was a big part of my life since I began working at Wyndham.

TechCrunch
I was also a little surprised to see that TechCruch covered the news too, Six Hotel Giants Team Up To Launch Hotel Search Engine Roomkey.com, Buy Hotelicopter. TechCrunch specializes in covering high tech news and I don't exactly consider hotel industry news high-tech, but when you get the largest companies in the industry together, it's well worth covering.

In a nutshell, Room Key is a joint venture of the world's six largest hotel chains who've created a search engine amongst themselves. After customers visit one of the six partner sites, they may be presented with an opportunity to see comparable hotel rooms from one of the other partners.

Sunday, January 8, 2012

Poor Man's Performance Monitoring

Amazon has been great at rolling out high end (enterprise class) web services which don't require expensive or long term contracts. Instead of signing a contract, Amazon Web Services are "pay by the drink" which literally means that a monthly bill can be less than a dime. You simply pay for storage and bandwidth used.

But, I've noticed one, key, service that Amazon has yet to roll out: website performance monitoring.

CDN
Five years ago, if your website had to deliver large media files, such as audio or video, then your best option was (and still is) a content delivery network (CDN). A CDN distributes copies of files all over the world so that they're as close as possible to the users which means faster download times. The problem with CDNs of the past, like Akamai, is that it's a service for the big boys requiring long term, expensive, contracts. Of course, when you spend thousands of dollars each month you do get enterprise class support and dashboards, but, many smart, lean, companies can develop their own dashboard specific to their needs.

A couple years ago Amazon began selling their own CDN service, called CloudFront, with no contract. CloudFront, like all Amazon Web Services, is "pay by the drink," so that any startup could deliver video and music just as fast as Netflix streaming movies or the Apple iTunes Store. Just like Amazon now offers a CDN web service, I can see them offering a performance monitor web service in the future.

Performance Monitoring
Performance monitoring is a way to monitor the status and performance of a website. Is the website up or down? How long does it take for your website to load for users in New York, L.A., and Paris? Are there any bottle necks causing delays?

There are two basic ways to monitor performance: internally and externally.

External Performance Monitoring
External performance monitoring would be at home as an Amazon Web Service. There are no shortages of companies providing external website performance monitor services and dashboards for hundreds or thousands of dollars per month. The services these companies provide are very complex and many times they offer more than any one company requires. Also, a company paying for these services will require a team of employees to gather and process the performance reports.

External performance monitors usually run automated scripts which follow a critical path, such as logging into an e-commerce website and making a purchase. These scripts can either run on simulated web browsers, in a data center, or on actual web browsers in homes or offices so that they can simulate the "last mile" performance. The latter can be very helpful when companies try to troubleshoot seemingly "strange" problems such as why a website has problems loading only for some customers and not others. Is the problem due to a misconfigured router, a misconfigured DNS server, etc?

Since Amazon already has points-of-presense all over the world, they would have little problem setting up an external performance monitoring service API.

Internal Performance Monitor
Even if a small company doesn't have the financial means to afford an external performance monitoring service, they should still implement simple internal performance measures on their servers. Off the top of my head, I can think of two simple measures which should be implemented from the get-go: web server segregation and code timers.

Web Server Segregation
Static web server resources should be segregated from web servers that serve up dynamic web pages. If this can't be physically done by using separate hardware, then use different host names and web server logs for dynamic versus static resources. If you only have one web server, then simply move all of your static web resources to Amazon's S3 web service.

Monitoring your dynamic web server logs is one way to determine what your customer's UX is like. I use Apache with the following log format:
%h %l %u %t "%r" %>s %b "%{Referer}i" %T

The most import part of this log format, for performance monitoring, is the last part, %T. This shows how long it took for the dynamic page to be requested, generated, and served to the client's web browser. Here's an example from an Apache log:
ool-182e94c5.dyn.optonline.net - - [08/Jan/2012:16:45:59 -0800] "GET / HTTP/1.1" 200 66321 "-" 2

The last number, 2, tells me that it took two seconds for this dynamic web page, which is 66,321 bytes long, to be generated and downloaded to the client's web browser. Historically, that number is less than one second in my logs, so seeing two seconds warrants further investigation which is where code timers come into play.

Code Timers
Code that is executed which could take longer than a second or requires "heavy lifting", such as generating reports, should be timed. All API calls to third parties, i.e. Twitter or Facebook, should also be timed and logged.

Here's the source code for a simple Timer.java utility class based on Apple's WebObjects app server.

The following Java method, which verifies a Twitter user's credentials, is used in actual production code. It demonstrates the timer's simplicity. The key to using the timer is that it's started at the beginning of the method and then the timer's results are logged just before returning from the method. The next step would be to log the high, low, and average response times and report them.

public static String twitterUsernameForUser(User user)

{

Timer timer = Timer.startNewTimer();

String twitterUsernameForUser = null;


Twitter twitter = new Twitter();

twitter.setOAuthConsumer(System.getProperty("twitter4j.oauth.consumerKey"),

System.getProperty("twitter4j.oauth.consumerSecret"));


AccessToken accessToken = new AccessToken(user.twitterOAuthToken(),

user.twitterOAuthTokenSecret());

twitter.setOAuthAccessToken(accessToken);


try

{

twitter.verifyCredentials();

twitterUsernameForUser = twitter.verifyCredentials().getScreenName();

} catch (TwitterException e)

{

e.printStackTrace();

NSLog.debug.appendln("Caught exception. Invalid twitter credentials.");

}


timer.stop();

NSLog.debug.appendln

("OAuthTwitterUtilities.twitterUsernameForUser() elapsed time: "

+ timer.elapsedTime());


return twitterUsernameForUser;

}



But, even if Amazon offers a web performance monitoring service, you should still segregate your web server and time your network API calls.


Sunday, January 1, 2012

Wearable World News Testing for Darius

This is test post for Wearable World News as a demonstration on how to get directly into Google's search engine. I'm doing this to show Michael Darius how it can work once a web site is considered authoritative.

BTW, here's a link to a WWN story about Apple and their iWatch which ran on wearableworldnews.com:
http://wearableworldnews.com/2014/02/10/apple-ceo-tim-cook-builds-iwatch-anticipation/

Sincerely,
Joe Moreno