Programmer quote of the day

by Joey deVilla on September 22, 2014

date time coding

Joe Wright wins the internets today:

Thanks to Leigh Honeywell for the find!

{ 0 comments }

The post-opening weekend iPhone 6 / 6 Plus news roundup

by Joey deVilla on September 22, 2014

A record-breaking 10 million iPhone 6 / 6 Plus units sold on opening weekend

ten million iphones

Apple announced that it sold over 10 million iPhone 6 and iPhone 6 Plus smartphones in the first three days of their general availability in the U.S., Australia, Canada, France, Germany, Hong Kong, Japan, Puerto Rico, Singapore, and the U.K. (China is notably absent from this list; the new iPhones will go on sale there later this year).

“Sales for iPhone 6 and iPhone 6 Plus exceeded our expectations for the launch weekend,” said Apple CEO Tim Cook in Apple’s press release, “and we couldn’t be happier.”

tampa apple store sept 20 2014

The crowd at the Apple Store in Tampa, Saturday, September 20, 2014.
Click the photo to see it at full size.

A couple of observations about that 10 million number

Farhad Manjoo, tech journalist at the New York Times, made a couple of observations about this news and the milestone of selling 10 million units. First, about the difference between this year’s iPhone 6 / 6 Plus release and last year’s iPhone 5S / 5C release…

…and secondly, about the difference in expectations between this year and 2007, the year the iPhone was first released:

The first iPhone 6 retail purchase and drop on the sidewalk, caught on video

Thanks to the magic of time zones, the first in-store iPhone purchase was made in Perth, Australia by Jack Cooksey. He also made his way into the record books by being the first person to drop a newly-purchased iPhone 6:

AnandTech posts their preliminary iPhone 6 / 6 Plus benchmark performance tests

iphone 6 sunspider

Anandtech say that they’re still working on their full review of the iPhone 6 and 6 Plus, but have decided to sate the public appetite for iPhone 6-related news by releasing some of the results of their benchmark performance tests. Among the results they posted were their browser benchmarks, which they say “can serve as a relatively useful proxy for CPU performance”. The numbers are good, with the iPhone 6 placing at or near the top of most tests.

iphone 6 google octane

The only exception to Apple doing very well on the benchmarks was the 3DMark 1.2 Unlimited – Physics test, where it placed near the bottom:

iphone 6 3dmark physics

Of note is the iPhone 6′s battery life in the tests:

iphone 6 web browsing battery life

AnandTech write:

\As one can see, it seems that Apple has managed to do something quite incredible with battery life. Normally an 1810 mAh battery with 3.82V nominal voltage would be quite a poor performer, but the iPhone 6 is a step above just about every other Android smartphone on the market.

Simply put, Apple know their power management, and for you, that means more bang for the battery.

Businessweek’s post-presentation interview with Tim Cook

tim cook and iphone 6 plus

Bloomberg Businessweek has posted their interview with Tim Cook about the iPhone 6 and the Apple Watch that they made on the day after their September 10th presentation.

Photos in different lands — Iceland and Disneyland — with the iPhone 6

austin mann iphone 6 photo

Smartphones aren’t just for work, but for the rest of your life, including being your primary camera. The iPhone 6 seems to be an excellent camera for not just personal snapshots as shown when TechCrunch took two to Disneyland (example below), but even for professional work as the photos of Iceland by Austin Mann (an example of which is shown above).

techcrunch disneyland

this article also appears in the GSG blog

{ 0 comments }

Swift/iOS developer tutorials of note

by Joey deVilla on September 22, 2014

swift kick

Even though the new iOS and new iPhones have finally been released, it’s still the early days of the iOS 8/Swift era. The language is still evolving, people are still trying to figure out how to best make use of its features, and there are no veterans. It’s not too late for you to get started with iOS development.

In this article, I’ll look at some Swift/iOS 8 tutorials of note, including one that I’ll be reviewing regularly.

