Categories
Programming Reading Material

My tutorial on iOS authentication using SwiftUI and Auth0

Banner: Get Started with iOS Authentication using SwiftUI

Hey, iOS developers! My latest tutorial article on the Auth0 blog shows you how to easily add authentication (that is, login and logout) to SwiftUI apps and display information from their user profile.

The article demonstrates the most basic use of the Auth0.swift SDK, the Auth0 SDK for all Apple platforms — not just iOS, but macOS, iPadOS, watchOS, and tvOS. It’s Auth0’s third most-used SDKs, accounting for more than one in ten API requests to Auth0 systems!

It’s a two-part tutorial. Part 1 of the tutorial starts with File → New Project…, adds some basic interactivity, adds the Auth0.swift package, walks you through setup on the Auth0 side, and finally enables login and logout:

iOS Simulator screen shot: Screen with title “SwiftUI Login Demo” and “Log in” button.
The app’s “logged out” screen.
iOS Simulator screen shot: Auth0 Universal Login screen.
Auth0’s Universal Login.
iOS Simulator screen shot: Screen with title “Logged in” and “Log out” button.
The app’s “logged in” screen.

Part 2 of the tutorial takes your basic login/logout app and gives it the ability to read user information from the user profile and display it onscreen:

iOS Simulator screen shot: Screen with title “Logged in”, photo of user, user]s name and email address, and “Log out” button.
The revised “logged in” screen.
Categories
Current Events Meetups Programming Tampa Bay

This Wednesday: the Downtown Tampa Software Developers meetup!

There’s a new tech meetup here in “The Other Bay Area” — the Downtown Tampa Software Developers — and I’m planning on attending their next meetup (and getting some dinner) this Wednesday, March 30th, at 7:00 p.m.!

Organized by Michael Berlet, it’s a weekly meetup for software developers at Tampa’s big food hall/gathering place, Armature Works, which provides a wide variety of food and drink.

Here’s the group’s description from their Meetup page:

We are a group of professional, freelance, and amateur software developers living in the vicinity of downtown Tampa.

If you’re sick of impersonal online developer webinars and want to meet, make friends, and network with other developers in physical space, then this is the group for you. We’re informal, and like to chat about work, personal projects, and life in general.

Join us! It sounds like it’ll be fun. You can RSVP on the event page.

In case you need it, here’s the parking map for Armature Works:

Categories
Programming Reading Material

Two Kotlin/data science articles from Yours Truly!

Kotlin developers who want to get into data science: these articles are for you! They’re about using Jupyter Notebook, but with Kotlin instead of Python. Why should Pythonistas make all the big bucks?

Read the articles, which appear on RayWenderlich.com (the premier mobile development site, and it’s where I learned iOS and Android dev) in this order:

  1. Create Your Own Kotlin Playground (and Get a Data Science Head Start) with Jupyter Notebook: Learn about Jupyter Notebook, get it set up on your computer, and get familiar with krangl, the Kotlin library for data wrangling.
  2. Beginning Data Science with Jupyter Notebook and Kotlin: Once you’re familiar with krangl, it’s time to get familiar with data frames and working with datasets. This article will help you get started by exploring real data, crunching it, and even getting some insights from it.

Categories
Humor Programming

The real reason programmers prefer dark themes

Comic by monstika. Click to see the source.
Categories
Humor Programming

What coding in Light Mode says about you

This made me chuckle.

Categories
Meetups Programming Tampa Bay

Building a “Wordle” function, part 1

These slides capture what we worked on Tuesday night’s “Think Like a Coder” meetup: coming up with a first attempt at a “Wordle” function. Given a guess word and a goal word, it should output a Wordle-style score.

We came up with a solution that I like to call the “close enough” algorithm. It goes through the guess word one character at a time, comparing the current guess word character with the goal word character in the same position.

When making those character-by-character comparisons, the function follows the rules:

Here’s the “close enough” algorithm, implemented in Python…

def wordle(guess_word, goal_word):
    
    # Go through the guess word one character at a time, getting...
    # 
    # 1. index: The position of the character
    # 2. character: The character at that position
    for index, character in enumerate(guess_word):
        
        # Compare the current character in the guess word
        # to the goal word character at the same position
        if character == goal_word[index]:
            # Current character in the guess word
            # matches its counterpart in the goal word
            print("green")
        elif character in goal_word:
            # Current character in the guess word
            # DOESN’T match its counterpart in the goal word,
            # but DOES appear in the goal word
            print("yellow")
        else:
            # Current character DOESN’T appear in the goal word
            print("gray")

