Today’s realization is that you can get important things done by consistently working on them for 15 minutes at the start of every day.
By doing it at the start of the day, you ensure that it gets done. And the rest of the day you don’t need to be stressed about not working on your important thing, because you already have.
Newsletter December 2024: Advent of Code
December is the month of Advent of Code. I had told myself not to participate this year because I know I get completely consumed by the problems and it has a negative impact on the rest of my life. It worked. Until December 15th. More on that later.
Code Editor Update
Last month I started working on a new code editor. It is a mix of a text editor and a structured editor. It is all text, but parsers and pretty printers allow you to work with a tree structure and not think too much about syntax.
I continued working on it this month. The big achievement was that I added support for another language in addition to JSON. The other language is rlmeta. Here is a screenshot showing the parser opened in the editor:
This is a big achievement because it ties everything together. You define a parser and a pretty printer for your language. That gives you all editing capabilities. However, you can also write a code generator, and now you have a full blown programming language with editing support “for free”. This potentially provides an environment to quickly experiment with new programming languages.
Conceptually, I’m quite happy with this achievement. However, there are many things to work on before this is “production ready”. First of all, the performance is pretty horrible because of the constant parsing and pretty printing. Second of all, I need to see if a tree based editor can actually become better than a regular text editor.
Advent of Code
I couldn’t help myself but to participate this year as well. The experience was not as stressful as last year. I still got consumed by the problems, but the feeling was mostly positive. I managed to complete all but 3 problems. Right now, the interest to complete them is pretty low. I might take a look at other solutions to see if I can learn something from that.
My approach to solving the problems is that I try to solve them in order, and I don’t look at others' solutions until I have solved both parts. However, I’m out of ideas to try on the last problems, and I think the competition part is over by now. I might learn something for next year if I look at solutions now.
This year I also practiced object oriented design. So my solutions involve many small objects interacting with each other to produce a solution. It was mostly a success I think. One of my favorite solutions is for day 11.
This year I also think that I got the hang of Dijkstra and A*. (I found Introduction to the A* Algorithm from Red Blob Games really helpful.)
You can find all my solutions on GitHub.
Today I ran part of the way to work. It was a cold, beautiful winter morning in Stockholm.
Sometimes, I solve programming problems by coding on paper. A few days ago, it looked like this:
I’ve started working on a code editor that is a mix of a text editor and a structured editor. It is all text, but parsers and pretty printers allow you to work with a tree structure and not think too much about syntax. It is a work in progress. Code is here.
We got some more snow. I like running in the winter. Especially when there is snow and the sun is shining.
I needed to submit some heic photos to a service that only accepted jpg. I didn’t know about the heic format, but a little searching gave me a solution:
$ heif-convert
bash: heif-convert: command not found...
Install package 'libheif' to provide command 'heif-convert'? [N/y] y
...
$ find . -iname '*.heic' -exec heif-convert -q 100 {} {}.jpg \;
Today was the first day of snow this season. Not much. I’m looking forward to many more runs on a white trail.
I was researching how to run Black (and possibly other formatters) from Vim and found Ergonomic mappings for code formatting in Vim. It was very helpful.
How would you improve this code?
def update_r_users(service)
r_users = []
for user in service.get_all_users():
if "r" in user:
r_users.append(user)
service.set_users_in_group("users_with_r_in_name", r_users)
Find out what I did it in my latest newsletter.
Today I learned about the Rison data serialization format. I wrote a function to convert a Python value to Rison format. It was an elegant recursive function with partial support for the format.
I’ve used testing without mocks quite extensively now. I’ve also used it in a work project for more than a year. My experience is that it’s the best testing strategy that I’ve ever used. I’ve never felt more confident that my code works. I refactor code without fear of it breaking. It’s so good.
It’s getting dark. It gives variation to the running.
Various things have kept me from running for a while. Today I had enough. I just had to go for a short run. It was the first run with warmer clothes. The weather was nice. I reclaimed some energy.
Pull requests discourage experiments because changes can only propagate after approval. The idea behind PRs is to only approve “good” changes.
First, the learning opportunities of mistakes are gone. Second, you might loose interest in experimenting because you are afraid of making mistakes.
Today I just needed to run. I had not run since I hurt my achilles tendon almost a month ago. I wanted to see if it still hurt. I felt something, but not too much. I think I still need to take it easy with running, but man it felt good moving again.
If you want to know how to implement a Bash-like shell, with support for redirects, in only 31 lines of Python, you should check out my latest blog post Bash Redirects Explained.