It has been 10 years since I moved to Japan.
While I still mostly enjoy a lot about living in Japan, this year was more challenging than previous years.
There is still uncertainty about what 2025 will hold but I remain optimistic.
Read More →
While experimenting with yamdl
to prototype an idea for a wiki-like django site, I was curious about the various lower level Django signals.
To better understand them, I wrote a simple app config to log the various checks.
To help them be more visible in the terminal, I have also somewhat randomly added some assorted colors.
import os
from pathlib import Path
from django.apps import AppConfig
from django.core.checks import register
from django.db.backends.signals import connection_created
from django.db.models.signals import class_prepared
from django.dispatch import receiver
from django.utils.autoreload import BaseReloader, autoreload_started, file_changed
from django.utils.termcolors import make_style
red = make_style(fg="red")
blue = make_style(fg="blue")
cyan = make_style(fg="cyan")
yellow = make_style(fg="yellow")
magenta = make_style(fg="magenta")
bold_yellow = make_style(opts=("bold",), fg="yellow")
class TestappConfig(AppConfig):
name = __package__
def ready(self):
print(bold_yellow("ready"), __class__, os.getpid())
if os.environ.get("RUN_MAIN"):
print(bold_yellow("On app thread"))
@register
def test_checks(*args, **kwargs):
print(red("test_checks"), args, kwargs)
return []
@receiver(connection_created, dispatch_uid="print_connection_created")
def print_connection_created(*args, **kwargs):
print(red("connection_created"), args, kwargs)
@receiver(autoreload_started, dispatch_uid="print_autoreload_started")
def print_autoreload_started(sender: BaseReloader, **kwargs):
print(magenta("autoreload_started"), sender, kwargs)
@receiver(file_changed, dispatch_uid="print_file_changed")
def print_file_changed(sender: BaseReloader, file_path: Path, **kwargs):
print(magenta("file_changed"), sender, file_path, kwargs)
@receiver(class_prepared, dispatch_uid="print_class_prepared")
def print_class_prepared(sender, **kwargs):
print(cyan("print_class_prepared"), sender, kwargs)
After adding my new app to my INSTALLED_APPS
setting, I get a similar output when I run it.
Read More →
I have several Django projects, like my timebox
or chore tracker
project.
Two fields I will often add to most models is some kind of description/memo field and a url/more field.
from django.db import models
class Project(models.Model):
# most of the model specific bits
...
# common fields I add.
description = models.TextField(blank=True)
url = models.URLField(blank=True)
I will typically allow either to be blank, since both are intended to be optional.
A name/title might be enough as a quick hint or label, but often having a longer description/memo field is essential to provide extra detail once you have enough objects.
I have mostly kept it as a plain text description (I will often use {{ obj.description|linebreaks }}
to allow a bit of formatting), though other times I will consider allowing a full markdown description.
Read More →
I tend to use my calendar and reminders to track a lot of what I want to do, but sometimes I want to manage the data externally and sync.
For certain kinds of repeating tasks, I wanted to edit a list of tasks in a group, and it seemed like csv might work.
While csv does not have a strong specification, many programming tools make it easy to work with.
The initial format I thought about was something simple.
Read More →
A friend recently wrote “our personal database
, about how they maintain a postgres database for various projects.
I wrote something similar when I wrote about my personal api
, though Rubenerd’s post made me want to write a little bit more about it.
Since I am already using django
for various projects, my personal API is also built on Django.
While I could modify thing directly using something like pgAdmin, building on Django means I can take advantage of the models
and admin
built in to Django.
Read More →
There have been a few times while working with Django
, where I have wanted to triger something only if the instance changed.
Since Django provides a robust signals system, I decided to use that for my prototype.
First we need to import the packages we will use.
from django.db import models
from django.db.models.signals import post_save, pre_save, ModelSignal
from django.dispatch import receiver
from django.forms.models import model_to_dict
Next, we want to handle our pre_save
signal.
We want to store a snapshot of the original object so that we can compare it later.
Read More →
Recently there is quite a lot of back and forth regarding ActivityPub based projects and Bluesky.
Read More →
Drinking more water.
Similar to a friend figuring out water
this is how I get myself to drink more water.
- A while back, I bought several 500 ml bottles from Daiso for about ¥ 100. At the beginning of the day I fill each of them up and put them in the fridge.
- Keep one at my desk. If I have a bottle next to me, I will reflexively drink sips while working.
- Any time I empty a bottle, I scan an nfc
tag on my desk to record it, and then get a new bottle from the fridge.
As a bonus, this also means short forced breaks throughout the day to empty water.
Read More →
3D Printing is still somewhat magical.
Several years ago, a friend gave me a ender3
that they were not using, and I have been using that for a few small projects, but it is an old printer so it is not always reliable.
Recently I have been considering 3D printing some more, and would really like to get a newer one.
Not unexpectedly, my recent youtube recommendations and now subscriptions have included quite a lot of 3D Printing, such as channels like Print Farm Academy
or Macy Makes
talking about creating 3D printing businesses or Hands on Katie
showing all kinds of things that she makes with 3D printing.
Read More →
I am not particularly fond of Kubernetes and have tried to avoid it as much as possible, but at times it feels somewhat inevitable.
In order to have a little more familiarity with how it works, I decided to go through Kubernetes the Hard Way
and setup a cluster.
Note:
If I was really going to use Kubernetes, I would likely use some project that managed it in a better way.
Going through this excercise is the same reason I went through Linux from Scratch
years ago to better understand how things were assembled together.
Read More →