sudo fish

Over the last week I setup a Linux VM alongside my current work—I needed decent docker support and also I got somewhat fed up with Windows as a development system.

Setting up a new system means I got to use sudo a lot, but often I typed a command line and only then realized I had to use sudo. So I added a new editor binding to my ~/.config/fish/functions/

function fish_user_key_bindings

    # Prepend sudo to the command line with M-s
    bind \es sudo-commandline

~/.config/fish/functions/ looks like this:

function sudo-commandline -d "Insert sudo at the beginning of the command line"
    set -l cmdline (commandline)
    commandline -r -- "sudo $cmdline"

Now I can just type Alt-S in Fish shell and I get sudo prepended to my current input. A small thing, but it already saved me a lot of frustration!

Git Gone

A few days ago Eugene Yokota published a git-gone script which deletes local branches left over from pull requests. I liked the idea; at work we use pull requests a lot and I already have many stale branches around.

We use Windows at work, tho. I know, folks frown about Windows as developer system, and I sure do miss my Mac at times, but it is what it is, and the job’s worth using Windows. And with a few tweaks, Powershell 6, ConEmu and VS Code it’s a decent system to my surprise. Anyhow, the one thing Windows can’t really do is run Bash scripts, and unfortunately Eugene’s tool is a bash script.

So I wrote git-gone in Rust with the git2 crate and published it to Enjoy.

Recursive Exceptions

A couple of weeks ago a former coworker send me this piece of code I had writtten:

private def getRootCause(throwable: Throwable): Throwable = {
  Option(throwable.getCause) match {
    case None => throwable
    case Some(cause) => getRootCause(throwable)

D’oh! A nice endless loop. It caused quite nice spikes in garbage collection metrics and peak response times, and it took them a few days to find the root cause.

Ironically I had explicitly added @tailrec to make this piece of code behave nicely. If I had omitted it, StackOverflowExceptions would have triggered alerts almost immediately after deployment.

I am sorry.

Bad Joke

Since a few releases the Akka documentation has this to say about persistent FSMs:

Persistent FSM is no longer actively developed.  Don't use it for new applications; it will be replaced by Typed Persistence.

Unfortunate since we use Persistent FSM quite a lot, but such is life, technologies come and go, and I generally appreciate adding more type safety to things, in particular Akka which has so far been an untyped mess.

Clicking on the link reveals that Typed Persistence doesn’t quite make the cut:

Akka Typed Persistence may change and is not recommended to use in production just yet.

That’s a bad joke, isn’t it?

Though I fully appreciate the irony of the entirely contradicting advises on both pages. New applications aren’t production-ready anyway, eh?


So I forgot my headphones at home today. A few months ago I’d have turned back and gone home to get them—it was impossible to work without something against the noise.

Today I didn’t even notice.

But I don’t work in an open space office anymore.

UTC is the Worst

Me as a web developer: UTC is awesome! All use UTC!!

Me today: FUUUUUUCK LEAP SECONDS. Can we pleeeease all use TAI?

UTC is the worst; and it’s going to get way worse:

Some time in the 22nd century, two leap seconds will be required every year. The current use of only the leap second opportunities in June and December will be insufficient, and the March and September options will have to be used. In the 25th century, four leap seconds will be required every year, so the current quarterly options will be insufficient. Thereafter there will need to be the possibility of leap seconds at the end of any month. In about two thousand years, even that will be insufficient, and there will have to be leap seconds that are not at the end of a month. In a few tens of thousands of years (the timing is uncertain), LOD will exceed 86,401 s, causing UTC to require more than one leap second per day.

In 40.000 years People will hate us for three things: Global warming, Nuclear waste, and UTC LEAP SECONDS!

A little dirty…

I’m a decade into programming but I never touched a SOAP interface before. So last week was a first: I saw my first WSDL ever.

There’s not much Scala tooling around SOAP so I went for Java. Now I know a lot of acronyms like JAXB or JAX-WS (I have no idea what these mean tho), and I generated code from WSDL like in the perfect wet dream of a 00s SOA consultant. Mutable Java classes of course, but you get what you pay for.

Although I didn’t really understand what I was doing everything worked well—I even wrote an SBT plugin to run wsimport and publish the generated code—and I spent no more time with this stuff that I should.

But I do feel a little dirty now…

Towards Hugo

I moved my blog from Jekyll to Hugo, the not-so-new and cool thing for static pages. I didn’t pick Jekyll consciuously—it’s just that before Netlify I had my blog hosted on GitHub Pages which runs on Jekyll.

Read More…

Algebraic Data Types In Scala

Object-Oriented Meets Functional

Scala claims to unite object-oriented and functional programming, and offers a rich set features from both worlds. Developers coming from object-oriented languages—Java in particular—quickly adopt the object-oriented features of Scala but often struggle to find their way around functional programming. Some aspects of functional programming found their way into object-oriented languages: Higher order functions or combinators like map and filter appear in today’s C# or Java code, and even a preference for immutable data structures spreads out into conventional object-oriented languages.

But algebraic data types (ADTs) still do not appear in object-oriented programming although these enable the true power of functional programming: Types well-founded on theory let us model the problem domain in types and thus help us write correct-by-construction code which provides a higher level of compile-time confidence than possible with the type systems of most object-oriented languages. This article aims to help developers from object-oriented languages understand what it means, and become familiar with the basic set of algebraic data types commonly used in functional programming and its appearance in Scala.

Read More…

SOAP, a convenient interface

Last week we got a big PDF with documentation about the almost-but-not-quite-entirely-unlike-REST HTTP API of an external partner. In the section about restrictions of their HTTP API:

For this functionality we recommend to use the SOAP API. This convenient interface offers almost unlimited possibilities to integrate Foo.

Emphasis mine. I have different memories of SOAP.

Favorite posts

My favorite posts:
2018, Feb 24 Algebraic Data Types In Scala
2017, Jul 03 Maven Central Releases with SBT
2016, Nov 21 Bye Bye Emojis: Emacs Hates MacOS
2016, Nov 15 Read and write files in Emacs Lisp
2016, Jul 19 I wished GNU Emacs had…
2015, Nov 29 Reproduce bugs in emacs -Q
2014, Aug 12 Emacs script pitfalls
2014, Jul 02 Autoloads in Emacs Lisp
2014, Jun 16 Advanced syntactic fontification
2014, Apr 15 Calling Python from Haskell
2014, Mar 26 Search-based fontification with keywords
2014, Mar 12 Syntactic fontification in Emacs