This kid’s a future mobile developer

by Joey deVilla on February 20, 2015

future mobile developer

Click the photo to see it at full size.

He’s got that mix of love for mobile, cleverness, and laziness that the job requires.

{ 1 comment }

3 out of 4 americans

Around this time last year, Nielsen’s U.S. Digital Consumer Report estimated that 65% of Americans — about two-thirds — owned a smartphone. Data from comScore’s MobiLens and Mobile Metrix surveys shows that this percentage has grown, with an estimated 75% of Americans owning smartphones during the period from October through December 2014.

top us smartphone oems dec 2014

The top smartphone vendor for that time period was Apple, who claimed 41.6% of America’s smartphone subscribers, followed by Samsung, with 29.7% of the market share. The next three OEMs, LG, Motorola, and HTC, trailed distantly with single-digit shares of the market, and the remaining vendors accounted for the final 11%.

top us smartphone platforms dec 2014

Android was the number one platform with 53.1% market share, followed by iOS with 41.6%. The two top players dwarfed the rest of the field, which includes Windows Phone at 3.4%, BlackBerry at 1.8%, and Symbian just hanging on with one-tenth of one percent of the market.

top us smartphone apps dec 2014

Facebook was the app most used by Americans, reaching 70.2% of the app audience, with a nearly 20-point lead over the runner-up, YouTube, with 52.5%.

this article also appears in the GSG blog

{ 1 comment }

date and time

swift kickIn previous installments in this series, we’ve covered:

In this installment, we’ll make getting the time interval between two dates — which normally involves a lot of typing — a little more Swift-like.

One common date arithmetic operation is to determine the interval between two given dates. This is usually a clunky two-step process based on NSCalendar‘s components method, which expects at least three parameters:

  • The time components you want the method to return, such as years, months, days, hours, minutes, and seconds. This is expressed by ORing together NSCalendarUnit values, and
  • the two dates, in NSDate form.

Let’s look at how it works. First, we’ll need a couple of dates. Create a new playground and put the following code into it:

In your playground’s sidebar, you should see the string representations of those dates:

  • goHomeYoureDrunkTime should display as something like January 1, 2015 at 3:45 a.m., and
  • badPoetryDay should display as something like August 18, 2015 at 4:20 p.m..

Let’s find out how many days, hours, minutes, and seconds there are between goHomeYoureDrunkTime and badPoetryDay with the following code:

You should see from difference that there are 229 days, 12 hours, 34 minutes, and 40 seconds between the two dates. We did a lot of typing to get this result, and there should be a nicer way to do it. How about this:

With this code, we’ve overloaded the - operator, so that when both its operands are NSDates, iy returns an NSDateComponents instance specifying the days, hours, minutes, and seconds between the two. I could’ve coded it so that it also returned the time in terms of months and years, but the size of those units vary depending on the month and year, while days, hours, minutes, and seconds always represent the same amount of time.


never mind the bollocks

Here’s a story that anyone who’s taking part in any of the activities of Tampa Bay Startup Week — or wishes they could take part — should read. It’s a story about a seemingly insignificant gathering of like-minded people, and how the ripples of what its attendees did can still be felt today, an ocean away…

johnny rotten

Johnny Rotten in 1976.

It’s June of 1976 in Manchester, England, and a small group of people gather in a tiny venue called the Lesser Free Trade Hall to see a band play. There’s nothing really remarkable about this group of 42 people, and that evening’s featured musicians are unknown at the time.

The band calls themselves the Sex Pistols.

sex pistols 1976

Glen Matlock, Johnny Rotten, and Steve Jones in 1976.

As I mentioned, there were no famous people in the crowd at this show, or at the follow-up show that happened about a month later. The Sex Pistols had not yet caused an uproar throughout Britain with songs like Anarchy in the UK and God Save the Queen, and it was well before they invaded the US in 1978.

Attendees ranged from the local mailman to a few rebellious school children. But a handful of others in that small audience became some of the most influential people in independent and now mainstream music.

