Skip to content

Instantly share code, notes, and snippets.

View warvariuc's full-sized avatar

Victor Varvaryuk warvariuc

  • Moldova, Chisinau
View GitHub Profile
@warvariuc
warvariuc / copy_header_with_each_row.vba
Last active March 13, 2024 10:37
Take current sheet, copy it as a new one, remove formulas leaving only values, insert first row (header) before each other. Useful for printing the table to able to cut with scissors each row with its own header.
Sub CopyHeaderWithEachRow()
Doc = ThisComponent
Sheets = Doc.Sheets
Controller = Doc.CurrentController
ActiveSheet = Controller.getActiveSheet()
Selection =Controller.getSelection()
SelAddress = selection.RangeAddress
@warvariuc
warvariuc / 1.py
Created November 23, 2023 19:23
Filter a MAC addr via API on an OpenWRT router
"""
https://github.com/openwrt/luci/blob/master/docs/JsonRpcHowTo.md
opkg update
opkg install luci-mod-rpc luci-lib-ipkg luci-compat
/etc/init.d/uhttpd restart
"""
import httpx
class Router:
def flatten_dict(data: dict):
"""Transform a dict with nested dicts/list to a one level dict with keys containing paths to
the original values encoded as `top_level_key.nested_key[list_item_index]`
"""
def iterate(_data, _path=""):
if isinstance(_data, dict):
for _key, _value in _data.items():
yield from iterate(_value, f"{_path}.{_key}".lstrip("."))
elif isinstance(_data, tuple | list):
@warvariuc
warvariuc / stale_remote_branches.sh
Last active June 10, 2023 18:23
List remote branches with latest commit date, author and description. The is used to review stale remote branches.
git for-each-ref --sort=committerdate refs/remotes/origin/ --format='%(committerdate:short) %(authorname) %(refname:lstrip=3)'
@warvariuc
warvariuc / crown_molding_king.py
Created March 19, 2022 06:20
This script will calculate the chop saw miter and bevel settings for any angle crown molding.
"""
This application will calculate the chop saw miter and bevel settings for any angle crown molding.
https://play.google.com/store/apps/details?id=com.crownking
"""
import math
wall_angle = 90 # Wall angle
sping_angle = 38 # Miter spring angle
sa2 = math.radians(sping_angle)
import functools
import logging.config
import mongoengine
import pydantic as p
logging.basicConfig()
@warvariuc
warvariuc / gist:470f71d121134d1d36d7ca0ac116f244
Last active March 15, 2022 08:33
Check environment variables passed to a docker container in cloud
root@4f2af8100e1f:# strings /proc/1/environ
PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=4f2af8100e1f
COMPUTERNAME=10-30-0-24
PLATFORM_VERSION=97.0.7.610
APPSVC_RUN_ZIP=FALSE
WEBSITE_SKU=LinuxFree
...
-------------------------------------------------------------------------------
import time
import math
import pygame
WIDTH = 320 # width of screen
HEIGHT = 240 # height of screen
FPS = 30 # frames per second setting
# Make test method names str more friendly for feeding them to ./manage.py test
unittest.case.TestCase.__str__ = lambda self: \
f'{self.__class__.__module__}.{self.__class__.__qualname__}.{self._testMethodName}'
#!/usr/bin/env python3
"""
A pure Python "ping" implementation, based on a rewrite by Johannes Meyer,
of a script originally by Matthew Dixon Cowles. Which in turn was derived
from "ping.c", distributed in Linux's netkit. The version this was forked
out of can be found here: https://gist.github.com/pklaus/856268
I've rewritten nearly everything for enhanced performance and readability,
and removed unnecessary functions (assynchroneous PingQuery and related).