Skip to content

Instantly share code, notes, and snippets.

@tyalie
tyalie / 01_readme.md
Last active November 9, 2024 19:01
Atuin ZSH up/down arrow integration

Simple script for zsh which gives us a more native up/down arrow behavior for the [atuin magial shell history][1] plugin with behavior similar to e.g. [zsh-history-substring-search][2]. This is an improved reimplemtation of [@Nezteb's gist][3] for the same issue.

Behavior

Note

This assumes default keybindings

First and foremost: The script is aware of multiline buffers. So when going up or down, the script will first try to step through the lines of a multiline buffer, before going to the next history entry.

When pressing up the shell will iteratively go through the previous atuin history and have each result directly in the command buffer / command line. Any text in the initial buffer will be used as a search query.

@tyalie
tyalie / 01 description.md
Last active February 27, 2022 11:44
Send with Ctrl-Enter on web.whatsapp.com

An annoyance of mine has always been that web.whatsapp.com doesn't allow switching ctrl-enter and the enter key. As every other chat application that I use has this feature it has happened more often than not that I accidentally send a message whilst trying to write a multiline one. Which is especially annoying considering that WhatsApp messages cannot be edited.

How it works

This script provides a solution for that. By overriding the EventTarget.addEventListener I can completely override how listeners should work and wrap them - if needed - in my own methods that prepare the events before giving them to the real listeners.

Interestingly enough the newest WhatsApp web version will use the Event.isTrusted property (which is provided by browser) in order to check whether to handle the event or not. Previous version didn't have that. And that is why the code is a bit longer than expected, as I first needed to create an object that looks like a keyevent, tastes like one, but has all it's properties on

# Disable keyboard on Gnome Wayland without disabling the screen or mouse
# This is incredibly useful when the only space left
# to take physical notes is on your keyboard
#
# I've last used it on a prolonged train drive
# 1. Get the event number of the device to be blocked
evtest # remember the path to the device
# 2. block keyboard
@tyalie
tyalie / _description.md
Last active August 21, 2020 11:42
An AdvancedSingleton for Multiple file management

I hit on a problem, were an existing code base with excessive multithreading (server) made excessive use of global variables for file handling. But this solution would crash the moment we enabled async executionn in the server application.

This class is just the fundament. In the project itself I don't return the file instance directly, but hidden behind another class that allows me read and write the original file threadsafe.

As such this class only handles the file open and close operations in a thread safe manner. The class garantuees that a file is only opened once. If multiple instances want to access a file they all get the same file instance.

But the class also closes a file instance if nobody wants to access it anymore.

@tyalie
tyalie / description.md
Last active August 13, 2020 17:11
Import all modules into global that are contained in folders named `tests`

This script traverses through the whole module tree starting from my_parent_module to find all python files that are contained inside a folder / module named tests (can be changed).

Usage

This script finds all modules / files that contain the module_to_search in their module path (my_parent_module.network.tests).

For that to work, the tests folder must a valid python module. Which means, that at least an empty __init__.py must be included.