So I felt I couldn’t really bring myself to do Advent of Code this year since I have more than enough other things to do (and watch and play) and with work and the kids, it’s always pretty miserable to keep up.
I saw this thing called December Adventure though and that fits in nicely with my current push to release a major update for Cuppings. If I’m going to be programming until late this month, then I’d prefer it to be on something that I can release.
I can’t promise that I won’t do any AoC (Factor is looking mighty cool) but I won’t force myself to do anything. With that, let’s get going.
1/12
I started working on the map view which clicking around looked like it could be really annoying. I found some dead ends and was afraid I’d have to hack in Leaflet support myself but I found a dioxus example hidden in the leaflet-rs repository.
Yes, I’m writing this website in Rust/WASM, why do you ask?
That example required a bunch of fiddling with the configuration and a couple of false starts, but now I have a vanilla map view.
I can say that I’m amazed that in this ecosystem 1. an example exists 2. that example works 3. it works in my project with a bit of diffing and 4. it seems to do what I need.
I raised a PR to the project to advertise this example on its README just like it does the others so that others wouldn’t have to search like I did. That PR got merged:
https://github.com/slowtec/leaflet-rs/pull/36
2/12
Today I’ll see if I can tweak the map view to show the location of the cafe we tapped and get things to a point where I can commit the change.
To do this I need to figure out how to pass information along to a router when we tap a venue. That should be easy enough but the Dioxus documentation is between 0.5 and 0.6 now and a lot of it is broken.
A tip from the Discord said I need to put the data into a context from a parent and then get it out again in a child. It’s a bit roundabout and required some refactoring, but it works.
Done on time even for a reasonable bed time.
3/12
Turns out my changes from yesterday did not make it to the staging server. I’ll fix that and manually run the job again.
That’s these annoying wasm-bindgen version errors that keep happening and that require a reinstall of this: cargo install -f wasm-bindgen-cli --version 0.2.97
and the dioxus-cli
. Dioxus which by the way is preparing its long awaited 0.6.0 release.
Yes, I build this on the same Hetzner box that hosts it. So here you go: https://staging.cuppin.gs
Other than that not that much will happen today since I spent most of the evening noodling around with Factor (despite my intention not to do any weird programming). It’s a nice language that’s very similar to Uiua which I tried out a while back but not being an array programming language makes it feel somewhat more ergonomic.
4/12
I can’t describe how nice it is to wake up and not have to deal with a mediocre story line involving elves and try to find time to attack a programming problem.
After today, I’m going to need that quiet morning, because I spent until 01:30 debugging an issue: Going to a detail view from the frontpage worked, but loading a detail view directly would throw an error.
There were two issues at play here:
Leaflet maps don’t deal well with being created multiple times so either we have to call `map.remove()
or we have to check whether the map has already been created and keep a reference to it somehow.
I solved it by pushing the map into a global variable:
thread_local!(static MAP: RefCell> = RefCell::new(None));
These are Rust constructs I would normally never use so that’s interesting. More interesting is that they work in one go and that they work on the WASM target.
Then the error was gone but the page was blank. Not entirely sure what was happening I poked at the DOM to see all the map elements there but simply not visible. Turns out that because of the different path, the path for the stylesheet was being added to the URL like this: http://127.0.0.1:8080/venue/176/main.css
It just has these two lines:
#map {
width: 100%;
height: 100vh;
}
But without a height the map is invisible.
Both issues are solved but not committed. I’ll see tomorrow whether I’m happy with the solution and how to package this up. Also I’m not sure how main.css
is being served on production and whether the same fix will work there.
5/12
I couldn’t help but noodle on Advent of Code a bit. Here’s my day 1 part 1 in Factor: https://github.com/alper/advent-of-code/blob/main/2024/day-01/day-01.factor
I like Factor the programming language. It’s like Lisp or Haskell but without all the annoying bits.
The environment that’s provided with it, I’m not so keen about. It’s annoying to use and has lots of weird conventions that aren’t very ergonomic.
6/12
I’ve been bad and I’ve finished part 2 of day 1 of the Advent of Code: https://github.com/alper/advent-of-code/blob/main/2024/day-01/day-01.factor#L27
Not so December Adventure after all maybe. I’ll promise I’ll finish the mapping improvements I was working on tomorrow.
7/12
Went on my weekly long bike ride. Then in the evening I didn’t have that much energy for programming other than finishing Advent of Code day 3 part 1: https://github.com/alper/advent-of-code/commit/0a74c38e7641141e10b4c48203c9e414cc492e1c
(I looked at day 2 part 2 but that just looked very tedious.)
8/12
Got in a ton of commits on Cuppin.gs today. After fixing the map, I wanted to see what would happen if I would add all 2000 markers to the map.
Performance seems to be doable but this is probably not ideal for a webpage. Dynamically rendering the venues is something for later. For now I can probably get away with filtering for the 100-200 nearest locations by distance and dumping those into the map view.
Now I’m back debugging Github Actions. I’m splitting up the build and deploy of the backend and the frontend into separate actions. Compiling dioxus-cli takes forever which is a step I hope I can skip with cargo-binstall.
Iterating on Github Actions takes forever and there really doesn’t seem to be a better way to develop this or a better CI solution that everybody is willing to use.