Monday, 25 August 2025

TIL Python: f"hello {thing!r}"

 When formatting strings in Python, you can use a suffix to run a conversion on it:

Three conversion flags are currently supported: '!s' which calls str() on the value, '!r' which calls repr() and '!a' which calls ascii().

Some examples:

"Harold's a clever {0!s}"        # Calls str() on the argument first
"Bring out the holy {name!r}"    # Calls repr() on the argument first
"More {!a}"                      # Calls ascii() on the argument first

 I ran into it while reading tiktoken/core.py:

    def __repr__(self) -> str:

        return f"<Encoding {self.name!r}>"

Friday, 18 December 2020

Fixing Open AI Retro Gym - Windows Integration UI crash

 I had trouble getting the Windows Integration UI to work - it kept crashing.  It turns out you need to drop the downloaded exe in your python retro package's install directory. You can find that directory using:

import retro

print(retro.__file__)

 See also: https://github.com/openai/retro/issues/159


Bookmark all tabs at once in firefox

You can bookmark all the tabs in the current window at once in Firefox (in 2020) using ctrl-shift-d.

via askvg


Wednesday, 22 April 2020

Sharing a mouse and keyboard between computers

I wanted to share a mouse and keyboard between two computers today. It happens to be between two Windows PCs, so I tried out Microsoft's Mouse Without Borders, instead of my usual Synergy (or US224 USB Sharing Device).

 I like it. It's easy to install, and has the settings I want.



  • Benefits over Synergy: It's free (Synergy you need to compile from source, or pay for). 
  • Benefits over my USB Sharing Device: Sharing Device takes several seconds to switch computers, Mouse Without Borders does not. 
  • Downside to Mouse Without Borders: Windows only.

Tuesday, 28 February 2017

Another shadertoy experiment.

Another shadertoy experiment.  There is a long and slightly boring story behind it, but I think I'll just show it to you. You can click in different places to change its settings.



Wednesday, 22 February 2017

wrong bash.exe when installing Windows Subsystem for Linux

If you're following the instructions at https://msdn.microsoft.com/en-au/commandline/wsl/install_guide to get Microsoft's Linux environment installed, but you also have a Ruby devkit on your path, the "Run bash" instruction doesn't work.  Because it runs the devkit bash instead of the WSL bash.

You want "Run c:\windows\system32\bash" instead.



Tuesday, 20 December 2016

TIL - harvesting energy by radiating heat into space

Today I learned:


I like that.