Skip to content

Instantly share code, notes, and snippets.

View knopki's full-sized avatar

Sergei Korolev knopki

View GitHub Profile
@knopki
knopki / restic-to-restic.py
Created November 15, 2025 17:12
Poor man's copy with re-chunking for restic
#! /usr/bin/env nix-shell
#! nix-shell -i python -p bash restic bubblewrap jq
import json
import logging
import os
import shlex
import subprocess
import sys
import time
@knopki
knopki / kopia-to-restic.sh
Created November 15, 2025 17:10
Convert kopia snapshots to restic snapshots with help of bubblewrap
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p bash restic kopia bubblewrap jq
set -euo pipefail
export KOPIA_CONF_DIR="$XDG_CONFIG_HOME/kopia"
export KOPIA_CONFIG_PATH="$KOPIA_CONF_DIR/kopia-main-repo-on-wdc3.config"
export KOPIA_PASSWORD="$(cat "$KOPIA_CONFIG_PATH.kopia-password" | base64 --decode)"
export RESTIC_PACK_SIZE=128
@knopki
knopki / rpc_ping.js
Created April 8, 2025 10:51
ODOO RPC pinger
let rpc = odoo.__DEBUG__.services['web.rpc']
let doQuery = async () => rpc.query({
// change this
context: {},
model: "mrp.production",
method: "read",
args: [[49759]],
});
let doPing = async () => {
const now = Date.now();
@knopki
knopki / README.md
Last active April 26, 2024 12:49
Формировании декларации с дивидендами от иностранных бумаг за 2023 год

Формировании декларации с дивидендами от иностранных бумаг за 2023 год

Здравствуй, мой маленький мамки инвестор. Сейчас я расскажу тебе как заполнить 105 событий получения дивидендов от иностранных бумаг в декларации о доходах физического лица не заполняя 105 форм.

Для начала надо получить от брокера налоговый отчёт. Отчёт каким-то образом надо преобразовать в такой вид:

let data = [
    {
    "date": "20.01.2023",
 "name": "Valero Energy Corporation_ORD SHS",
@knopki
knopki / Containerfile
Last active March 7, 2024 10:30
Контейнер для запуска КриптоПро и ГОСТ-браузера для работы с ЭЦП РуТокен
FROM quay.io/toolbx/ubuntu-toolbox:22.04
ENV DEBIAN_FRONTEND noninteractive
ENV PATH="${PATH}:/opt/cprocsp/bin/amd64/"
RUN apt update && \
apt install -y whiptail libccid libpcsclite1 pcscd pcsc-tools opensc
#
# CryptoPro
@knopki
knopki / README.md
Created May 25, 2023 10:11
Equilibrium/Genshiro balances monitor

Install @polkadot/api npm package. Set NODE_ADDR environment variable to "wss://node.ksm.genshiro.io" for Genshiro or "wss://node.pol.equilibrium.io" for Equilibrium. Set MASTER_ADDR to your substrate address. Run and see balances changes in log.

@knopki
knopki / genshiro_balances.js
Last active May 25, 2023 02:08
Genshiro Get Balances
const MASTER_ADDR = '<insert your address here>';
// go here https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fnode.ksm.genshiro.io%2F#/js
// paste && click on 'play'
const DECIMALS = 9;
function hex2a(hexx) {
const hex = hexx.toString();
let str = '';
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16))

Linking my account knopki on GitHub with my address 5DZRYpZFHZCZpKfPwtVHDbssUkdaMcNdtqGahramkZUFFrsP on Substrate in mycryptoprofile.io, and the challenge code is: 25a448ed60385f41aec70f9803dbaa16. #LitentryVerifyMyAddress

DO $$ DECLARE
r RECORD;
BEGIN
FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP
EXECUTE 'DROP TABLE IF EXISTS ' || quote_ident(r.tablename) || ' CASCADE';
END LOOP;
FOR r IN (SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()) LOOP
EXECUTE 'DROP SEQUENCE IF EXISTS ' || quote_ident(r.sequence_name);
END LOOP;
END $$;
@knopki
knopki / cache_hists.sql
Created August 9, 2022 14:41
Postgres disk vs cache
-- perform a "select pg_stat_reset();" when you want to reset counter statistics
with
all_tables as
(
SELECT *
FROM (
SELECT 'all'::text as table_name,
sum( (coalesce(heap_blks_read,0) + coalesce(idx_blks_read,0) + coalesce(toast_blks_read,0) + coalesce(tidx_blks_read,0)) ) as from_disk,
sum( (coalesce(heap_blks_hit,0) + coalesce(idx_blks_hit,0) + coalesce(toast_blks_hit,0) + coalesce(tidx_blks_hit,0)) ) as from_cache
FROM pg_statio_all_tables --> change to pg_statio_USER_tables if you want to check only user tables (excluding postgres's own tables)