Before you begin: Xcode 6.0.1 now available!

xcode iconYou may have missed it amidst all the hoopla about the new iPhones and upcoming Apple Watch: Xcode has already undergone its first post-iOS 8 update. Xcode 6.0.1 was released on Wednesday, September 17th – get it now!

The iOS Apprentice, Third Edition

ios apprentice swift edition

When people ask me the question “What tutorial would you recommend for getting started with iOS programming?”, my answer is consistently The iOS Apprentice, published by RayWenderlich.com and written by Matthijs Hollemans. I recommend it to both people who are completely new to programming, as well as experienced developers who want to get the hang of iOS programming.

In 4 tutorials spanning 900 pages, Matthijs takes the reader from building a simple “Hello World” app and through all sorts of iOS development topics from UI controls to common iOS design patterns to working with location and mapping to storing data to accessing web services and more. The iOS Apprentice is written in a casual style and packed with screenshots and illustrations to make sure that you get the point. The third edition has been rewritten for programming in Swift and using the iOS 8 SDK, he also covers the Swift programming language.  With the tutorials, you also get each app’s full source code and assets, which you can reuse in your own apps.

Part 1 of the third edition is available right now, and it’s free if you subscribe to RayWenderlich.com’s newsletter. You have to buy The iOS Apprentice to get parts 2 through 4, and the third edition of these parts will become available in the coming weeks (in the meantime, you’ll be able to get the 2nd edition, which is in Objective-C and covers iOS 7′s SDK).

All four parts of The iOS Apprentice are a great deal at $54, and it was helped me get up to speed with iOS programming very quickly. I can’t recommend it highly enough. Bonus: If you bought an earlier edition of The iOS Apprentice, you get the third edition for free!

Find out more about The iOS Apprentice on its page at RayWenderlich.com.

(By the bye, you should check out RayWenderlich.com regularly; it’s a great source of iOS programming info.)

Swift for Rubyists / Swift for JavaScript Developers

If Ruby is your native tongue, JP Simard (an iOS developer at Realm) can help ease you into Swift programming in his 50-minutes-and-change session titled Swift for Rubyists. The video above is only part of the experience; you should go to the Swift for Rubyists blog entry on Realm’s site where you can see the video synced up with his slides and read the transcript of his presentation, complete with code.

If you’re more comfortable with JavaScript, JP also gave a presentation of Swift for JavaScript developers. It’s from the end of July, and while some details may have changed between then and Swift 1.0, most of it should still be applicable today.

(You might also want to check out Realm itself; it’s a mobile database and API that replaces Core Data and SQLite. They’re also working on an Android version.)

Free Swift/iOS game programming tutorial

swiftris

Bloc, “the world’s largest online bootcamp”, offers a free tutorial in which you learn iOS game programming in Swift and Sprite Kit by building Swiftris (pictured above), a version of the classic game Tetris.

I’ll be your guinea pig: Going through Rob Percival’s “Complete iOS 8 and Swift Course”

rob percival udemy course

Rob Percival’s courses on Udemy have an impressive number of five-star ratings. His Complete Web Developer Course has over 900 five-star reviews, and his iOS 7/Objective-C course has earned rave reviews. He’s updated his iOS course, which is now called The Complete iOS 8 and Swift Course, which makes the claim of being “THE most comprehensive, cost-effective and career-enhancing mobile app development course you’ll find on the web – or your money back.”

In the course, you learn iOS 8 and Swift development by building “15 Real World Apps” over 145 lectures and over 19 hours of content, starting from the basics and working your way up to building clones of Instagram and Snapchat. He even throws in some very tempting extras, including:

  • A tutorial on loading OS X and Xcode on a Wintel machine so you don’t need to use a Mac
  • Unlimited web hosting for one year (“worth $200″) and a WordPress tutorial so that you can set up a site with which to promote your apps
  • A copy of his ebook, How to Earn $10,000 While Learning to Code
  • Over 1,000 graphical assets (“worth $300″) to use in your own apps

