Skip to content

Instantly share code, notes, and snippets.

View mierzejk's full-sized avatar

Krzysztof Mierzejewski mierzejk

  • BI Insight
  • Warsaw, Poland
View GitHub Profile
@mierzejk
mierzejk / get_package_extras.py
Last active April 5, 2024 08:20
Get distribution package extras requirements with importlib_metadata library.
import pprint
import re
from collections import defaultdict
from functools import partial
from importlib_metadata import metadata
__semicolon_split = partial(str.split, sep=r';', maxsplit=1)
@mierzejk
mierzejk / PipeOperator.kt
Created November 16, 2023 14:09
Kotlin pipe forward operator implemented with an infix function, featuring classic functional paradigms like partial functions and function currying.
typealias id<T> = (T) -> T
typealias rec_bin<T> = T.(T) -> T
inline infix fun<T> T.`|`(fnc: id<T>) = this.let(fnc)
inline infix fun<T> id<T>.`|`(crossinline fnc: id<T>): id<T> = { this(it) `|` fnc }
fun<T> partial(op: rec_bin<T>, operand: T): id<T> = { it.op(operand) }
val addCinque = partial(Int::plus, 5)
val negative = partial(Int::times, -1)
@mierzejk
mierzejk / Setting xinput properties of pointing devices having indistinct names.md
Last active August 16, 2023 11:41
Two bash scripts to get xinput id of a pointing device that is listed more than once by the same name, and apply it for setting the device properties.

The scripts returns (echos) xinput id of a pointing device by its name, and if the name is not unique also by its USB interface number.
It is suggested to set the script mode to grant execute permissions.

Arguments

Name Position Mandatory Default value Description
DEVICE_NAME 1 yes The device name as reported by xinput list.
DEVICE_NUM 2 optional 0 The device USB interface number: udev's bInterfaceNumber / ID_USB_INTERFACE_NUM value.
If the value is one character (digit) only, then it is left padded with 0.
flags:
-f or --force
last optional absent If the flag is present, always compare DEVICE_NUM value, even if there is only one device with DEVICE_NAME.
@mierzejk
mierzejk / Python capturing standard streams.md
Last active March 14, 2023 14:16
Python script to capture process real output (stdout, stderr).

In Python, capturing process output with contextlib.redirect_stdout / contextlib.redirect_stderr, or manual redirection of sys.stdout and sys.stderr works only when sys file objects are actually being used by the producer to write to standard output or error. If data streams are referred directly, for instance by an underlying C/C++ library invoked by the interpreter, hence eliding sys file objects, these methods are inadequate.
Fortunately, the os module lays on a number of file descriptor operations that can be availed to capture the actual standard streams

@mierzejk
mierzejk / Install NVIDIA Driver and CUDA.md
Created September 18, 2022 17:30 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
@mierzejk
mierzejk / GNOME Aggregate Menu arrow commandline.md
Last active March 31, 2022 15:36
GNOME panel Aggregate (System) Menu arrow visibility

With the help of gdbus, the dropdown arrow visibility can also be toggle from terminal:

  • To hide:
    • gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.panel.statusArea.aggregateMenu._arrow.visible = false;'
      or
    • gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.panel.statusArea.aggregateMenu._arrow.hide();'
  • To show:
    • gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.panel.statusArea.aggregateMenu._arrow.visible = true;'
      or
    • gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval 'Main.panel.statusArea.aggregateMenu._arrow.show();'
@mierzejk
mierzejk / Denon Vtuner example.md
Created January 25, 2020 20:26 — forked from joleuger/Denon Vtuner example.md
Denon Vtuner example

Tcpdumps of AVR-1713. Reason for dumps: If Denon ever discontinues the vtuner service I need to serve my receiver these dumps:

Press Favorite Station 1 long to save current station as favorite.

Entrance link http://denon.vtuner.com:80/setupapp/denon/asp/browsexm2/navXML.asp?rLev=&gofile=web&mac=xxxxxxxxxxxxxxxxxx&fver=xxxxxx&dlang=ger&startitems=1&enditems=10

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>^M
<ListOfItems>^M
<ItemCount>3</ItemCount>^M