I'm sitting at Panera Bread, reviewing the first two chapters of the Scala Cookbook. Chapter 1 sucks, someone’s gonna have to do something about that. Chapter 2 isn’t too bad.
A note from June 24, 2012
I'm sitting at Panera Bread, reviewing the first two chapters of the Scala Cookbook. Chapter 1 sucks, someone’s gonna have to do something about that. Chapter 2 isn’t too bad.
A note from June 24, 2012
The bad news is that I’ll be in the hospital most of next week after surgery to remove part of my digestive system, but the good news is that I just received the first proof of Hello, Scala, and I should have time to review it.
“She had been born with a face that would let her get her way
He saw that face and he lost all control
All control”
A thing I love about Bob Seger is that his lyrics and the enthusiasm of his music remind me of being a much younger man, maybe the end of the teenage years and the beginning of the 20s. These lyrics in particular are from his song Hollywood Nights.
Two thoughts of the day:
Nobody owes you anything. I’m often surprised to hear people tell stories about how they’re butthurt because they feel like someone owes them something. (Typically they think friends and family members should owe them something.)
The only time you really lose is when you don’t try. A lot of people have interesting ideas, but never do anything with them. I think I lost nine games as a baseball pitcher in high school, but I won a lot more games than that, and it would have been a much bigger loss if I thought, “Gosh, I could be a great pitcher if only someone gave me a chance.”
If you’re ever in Alaska, adn.com has a nice list of twelve Anchorage-area hikes.
Dear Diary: Day 20 of not having a thyroid (because of thyroid cancer), not taking thyroid medicine, and the low-iodine diet.
I didn’t know if a person could lose weight without a thyroid, but I’ve dropped six pounds so far. In all I’ve dropped 20 pounds since I finished writing the Scala Cookbook (when I was working around the clock, not exercising, and eating crap).
Blood pressure is usually about 96/56, heart rate 48-54 BPM, and that’s without taking any heart meds. (I’d pass out for sure if I took those.) Low on energy and can’t take my usual long walks without getting the shakes.
Hopefully I’ll pass the blood test on Wednesday — my TSH level needs to be 30 or higher — so I can start the radiation treatment.
~ a note from June 16, 2014, after having my thyroid removed
I don’t remember the original source of this Zen selfie stick image, but I like it.
This page contains dozens of examples that show how to use the methods on the Scala Array class.
The Scala Array class is a mutable, indexed, sequential collection. Unlike the Scala ArrayBuffer class, the Array class is only mutable in the sense that its existing elements can be modified; it can’t be resized like ArrayBuffer.
I just noticed this quirk when trying to create an array of characters with the Scala Array.range method:
# works as expected
('a' to 'e').toArray // Array[Char] = Array(a, b, c, d, e)
# surprise: Array.range always returns Array[Int]
val a = Array.range('a', 'e') // Array[Int] = Array(97, 98, 99, 100)
I was surprised to see that the Scaladoc for the Array object states that the second example is expected behavior; Array.range always returns an Array[Int]
. I suspect this has something to do with a Scala Array
being backed by a Java array
, but I didn’t dig into the source code to confirm this.
For much more information about arrays, see my Scala Array class examples tutorial.
Note: I’ve disabled comments and the contact form on this website until after I recover from my next surgery.
I can’t eat solid foods right now, but after the operation I’m going to check out Fuzzy’s Taco Shop. Or go to Texas. One of those two. Maybe both.
typelevel.org has a nice article on shared state in functional programming.
As a brief note to self, here’s an example JavaFX application written using Scala 2:
package pizzastore import javafx.application.Application import javafx.event.ActionEvent import javafx.event.EventHandler import javafx.geometry.{Insets, Pos} import javafx.scene.Scene import javafx.scene.control.{Button, Label, Separator} import javafx.scene.layout._ import javafx.scene.paint.Color import javafx.scene.text.Font import javafx.stage.Stage object MainWindow { def main(args: Array[String]) { Application.launch(classOf[MainWindow], args: _*) } } class MainWindow extends Application { override def start(stage: Stage) { val borderPane = new MainBorderPane val scene = new Scene(borderPane, 600, 400) scene.getStylesheets.add(getClass.getResource("pizza.css").toExternalForm) stage.setScene(scene) stage.setTitle("Al’s Pizza") stage.show } } class MainBorderPane extends BorderPane { // others need to be able to get this to add an action to it val placeOrderButton = new Button val alsPizzaLabel = new Label("Al’s Pizza") //label.setId("fancytext") //css approach alsPizzaLabel.setFont(new Font("Arial", 50)) alsPizzaLabel.setTextFill(Color.TOMATO) placeOrderButton.setText("Start An Order") placeOrderButton.setOnAction((e: ActionEvent) => { println("Hello World!") }) placeOrderButton.setFont(new Font("Arial", 24)) // a spacer to push the visible elements up a little val spacer = new Region spacer.setPrefHeight(40) val vbox = new VBox vbox.setSpacing(40) vbox.setAlignment(Pos.CENTER) vbox.getChildren.addAll(alsPizzaLabel, placeOrderButton, spacer) this.setCenter(vbox) }
“Mast cell disorders are neoplastic disorders, which means the mast cells multiply continuously over the patient’s lifetime. As with cancer cells, mast cells do not die, disappear, or cease to function, on their own.”
“I’ve stuck with Zen because it is unflinchingly honest, but at the same time accepting, kind, and caring — not in a soft syrupy way, but in a rugged, rough and tumble way. To become clear you have to see what’s really there, all the mental junk you’ve made and accumulated over the years. The honesty will force you to acknowledge the parts of yourself you’d rather keep hidden. The acceptance allows you to look at the less savory parts of your self without being overly self-critical.”
~ from this kwanumzen.org page
Here’s a note about the Scala 2.13 Collections Feature Freeze., which includes a link to this post on how/why the Scala 2.13 collections were redesigned from scratch.
The Farnam Street Blog has a nice set of core principles in regards to “all that we write about, think about, and strive to achieve”:
- Direction Over Speed
- Live Deliberately
- Thoughtful Opinions Held Loosely
- Principles Outlive Tactics
- Own Your Actions
I came across quite a few bald eagles in Canada and Alaska, but didn’t know we had them right next door here in Colorado. I knew construction on this project had been held up for at least two years, and now I know why.
I have a rough surgery coming up in a couple of weeks, and when I came across the saying, “Collect beautiful moments,” it reminded me that that’s pretty much all we can do in life.