Clojure Projects

24 March 2025

I have a long list of Clojure projects I’ve created over the years to learn Clojure and accomplish various personal tasks.

Advent of Code

As of the end of 2024, I’ve done at least some of Advent of Code for 7 years in a row. I’ve had the most fun and practice parsing and transforming the input data for each puzzle.

I learned pretty quickly from the puzzles to store the common grids as sparse maps to save lots of memory and keep the problem in memory. I sometimes got stuck on the puzzle and the algorithm, but I still got lots of practice in general Clojure. I definitely see that the Clojure data structures lend themselves well to the puzzles. I’ve gotten to effectively apply lots of common Clojure libraries like core.async and core.logic.

Incidents

My incidents project scrapes an RSS feed of emergency response incidents in Lancaster County and stores them into an XTDB database for history. It generates static site of current events with hiccup and historical charts with Clerk.

Running this project day-to-day, I learned that the Clojure/JVM start up is a bit too heavy to start frequently from cron, so I run it as a service in systemd with its own scheduling. Clerk and the amount of data I’m processing is also a bit heavy, so I have that scheduled to rebuild less frequently than the scraper. The site is still all static.

Event Logger

With this CLJS project, I was trying to derive a standard shadow-cljs workflow to make sure I could start any new CLJS web project quickly. It started using Reagent, and I migrated to Helix to be less-insulated from newer React features. I also wrote code to migrate data in local browser storage from an old Transit format to EDN. I’m constantly learning the better flows for data in React and local storage.

COVID Warehouse and COVID Web

The beginning of 2020 provided some of us with lots of downtime, so I started loading and analyzing Johns Hopkins University’s data on COVID with my own data warehouse and web app to display my data.

The data was pretty messy early on, and it changed over time, so I needed to parse lots of different formats. I generated a static site with my historic graphs and focused on World, US, and counties in Pennsylvania. It was a classic ETL for a star schema data warehouse, since I wanted to refresh my experience on that. I initially stored in in a SQL database using hugsql and next.jdbc.

After a bit of time, this became my first project to explore CRUX/XTDB and NoSQL data structures. I learned a bit about how changes applied in XTDB and how to limit history and otherwise save space on my small server environment. I could easily apply core.async when it was time to get things done faster.

The web app project that I added later provided a more dynamic Reagent app in CLJS that used the static data produced by warehouse project.

Planning Poker

I wanted a simple tool for conducting planning poker in sprint planning, so I built one in JS to run on mobile phones. When I started learning CLJS, I converted it to Reagent and used Leiningen to build it.

Clojure All the Other Things!

I’ve enjoyed finding there are ways to apply Clojure to everything!

Structured Intepretation of Computer Programs

Music in Overtone

I have a project where I play with data structures for music and explore lots of examples in Overtone, including Rich Hickey’s experiments in additive synthesis and sequencing some simple beats from drum-n-bass tutorials for other DAWs.

It required lots of yak-shaving work over the years to keep the native wiring to Supercollider and Linux sound working.

3D Objects

I’ve found a library to interface Clojure to OpenSCAD, so I have some 3D models defined in Clojure code for printing.


LetsEncrypt

18 September 2018

Months ago, I started setting up LetsEncrypt using certbot on my Debian web server. It hosts multiple virtual hosts, so I setup 2 different sets of certificates: one for hjsoft.com/www.hjsoft.com and the other for johnflinchbaugh.com/www.johnflinchbaugh.com/blog.johnflinchbaugh.com.

On Debian, at least when I got started, it was recommernded to have certbot shutdown your apache2 and let it start its own temporary web server to verify the LetsEncrypt setup (--authenticator standalone). The other trick is to register multiple domain names for one certificate by repeating the -d option. I did this with this invocation:

certbot \
    --pre-hook "systemctl stop apache2" \
    --post-hook "systemctl start apache2" \
    --authenticator standalone \
    --installer apache \
    -d johnflinchbaugh.com \
    -d www.johnflinchbaugh.com \
    -d blog.johnflinchbaugh.com

I got it started a couple months ago, but I didn’t know how to setup multiple domain names, so I was always getting errors that this certificate was for a different name: johnflinchbaugh.com instead of www.johnflinchbaugh.com, etc.

That’s all sorted out now, and all my sites should be SSL all the time.

For more information on setup, certbot has a great set of guides based on your OS and web server.


A Groovy First Monday

22 September 2010

The new K-Prep website is implemented in Grails now, so I was looking for a Groovy way to let the computer do the heavy lifting of figuring out dates for each week (starting with the first Monday) of the school year and matching them to a list of themes.

I got the algorithm working in about 8 lines of Groovy code, and then generalized it a bit more for you here to allow you to ask for any day of any week of any month. e.g. 3rd Wednesday in December.

To get the date for the 3rd Wednesday in December, my call looks like this:

dayByWeek(2010, DECEMBER, 2, WEDNESDAY, 0)

And the implementation looks like this:

import static java.util.Calendar.*

def dayByWeek = { year, month, week, day, shift ->
    def c = Calendar.instance
    c.minimalDaysInFirstWeek = c.firstDayOfWeek + 7 - day
    c[YEAR] = year
    c[MONTH] = month
    c[WEEK_OF_MONTH] = week + 1 + (shift?:0)
    c[DAY_OF_WEEK] = day
    c.time
}

The shift parameter allows me to optionally start a theme on the previous week in cases where that day is the end of the previous month. The static import allows me to conveniently refer to the Calendar constants without qualifying them, and finally, setting the minimalDaysInFirstWeek allows days early or late in the week to still be found when the Calendar would have otherwise preferred a longer week to start searching.


Events for the Photo Site

26 February 2010

Way back in the day, when I used to shoot at clubs and raves, I'd always want a way to share the images with the people I'd meet, but exchanging email could be a bit cumbersome or just be a deterrent.

While I'm not out clubbing these days, I'm still often out at various events, so I still need a quick and easy way to point people to the images, so I just added the Event Code box to the photo site.

While I'm out shooting, I can create an event code (from imagination or using my phone), and then write that short code on my business card to hand out. Then it's really easy for someone to hit my site, punch in the code, and get right to the photos on Flickr or in the Gallery.

It's just one of those little things I've wanted for a while, and now I've finally added it.


All the Posts

March 2025

September 2018

September 2010

February 2010

January 2010

March 2008

January 2008

August 2007

February 2007

November 2006

October 2006

September 2006

August 2006

July 2006

June 2006

May 2006

April 2006

November 2005

June 2005

May 2005

February 2005

January 2005

December 2004

October 2004

September 2004

June 2004

May 2004

April 2004

March 2004

January 2004

September 2003