A gig attended by a few dozen in a venue that could easily hold hundreds would normally be considered a flop, but turned out to be anything but an ordinary concert. The influence of the Sex Pistols and the punk rock movement they helped kickstart can still be heard today in every band that features a spikey-haired youngling beating rapid power chords on a guitar. Johnny Rotten would later found the more experimental Public Image Ltd, and manager Malcolm McLaren would cast his musical net even wider, branching out into disco, funk, hip, electronic music, world music, and even opera.

That “handful of others” in the audience were just as important. Among them were:

These output of the bands that arose from this one gig would help define alternative rock and its subgenres, from punk to goth to synthpop to grunge, for decades to come. All this came from a concert that almost nobody cared about at the time, attended by people nobody had heard of at the time.

“The gig that changed the world,” as alt-rock aficionados sometimes call it, did so because it brought together people with similar interests who were passionate about what they did. Its attendees saw that popular music was changing, and after being inspired by a group of troublemakers, decided that they could be part of that change. They went on to create music their way, and make their mark on the world.

tb startup week organizers

The people behind Tampa Bay Startup Week (pictured above) may not look punk rock, but they’ve most certainly got its DIY, “we have an idea and we’re going for it” spirit. Like the Sex Pistols, they’re a band of troublemakers putting on an event on a shoestring budget (yes, Chase is sponsoring, but without them, the budget would likely go from shoestring to none), and at the moment, it isn’t being noticed by most of the world outside “the other bay area”.

Like the music scene in Manchester the mid-1970s, the work-life dynamic in Tampa Bay in the mid 2010s is undergoing some big changes:

If you look carefully, you can see the initial rumblings of change here, from the One Million Cups gathering that takes place every Wednesday to all the local interest in The Iron Yard to places like The HiveTampa Hackerspace, and Eureka! Factory to the ex-Marine who’s doing good and helping your beard feel good at the same time. I see a lot of the necessary ingredients for change here that I saw in Toronto in the mid-2000s, and so does GeekWire…and with a subtropical climate to boot!

I hope that like those 42 people who attended that Sex Pistols concert in 1976, that some of the people at Tampa Bay Startup Week’s events will get inspired, start their own businesses, and shake the universe.

(I’ll be at tonight’s tech cocktail mixer with my accordion. If you ask, I’ll gladly play you my rendition of Anarchy in the UK.)

Upcoming Tampa Bay Startup Week events



This article also appears in my personal blog, The Adventures of Accordion Guy in the 21st Century.

{ 1 comment }

Scenes from Tampa Bay Startup Week’s kickoff party

by Joey deVilla on February 3, 2015

tampa bay startup week

Photo by David Betz.

tampa bay startup week buttonMonday marked the beginning of Tampa Bay Startup Week, a five-day-long series of events meant to bring creatives, techies, entrepreneurs, and anyone who’s a combination of any of those together to meet, plot, and party. There’s a small but interesting tech scene here in the Tampa Bay area, and a number of factors including the subtropical climate, low cost of living, and the influx of people to the area — you might call it a brain gain — could help it grow dramatically over the next few years.

joey and anitra at startup week tampa bay kickoff

Me and Anitra, working the room. Photo by Laicos.

The week’s kickoff party took place at the Chase Basecamp, a rented venue on 7th Avenue, the main street of Ybor City (pronounced “EE-bor”), Tampa’s nightlife and party neighborhood. The Basecamp (located at the corner of 7th Avenue and 20th Street), serves as the central meeting place for Startup Week participants, as well as a venue for many of the scheduled events.

tbstartupweek kickoff 1

Photo by Laicos.

While chatting up the people from local mobile development shop Sourcetoad, I was introduced to the friendly-looking gentleman below, who went up to me and said “I just have to tell you, I love that accordion!”

bob buckhorn 1

Photo by Laicos.

