Categories
Humor Programming

Demonstrating map, filter, and reduce in Swift using food emoji

In my last article, I posted this graphic, which uses emoji to make it easier to understand what the map, filter, and reduce functions do:

map filter reduce in emoji

Since then, I’ve been asked by a couple of friends if what’s in the graphic is just pseudocode or if it could actually be implemented. I told them it was the latter, and here’s my implementation in Swift:

// Map

func cook(_ item: String) -> String {
  let cookupTable = [
    "🐮": "🍔", // Cow face -> burger
    "🐄": "🍔", // Cow -> burger
    "🐂": "🍖", // Ox -> meat on bone
    "🐷": "🍖", // Pig face -> meat on bone
    "🐽": "🍖", // Pig nose -> meat on bone
    "🐖": "🍖", // Pig -> meat on bone
    "🐑": "🍖", // Sheep -> meat on bone
    "🐐": "🍖", // Goat -> meat on bone
    "🐔": "🍗", // Chicken -> poultry leg
    "🦃": "🍗", // Turkey -> poultry leg
    "🐸": "🍗", // Frog  -> poultry leg (no frog leg emoji...yet)
    "🐟": "🍣", // Fish -> sushi
    "🐠": "🍣", // Tropical fish -> sushi
    "🐡": "🍣", // Blowfish -> sushi
    "🐙": "🍣", // Octopus -> sushi
    "🍠": "🍟", // (Sweet) potato -> French fries
    "🌽": "🍿", // Corn -> popcorn
    "🌾": "🍚", // Rice -> cooked rice
    "🍓": "🍰", // Strawberry -> shortcake
    "🍂": "🍵", // Dried leaves -> tea
  ]
  if let cookedFood = cookupTable[item] {
    return cookedFood
  }
  else {
    return "🍽" // Empty plate
  }
}

let cookedFood = ( ["🐮", "🍠", "⚽️", "🐔", "🌽"].map { cook($0) } )
// cookedFood == ["🍔", "🍟", "🍽", "🍗", "🍿"]


// Filter

func isVegetarian(_ item: String) -> Bool {
  let vegetarianDishes = Set([
    "🍟", // French fries
    "🍿", // Popcorn
    "🍚", // Cooked rice
    "🍰", // Shortcake
    "🍵", // Tea
  ])
  return vegetarianDishes.contains(item)
}

let meatFree = ["🍔", "🍖", "🍟", "🍽", "🍗", "🍿", "🍰"].filter { isVegetarian($0) }
// meatFree == ["🍟", "🍿", "🍰"]


// Reduce

func eat(_ previous: String, _ current: String) -> String {
  let qualifyingFood = Set([
    "🍔", // Burger
    "🍖", // Meat on bone
    "🍗", // Poultry leg
    "🍣", // Sushi
    "🍟", // French fries
    "🍿", // Popcorn
    "🍚", // Cooked rice
    "🍰", // Shortcake
  ])
  if (previous == "" || previous == "💩") && qualifyingFood.contains(current) {
    return "💩" // Poop
  }
  else {
    return ""
  }
}

let aftermath = ["🍔", "🍟", "🍗", "🍿"].reduce("", combine: eat)
// aftermath == "💩"

I put this into a Swift playground, which you can copy from this Gist or download here.

Categories
Uncategorized

Map, filter, and reduce explained using emoji

Picture showing three functions: 1. the map function taking an array containing the cow face, roasted sweet potato, chicken, and ear of maize emojis and the cook function as its arguments and returning an array containing the cheeseburger, french fries, poultry legs and popcorn emojis; 2. the filter function taking an array containing the cheeseburger, french fries, poultry legs and popcorn emojis and the isVegetarian functions as its arguments and returning an array containing the french fries and popcorn emojis; 3. The reduce function taking an array containing the cheeseburger, french fries, poultry legs and popcorn emojis and the eat function as its arguments and returning the pile of poo emoji as its result.

Click the graphic to see it at full size.

I made the graphic above based on this amazing tweet by Steven Luscher (@steveluscher):

It’s a geeky t-shirt waiting to happen.

Categories
Uncategorized

Amy Poehler on…coding?

everyone lies about writing

yes please

This is from the preface of Amy Poehler’s book Yes Please, and it tells the truth about writing:

Everyone lies about writing. They lie about how easy it is or how hard it was. They perpetuate a romantic idea that writing is some beautiful experience that takes place in an architectural room filled with leather novels and chai tea. They talk about their ‘morning ritual’ and how they ‘dress for writing’ and the cabin in Big Sur where they go to ‘be alone’—blah blah blah. No one tells the truth about writing a book. Authors pretend their stories were always shiny and perfect and just waiting to be written. The truth is, writing is this: hard and boring and occasionally great but usually not. Even I have lied about writing. I have told people that writing this book has been like brushing away dirt from a fossil. What a load of shit. It has been like hacking away at a freezer with a screwdriver.

