kill Despite its name (that it’s gotten from its most popular usecase), kill is very versatile tool used to send specified signals to individual processes, or process groups.
It is part of the util-linux collection of programs and is widely available.
Here area a couple of usage examples. If no signal name/number is specified, SIGTERM (15) is assumed:
Send a SIGTERM (15) signal to every process invoked as 'firefox'.
I spent some time trying to get things to work and in the end I decided to compile the instructions in a compact and coherent guide.
Install Chromium 81.0.4044.122 or later, or Firefox 84.0-1 or later. Install pipewire, and if you’re using Chromium, libpipewire02 as well. If you’re using Arch, both packages are available in the official repositories. Install xdg-desktop-portal-wlr. It is available in the official Arch repositories. If you’re running Firefox, make sure that MOZ_ENABLE_WAYLAND=1 is set before you start it to make sure it’s running natively.
A short reference listing some of the common bitwise operations that I document as I encounter them
Create a mask with a single set bit (1 << k) can be used to create a mask where a single k + 1-th bit is set.
Extracting bits Say we wanted to extract the highest 3 bits of a single byte (0bxxxxxxxx). We create a bitmask with those bits set to 1s, and all other bits to 0s, and we AND the two values together:
As of writing, Unicode contains 1,112,064 possible codepoints.
Actual codepoints range from 0 through 0x10FFFF though a part is reserved for backwards compatibility of other codecs with UTF-16, resulting in 1,112,064 actually available codepoints.
It’s important to note that not all (in fact most) codepoints are not characters. A common example is the Combining Diaeresis (e.g. ï) or the “double dot above” mark that, when rendered, simply appears above the adjecent previous character.
This post documents my understanding of the basics regarding concurrency and parallelism and their manifestation in operating systems.
Definitions Before I begin I want to define what exactly parallelism and concurrency are. However as it turns out, this isn’t exactly set in stone, and the definitions are somewhat convoluted.
The StackOverlfow question (What is the difference between concurrency and parallelism?) in particular has quite a number of somewhat conflicting answers, which is understandable, since if someone asked me what the difference between the two terms are - I wouldn’t be able to answer.
This post summarizes behavior of different operations on FIFO files on linux and is to serve as a future reference. It may or may not go particularly in-depth on the subject, it depends.
All of this information is available in the fifo(7) and pipe(7) manpages.
Opening opening a FIFO for reading will block until it is also open for writing on the other end (“other end” here meaning inside another process or another thread in the same process).
Context Managers in python3 are a simple but powerful feature.
The most common example is opening a file and not having to worry about manually closing it later on, and instead letting the context manager implementation do the work for you:
with open("file", "rb") as file: ... Instead of having to manually call file.close() later on, once the “with” block ends the associated cleanup (in this case flushing the file to disk and closing the file descriptors) is automatically performed.
Decorators are a way to modify behavior of functions using other functions.
Take a look at the following routine:
def sum(x, y): return x + y Say we wanted to alter this function so that it would always return a result by 1 larger than the sum. We can write a decorator for that:
def increment(func): def add_one(x, y): return func(x, y) + 1 return add_one @increment def sum(x, y): return x + y > sum(5, 4) 10 Under the hood, sum becomes increment(sum), i.
Recently I needed a way to infinitely loop over a list in Python. Traditionally, this is extremely easy to do with simple indexing if the size of the list is known in advance. For example, an approach could look something like this:
l = [1, 2, 3] i = 0 while True: print(l[i]) i += 1 if i == len(l): i = 0 Eventually I settled on a an inbuilt approach using the itertools module from the standard library.
Python is a programming language. It is nothing more but one large document of text and code examples (a standard) that describes exactly how the language is to behave. You can’t run it, download it, or execute it. That’s it, it’s just text.
The latest edition of it is up on the official Python website as the The Python Language Reference. As Python also consists of a standard library of functions, a document that describes how the modules and their respective functions are to behave is also readily available as The Python Standard Library.