As he walked away, Anitra told me that I just shook hands with Bob Buckhorn, mayor of Tampa. I’m a relatively recent transplant from Toronto, so I’ve never seen a photo of him, and I’m too used to picturing the mayor as either a sweaty, drug- and booze-addled, embarrassing mess, or too attached to highfalutin’ extravaganzas that are full of sound and fury but ultimately signifying nothing to care about a small grassroots effort like this one. I’m also not used to a mayor with his approval rating.

bob buckhorn 3

Photo by Yours Truly.

He gave a short speech to the crowd, in which he encouraged everyone to meet other people of like minds and ambitions, do what we do, “be a little crazy”, disrupt things, and start businesses. He talked about the brain drain that existed until recently, when people would leave Tampa in search of their fortunes. The situation has been turned around, what with Florida being one of the most moved-to states in the U.S. (as of this writing, it’s the third most populous state, after California and Texas), the population growth in the Tampa Bay/Jacksonville corridor and “Orlampa”, and Penske rental truck data that suggests that the Tampa Bay/Sarasota area is in the top 10 most moved-to locales. He asked the group to keep working to make Tampa a better place to be, if only to make sure that his daughters don’t move away to Atlanta, Austin, or anyplace else.

The money quote that got the audience to really put their hands together:

“I want Tampa Bay to be the economic engine of the southeast.”

It’s bold. It’s ambitious. I like it.

After all the speechifying, he then did what any good mayor would do: take control of the decks and drop a fat beat.

bob buckhorn 2

Photo by Laicos.

Anitra and I spent the rest of the evening either catching up with or getting to know the people in attendance, including:

tampa bay startup week banner

Here’s what’s happening with Tampa Bay Startup Week today and tomorrow. These events are free — just visit the Tampa Bay Startup Week site and sign up!

Today (Tuesday, February 3):

Tomorrow (Wednesday, February 4):

This article also appears in my personal blog, The Adventures of Accordion Guy in the 21st Century.

{ 1 comment }

date and time

swift kickSo far in this series, we’ve looked at:

So far, everything we’ve done has a distinctly un-Swift-like feel to it. That’s because Cocoa’s date and time classes were built with its original programming language, Objective-C, in mind. In this article, we’ll look at ways to make date calculations feel more “human” and Swift-like.

Make date comparisons more Swift-like

Let’s start with a new playground and some quick definitions:

  • A reference to the user’s calendar,
  • an NSDateFormatter and format string that makes it easy to define dates in a hurry,
  • and two dates:
    • Valentine’s Day (February 14, 2015 at midnight)
    • St. Patrick’s Day (March 17, 2015 at midnight)

Here’s what your code should look like:

In the previous article, we looked at NSDate's compare method, which compares two NSDates and returns a result of type NSComparisonResult as shown in the table below:

If… compare returns…
the first date is earlier than the second date .OrderedAscending
the first date is equal to the second date .OrderedSame
the first date is later than the second date .OrderedDescending

Add the following code to your playground:

The compare method works well, but its syntax has that C-style clunkiness. It’s a bit jarring in Swift, which has a lot of features that so-called “scripting” languages have. Wouldn’t it be nice if we could compare dates using the ==, <, and > operators?

Let’s make it happen. Add the following code to your playground:

With these functions, we’re simply overloading the ==, <, and > operators so that they work on NSDates and hide the clunky compare syntax behind some syntactic sugar. In case you’re wondering about the parameter names, lhs is short for “left-hand side” and rhs is short for “right-hand side”.

Note than in our overload of the == operator, there are a couple of ways that two dates can be considered equal:

  • Their compare result is NSComparisonResult.OrderedSame, or
  • the two dates being compared are the same NSDate object (=== is the identity operator; if a === b, then a and b both reference the same object).

Make date comparisons more “human”

picard data riker

One recurring theme in science fiction and especially in Star Trek is the tendency for ultra-smart characters and computers to be overly, needlessly, pointlessly precise. The writers for the original series often did this with Spock, and it seemed that at least a few writers were aware of this annoying trope in later series. Here’s a bit of dialogue from The Next Generation:

