slowly

A Scala method to run any block of code slowly

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 (without a catch clause), 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)

How to slowly minimize a Mac OS X window to the Dock using the Genie effect

If you ever want to impress your friends with a fun Mac OS X trick, just minimize a window in super slow motion. Steve Jobs used to do this during his presentations, but I don't know if he's done it in a few years now. Here's an image of what this slow-motion Genie effect looks like:

Mac OS X slow motion Genie minimizing window effect