Scala, Java, Unix, MacOS tutorials (page 1)

Summary: This page is a printf formatting cheat sheet or reference page. I originally created this cheat sheet for my own programming purposes, and then thought I would share it here.

A great thing about the printf formatting syntax is that the format specifiers you can use are very similar — if not identical — between different languages, including C, C++, Java, Perl, PHP, Ruby, Scala, and others. This means that your printf knowledge is reusable, which is a good thing.

Every once in a while when something hits you, you really remember it; it stands out in your mind as an “Aha” moment. One of those moments for me was when I saw a particular “Model/View/Controller” (MVC) diagram, and the light bulb went on. This diagram made the MVC pattern very simple, and I’ve never forgotten it.

The Model / View / Controller diagram

The diagram I’m talking about comes in two parts. The first MVC diagram shows the symbols the authors use for Model, View, and Controller objects. Here’s that diagram:

Model View Controller - symbols for MVC objects

Kotlin FAQ: How do I iterate over a Map in Kotlin?

Solution: Here’s an example that shows how to iterate over the elements in a Kotlin Map using a for loop:

val map = mapOf("a" to 1, "b" to 2, "c" to 3)

for ((k,v) in map) {
    println("value of $k is $v")

I saw the following image on this Twitter page:

and immediately became curious, “How can I create something like that Ruby %Q function in Scala, but where each line becomes a string in a list, i.e., a Seq[String]?”

“It is not the critic who counts; not the man who points out how the strong woman stumbles, or where the doer of deeds could have done them better.”

“The credit belongs to the woman who is actually in the arena, whose face is marred by dust and sweat and blood; who strives valiantly; who errs, who comes short again and again, because there is no effort without error and shortcoming; but who does actually strive to do the deeds; who knows great enthusiasms, the great devotions; who spends herself in a worthy cause; who at the best knows in the end the triumph of high achievement, and who at the worst, if she fails, at least fails while daring greatly, so that her place shall never be with those cold and timid souls who neither know victory nor defeat.”

~ “The Man in the Arena” speech by Teddy Roosevelt, with a few minor changes, which I was reminded of by this article

As a brief note to self, here’s some Laminar source code that shows how to create a div in Laminar, as well as some settings/elements in that div, as well as one way to handle a reactive button click:

In my first Laminar tutorial I showed how to set up a Scala/sbt project to use Laminar to render “static” HTML code. Then in Laminar 102: A reactive “Hello, world” example, I showed how to create a small, reactive Laminar example, that sends signals from one widget to another using observables and observers.

In my experience, the next thing you’ll need to know about Laminar is routing, i.e., how to transition from one page to another in a single-page app (SPA). Therefore, in this tutorial I’ll show how to implement that for very small applications.

In my first Laminar tutorial I showed how to set up a Scala sbt project to use Laminar, and then showed a “static” example — i.e., there were no moving parts. Please see that tutorial first if you’ve never used Laminar.

BUT, because Laminar is meant for writing reactive applications with observables and observers, this tutorial begins to show its reactive concepts.

This article contains a collection of quotes on design from former Apple designer Jonathan Ive (or “Jony Ive,” as Steve Jobs called him). As an interesting note, Mr. Ive prefers to refer to himself as a “builder” or “maker” as opposed to a designer.

For those who don’t know of him, Jonathan Ive is credited with designing almost every Apple product from 1997 until roughly 2020. Given that very long string of success, I became interested in what Mr. Ive has to say about design, and to that end, here’s a collection of Jonathan Ive design interview quotes I’ve gathered over the last few years.

This page contains a list of my favorite “mindfulness reminder” quotes. In particular these are short, concise quotes that I think work well with my “Just Be” mobile app.

Just Be is currently an app for Android users. If you haven’t seen it before, this is what the reminders/notifications look like when you receive them on an Android phone or tablet:

[toc hidden:1]

I recently started a new Scala project that uses the Scala/Scala.js Laminar library for frontend development (i.e., as a JavaScript replacement).

Laminar is a library that’s built on top of Scala.js to let you build “reactive” web applications with observables, and in this tutorial I’ll show how to create a static “Hello, world” application from scratch. Once we get past these basics, I’ll show in Part 2 of this series how to create a reactive single-page application (SPA) with Laminar.

When I first saw Scala code like this ~12 years ago, my initial thought was, “Wow, maybe I need to think about a different career”:

def race[A, B](lh: IO[A], rh: IO[B])(implicit cs: ContextShift[IO]): IO[Either[A, B]]

But in the end, as Rocky once said, it ain’t so bad. :)

