Brianna Rainey's Blog

Funtimes is offline now because bat2web is not good enough. I designed it to work on the terminal first, and making it work on the web was an afterthought. Also, I knew less about Flask when I made it (which is why you can't save the game into a cookie yet).

When requesting input from the user, as a quick hack to make it work online, bat2web enters a while loop and continuously checks if user input is in a queue that gets filled by another thread. It's bad, but it works... kinda. I'll call it a proof of concept. 😛

There's two methods I've thought of to improve the program. One method would be a better system for separating these threads into different processes, keeping them alive as we do now, and managing them at a higher level. That sounds annoying, although it would be cool.

Another method (which I'm more inclined to do) would be to make Batchfile.py's state serializable so that the Python process can be started fresh with each network connection.

I think I can re-enter an arbitrary part of a batchfile chain if I store the callstack with line-numbers and the currently defined variables. I think it would work? 🤔 Perhaps not for all batchfiles, but it should work for Funtimes.bat

The server would receive the callstack as a list of dictionaries, and the variables as a dictionary. Create a new Python process with Batchfile.py, then define the variables and jump to the line-number belonging to the last member of the callstack list. If an exit must be performed, pop the last item from the callstack and go to the line-number above it. When the callstack is empty, exit the program.

Not sure if I'm going to program this or if it would actually work, but it's an idea.

I was already pretty satisfied with Python tracebacks, but these improved tracebacks coming in 3.11 look awesome: peps.python.org/pep-0657/

Instead of just saying the line where an exception occurred, it will also identify the column using arrows. Small thing but it should save some time while debugging. I didn't think it sounded too special before, but seeing the examples in that PEP makes me excited for it 👍

So I wanted a reminders app for the tmux statusbar, and I also wanted a =^.^= in the tmux statusbar as I mentioned here: tassaron.com/@brianna/10827462

I combined the ideas and wrote this small Python script + tmux plugin today & last night. It's called nagcat: github.com/tassaron/nagcat 🐈

You can customize the cat's appearance from the CLI. By default it will show =^.^= if you have no overdue reminders, or =u.u= if it's after 14:00 and you need to drink water. The reminders can be edited with "nagcat config" ('drink water' at 14:00 is the default reminder).

Say "nagcat why" and nagcat will tell you what the reminder is. Say "nagcat pet" to calm nagcat and stop the reminder for today. Reminders are always daily and are defined in 24-hour time in a json file. The data is like {"14:00": "drink water"}

The "tmux plugin" part is just a small Bash script that replaces #{nagcat} in the tmux statusbar with a call to the Python script. And apparently pip can put shell scripts on $PATH for me without much work, which is handy. Setup is `pip install nagcat` and adding a single line to the tmux conf

I think I'm gonna use this a lot! =^.^= And I'll probably discover some fleas on it this week, since it's new 🙃

Oh cool, you can add a `scripts` key to setup.py and it actually just works like you'd want it to. It puts a Bash shell script in the $PATH! So creating a Python package which installs a corresponding tmux plugin is easy :)

older posts