Coding is romanticized in the same way these days, thanks to the tech success stories we hear in the news, the increasing ubiquity of processors and the rise of the Internet of Things, concerns about job security and being “automated away”…and possibly because coding looks a lot like writing. “You must learn to code!” has been the battle cry of the White House, organizations like Code.org, tech titans, millennial entrepreneurs, and even that homeless guy:

I understand the urge to evangelize coding; in fact, it’s been a good chunk of my career. There’s nothing like the feeling you get when you run a program that you’ve written and seeing a computer or device turn your ideas into action. Even after coding for decades, I still give myself a Barney Stinson-style “self-five” when my code compiles and runs as I expect.

programmer punching through laptop screen

But as with writing, between the initial rush of setting out to code a program and the point that you declare the job done is a long journey of days, months, and even years. That journey has its moments of joy, discovery and wonder, but they’re punctuated with stretches of tedium, toil, and beating your head against your desk (usually figuratively, but sometimes literally) wondering why you can’t get the damned code to work. Like many writing projects, both professional and personal, many coding projects are abandoned. Writing and coding projects are never really finished; “done” is an arbitrary point determined by the writer or coder, and both are left with a lingering feeling that their project could benefit from just a few more changes. And that homeless coder is still homeless:

Thanks to the similarity between writing and coding, I’ve occasionally paraphrased Dorothy Parker: “I hate programming, but I love having programmed.

web horizontal rule

Want a coding-themed blast from the past featuring Amy Poehler? Here’s the pilot for a ’90s TV series called RVTV, in which Poehler plays a hacker who’s infiltrated the NRA database. She also breaks into some old-school rap:

Categories
Uncategorized

Next Tampa iOS Meetup on June 28th: What’s new in iOS 10 and Swift 3.0

what's new in iOS 10 and swift 3

The next Tampa iOS Meetup has been announced for Tuesday, June 28th at 6:30 p.m., and we’re going to talk about the announcements made at this week’s Apple Worldwide Developers Conference, with special attention to iOS 10 and Swift 3.0. It takes place at our usual spot: Energy Sense Finance, 3825 Henderson Boulevard (just west of Dale Mabry), Suite 300.

At the meetup, we’ll:

  • Present a review of what was announced at WWDC, with a particular focus on iOS and tvOS development
  • Show you how to get your hands on the beta software, including Xcode 8 and iOS 10
  • Take a look at the changes introduced in Swift 3, with an emphasis on where you may have to update your existing code
  • Talk about what you’d like to see in upcoming Tampa iOS Meetup sessions

Join us on the 28th, get to know your fellow Tampa Bay iOS developers, and get ready to learn and have some fun!

Tampa iOS Meetup is a monthly meetup run by local mobile developer/designer Angela Don and Yours Truly. While Tampa has a couple of great iOS developer meetups — Craig Clayton’s Suncoast iOS and Chris Woodard’s Tampa Bay Cocoaheads, we figured that there was room for a third iOS meetup in the Tampa Bay area, and especially one that would stray into other areas of mobile development. So we made one.

The Details

  • What: Tampa iOS’ Meetup’s “What’s new in iOS 10 and Swift 3.0” session. Please sign up on our Meetup page so we can plan accordingly!
  • When: Tuesday, June 28, 2016, 6:30 p.m. – 8:30 p.m. We’ll have some snacks at 6:30, with the presentation beginning at 7:00.
  • Where: Energy Sense Finance, 3825 Henderson Boulevard (just west of Dale Mabry), Suite 300. See the map below.
  • What to bring: Yourself, but if you’d like to follow along, bring your Macbook and make sure it’s got the latest Xcode.
  • What to read in advance: If you’re one of those people who likes to do some readings ahead of a presentation, check out What’s New in Swift 3? by the folks at RayWenderlich.com.
Categories
Uncategorized

OpenHack Ybor tonight!

IMG_2475

If you’re a developer or tech-minded person in the Tampa Bay area and you’re looking for some fun conversation this evening, join us tonight from 6:30 to 9:00 at New World Brewery in Ybor City for Ybor Tech’s June OpenHack!

ybor tech

OpenHack Ybor, held once a month, is run by local Ruby developer Tony Winn and Jessica Arango for techies of all stripes who want to get to know their local peers, see what they’re up to, and enjoy some craft beer and free pizza.

IMG_2476

We usually gather on the patio of New World Brewery, a brewery-turned-bar in Ybor City, Tampa’s historic warehouse district that was once home to a large cigar-making industry and is now one of those hip mixed-use areas with schools, offices, bars, restaurants, and alas, the Church of Scientology. You can’t win ’em all.

IMG_2477

Some of us are just happy to converse, and some of us like to pull out our computers and show off their latest project or gear. Either approach works just fine, and Tony usually brings a wifi hotspot for those of you who need to get online. There are tables a plenty to “set up shop”, and the covered part of the patio has outlets.

I’d be remiss if I didn’t mention New World’s excellent selection of beers…

IMG_2478

…and for you Marvel/pinball fans, their current selection of distractions is pretty nice too:

IMG_2474

It’s also worth mentioning that whoever’s in charge of the music at New World has eclectic, excellent taste.

