Skip to content

Instantly share code, notes, and snippets.

View bhdn's full-sized avatar

Bogdano Arendartchuk bhdn

View GitHub Profile
@bhdn
bhdn / snack.txt
Created September 29, 2022 16:38
Quick Guide to Python's Snack Module
[Found in https://www.cnblogs.com/lexus/archive/2012/02/26/2368378.html]
Written by Jared Riley
Snack is a python library based on newt that can be used to
create a simple text based User interface. This is the package
that was used by Red Hat to create their installation along with
a number of configuration tools. It is an ideal platform upon
which to create installation and configuration scripts,
particularly if you don't want to rely on X, or you want to

Using the (phone) as a desktop webcam

Install the IP Webcam Android app. Likely works with others and in iOS as well.

Load the v4l2loopback module (install it in case it's not already available on your system):

modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1 max_buffers=2

Connect the phone to USB of the desktop. Enable tethering in Settings -> Connections. Take a note of the address on the new default route added to your system. Remove the

@bhdn
bhdn / pacemaker.json
Last active November 28, 2019 10:40
lnav pacemaker format extended -- testing before submitting the changes upstream
{
"pacemaker_log" : {
"title" : "pacemaker log",
"description" : "Log format for pacemaker cluster management framework",
"file-pattern": ".*pacemaker.*",
"url" : "",
"regex" : {
"std" : {
"pattern" : "^(?<timestamp>\\w{3} \\d+ \\d{2}:\\d{2}:\\d{2}) \\[(?<pid>\\d+)\\] (?<hostname>\\S+)\\s+(?<subsystem>[\\-\\w]+):\\s+(?<level>\\w+):\\s+(?<body>.*)$"
},
@bhdn
bhdn / group-lsof.py
Created June 5, 2019 09:29
The lsof output is terrible
#!/usr/bin/env python2
import re
import sys
# COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# systemd 1 0 cwd unknown / (stat: No such file or directory)
# systemd 1 0 rtd unknown / (stat: No such file or directory)
# systemd 1 0 txt unknown /usr/lib/systemd/systemd (stat: Resource temporarily unavailable)
# systemd 1 0 mem REG 254,1 19534244 /usr/lib/systemd/systemd (stat: Resource temporarily unavailable)
# systemd 1 0 mem REG 254,1 19530388 /usr/lib64/libuuid.so.1.3.0 (stat: Resource temporarily unavailable)
@bhdn
bhdn / nonstop-top100-nue.txt
Created March 28, 2018 20:10
Top 100 Europe with nonstop connection from NUE
London-Stansted LON
Paris Charles de Gaulle PAR
Amsterdam AMS
Frankfurt FRA
Istanbul IST
Madrid MAD
Barcelona BCN
London-Stansted LON
Paris Charles de Gaulle PAR
Palma de Mallorca PMI
@bhdn
bhdn / prepend.py
Last active February 26, 2018 18:09
A decorator for prepending parameters to a decorated function
"""
This example allows extending the signature of a decorator in order to fool
pytest so that all fixtures are provided, leaving at the discretion of the decorator
how to call the test at the end.
In this example, test_something(fixture_a, fixture_b) should have the signature
test_something(the_fixture_needed_by_this_decorator, fixture_a, fixture_b), but getting
invoked at the end with the original two arguments.
"""
from inspect import Parameter, signature
@bhdn
bhdn / gist:ab563117e5f666cc2c72d01d74ec9d19
Created January 24, 2018 23:51
Grep fica mais fácil
This file has been truncated, but you can view the full file.
ABLENIO, Paulino 1891 italiana 438 4003
ABRAHÃO, Catharina 1891 polonesa 424 0777
ABRAHÃO, José 1891 polonesa 424 0776
ABRAHÃO, Marianna 1891 polonesa 424 0778
ABRAMOSKI, Adam 1890 russa 428 3259
ABRAMOSKI, Leocadia 1890 russa 428 3260
ACCORDI, Pier Antonio 1877 italiana 834 1642
ACCORDI, Piombina 1877 italiana 834 1643
ACCORDI, Rosa 1877 italiana 834 1644
ACHARA, Pedro 1891 espanhola 438 0003
@bhdn
bhdn / enforce-permissions.rb
Created February 17, 2015 20:19
Example for watching some directory tree for incoming files using inotify and modify their permissions after 3 seconds
#!/usr/bin/ruby
require 'rb-inotify'
require 'thread'
DELAY = 3
queue = Queue.new
consumer = Thread.new do
diff -up ./source3/client/client.c.orig ./source3/client/client.c
--- ./source3/client/client.c.orig 2013-02-01 18:32:09.161766000 +0100
+++ ./source3/client/client.c 2013-02-01 19:20:56.992523000 +0100
@@ -51,6 +51,7 @@ static char *service;
static char *desthost;
static char *calling_name;
static bool grepable = false;
+static bool ignore_perms = false;
static char *cmdstr = NULL;