• portrait

    anders murphy

    coffi to build a Clojure SQLite wrapper.

    turbo and datastar both of which use server sent events to broadcast updates to the client. Traditionally, server sent events work best with asynchronous ring handlers. But, personally I much prefer the simplicity of synchronous handlers, and with the advent of virtual threads we can have our cake and eat it. This post will go over how to build a synchronous ring handler for server sent events.

    structured concurrency, scoped values and binding conveyance. In this post we'll explore the performance limitations of dynamic var in the context of virtual threads and why scoped values exist.

    claypoole a fantastic library for simple but effective parallelism using thread pools. However, things get complicated with virtual threads, they shouldn't be pooled, as they aren't a scarce resource. So how do we limit throughput when we have "unlimited" threads? In this post we will look at using java Semaphore class to implement basic token bucket rate limiting to control throughput.

    virtual threads and Generational ZGC. Unfortunately, I couldn't find an easy way to use Circle CI with Clojure and Java 21. So I figured I'd give Github Actions a go.

    clj-kondo has had really nice datalog syntax checking for a while. However, on some projects you might have wrapped the underlying datalog query function q or be using a datalog implementation clj-kondo doesn't know about. Thankfully, it's trivial to add linting support to any implementation of the query function q as long as it conforms to the Datalog dialect of Datomic.

    Java 19 introduce virtual threads as a preview feature. Virtual threads are lightweight threads that allow you to write server applications in a simple thread-per-request style (as opposed to async style) and still scale with near-optimal hardware utilisation. The thread-per-request approach is generally easier to reason about, maintain and debug than it's asynchronous counterparts. In this post we'll cover configuring Jetty to make your ring handlers use virtual threads and benchmark it against regular threads to show how it alleviates the need for tuning thread pools.

    Java 19 introduce virtual threads as a preview feature. Virtual threads are lightweight threads that allow you to write server applications in a simple thread-per-request style (as opposed to async style) and still scale with near-optimal hardware utilisation. The thread-per-request approach is generally easier to reason about, maintain and debug than it's asynchronous counterparts. In this post we'll cover configuring http-kit to make your ring handlers use virtual threads and benchmark it against regular threads to show how it alleviates the need for tuning thread pools.

    a game jam game for PICO-8 using Fennel. This post goes over setting up a project to write PICO-8 games in Fennel.

    Application-Defined SQL Functions that lets you create custom SQL functions that call back into your application code to compute their results. This lets us extend SQLite in Clojure. Want to query with regex or jsonpath? Want custom aggregation functions? Don't want to write C? Don't want to manage different precompiled binaries for different operating systems. No problem Application Defined SQL Functions have you covered.

    Project Panama to explore building a simpler and lighter SQLite driver to use from Clojure. This required downloading and compiling SQlite from source for macOS/OS X.

    SendGrid are easy to use and offer a plethora of features like bounce and open rate monitoring, they are not the cheapest option. Gmail's SMTP service on the other hand, although not as feature rich, is more affordable. In this post we will cover setting up Gmail SMTP with postal.

    Honeysql is an amazing library that lets you write SQL using clojure data structures. This makes SQL much more composable as you no longer need to smash strings together. That being said, when using it with postgresql there are some features that don't work out of the box. Thankfully, honeysql is very easy to extend. This post will show you how to add support for alter column and add constraint.

    Relish mobile app is built in Clojure. It runs on Heroku and we use lein as our build tool. This has been a great development experience. But, for the next Clojure project I wanted to try tools.deps and tools.build. Unfortunately, there isn't an official Heroku buildpack and none of the unofficial alternatives were quite what I was looking for. In the end I decided to roll my own to get comfortable with Heroku's build pack API.

    Clojure highlighter from scratch in 160 lines which inspired me to add some very basic highlights back to this site. This post is about implementing my own Clojure highlighter from scratch in 8 lines (and a fraction of the functionality).

    open closed principle), this even extends to third party code. This decoupling is so good that it's not unheard of to deploy your system without all the defmethod extensions being required! This post will teach you how to prevent this.

    this post we created a macro called cond-merge to conditionally associate in values to a map. In this post we will revisit some of the limitations of cond-merge when it comes to nested conditionals and conditionals that return maps that can lead to overwriting data rather than merging data.

    the previous post we created a macro called cond-merge to conditionally associate in values to a map. In this post we will cover adding disassociation (removal of items) to this macro.

    cosine similarity to determine how similar two strings are to each other.

    next-jdbc uses parameterised queries to prevent SQL Injections. These queries can take parameters by passing question marks (?) in the query and then by replacing each question mark index with required values. However this can make some sql operators more challenging to use programmatically. In particular in(?,?,?). In this post we cover using postgresql's any(?) and all(?) to get around this.

    Apheleia is an awesome Emacs package for formatting code quickly using external command line tools like prettier. Not only is it fast but it also does a great job at maintaining point position relative to its surroundings (which has been one of my minor frustrations with other Emacs formatters). It's also language agnostic so you can use it with any language that has a command line formatting tool. This post will cover setting up apheleia with prettier (for JavaScript) and zprint (for Clojure).

    GraalVM is a recent development in the Java ecosystem that allows you to generate native binaries for applications that run on the Java Virtual Machine (JVM). One of the main advantages of this is that it gets around the JVMs slow startup time which is a problem for short lived programs that are run often. This has lead to a projects like zprint releasing native binaries. This is great but, it doesn't give you a nice reproducible way to install/manage/uninstall these executables. For that we want a package manager like homebrew.

    pre-commit to automatically format Clojure code with zprint to achieve a more streamlined workflow.

    homoiconicity. This article will explore this concept.

    Advent of Code problem and part of the solution required generating all the permutations of a set of numbers. Permutation is the act of arranging the members of a set into different orders. I wanted to write a recursive solution rather than an imperative solution. After some searching I found a Scheme implementation. As Scheme and Clojure are both dialects of Lisp, translating one into the other wasn't too difficult.

    Functional Pearls The zipper) to make manipulating hierarchical data structures simple and efficient. This article will cover how to use zippers to manipulate HTML/XML in Clojure.

    this article for an introduction to Clojure 1.10's tap system.

    Clojure Spec to generate test data to verify its output.

    SendGrid web API to email a .csv file.

    googlei18n/libphonenumber is a Java library for doing just that (and more). Thanks to Clojure's great java interop using this library in your project is straightforward.

    ProGuard. ProGuard overcomes "The 65k limit" by removing unused method references, this can make a big difference if you are using large third party libraries like Guava. If configured correctly (disabling optimization/obfuscation) ProGuard can have little to no negative impact on your build times (in the case of larger project it can even decrease build time).

    IntelliJ IDEA or Android Studio. Although, this eases the burden on the writer, it doesn't ease it on the reader. As a developer, you spend a lot more of your time reading code than writing it. This is where I find the additional cognitive overhead of boiler plate code has a habit of stymying development.

    lambda expression and method reference. Unfortunately, at the time of writing, Android does not support Java 8. Thankfully, there is a project called Retrolambda that allows you to backport lambda expressions and method references to Java 7. As Android uses the Gradle build system, this guide will be using the Retrolambda gradle plugin to add Retrolambda to an Android project.

    Butter Knife to the rescue!

    Advantages of an Android free zone

    27 Aug 2015


    In Android projects I like to set up an “Android Free Zone”. This is a Java module that doesn’t have any dependencies on the Android libraries. This is where the business logic of the app lives.

    © 2015-2026 Anders Murphy