Skip to content

Instantly share code, notes, and snippets.

@terenty-rezman
terenty-rezman / scrollbar.py
Last active July 2, 2020 18:26
QScrollBar over content
# to have fancy transparent scrollbars over your content
# all you need is to adjust viewport margins with negative values like this:
# scroll_area = QScrollArea()
scroll_area.setViewportMargins(0, 0, -8, -8)
# also here are some styles to make your scrolbars even fancier:
QScrollBar:vertical {
border: none;
background-color: transparent;
@terenty-rezman
terenty-rezman / mobaxterm_wrapper.bat
Last active July 23, 2020 14:04
EVE-NG mobaXterm wrapper Windows
python "C:\Program Files\EVE-NG\mobaxterm_wrapper.py" %1
@terenty-rezman
terenty-rezman / openvpn_clients.py
Created July 23, 2020 10:25
print currently connected OpenVPN clients to console
#!/usr/bin/env python3
from telnetlib import Telnet
import telnetlib
import re
# openvpn managment address and port
HOST = "localhost"
PORT = 9969
@terenty-rezman
terenty-rezman / logger.py
Created October 12, 2020 20:24
linux 'logger' command in python
#!/usr/bin/env python3
"""
does the same as linux 'logger' command (on a basic level)
writes msg to rsyslog from current user
linux 'logg
@terenty-rezman
terenty-rezman / build-linux-img.sh
Created February 2, 2021 20:00
build bootable linux.img from linux kernel image and initrd image
#!/usr/bin/env bash
# creates bootable disk image as file (e.g. linux.img)
# places kernel image and initrd image on this disk
# and uses grub install to make it bootable
# then you can test it with smthng like 'qemu-system-x86_64 linux.img'
echo
set -e # terminate script on error
@terenty-rezman
terenty-rezman / serialize.cpp
Created March 3, 2021 13:18
Qt serialization example
#include <QtCore/QCoreApplication>
#include <qdatastream.h>
#include <qvector3d.h>
#include <qdebug.h>
#include <qtcpserver.h>
#include <qtcpsocket.h>
int main(int argc, char* argv[])
{
@terenty-rezman
terenty-rezman / flex_scroll_child.html
Created May 10, 2021 21:08
css flex children with overflow and scroll on them
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>flex with scrolls</title>
<style>
html, body {
margin: 0;
height: 100%;
@terenty-rezman
terenty-rezman / wait_for_tcp.sh
Created October 23, 2021 16:16
docker curl wait for db available
#!/bin/sh
# wait_for_tcp.sh
# wait for tcp port to become available
# usage
# $ ./wait_for_tcp localhost:80
host="$1"
until echo -e '\xdclose\x0d' | curl -v telnet://$host/ ; do
@terenty-rezman
terenty-rezman / mongodump.sh
Last active November 9, 2021 13:36
mongodb dump from running docker container
#!/bin/bash
# dump mongodb from running docker container to specified archive file
# exit on first error
set -e
ARCHIVE_FILE="${2:-mongo_all.db.archive}"
DIR_NAME="$(dirname ${ARCHIVE_FILE})"
@terenty-rezman
terenty-rezman / telegram_bot_dialog_interrupt.py
Created January 11, 2022 20:29
python-telegram-bot dialog interrupt workaround / converstaionhandler
"""
workaround for dialog interruption for python-telegram-bot
see the problem of parallel dialogs:
https://stackoverflow.com/questions/64146229/python-telegram-bot-disallow-nested-conversations
https://github.com/python-telegram-bot/python-telegram-bot/issues/1640
"""
from telegram import ReplyKeyboardMarkup
from telegram.ext import (
Updater,