openhack at new world brewery wide

Click the photo to see it at full size.

There aren’t many better ways to enjoy the fantastic and fabulous Ybor City and our sub-tropical paradise while having great conversation and drinks with your fellow Tampa Bay area geeks than hanging out at an Ybor Tech OpenHack. Come on down — we’d love to see you there!

web horizontal rule

Need more details? Visit Ybor Tech’s June OpenHack event page.

Categories
Uncategorized

Microsoft adds LinkedIn to its professional network

microsoft acquires linkedin

Microsoft CEO Satya Nadella announced it to his employees in this company-wide email, and LinkedIn CEO Jeff Weiner did the same with his employees: they announced that Microsoft is acquiring LinkedIn for $26.2 billion in a pure cash transaction.

Here’s a short (1:43) video of Nadella and Weiner in a Microsoft-produced interview where they talk about the acquisition:

The video ends with the two companies’ mission statements:

linkedin microsoft mission statements

And they are:

  • LinkedIn: To connect the world’s professionals to make them more productive and successful.
  • Microsoft: To empower every person and every organization on the planet to achieve more.

They’re pretty similar, and if LinkedIn and Microsoft’s really follow (or at least act as if they’re following) their respective mission statements, then the acquisition makes sense: these are two companies chasing roughly the same goal, one via productivity software and cloud services, and one via social networking. Jeff Weiner said pretty much the same thing in this interview with TIME: “Essentially, we’re both trying to do the same thing but coming at it from two different places.”

Here’s my summary of who gets what in this deal. Keep in mind that I’m an opinionated developer evangelist and not a professional industry analyst. Take this with the appropriately-sized grain of salt:

microsoft linkedin acquisition possible outcomes

  • LinkedIn will eventually be hosted on Azure, giving Microsoft another success story they can point to when trying to convince people to host their stuff on their cloud platform.
  • Office gets LinkedIn’s social graph, which will likely be tied into various services:
    • Finding people: Active Directory, Bing
    • Communicating: Outlook, Skype/Skype for Business
    • Coordination people: Outlook, Project, Dynamics
    • A new source of data points for Cortana
  • The number one slideware, PowerPoint, gets tied into the number one way to share slides online, SlideShare.
  • LinkedIn gets the resources of a parent with plenty in the bank, which is a relief after the beating investors gave it earlier this year
  • Microsoft hopes to strengthen its ties with the working world, which has been looking to other places for solutions

microsoft and linkedin graphs

Professional Microsoft watcher Mary Jo Foley points to the above image from Microsoft, and says that the two companies’ graphs are disjoint, and putting them together into a unified dataset opens a world of opportunities.

cancelled linkedin wwdc watch party

One interesting side effect of the acquisition: LinkedIn’s “WWDC Watching Party” — a gathering where people could get together to watch Apple’s Worldwide Developer Conference on big screens at LinkedIn’s San Francisco office  — was cancelled. What’s still on is the Microsoft WWDC afterparty, held next door to WWDC, where they’re offering free food and drinks, and showing off their Xamarin IDE and Test Cloud, two recently-acquired Microsoft products that they’re hoping to get iOS developers to start using.

Categories
Uncategorized

How to watch or follow the WWDC 16 live keynote

hello wwdc16

Once again, it’s time for one of the biggest tech events of the year: Apple’s WWDC, short for World Wide Developer Conference, taking place on Monday, June 13, 2016 at 10:00 a.m. Pacific / 1:00 p.m. Eastern. It’s a conference for people who develop for Apple’s various platforms, and it starts with a layperson-friendly keynote featuring big announcements. Here are some of the goodies that Apple’s announced at WWDCs past:

  • 2014: The Swift programming language
  • 2012: Apple Maps
  • 2010: iPhone 4
  • 2009: iPhone 3GS, iOS 3, and Find My iPhone
  • 2008: Apps for the iPhone! App Store!
  • 2005: Mac switches to Intel chips and podcast support in iTunes
  • 2003: Safari browser
  • 2002: End of OS 9
  • 1998: Steve Jobs’ new OS X strategy

How to watch the keynote on your iOS device or computer

You’ll need one of these:

  • An iPhone, iPad, or iPod Touch with Safari running iOS 7 or later
  • A Mac with Safari 6.0.5 or later, running OS X 10.8.5 (“Mountain Lion”) or later
  • A Windows computer running Microsoft’s Edge browser on Windows 10

…and you should point your browser (Safari on the Mac, Edge on Windows 10) to http://www.apple.com/apple-events/june-2016/.

How to watch the keynote on your Apple TV

If you have one of these:

  • A 2nd- or 3rd-generation Apple TV running tvOS 6.2 or later
  • A 4th-generation Apple TV (the kind that runs apps from the App Store)

…fire up your Apple TV, go to the App Store, and get the WWDC 16 app. Download it, open it, and enjoy the show!

If you can’t watch the keynote but want to follow along

If your work situation or technology won’t let you watch the keynote, you can still follow along with all the people liveblogging the event: