Eurobubba

Any Canadians reading this? What do you put in your cars, “gasoline”/“gas” or “petrol”? (This is about word usage, not alternative fuels.) Thanks!

Barry Olsen in *MultiLingual* on the impact of artificial intellence

An insightful article about the current state of machine translation and what it suggests about the ways artificial intelligence may impact other domains. Key takeaway: AI is a tool that can change the way work is done and can even have a far-reaching impact on the structure of the market, but it still won’t be replacing human professionals just yet.

I’d rather be writing the software that will replace my job.

Trying to trim a 1.6 million TU translation memory down to 75,000 or so, to leave some room for growth before hitting the recommended maximum of 100k again.

☞ This season is about spinning the flywheel.

Kourosh Dini asks an important question: “What differentiates perfectionism from mastery?

Watching season 11 of The Walking Dead. Starting to root for the zombies.

I find myself trying to spin up three different mostly unrelated businesses plus hit fitness goals plus build a relationship, and maybe even steal a couple of hours now and then for friends, family, and community, all while still tied to a full-time job. I am a madman.

☞ Next week is about agency.

☞ Next week is about engineering.

☞ This week is about momentum.

☞ Next week is about unarchiving SPT.

None of my old Safari web archives from a few years ago will open any more.

Wordle 523 1/6

🟩🟩🟩🟩🟩

☞ Next week is about making it click.

Working with the garage door up: MetaboLog

A few weeks ago I finished Paul Hudson’s excellent 100 Days of SwiftUI course. The next step in getting hired as a developer and/or building an indie developer business while continuing to develop my skills is to start building an app or two.

Since I’m currently trying to lose some weight (so I can fit back into some really nice bespoke-tailored shirts that I’ve, ahem, outgrown), and I’ve only ever succeeded at that in the past via old-school calorie counting, I decided my first project would be an app I can use to log my weight against my food intake. I call it MetaboLog.

Tailored shirts
Motivation

Besides calories, I want to be able to track macronutrients (protein, fat, and carbohydrates) as well as, optionally, micronutrients such as vitamins and minerals. To minimize friction, I also want the flexibility to be able both to log known meals with a click and to analyze previously unrecorded dishes from their ingredients.

MetaboLog screenshot

I’ll be drawing the detailed nutritional data from the U.S. Department of Agriculture’s FoodData Central database. The data structure from its API — multiple APIs, actually — is quite a bit more complex than anything in a coding tutorial, but I suppose that’s the game I signed up to play.

As of right now I’m at a loss why the JSONDecoder can parse “lowercaseDescription”:“cheddar cheese” just fine, but fails to parse “servingSizeUnit”:“g” within the same chunk of JSON.

Update: the “servingSizeUnit” attribute doesn’t exist for every element in the JSON dataset, so it has to be decoded as an optional String? rather than a plain String. Ahhhhbviously!

In Big Bend Ranch State Park last week

SwiftUI class notes 2022-01-29

Screen Shot 2022-01-29 at 17.24.04.png
For now at least, weekends (and holidays) are the only times I really have the opportunity to focus on code for more than an hour or two at a time, so if I want to complete the more difficult “challenges” in 100 Days of SwiftUI or other courses, that’s when I’ll have to work on them. That means setting aside work on my own app(s) any time I reach a course challenge that I can’t get past in a couple of hours. Since (at least at my skill level, and maybe at all) there’s no reliable way of estimating how long it will take to reach a stopping point in my independent work, I can’t really do it the other way around. So I’m setting aside MinderBoard and turning back to 100 Days of Swift, which I’d like to finally finish within the next few weeks.

I’m actually focused on UIViewControllerRepresentable right now in both MinderBoard and the 100 Days challenge anyway.

Nick Sarno’s Use UIViewControllerRepresentable to convert UIKit controllers to SwiftUI video on YouTube and Paul Hudson’s series starting with Wrapping a UIViewController in a SwiftUI view cover very similar territory. Without digging through Apple’s documentation, the UIImagePickerController type in Nick’s video and the PHPickerViewController in Paul’s seem to do (exactly?) the same thing.

The code in the two tutorials is also very similar, with a few notable exceptions. Rather than replicating the view controller struct’s @Binding variables inside the Coordinator class, Paul creates a reference to the view controller as the Coordinator’s parent, allowing us to access its properties. This seems like a much more elegant approach. Using the view controller’s .dismiss() method also feels cleaner than passing showScreen around as a binding.

By defining the @State image variable in his main SwiftUI ContentView as an (optional) UIImage? rather than an (optional) SwiftUI Image? in the first place, on the other hand, Nick has no need of Paul’s additional @State inputImage variable, loadImage() function, and .onChange() modifier.

Paul’s beautiful dogs make an appearance in his videos, so that’s points for him. Advantage, Paul Hudson.


For Paul’s Challenge I do need to detect when a new photo is added, so I’ll actually still need the .onChange modifier. But it’s getting to be dinner time, so I’ll continue tomorrow.

Why do Markdown unordered lists in my micro.blog posts look fine in the Mac app preview but display as unbroken paragraphs in Safari?

SwiftUI class notes 2022-01-23

Still working on getting my head wrapped around UIViewRepresentable and UIViewControllerRepresentable. A pair of YouTube videos from Nick Sarno (Swiftful Thinking) is offers a helpful different perspective from Paul Hudson’s material that I’ve mostly been following.

Not sure I quite get the concept of “context”.

Elements of a UIViewRepresentable struct:

  • @Binding var — data being passed between the representable UIView and the parent SwiftUI view
  • Coordinator class and func makeCoordinator() -> Coordinator
  • func makeUIView(context: Context) -> some UIView
  • func updateUIView(_ uiView: UIViewType, context: Context)

Open questions:

  • ¿Does every UIView and UIViewController subclass have its own delegate protocol?
  • ¿What’s the self._text thing about?

Excellent explanation by @twostraws of using UIViewControllerRepresentable and Coordinator to incorporate UIKit elements into a SwiftUI app. A complex topic clearly laid out. www.hackingwithswift.com/books/ios…

SwiftUI class notes 2022-01-02

Just like it says in the title, Peter Friese’s Building a To-Do List App with SwiftUI, Combine, and Firebase calls for a dive into Combine, which I haven’t studied yet.

combine harvester Seems like something I’m going to have to learn sooner or later, though. Fortunately I bought Daniel Steinberg’s A Combine Kickstart on Black Friday.

The question now is whether I want to take a 500+ -page detour before making something, when the plan for weekend coding was supposed to be to get away from tutorials and see what I can do on my own. Since I’ll be pushing and pulling data from outside my app, I’ll presumably want to use some kind of async code, but maybe I should try the new Swift async/await first instead? In which case, given that I’m not interested in using Firebase for this project either, Friese’s project may end up not being all that useful.

I’m not getting very far with just the Apple developer documentation for EventKit, so let’s see what else is out there…

SwiftUI class notes 2021-12-12

Friese’s Task model:

enum TaskPriority {
  case high
  case medium
  case low
}

struct Task: Identifiable {
  var id: String = UUID().uuidString
  var title: String
  var priority: TaskPriority
  var completed: Bool
}

By contrast, Apple’s native EKReminder is a class that inherits from EKCalendarItem, which in turn inherits from EKObject. Its accessible properties:

  • EKReminderPriority (an enum with values none, high, medium, and low)
  • priority: Int
  • startDateComponents: DateComponents?
  • dueDateComponents: DateComponents?
  • isCompleted: Bool
  • completionDate: Date?

And accessible properties inherited from EKCalendarItem:

  • calendarItemIdentifier: String
  • calendarItemExternalIdentifier: String! — external identifier as provided by the calendar server
  • calendar: EKCalendar!
  • title: String!
  • location: String?
  • creationDate: Date?
  • lastModifiedDate: Date?
  • timeZone: TimeZone?
  • url: URL?
  • hasNotes: Bool
  • notes: String?
  • hasAttendees: Bool — so a reminder can have attendees?
  • attendees: [EKParticipant]?
  • hasAlarms: Bool
  • alarms: [EKAlarm]?
  • hasRecurrenceRules: Bool
  • recurrenceRules: [EKRecurrenceRule]?

The EKObject class’s properties, booleans hasChanges and isNew, relate to saving and restoring state.

¿Why two different priority properties?
¿Why simply completionDate and not completionDateComponents?