If you’ve every stumbled across an ad for the course or the page for the course itself, you may have wondered “Is this course everything it claims to be?”. I’ve wondered myself, and I’ve decided to give it a try. I signed up for the course (thanks to a very short-lived deal where it was available for a mere $29) and will go through every lesson, lecture, and exercise. I’ll report my findings regularly here on Global Nerdy.

{ 0 comments }

test tubes

Clinical laboratories today are experiencing the most financial pressure they’ve had to face in the past twenty-five years. Their line of work requires the use specialized equipment that’s only been getting more expensive. With hospitals making less for each inpatient and insurers are paying labs less for their work, the clinical lab industry is expected to face yearly cuts in budgets and revenue for the next few years while maintaining quality of service.

Our client, whom we’ll refer to as “The Client”, is a provider of clinical laboratory services used by doctors, hospitals, insurers, and other organizations that rely on lab results for diagnoses and decision-making. The Client was facing the following challenges:

  • They had no centralized view of their mobile communications spending, which amounted to $618,000 a month

  • They had no idea of how much money was being lost as a consequence of out-of-control voice and text usage

  • They were are incurring costs from excess operational resources used in trying to manage their mobile spending

The Client decided to make the the transition from corporate-liable to BYOD, moving their executives from company-owned mobile devices to using their personally-owned ones for work, to connect to corporate resources such as email, contacts, and calendar, and well as other online systems. Implementing a BYOD program was outside their IT department’s skill set, so they brought in GSG to help with the process.

With a BYOD program enabled through the GSGCloud platform, The Client was able to:

  • Achieve 19% in overall savings, translating to $188 in annualized savings per device
  • Rein in out-of-control mobile usage
  • Free up resources that were devoted to managing the excess spending brought about by out-of-control mobile usage
  • Develop and standardize a BYOD policy, and track and ensure compliance

download pdf

Download our case study [2.6MB PDF] to find out how we helped a healthcare business make the switch to BYOD and reduced their mobile expenses by $1.7 million a year.

this article also appears in the GSG blog

{ 0 comments }

programmer

oreilly programming books

Its’ the 256th day of the year, which means it’s Programmer’s Day!

O’Reilly’s Programmer’s Day ebook and video sale

It may not be any sort of official holiday, but since 256 is the largest power of two that’ll fit into 365, it’s as good an excuse as any. O’Reilly are celebrating — any by “celebrating”, I mean moving some inventory — by having a one-day sale on all programming ebooks and video training. When you check out, use the discount code PROGDY at checkout to get the half-off deal. The offer is available until Sunday, September 14th at 5 a.m. Pacific (8 a.m. Eastern).

Cocktails for Programmer’s Day

severe perl

GitHub isn’t just for code — sometimes you can find recipes there too! Cocktails for Programmers is a GitHub repo featuring recipes for cocktails based on programmers’ lives (and no, they’re not virgin cocktails, thank you very much). The two that sound most appealing to me are the Severe Perl (gin, sweet vermouth, lemon juice, simple syrup) and the Python (white rum, mint liqueur, pineapple juice, lemon juice, Sprite or 7-Up).

python cocktail

{ 0 comments }

iPhone 6 news for people who work for a living

by Joey deVilla on September 12, 2014

iphone 6
You’ll find all sorts of articles about the iPhone 6 and iPhone 6 Plus online right now, and you should expect more this weekend. A good number of them will talk about the underlying hardware, iOS 8′s features, how the new phones will stack up against Samsung and other Android offerings, previews of the games, and so on. We’ll leave other people to cover those topics for now — let’s talk about what matters to those of us who work for a living.

Who’s got the iPhone 6 / iPhone 6 Plus deals?

iphone 6 and iphone 6 plus