Rocky: You ain’t so bad

For many years I struggled with how to combine two of my main interests, Zen and work. I have read that the Zen mind is the mind before thinking, so it seems like Zen and work must be totally unrelated; you need your mind to work. And then over time I came to understand phrases like, when working, just work.

This article contains a collection of quotes that have been helpful to me in understanding the relationship between Zen and work. Please note that I don’t wrap each quote in double quotes, and I also try to attribute each quote to the correct author/speaker. If you’re interested in how to combine Zen and work, I hope you’ll find them helpful.

At some point somebody was like, “Let’s get a mast cell — a type of white blood cell — from a bone marrow biopsy, magnify it 1,000 times, piss it off, and see what happens.”

The result? Ka-boom! It looks like a little firework went off when it released its histamine, tryptase, serotonin, superoxide, heparin, thromboxane, PGD2, PAF, and other granules.

That’s pretty much what it feels like, lol. I used to tell doctors that it felt like I had been drugged, and indeed, I was.

(Image from this research paper.)

MCAD: What an activated mast cell looks like

Over on my Valley Programming website I wrote a little User Story Mapping Example Using Facebook. Whether people currently have a Facebook account or not, at one time almost everyone did, so it makes for a good example when running a story mapping workshop. See that link for more details.

A User Story Mapping Example Using Facebook

This is an excerpt from the Scala Cookbook, 2nd Edition. This is Recipe 3.10, Using Java Collections in Scala.


You’re using Java classes in a Scala application, and those classes either return Java collections, or require Java collections in their method calls, and you need to integrate those with your use of Scala collections.


Use the extension methods of the scala.jdk.CollectionConverters object in your Scala code to make the conversions work. For example, if you have a method named getNumbers in a public Java class named JavaCollections:

This is an excerpt from the Scala Cookbook, 2nd Edition. This is Recipe 23.9, Simulating Dynamic Typing with Union Types.


You have a situation where it would be helpful if a value could represent one of several different types, without requiring those types to be part of a class hierarchy. Because the types aren’t part of a class hierarchy, you’re essentially declaring them in a dynamic way, even though Scala is a statically-typed language.


In Scala 3, a union type is a value that can be one of several different types. Union types can be used in several ways.

In one use, union types let us write functions where a parameter can potentially be one of several different types. For example, this function, which implements the Perl definition of true and false, takes a parameter that can be either an Int or a String:

Summary: This tutorial shows how to use Unix/Linux curl scripts to test REST/RESTful web services.

There may be better ways to do this, but when I was writing a mobile app — with a JavaScript client written in Sencha Touch, and the server written with the Play Framework — I wrote some curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework REST/RESTful web services.

You can also write REST clients with Scala, Java, and other languages, but for various reasons I wanted to test these web services with curl. As an added bonus, you can include scripts like this into your testing and integration process, if you like. You can also use the same approach with Nagios to make sure your service is still running.

Flutter 3 was released in mid-May, 2022. You can read more about it here on, and on other websites.

Flutter 3 release, May, 2022

As a brief note, SQLite doesn’t have date/time (datetime) fields, so when you want to use a datetime field with Flutter and Dart, you have to do something else.

My choice was to store my date/time data as a SQLite INTEGER field. I did this so I can query and sort that field easily myself. The benefit of storing a datetime field as a TEXT field is that you can read it easier, but I think an INTEGER field is a little easier to work with, though YMMV.