Coffee into Code -- C8H10N4O2 => {}

I have made something useful, I think

Photo by Mark Fletcher-Brown As a developer I have created countless side projects that didn’t go far and weren’t very useful.

I think the most functional among them **allows you to translate text into covefe **

Recently I have hacked something together that solves a problem.


All three of my kids are competitive swimmers for our local Y swim team.


In a usual season they would be in the midst of competing in invitationals hosted by other league members in and around southwest Ohio.


Due to COVID, we are only having virtual meets. Now every team competes at their home pool. And then sends in their results to the host team after they are done swimming. Its not perfect but its safer and they get to compete.


What does this have to do with programming or side projects? I am glad you asked :)


Most swim meets publish their results using active.com’s meet mobile software. Its somewhat of a defacto standard for swimming results. Virtual meets make it somewhat less useful because not all teams are competing at the same time and the results are not known for a week or so.

What our team has opted to do is publish those results using a feature with our meet management software that publishes out to a static html site. I don’t think the generated markup has been updated since 1999. Here is the markup for the index page for reference.

<html>
<head>
<title>Meet Results: 2020 CFY Halloween Invitational-SPY</title>
</head>
<frameset cols="250,*">
<frame name="index" src="evtindex.htm" />
<frame marginHeight="1" name="main" src="main.htm" />
</frameset>
</html>


You can see it in action at: http://results.teamunify.com/ofsfymca

Because it was created when framesets were all the rage, it is not mobile friendly

Hytek live results on team unify

Each event is published to html that is wrapped in <pre> tags, with the results as a fixed length record.

Which is where I saw some opportunity. Since last year I had been thinking about this and started to play around with ruby and nokogiri to fetch the pages and parse the results. Earlier this year I switched jobs away from working in ruby and rails and missed it quite a bit. Once it was clear this was going to be our mode of publishing results I started to work on it more seriously.

I first built a process that fetches and parses results and dumps them into and array. That data is stored in a redis cache and updated every 5 minutes using a sidekiq job. Using rails and the excellent tailwindcss and tailwindui I built a frontend that would be mobile first and much more attractive. I even bought a domain and published it to heroku. There is a litte javascript sprinkled in using stimulus.js

Event List Page Event Result Page

https://ohsfymca.swimresults.live

That got it through the first weekend. Its pretty performant, unfortunately because it has a web portion and worker portion it requies 2 heroku dynos as well as their free tier redis. While it is very easy to use, I thought I’d like more flexibility. So I put some time and put it on a $5/month droplet on Digital Ocean. It uses nginx as a proxy to puma and a redis instance all on the same box.

I spent a lot of time figuring systemd scripts as well as what direction I wanted to go with installing ruby. This felt more difficult than it should have been. In the end I just compiled the version I needed from source. Using rvm startup was failing because if could not find, ruby or puma or bundler because rvm was installed under a non-root user doing the deployment. I am sure there is a way to make this work, probably with binstubs. I’ll probably circle back to this. For now its running, I’ll refactor later right?

This has really been a great way to experiment and learn. This is the first rails app that I’ve built that wasn’t an api. I am seeing how much SPA like behavior is possible with just using stimulus. I might get into some action cable and see whats possible similiar to Phoenix Liveview. Or maybe just rewrite it in Phoenix for fun.

Part of the journey was building up a CI/CD pipeline. I chose github actions as it didn’t seem any different than using the free tier of another service like CircleCI, Semaphore, etc. Run the tests, precompile the assets, then run the deployment via some ssh remote commands. Its pretty simple and fast. Espcially given the number of tests :D

In addition it has been fun playing around with the free tiers of some other Saas products. I am using skylight.io for APM and sentry.io for exception reports. It is really nice to have all these tools at your disposal to experiment with. I really miss working with Rails, Ember and Elixir, it has been very theraputic to work on this project and some others.