Data: 6 days, 13 hours, 47 minutes.
Riker: What, no seconds?
Data: I have discovered, sir, a certain level of impatience when I calculate a lengthy time interval to the nearest second. [beat] However if you wish…
Riker: No. No. Minutes is fine.

NSDate‘s compare method, and, by extension, the ==, <, and > overloads we defined, have the same problem with being overly precise. Let’s consider a case where we have two NSDates that are only a second apart:

  • Groundhog Day 2015 (February 2, 2015) at 12:00 a.m. EST
  • One second after Groundhog Day 2015 at 12:00 a.m. EST

For most purposes, we’d consider midnight on Groundhog Day and one second after midnight Groundhog Day the to be the same time. We need a way to do date comparisons at granularities other than seconds.

If you’re targeting iOS 8 or later, such a way already exists: NSCalendar‘s compareDate method! It expects the following parameters:

Parameter Description
fromDate The first date in the comparison.
toDate The other date in the comparison.
toUnitGranularity The level of precision for the comparison, expressed as an NSCalendarUnit value, which includes:

  • .SecondCalendarUnit
  • .MinuteCalendarUnit
  • .HourCalendarUnit
  • .DayCalendarUnit
  • .MonthCalendarUnit
  • .YearCalendarUnit

This is a Cocoa method with the word “compare” in its name, and you’ve probably guessed that its return type is NSComparisonResult. Here’s what it returns:

If… compareDate returns…
fromDate is earlier than toDate, when compared at the specified level of precision .OrderedAscending
fromDate is equal to toDate, when compared at the specified level of precision .OrderedSame
fromDate is later than toDate, when compared at the specified level of precision .OrderedDescending

Let’s try compareDate out:

Note that compareDate checks to see if the two given dates are in the same given time period. It doesn’t check to see if the two given dates are separated at most by the given time period. If you’re finding that distinction hard to follow, don’t worry; it’s hard to explain.

It’s easy to demonstrate, however. Suppose we create a new NSDate that represents one second before Groundhog Day and run some compareDate tests on it:

Note that compareDate isn’t available in iOS versions prior to 8. Code targeting iOS 7 or earlier will require writing an equivalent method, which I’ll leave as an exercise for the reader.

Making date arithmetic more Swift-like

You may have noticed in the code so far that I’ve been creating NSDates by using an instance of NSDateFormatter and a defined format string. That’s because this approach uses fewer lines than creating an NSDateComponents instance, setting its properties, then using a calendar to use the NSDateComponents instance to create an NSDate. Unfortunately, there’s no built-in quick way to build an NSDateComponents instance that represents an interval of time.

This means that answering questions like “What will the date be 1 month, 8 days, 6 hours, and 17 minutes after Groundhog Day?” requires a lot of yak shaving, my favorite term for “tedious setting-up”:

This approach is a clunky Objective-C-flavored way of doing things. I’d much rather do this calculation with code that looked like this:

Luckily, we’re working with Swift. Some judicious use of operator overloading and extensions will let us do just that!

First, we need to overload some operators to simplify date component arithmetic:

I derived these functions from Axel Schlueter’s SwiftDateTimeExtensions library. He wrote them when Swift was still in beta; I updated them so that they compile with the current version and added a couple of tweaks of my own. They make it possible to:

  • Add the respective second, minute, hour, day, month, and year properties of two NSDateComponent instances,
  • subtract the second, minute, hour, day, month, and year properties of one NSDateComponents instance from the corresponding properties of another NSDateComponents instance, and
  • negate the second, minute, hour, day, month, and year properties of an NSDateComponents instance.

The addition and subtraction operations are so similar and so tedious; that’s a sign that there’s an opportunity to DRY up the code. That’s why we have the combineComponents method doing the work and the + and - overloads calling it with the right parameters. The combineComponents code is dense with ternary conditional operators, so I thought I’d explain what’s going on under the hood with this flowchart:


