~ephes

Building things with Django and coding agents. Breaking things in my home lab. Writing about both.

Weeknotes 2024-07-08

ZIZEK: that AI will be the death of learning & so on; to this, I say NO! My student brings me their essay, which has been written by AI, & I plug it into my grading AI, & we are free! While the 'learning' happens, our superego satisfied, we are free now to learn whatever we want --Zack Brown

Workwise, last week was quite busy. However, I managed to attend a meeting of PyDDF, our local Python user group, which was great. I also recorded and published a podcast episode about the DjangoCon Europe 2024 conference. Then I had to roll out a security update for Mastodon, which usually requires minimal maintenance, and updated Takahē along with it. There was also a new release of django-cast, which includes some bug fixes and a new feature: subtitles for blogs.

Here's a tip I discovered while trying to import pictures from my new camera: If you use Apple Photos to manage your pictures and it doesn't read RAW files from newer cameras, you can use the free Adobe DNG Converter to convert RAW files to DNG and then import them into Apple Photos. Unfortunately, it's not possible to preserve changes made in Nikon NX Studio, which has the best RAW support for Nikon cameras, when converting the RAW files to DNG.

Fediverse / Twitter

Out of Context Images

Read more →

Weeknotes 2024-07-01

ACARS Message From: C-FWJS/WS0456
Message: HI. I JUST ACCIDENTLY CLEARED AN ACARS MESSAGE BEFORE WE COULD READ IT. DO YOU KNOW WHAT IT WAS ABOUT..... --ACARS Drama

I made numerous small fixes and improvements to django-cast. I also dabbled in Rust game development again and can now draw 2D maps in LDtk and load them into a game. It's just a small step forward, but I didn't struggle with the compiler as much as I anticipated - I'm starting to like Rust.

The weather has been lovely lately, so we bought a barbecue and visited a nearby zoo.

TIL

Fediverse

Out of Context Images

Read more →

Unwrapping functools.wraps: How to Remove Decorators from a Python Function

Sometimes, you need to call a Python function without its decorators. I encountered this need while implementing custom exception handling for the ACS (Assertion Consumer Service) view in django-saml2-auth. This view was decorated with an exception_handler that rendered responses, which interfered with my custom handling. Fortunately, functools.wraps comes to the rescue, storing the original function in a __wrapped__ attribute.

Here’s an example to demonstrate:

from functools import wraps

def heading(f):
    @wraps(f)
    def wrapper(*args, **kwds):
        to_decorate = f()
        return f"<h1>{to_decorate}</h1>"
    return wrapper


@heading
def decorated_hello():
    return "Hello World!"


# Using the decorated function
print(decorated_hello())
# Output: '<h1>Hello World!</h1>'

# Accessing the original, undecorated function
print(decorated_hello.__wrapped__())
# Output: 'Hello World!'
Read more →

Weeknotes 2024-06-24

I really hate these new "Dyson Airblade" urinals --Souvlaki Space Station

Still battling this stomach bug. Managed to get some work done but didn't have much time for anything else. Filed a PR to fix last week's Wagtail issue and got the alt text for cover images working. Visited old friends near Stuttgart over the weekend for a party.

Music

TILs

Fediverse

Read more →

Python String Capitalization

I frequently copy titles from websites to use as anchor texts for links. However, these titles are often in all caps, and I don’t want to seem like I’m shouting. Previously, I would paste the all-caps title into a Python REPL, convert it to lowercase, and then manually capitalize the necessary words to make it look like a proper title. But today, I discovered a much simpler built-in solution:

>>> print("THIS IS A LOUD TITLE".title())
'This Is A Loud Title'

I had no idea about this function! 😅

Read more →