…and here’s the JavaScript implementation:

function wordle(guessWord, goalWord) {
    
    // Go through the guess word one character at a time
    for (let index in guessWord) {
        // Compare the current character in the guess word
        // to the goal word character at the same position
        if (guessWord[index] == goalWord[index]) {
            // Current character in the guess word
            // matches its counterpart in the goal word
            console.log('green')
        } else if (goalWord.includes(guessWord[index])) {
            // Current character in the guess word
            // DOESN’T match its counterpart in the goal word,
            // but DOES appear in the goal word
            console.log('yellow')
        } else {
            // Current character DOESN’T appear in the goal word
            console.log('gray')
        }
    }
}        

I call the solution “close enough” because yellow is a special case in Wordle. If the guess word is ATOLL and the goal word is ALOFT, the first L in ATOLL should be yellow and the second should be gray because there’s only one L in ALOFT.

We didn’t settle on the “close enough” algorithm — it was just enough for that night’s session. In the next session, we’ll refine the algorithm so that it matches Wordle’s!

Want to become a better programmer? Join us at the next Think Like a Coder meetup!

Categories
Meetups Programming

Slides from the upcoming “Let’s figure out how to code Wordle” meetup

Here are the first 15 slides from the upcoming Think Like a Coder! meetup, which happens ONLINE on Tuesday, Feb. 8 at 7 p.m. EST! The first slide summarizes what we’re going to be doing in JavaScript and Python.

The mission of Think Like a Coder! is to turn Tampa Bay into a place packed with skilled, successful coders.

And no, you don’t have live in Tampa Bay or anywhere nearby to participate in this meetup — I just happen to live in the Tampa Bay area.

One of the biggest challenges in coding is making the leap from knowing the theory — if statements, for and while loops, functions, classes, and so on — and the actual practice of using those things to make working applications.

Many jobs involve following the same procedure every day. The steps are laid out for you, and are often documented in a 3-ring binder (Neal Stephenson talks about 3-ring binders in his cyberpunk novel, Snow Crash). You don’t have to think about them. You succeed when you follow procedure, and you excel when you can follow procedure quickly.

Coding falls into that category of jobs where there isn’t a clearly documented procedure for every little thing. You have to figure out how to accomplish the goal.

This photo in the slide above from the film Apollo 13, where engineers had to figure out how to improvise a way to remove excess carbon dioxide from the ship’s air, using only the stuff that the astronauts had on hand. You can read more about it in the article The Greatest Space Hack Ever.

Yes, you need to know your programming language keywords. Sometimes, it even helps to know what’s happening at the processor level.

See that diagram on the left of the slide above? That’s what your computer is actually doing, under the hood. If you like, I can talk about it at an upcoming meetup.

You need to know how to apply those fundamentals, and that comes with practice.

You also need to learn how to see patterns and similarities, which will help you come up with solutions. For instance, did you know that Mortal Kombat is essentially a fancier version of Rock-Paper-Scissors?

With all that preamble out of the way, it’s time to tell you what we’re doing Tuesday evening at the meetup.

In case you haven’t yet played “Wordle”, here it is, summarized on a single slide, including a screenshot of the game I played on Saturday.

Sure, it’s a hot topic right now because everyone’s posting their Wordle scores on social media and because its developer just sold it to the New York Times in a “low seven-figures” deal, but it’s also good coding practice.

The meetup will run from 7:00 p.m. EST (UTC-5) to 9:00 p.m., so we’re NOT going to build a complete Wordle game. There just won’t be time, once you factor in introductions, setup, and Murphy’s Law.

What we WILL build — or more accurately, we’ll ***figure out how to build it*** — is the “referee”, or the thing that takes the player’s guess, compares it to the actual word, and provides the feedback.

That thing will be a function that takes two inputs — a guess word and a goal word — and outputs a value that represents those colored blocks. It’s a little trickier than you might think, and you’ll find out why…

Join us this Tuesday, February 8th at 7:00 p.m. EST (UTC-5) for Think Like a Coder! and let’s figure out how to code Wordle!