Programming

Simple ordinal date queries in Swift

That happy moment when the API you need already exists

Ronald Martin

4 minute read

I had a very specific question a while ago: When is the next 5th Sunday of the month? That is, what is the next date which is not only a Sunday, but also the 5th occurrance of Sunday in its enclosing month? This only occurs a handful of times in any given year (in the Gregorian calendar): an average of 30 days per month means 30 days/month / 7 days/week = ~4.

My First Android Library, Part I

What I learned from building a custom widget

Ronald Martin

5 minute read

Feature image

I built a software library recently. It’s a page indicator for mobile apps; the kind you’ve probably seen before with dots that change color to show what page you’re on. The one I made replicates Google’s latest iteration of this pattern with Material Design inspiration. It’s really rather cool looking, I think:

As you can see, each dot represents a page, where the white dot is the current page and the gray dots are the other pages.

Kotlin's Computed Properties Are Just Methods

But don't use them to make Observables

Ronald Martin

12 minute read

Bytecode generated in Android Studio

Note: this post assumes familiarity with Java language features and conventions. RxJava familiarity is useful, but not required. I was curious today about the relationship of Kotlin’s computed properties and methods. They do very similar things, so are they implemented similarly? (Spoiler: Yes. Yes they are.) Somehow, however, I also ended up drawing some conclusions on the semantics of reactive Observable generation. Kotlin’s computed properties can be a powerful tool for expressing your program’s intent with Observables, but you should think twice before using them for that purpose.