Skip to content

Instantly share code, notes, and snippets.

@ephemerr
ephemerr / xml-merge.py
Created April 19, 2023 20:35
Merge multiple fb2 files into one example
from bs4 import BeautifulSoup
import os
xml = '<?xml version="1.0" encoding="UTF-8"?>'\
'<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink">'\
'<description>'\
' <title-info>'\
' <genre>foreign_prose</genre>'\
' <genre>literature_20</genre>'\
' <author>'\
@ephemerr
ephemerr / qt-sqlite-removecolumn.cpp
Last active December 20, 2017 13:01
Missing remove column implementation for sqlite upon QSqlQuery.
#include <QLoggingCategory>
#include <QSqlQuery>
#include <QSqlError>
Q_LOGGING_CATEGORY(hfCoreM, "hf.core.migration");
QString getOneTableDbSchema(QString table_name) {
auto q = QString(
"SELECT * FROM `sqlite_master` WHERE `type` = 'table' AND `name` = '%1'").arg(table_name);
#!/bin/bash
function get_setting_value {
declare SECTION=$1
declare KEY=$2
sed -nr '/\['$SECTION\]'/,/\[.*\]/{/'$KEY'/s/(.*)=(.*)/\2/p}' "$INI_FILE"
}
function set_setting_value {
declare SECTION=$1
@ephemerr
ephemerr / stripper.txt
Created August 22, 2017 11:21
strips color codes
perl -pe 's/\e\[?.*?[\@-~]//g'
@ephemerr
ephemerr / ssh_help.txt
Last active August 16, 2017 09:06
SSH tunneling cheatsheet
Remote:
ssh.exe -R 1333:10.50.2.1:722 kahuna@8.8.8.8
Add port from current scope to remote machine. Where:
1333 - port in remote scope
10.50.2.1:722 - port in current scope
kahuna@8.8.8.8 - remote machine(ssh server)
Local:
ssh -L 127.1:1333:127.1:3128 kahuna@8.8.8.8
@ephemerr
ephemerr / git-subrepo-clone-modular.sh
Last active July 5, 2017 08:50
Create clone of SUBMODULE based git repository(MODULAR) convering it to SUBREPO repository(TARGET).
#!/bin/bash
# Create clone of SUBMODULE based git repository(BASE) convering it to SUBREPO repository(TARGET).
#
# Use this script with care it can make severe changes both to TARGET and to BASE.
#
# Call it from directory of TARGET, with path to BASE.
# On a go, script make changes to BASE, creating branches named MODULAR_PRJ_NAME/ROOT_BRANCH_NAME for each submodule.
# It overrides already existing ones!
# In TARGET project it creates remote named 'modular', if there is alredy one - it is overrided!
scratchpad.patch for dwm 5.9
A scratchpad is a window that is assigned the (hidden) scratchtag.
A window becomes a scratchpad if its WM_NAME at its creation time is the value
of the scratchpadname variable.
togglescratchpad() is actually a variant of toggleview().
To use this, put the following definitions in config.h:
static const char scratchpadname[] = "Scratchpad"; /* make it unique, avoid name collision */
static const char *scratchpadcmd[] = { "uxterm", "-title", scratchpadname, "-geometry", "80x20", NULL }; /* WM_NAME must be scratchpadname */