The newest iPhones — the iPhone 6 and 6 Plus – are available for online pre-order as of this writing (Friday, September 12th), but that doesn’t mean they’ll be easy to come by. There are reports that Apple’s servers were overloaded by incoming visitors eager to get their latest and greatest, and AT&T are reporting that the demand for iPhones is higher than it’s been for the past two years.

If getting one sooner than later is important to you, you’ll want to order the smaller iPhone 6, as the iPhone 6 Plus seems to be in greater demand and has been selling out. You can also try your luck at your local Apple Store, which will start carrying them next Friday, September 19th.

verizon Verizon are offering a $200 gift card, the price of entry-level 16GB iPhone 6 with a two-year contract, if you bring an iPhone 4 or 4s for trade-in. As TIME notes, this is a better deal than the one you’ll get at Apple; they’re offering $60 for a trade-in of an iPhone 4 in good condition.

att jpg If you register a new iPhone with AT&T’s Next plan by September 30th, whether you’re a new or current customer, AT&T will give you a $100 credit on your mobile bill. They’ll also buy your old iPhone for up to $300, which you can apply to a purchase of an iPhone 6 or 6 Plus.

sprint Sprint will beat any trade-in offer on the iPhone 6 or 6 plus from a major carrier, and they’ll pay up to $350 per line if you switch to them. They’re also offering a new plan specifically for iPhone 6/6 Plus customers with unlimited voice, text, and data for $50 a month.

t-mobile T-Mobile is also taking the “find an iPhone trade-in deal and we’ll match it” tack and sweetening it with an additional $50 credit on your bill, plus up to $350 for switching.

walmart If you’re on a budget but still want the new iDevices, Walmart will sell the base versions of the 6 and 6 Plus at a $20 discount; Sam’s Club will add an extra $2 to that discount.

Will you be able to use the iPhone 6/6 Plus (or any iDevice running iOS 8) at work?

The answer is: probably, but definitely if you work at a place where your devices are being managed using SAP’s systems.

SAP logoSAP have announced that their SAP® Mobile Platform SAP Mobile Secure portfolio and mobile apps will support the upcoming iPhone 6 devices and iOS 8 operating system. This isn’t unexpected, given iOS’ commanding share of apps and tablets in the enterprise and the fact that the lion’s share of its users run the current OS version.

From their press release:

Many of the new enterprise features within iOS 8 can benefit SAP customers eager to adopt corporate security requirements such as single sign-on, per-app VPN and app configuration. SAP has validated iOS 8 for apps running on SAP Mobile Platform and plans to further enhance support with upcoming releases of the software development kit (SDK) for SAP Mobile Platform. Companies can mobilize their business with SAP Mobile Platform by quickly building, deploying and securely managing apps for employees, customers and partners. The new harmonized API is available for consuming online and offline data and will be compatible with Swift programming language for developing mobile applications.

“With mobile playing a critical role in helping to simplify business we constantly expand the ability for our employees to manage all their work needs on any device, as early as possible,” said Michael Golz, CIO, SAP Americas. “At SAP we support more than 66,600 iPhones and iPads used by our employees worldwide. Our teams continue to offer the same support for deploying the iPhone 6 and iOS 8 as we have in the past. The SAP Mobile Secure portfolio will support all of the company’s devices as well as employees’ own devices. A top concern with deploying new devices is security, so it is imperative that our complete mobile portfolio is ready for the new iOS 8 on day one.”

What about the iWatch?

apple watch

TechRepublic says that we should expect the Apple Watch to be “in heavy BYOD demand from Day One”. We won’t know how well it’ll sell when it’s released early next year, but considering Apple’s cachet in the enterprise and that the Watch’s target market is the executive class, it’s likely to find its way into business IT; first by being snuck in, and then openly.

Hey, I work for a living and I’d still like to watch the Apple presentation. Where can I do this?

If you tried to catch the streaming broadcast of Apple’s September 9th announcement, you were treated to this image and no sound for a long time:

tv truck schedule