You may be wondering why we defined a negation method and didn’t use it when performing subtraction. That’s because the negation method simply ignores undefined components, while addition and subtraction require treating undefined component values as 0. The negation method comes in handy in other scenarios, which I’ll show later.

Now that we’ve got date component addition, subtraction, and negation defined, let’s extend the Int type so that it has some instance properties that let us define components with statements like 5.seconds, 3.minutes, 7.hours, 2.days, 4.weeks, and so on:

Once again, I derived these functions from Axel Schlueter’s SwiftDateTimeExtensions library and added a couple of tweaks of my own.

There’s a little redundancy in the code above; it’s to allow for grammatically correct code. I didn’t like seeing code like 1.seconds, 1.minutes, 1.hours, 1.days, and so on.

With the date component addition and subtraction overloads and the extension to Int, building date components that represent time intervals is far less tedious:

With all our tweaks, adding components to dates using NSCalendar‘s dateByAddingComponents feels clunky by comparison. Here are some operator overloads that make this sort of coding more elegant if you’re working with dates and date components expressed in terms of the user’s current calendar:

With these methods, date arithmetic now looks like this:

That code is so much more pleasant to read (and write!).

And finally, a Ruby on Rails trick comes to Swift

Ruby on Rails lets you do very readable calculations like 2.days.from_now and 2.days.ago. We can bring that Rails magic to Swift by using everything we’ve build so far and extending NSDateComponents with two computer properties:

Equipped with everything we’ve made, we can now write code like this:

The entire playground

And with that. we’ve got a more Swift-like way of doing date arithmetic. I’m going to take all these methods and extensions and post them as a library on GitHub, but in the meantime, here’s the complete playground for the exercises in this article. Go forth and write some readable date/time code!


delete my browser history shirt 2

You’d think that a wizard would know about “Privacy Mode” (which I sometimes refer to as “porn mode”), but I suppose one doesn’t pick up that sort of thing when one is on a mission to save Middle Earth.

This T-shirt is available right now for $15 plus free shipping at Woot!

How to delete your wizard friend’s (yeah, right) browser history

delete my browser history shirt

Should a wizard ever ask you to do him this favor, here’s how you do it. The instructions for Chrome, Firefox, and IE come straight from Woot!’s page for the T-shirt, and the instructions for Safari on Mac OS come from Yours Truly.

Instructions for Chrome:

  1. Open your browser
  2. Click the Chrome button in the top-right of the browser window
  3. Select History
  4. Click the Clear browsing data button
  5. From the drop down, select the duration of time you want to delete from your history. To delete all history, select the beginning of time
  6. Check the boxes of the data you would like to delete, including Browsing history and Download history
  7. Click the Clear browsing data button
  8. Slay balrog

For Mozilla Firefox:

  1. Open your browser
  2. Click the menu button in the top-right of the browser window
  3. Select History, then Clear Recent History
  4. Select the time range to clear. To clear all browser history, select Everything
  5. Click Clear Now
  6. Return to Middle Earth as angelic white wizard

For Internet Explorer:

  1. Open your browser
  2. Click the Tools button in the top-right of the browser window
  3. Select Safety, then Delete Browsing History
  4. Check the boxes of the data you would like to delete, including Temporary Internet files and website files, History and Download History
  5. Un-check Preserve favorite website data
  6. Click Delete
  7. Ride forth upon Shadowfax and lead the Rohirrim to victory at Hornburg

For Safari (on Mac OS)

  1. Open your browser
  2. Select Clear History… from the History menu
  3. Click Clear when the Are you sure you want to clear history? dialog appears
  4. Open Preferences by either selecting Preferences… from the Safari menu or typing ⌘, (the “command” and “,” keys simultaneously)
  5. Select the Privacy tab and click Remove all website data…
  6. Click Remove Now when the Are you sure you want to remove all data stored by websites on your computer? dialog appears
  7. Evade the omnipresent glance of the Eye of Sauron