On my list to listen to: A TED Radio Hour discussion, Why Does Time Exist?
Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X
“There could have been no two hearts so open, no tastes so similar, no feelings so in unison.”
I realy like this quote from baseball pitcher Jason Marquis, talking about Tony LaRussa, Manager of the St. Louis Cardinals:
“One thing Tony (La Russa) always preached over there was execution and minimizing mental mistakes. You don’t have to have the most talented team to do that, and it doesn’t take the most talented team to win.”
In baseball and in work I think this is true. It’s similar to this quote from Mike Ditka:
“Effort without talent is a depressing situation....but talent without effort is a tragedy.”
The book, Advanced Scala with Cats, has a nice little function you can use to run a block of code “slowly”:
def slowly[A](body: => A) = try body finally Thread.sleep(100)
I’d never seen a try/finally block written like that, so it was something new for the brain.
In the book they run a
factorial method slowly, like this:
slowly(factorial(n - 1).map(_ * n))
FWIW, you can modify
slowly to pass in the length of time to sleep, like this:
def slowly[A](body: => A, sleepTime: Long) = try body finally Thread.sleep(sleepTime)
This 2014 underscore.io post states, “Those interested in FP purity in a Scala world, you’ll want WartRemover.” (Of course that recommendation may have changed by now.) The current ScalaStyle website states, “Scalastyle is used as part of the grading framework for the course Functional Programming Principles in Scala by Martin Odersky on Coursera.”
While reading the excellent Scala/FP book, Advanced Scala with Cats, I was just reminded that Scala’s
Either class was redesigned in Scala 2.12. Prior to 2.12,
Either was not biased, and didn’t implement
flatMap methods. As the image from the book shows,
Either is redesigned in 2.12 to include those methods, so it can now be used in Scala for-expressions as shown.
(I write about biasing in my book, Learning Functional Programming in Scala.)
Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here.
A cool thing about the printf formatting syntax is that the specifiers you can use are very similar, if not identical, between several different languages, including C, C++, Java, Perl, Ruby, and others, so your knowledge is reusable, which is a good thing.
“Pleasure in the job puts perfection in the work.”
I recently started working on a project that may or may not make it into my Scala/FP book. I’m currently calling it “Akkazon Ekko” — or “Ekko” — because it’s a little like the Amazon Echo, but written with Scala and Akka.
If you want to create multiple Scala Futures and merge their results together to get a result in a
for comprehension, the correct approach is to (a) first create the futures, (b) merge their results in a
for comprehension, then (c) extract the result using
onComplete or a similar technique.
“If you speak and act with a pure mind, happiness will follow you as a shadow clings to a form.”
~ from the Kung Fu tv series
Android FAQ: When is the Android Fragment
onCreateOptionsMenu method called?
I was just working through a problem with an Android Menu and MenuItem, and added some debug code to the methods in my Android Fragment, and found that the
onCreateOptionsMenu method is called after
onStart. I didn’t put Log/debug code in every activity lifecycle method, but for the ones I did add logging code to, the specific order of the fragment method calls looked like this:
After 84 days, the Sun finally set in Barrow, Alaska (now known as Utqiaġvik) on August 2, 2017.
(Image from this Twitter page.)
Apparently there’s a honey badger roaming around the University of Colorado campus in Boulder. For more information, see the DailyCamera.com.
“It is the sign of a great mind to dislike greatness, and to prefer things in measure to things in excess.”
Last call: My new book, Learning Functional Programming in Scala, goes up to $30 tonight (August 1, 2017).
“Your attitude is such an important topic, I want to end this book by getting you to look at yourself the way other people see you.”
A quote from the last chapter of my book, A Survival Guide for New Consultants.