In limiting the streaming to only those people with Macs (and even then, only if you use Safari), Apple TVs, and iDevices, Apple missed out on a big opportunity, as Anthony Leather points out in his article in Forbes:

…by far worst thing that happened on Tuesday was Apple’s shortsightedness at restricting viewing to Safari users, namely iPhone and iPad owners. The iPhone 6 represents the biggest changes to the iPhone perhaps since its inception and it enters a market that’s a little stagnant in terms of new features. This was a massive opportunity for Apple to tempt Android users away from their Samsungs and HTC’s with a bigger screen and plenty of other unique features besides.

After the fact, Apple posted the full video for their presentation, which I’ve included below. Be warned: it’s long. As in 2 hours, 3 minutes, and 25 seconds long. You’ll either want to fast-forward through the slow bits, or spread this out over a few lunches at your desk:

If you don’t have the two hours to spare, The Verge have got you covered. They condensed it down to a coffee-break-friendly 11 minutes in a video titled, appropriately enough, The Apple Keynote in 11 Minutes:

If you can’t get enough Apple promos, they’ve posted a number of videos to coincide with the iPhone 6, iPhone 6 Plus, and Apple Watch on their YouTube channel.

this article also appears in the GSG blog

{ 0 comments }

a simple shoot em up game

swift kickThis article is part two in a series that looks at a simple “Shoot ‘Em Up”-style game for iOS written using Sprite Kit and Swift. If you missed the first installment, which provides the complete code, the necessary graphics and sound resources, as well as instructions for assembly, it’s here.

In this article, we’ll look at:

  • How the code is organized, both in the way it’s ordered, and through the use of MARK: comments, and
  • The operator overloads and extensions to CGPoint that support vector math

How the code is organized, and those MARK: comments

The code in the Simple Shoot ‘Em Up game is divided into two major sections:

  1. A set of operator overrides and extension properties for doing vector math on CGPoints
  2. The GameScene class, which defines the entire game

The GameScene class is divided into three subsections:

  1. Properties
  2. Event-handling methods
  3. Game state methods

Each section is marked with a MARK: comment. If you’re familiar with iOS development with Objective-C, // MARK: is Swift’s answer to good ol’ #pragma mark. If you’re not familiar with #pragma mark, read on…

Organizing code with MARK: comments

There’s a jump bar at the top of every editor window in Xcode, which makes it easy to navigate throughout your project. If you’re editing the GameScene.swift file (go edit it right now if you’re not), it should look like this:

jump bar

Click on the part of the jump bar just to the right of GameScene.swift, as shown below:

click on the jump bar

A menu will appear. It will display the various named entities — functions, classes, properties, methods, and so on — inside GameScene.swift:

jump list menu

You might notice that the menu lists the entities in the order in which they appear in the code, and that they’ve been organized into the following sections. You’ll see that:

  • There’s a line above each major section: one for the vector math stuff, and one for the GameScene class, and
  • The code has named sections, namely:
    • Vector math operators and CGPoint extensions: A set of operator overloads and extension properties to allow for vector math on CGPoints.
    • Properties: Properties of the GameScene class.
    • Events: Methods that respond to events.
    • Game state: Methods that change the game state.

These divisions were created using MARK: comments:

  • The Properties, Events, and Game state sections were created using the comments // MARK: Properties, // MARK: Events, and // MARK: Game state respectively,
  • The Vector math operators and CGPoint extensions section, complete with a line above it, was created using the comment // MARK: - Vector math operators and CGPoint extensions. Note the - (minus sign) that comes between // MARK: and the section name.
  • The dividing line separating the vector math stuff and the GameScene class was created with the comment // MARK: - — that is, // MARK: followed by a - (minus sign with nothing after it).

Using // MARK: and its Objective-C cousin, #pragma mark to organize your code is a good habit to take up.

Vector math

In the game, the player’s ship remains stationary and dead-center at the bottom of the screen. The player shoots at the aliens passing overhead by tapping on the screen, and the ship fires shots in the direction of that tap:

vector 1

In order to program this action, we’ll need to make use of vector math.

Before we begin: Sprite Kit’s coordinate system

Most UI and computer graphics programming systems have their origin at the upper right-hand corner of the screen, with X increasing as you go rightward, and Y increasing as you go downward. Sprite Kit is based on OpenGL, which uses the same coordinate system that you use in math, with X increasing as you go rightward, and Y increasing as you go upward:

origin

With this coordinate system, the origin (0, 0) is located at the lower left-hand corner of the screen rather than the upper left-hand corner.

Vectors and points

An ordered pair (x, y) can represent:

  • A point located at (x, y), or
  • A vector that starts at (0, 0) and ends at the point (x, y)

vector 2

We’re going to use the connection between point coordinates and vector coordinates to create some overloads and extensions that will help simplify programming our game.

Vector addition

The first overload we’ll implement will allow us to add two vectors together, as pictured below:

vector 3

If you take a vector (x1, y1) and add another vector (x2, y2) to it, the resulting vector is (x1 + x2, y1 + y2).

In Swift, we’ll implement vector addition by taking advantage of the point coordinate/vector coordinate connection and use CGPoints to represent vectors. As a result, our vector addition overload of the + operator takes two CGPoints (x1y1) and (x2y2), and returns the vector sum (x1 + x2y1 + y2):

// Vector addition
private func + (left: CGPoint, right: CGPoint) -> CGPoint {
  return CGPoint(x: left.x + right.x, y: left.y + right.y)
}

With this overload, you can add any two vectors represented by CGPoints just by adding them with the + operator.

Vector subtraction

It’s easy to picture vector addition, but it’s a little harder to picture vector subtraction. The diagram below should help:

vector 4

Subtracting a vector is easy to see in equation form: taking a vector (x1y1) and subtracting another vector (x2y2) gives you a resulting vector (x1 – x2y1 – y2). Here’s our game’s implementation of vector subtraction:

// Vector subtraction
private func -(left: CGPoint, right: CGPoint) -> CGPoint {
  return CGPoint(x: left.x - right.x, y: left.y - right.y)
}

This overload lets you subtract a vector represented by a CGPoint from another vector represented by a CGPoint through the use of the - operator.

Vector multiplied by a scalar

Multiplying a vector by a scalar preserves the vector’s direction, but changes its magnitude:

vector 5

Multiplying a vector (xy) by a scalar k gives you the resulting vector (kx, ky). Here’s how we implement vector-scalar multiplication in our game:

// Vector * scalar
private func *(point: CGPoint, factor: CGFloat) -> CGPoint {
  return CGPoint(x: point.x * factor, y:point.y * factor)
}

With this overload, you use the * operator to multiply a vector represented by a CGPoint by a scalar factor represented by a CGFloat. Note that order is very important in this operation: the first operand must be the vector, and the second operand must be the scalar — it won’t work the other way around!

Length of a vector and normalizing a vector

We’ll need to get the length of a vector, and for that we’ll use the Pythagorean theorem:

vector 6

Being able to get the length of a vector will come in handy when we want to normalize it. By “normalizing”, we mean preserving its direction, but changing its length to 1:

vector 7

I wrote an extension to the CGPoint struct that provides two properties:

  • length, which returns the length of a vector represented by a CGPoint, and
  • normalized, which returns a CGPoint representing 1-unit-long vector that has the same direction as the vector in question.

Here’s the code:

private extension CGPoint {
  // Get the length (a.k.a. magnitude) of the vector
  var length: CGFloat { return sqrt(self.x * self.x + self.y * self.y) }
   
  // Normalize the vector (preserve its direction, but change its magnitude to 1)
  var normalized: CGPoint { return CGPoint(x: self.x / self.length, y: self.y / self.length) }
}

Next steps

With the code organization explained and the vector math taken care of, we’ll cover the actual workings of the game in the next installment.

{ 0 comments }