Albin Larsson: Blog

Culture, Climate, and Code

Making Everything an RSS Feed

17th July 2023

A while back I made a goal along the line of “make all the data on available as an RSS feed”. One might ask why, well, I think that one shouldn’t be required to use the FornPunkt website to access and reuse its content. I also think that RSS is a great format for this given that most content has a temporal component to it and that RSS has many great clients, integrations, and extensions.

And so on. Some of these are more useful than others. The GeoRSS ones appear to be rather popular while the “Comments on a given post” is not very much used. Ii wasn’t much overhead to add these feeds as I already had two base classes for RSS and GeoRSS feeds in the core Django application.

In the end not only do users end up with the option to use one of many RSS clients, but there is also an extra set of APIs that might be more accessible than many of the other APIs given that RSS is a well-known format and that it is easy to discover. Will I keep to this goal? Will I expand it to other sites? I don’t know, but given the low overhead in this case I do not yet regret it.

New York Times Sudoku Scraper

12th May 2023

You get home late and go to bed only to find that you missed the New York Times’ daily sudoku puzzle? Maybe you skip the puzzle one day? Or maybe you just want to play it in an app of your choise.

I just wrote a basic script, which uses Regular Expressions to extract the puzzle from the New York Times website. I’m particularly fond of how it parses the JavaScript game data as JSON, who knows how long it will last. Combined with a sheduled Github Action’s workflow and a little bit of Git scraping it should pull the hard pussle each day and store it in a .sdk file.

The script is available on Github and hopefully it will build up a nice Sudoku archive over time. Now I just need to make it easier to load custom games into GNOME Sudoku.

Quick Links in Django Admin

12th January 2023

Whenever you are viewing a model-page in Django’s admin-interface there is a sidebar to the left giving you quick access to other models:

Screenshot of the default sidebar on a model page.

This sidebar, however, isn’t utilized on the start/index page. By enabeling the sidebar we can get space for various types of shortcuts and links that can be useful to admins. The sidebar will also fit right into Django’s structure and style.

Screenshot of a sidebar with quick links on Django's admin index.

By creating templates/admin/index.html in our ocal project we can override the default admin index from Django an replace it with our own. Because the default page contains the template block hosting the navbar, even through it’s unused we can extend the existing Django’s template and reuse the pattern/semantics used by the sidebar eslewhere.

Here is an example creating two sidebar sections with two links each:

{% extends "admin/index.html" %}

{% block nav-sidebar %}
{% load i18n %}
<button class="sticky toggle-nav-sidebar" id="toggle-nav-sidebar" aria-label="{% translate 'Toggle navigation' %}"></button>
<nav class="sticky" id="nav-sidebar">
    <input type="search" id="nav-filter"
         placeholder="{% translate 'Start typing to filter…' %}"
         aria-label="{% translate 'Filter navigation items' %}">
    <div class="module">
                <th scope="row"><a href="#">Email</a></th>
                <th scope="row"><a href="#">Report Bug</a></th>
    <div class="module">
                <th scope="row"><a href="#">Repository</a></th>
                <th scope="row"><a href="#">Backlog</a></th>
{% endblock %}

Python Dependencies and Flatpak

7th November 2022

I’m learning how to create responsive Gnome applications with Python, GTK4, and Flatpak. One of the early issues I ran into after I generated a new Python project using Gnome Builder’s built in template was how to make Python dependencies from the Python package index aviable to my app.

I’m currently lacking a good resource describing the solution for my development log, so here is my take.


If you generated your project using Gnome Builder, you likley have a JSON file in the root of your project directory it bears the name of your application identifier. This file, it turns out, is called a Flatpak mainfest.

It contains a section called “modules” which in my case is an array containing a single object(module for the application itself). This array, however, does not only take objects. It also takes strings/paths to other manifests.

For each of one’s PIP dependecies we need a module definations. Once generated, module sections might remind you of lock-files. It would be cubersome to create these “manually” or induvidually. So there is a “Flatpak PIP Generator” script that among, other things, that can generate these module definations given a requirements.txt file.

Put the flatpak-pip-generator script in the root of your project(you might want to add it to your .gitignore). Then create a requirements.txt file containing all your direct dependecies and then run:

./flatpak-pip-generator -r requirements.txt -o python-deps

The above should have generated a Flatpak manifest file named python-deps.json in the root of your project, containing one module defination for each dependency.

In the “modules” section in the initial Flatpak maifest one can then add a new entry python-deps.json. Now your app should build and run with all the dependecies avaible. If it dosn’t run make sure you clean and rebuild the project as the module configs might be cached.

Final notes

Here are some of the resources that I used while tinkering with the above: Flatpak documentation, a StackOverflow question and a Gnome Discourse question.

Older Posts