blog SQLite Virtual Tables from Django

Sqlite has support for virtual tables which can be used for external datasources. There is an example csv data source that allows you to query a csv file as if it was a regular table.

.load ./csv
CREATE VIRTUAL TABLE temp.csv USING csv(filename=FILENAME);
SELECT * FROM csv;

I do not really want to write C for this, but I found the rusqlite project which allows writing a loadable_extension that provides virtual tables. Using their vtablog example (slightly modified) I was able to test from sqlite with a rust module.

Read More →

blog Factorio: Space Age

Recently completed Factorio: Space Age with my weekend gaming group . This is a group who have been playing games together for many years, and we tend to rotate through various games.

While on Nauvis, two of our group kept biters in check, while one worked on the main factory parts and I often worked on resources. Once we were ready to expand to space, we each took a planet to be in charge of. I was in charge of Vulcanus which we tried to setup reasonably quickly, due to a few achievements we were also trying to go for this run.

Read More →

blog Weekend Gaming Group

For quite a while, nearly every Saturday, I have a core group that plays games together. Two of the core games that brought us together are Natural Selection (2002) and Guild Wars (2005) though our regular weekend gaming didn’t start till sometime later after that. I am uncertain when we started doing regular gaming together since we previously used IRC for collaboration, but our shared calendar’s oldest entry is 2018-11-25.

One of the challenges of the group, is our distributed timezones with one in the United States, one in Canada, one in the United Kingdom, and one in Japan. Our current game time is pinned to one member’s daughter’s bed time. This mostly works due to our UK member being fine with an all nighter.

Read More →

blog Home Assistant, ESPHome, and Unexpected Changes

I have been using esphome with various m5stack controllers with home assistant for collecting environment data in my apartment. Being able to write a bit of yaml and have a fairly functional sensor is great.

I have been using the picture element card with some state badges to have a nice overview of my apartment and it has generally worked well. I noticed however with a recent update, that all of the badges had a much longer label and needed to look into what changed.

Read More →

blog Dotfiles in External Worktree

As a developer, I tend to keep all kinds of things beyond just code managed with git.

In the past I have used a ~/.dotfiles repo with multiple symlinks, though there are alternate ways to handle it.

Having remembered that bare repositories and alternate work-trees are a thing, I did a short search before finding a tutorial. Initially using their example directly, we arrive at commands that look like this.

Read More →

blog Offline Code Reference

While most code forges have a decent way of navigating code, going back and forth becomes tedious and it can often be easier to check things offline. The trick I use on my machine, is to combine alfred and a alfred-repos plugin for helping make things easier to search.

Using my own forked version to add some icons, I have a configuration file that looks like this.

{
  "__workflow_last_version": "4.1.0",
  "app_alt": "Terminal",
  "app_cmd": "Gitup",
  "app_default": "Visual Studio Code",
  "app_ctrl": "Browser",
  "global_exclude_patterns": [],
  "search_dirs": [
    // Projects is self explanitory
    {
      "depth": 2,
      "path": "~/Projects",
      "icon": "project.png"
    },
    // References is any 3rd party code I might want to view
    {
      "depth": 2,
      "path": "~/References",
      "icon": "references.png"
    },
    // I keep some documents in git as well
    {
      "depth": 2,
      "icon": "document.png",
      "path": "~/Documents"
    }
  ]
}

Adding icons gives me an extra visual hint what type of repo is found from Alfred.

Read More →

blog Making a Start Page

Even though I wrote about it in a previous week note I have not been using my start page to much yet. Yesterday I randomly decided to start using it after cleaning a few things up. Combined with my dev server I had some of the pieces ready.

First, I configured Firefox to change my start page to start.localhost, where I have my page running. Unfortunately, while you can configure the home page, you can not currently configure the new tab page.

Read More →

blog Norikae Dev Server

Over a year ago, I wrote my first draft dev proxy launcher in Async Python, based on an idea I had to have something like xinetd for my various in development projects.

[service.django]
host = "django.localhost"
port = 8001
cwd = "~/Projects/my-django-project"
command = "uv run manage.py runserver {port}"
delay = 3

[service.hugo]
host = "hugo.localhost"
port = 8002
cwd = "~/Projects/my-hugo-site"
command = "hugo server --buildDrafts --buildFuture --port {port}  --liveReloadPort 80"

While the Python version validated the idea, and usually worked well, there were a few cases that did not work as well.

Recently, I decided to work on a new version using rust and hyper to handle the proxied requests, which I have named Norikae (乗り換え).

Read More →

blog Attempting a Windows Service

On my Mac, I wrote a small nagger app to help remind me when I may have extended a break too long. It is connected via mqtt to a hardware bell I have on my desk.

Recently I have been spending a bit too much time in Factorio so wanted to see if I could make a similar version on Windows.

I have not previously used my Windows PC for development (I do all of my work on MacOS or Linux), so the first step was to install VSCode, uv , and git. This was not particularly difficult and recently it seems like installers automatically handled updating PATH for powershell.

Read More →

blog Entry Points With Enums

While updating my PowerPlug ( pypi ) project, I implemented a pattern I have started using in a few other places that I use entry-points .

By creating a custom enum using one of Django’s enumeration-types , you can make it much easier to load these modules.

from importlib import metadata

from django.db import models
from django.utils.translation import gettext_lazy as _

class EntryPoints(models.TextChoices):
    APPS = "powerplug.apps", _("Installed Apps")
    REST = "powerplug.rest", _("Installed APIs")
    SIGNAL = "powerplug.signal", _("Installed Signals")
    TASK = "powerplug.task", _("Installed Tasks")
    URLS = "powerplug.urls", _("Installed URLs")
    CONTEXT = "powerplug.context", _("Installed context processor")

    def group(self) -> metadata.EntryPoints:
        return metadata.entry_points(group=self.value)

Using an enum like this, makes it very easy to load one of our entry points, while keeping all the definitions for our app in a single place.

Read More →