Blog Articles - page 2
-
Implicit vs Scala 3's Given
I don’t like
Read article →given
, as an alternative toimplicit
in Scala 3. The more I try working with it, the more it annoys me; and my understanding may be superficial, but I don’t like this direction. Here’s a comparisson betweengiven
andimplicit
, that I hope is fair… -
Scala OOFP Design Sample
Scala is considered a multi-paradigm language, for better or worse, being one of the best OOP languages, which is why it’s so versatile. Let’s do a design exercise, going from OOP to static FP, and back. Let’s understand the various techniques promoted in the community, and understand why the OOP design isn’t just “idiomatic” for Scala, but can be superior to alternatives.
Read article → -
Scala's Gitter to Discord migration mistake
The Scala community is increasingly using Discord for “real-time chat”. This was announced in December, and the community page lists several Discord “servers”, one of them belonging to Typelevel. I think this move from Gitter to Discord is probably a mistake.
Read article → -
On Typelevel and Monix
Planning the future is difficult, but can bring clarity and purpose. I’m stepping down from the Typelevel Steering Committee. I also have plans for Monix’s future.
Read article → -
A Return to Blogging
I like writing about my personal projects and about programming in general. Helping others learn programming seems to be my calling. I rarely write on this blog, however, but I’m trying to change that. You should have a blog too.
Read article → -
Finding Focus in Harsh Times
Since 2020 world events have obliterated my ability to focus, and anxiety has gone through the roof. This is a personal reflection and a plan for recovery.
Read article → -
Cleanup Scala/Java project
Snippet for cleaning up a Scala project’s directory of all compiled files.
Read article → -
VSCode workplace recommended extensions
You can recommend the required VSCode extensions per repository to your fellow programmers. This is what VSCode calls “workspace recommended extensions”.
Read article → -
Unsafe Lazy Resource.scala
Snippet for an impure way (no IO) to create a resource that can later be closed.
Read article → -
Combining the terminal (iTerm) with the IDE
Read article →⌘+Click
on a file path triggers my terminal to open that file inside my IDE, and that helps a lot. -
Tolerance
I just refactored a piece of code. I deleted 6 source code files, and rebuilt the functionality with a bunch of dirty OOP classes shoved in a single file 😱
Read article → -
Atom/RSS Feeds are the Best Way to Consume the Web
I stay connected to websites I care about via an RSS/Atom feed reader. It’s better than social media for finding out what’s new because it’s clutter-free. By following RSS/Atom feeds, I discover wonderful gems that otherwise would be lost in the noise.
Read article → -
ING Scala Meetup on Scala 3 (live coding session)
Online meetup on Scala 3’s newly introduced types and features for encoding type classes.
Read article → -
Implementing a CountDownLatch (async and dirty)
Yo dawg, I heard you liked concurrency primitives. Let’s implement our own asynchronous, dirty CountDownLatch.
Read article → -
Matomo (Analytics) Hosting via Docker
Docker setup for self-hosting Matomo, an open-source alternative to Google Analytics.
Read article → -
Scala's List has a Secret
OOP couples the data with the methods operating on it, and this is considered bad in FP circles. But is it?
Read article → -
Tail Recursive Functions (in Scala)
Turning imperative algorithms to tail-recursive functions isn’t necessarily obvious. In this article (and video) I’m showing you the trick you need, and in doing so, we’ll discover the Zen of Functional Programming.
Read article → -
Snippet: Tagless Final vs OOP
Snippet of code discussing Tagless Final vs OOP-style dependency injection.
Read article → -
Snippet: Remove blank lines from text
Just a regular expression.
Read article → -
Execute shell commands in F#
Snippet in plain F# with no dependencies. Features a neat shebang.
Read article → -
Using ScalaTest for Effects
Helpers for integrating with
Read article →cats.effect.IO
. -
Best practice for natural Ordering
Definitions of
Read article →scala.math.Ordering
MUST BE consistent withequals
, an often overlooked law that can lead to problems. -
Managing Database Migrations in Scala
The database schema should be described as code, in your repository. And you should be able to semi-automatically update your database schema on new deployments.
Read article → -
List static blog tags in folder (Jekyll, etc)
Script for listing the used tags of a Jekyll directory of articles.
Read article → -
I like Option.get
We should strive to make illegal states unrepresentable.
Read article →Option.get
is a partial function that, according to many, shouldn’t be in the standard library. Yet it doesn’t bother me; the inability of Scala to make it safe is the problem. -
Organize and Index Your Screenshots (OCR) on macOS
Screenshots contain text, text that should be searchable, as finding a screenshot later is the whole point of creating it.
Read article → -
Block comments on the web
Comments on the web can be toxic, and a waste of time. Here’s how to block them…
Read article → -
Generic IOApp alternative
Read article →IOApp
alternative, for Cats Effect v2, that can work with any effect type. -
Effect Runtime
Defining a “runtime” for Cats-Effect v2 that provides the underlying environment necessary (i.e.
Read article →ContextShift
,Timer
,Clock
). -
When My World Vanishes
It’s me, facing a hard to solve problem. It’s a difficult one, and I’m having problems focusing. I make some coffee, I move to another room, and I’m already thinking of running to some coffee shop, forgetting that we’re still in a pandemic.
Read article → -
Scala Snippet: Unlawful Effects
Unlawful/independent version of
Read article →cats.effect.Effect
. -
Running integration tests, with Scala + sbt
Scala sbt setup for separating unit tests from integrationt tests.
Read article → -
Scala Snippet: Flow/Processor to Effect
Converts an Akka Streams
Read article →Flow
into anIn => IO[Out]
method, thus wrappingFlow
into Cats-Effect’sIO
. -
Privilege
Today it’s my 38ᵗʰ birthday. I was born into privilege. Other people aren’t as lucky.
Read article → -
Scala Snippet: Safe Passwords
For security, it’s not a good practice to keep sensitive data in RAM indefinitely.
Read article → -
Sample Error Hierarchy in Scala
Mimicking the HTTP error codes.
Read article → -
Snippet: turn on JVM debugging in sbt
Remote debugging can be used to debug externally executed programs, useful to activate in
Read article →sbt
in order to keep using it while debugging with your favorite IDE. -
TypeScript Sample: Flow Sensitive Typing
Demonstrating Typescript’s untagged union types.
Read article → -
Retry Failing Tasks with Cats and Scala
Retry actions ending in failure via simple functions and Typelevel Cats type-classes.
Read article → -
Scala Snippet: Cats-Effect Resource to Reactive Streams
Cats-Effect’s Resource can’t be converted directly into a Reactive Streams Publisher. Beware!
Read article → -
ExecutionContext Must Be Stack-safe
Sample demonstrating that directly executing runnables in your
Read article →ExecutionContext
(with no stack-safety) is a really bad idea. -
Fatal Warnings and Linting in Scala
Strengthen your code via
Read article →-Xfatal-warnings
, linting and piss off your colleagues with useful compiler errors. -
Parallelizing Work via a JavaScript Semaphore
Simple and very effective implementation of a Semaphore, used for easily parallelizing work in JavaScript/TypeScript.
Read article → -
Blog Updates
Dusted off my website, with big plans ahead.
Read article → -
Python Snippet: Send Email via SMTP
Python snippet for sending an email via SMTP.
Read article → -
Shell Snippet: Encrypt Files with AES256
Quickly encrypt a message or a file for sending to your colleagues over unsecure messengers (Slack, etc).
Read article → -
Haskell Snippet: Sierpinski Triangle
A fun Haskell sample that draws a Sierpinski triangle via ASCII characters.
Read article → -
Regexp Replacement via Function in Java/Scala
Replace in strings via regexp, with the replacement being calculated via a function.
Read article → -
Async Queue in TypeScript
Production-ready, Promise-enabled async queue.
Read article → -
Scala Snippet: Blocking Task
Monix Task implementation for wrapping (suspending) blocking I/O such that it can be canceled. s Imported from gist.github.com.
Read article →