Skip to content

Instantly share code, notes, and snippets.

View snikitin-de's full-sized avatar

Sergey Nikitin snikitin-de

View GitHub Profile
@snikitin-de
snikitin-de / calculate_column_avg_size.sql
Last active August 22, 2024 07:52
Вычисление среднего размера строк в байтах в колонке БД Postgres
CREATE OR REPLACE FUNCTION calculate_column_avg_size(schema text, table_pattern text, column_name text)
RETURNS void
LANGUAGE plpgsql
AS $$
DECLARE
avg_size numeric;
combined_query text;
BEGIN
SELECT INTO combined_query
string_agg(
@snikitin-de
snikitin-de / Program.cs
Created May 20, 2024 07:44
Конвертация HTML страницы в PDF
using SelectPdf;
class Program
{
static void Main(string[] args)
{
var html = @"
<html>
<head>
<meta charset='utf-8'>
@snikitin-de
snikitin-de / PrusaSlicer_config_bundle.ini
Created December 10, 2023 14:43
Конфиг UlTi Steel для PrusaSlicer
# generated by PrusaSlicer 2.7.0+win64 on 2023-12-10 at 14:42:36 UTC
[print:FBG4S - Height 0.2 mm. Normal Speed. Nozzle 0.4]
arc_fitting = disabled
avoid_crossing_curled_overhangs = 0
avoid_crossing_perimeters = 1
avoid_crossing_perimeters_max_detour = 20
bottom_fill_pattern = monotonic
bottom_solid_layers = 2
bottom_solid_min_thickness = 0
@snikitin-de
snikitin-de / MediaPlayer.cs
Last active November 21, 2023 17:31
Playing music from resources
public class MediaPlayer
{
private UnmanagedMemoryStream sound;
private MemoryStream memoryStream;
private WaveFileReader waveFileReader;
private WaveOutEvent waveOutEvent;
private bool isLooping;
public MediaPlayer(UnmanagedMemoryStream sound, bool isLooping = false)
{
@snikitin-de
snikitin-de / print_heart.py
Created September 15, 2023 16:43
Print heart with text
def print_heart(text):
print('\n'.join
([''.join
([(text[(x-y)%len(text)]
if((x*0.05)**2+(y*0.1)**2-1)
**3-(x*0.05)**2*(y*0.1)
**3<=0 else' ')
for x in range(-30,30)])
for y in range(15,-15,-1)]))
@snikitin-de
snikitin-de / alert.rules
Last active September 7, 2023 19:57
Host + Docker monitoring stack + Logging
groups:
- name: node_exporter_alerts
rules:
- alert: HostHighCpuLoad
expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[2m])) * 100) > 95
for: 5m
labels:
severity: warning
annotations:
summary: Host high CPU load
@snikitin-de
snikitin-de / python_systemd.md
Created September 8, 2021 15:43 — forked from ilyasst/python_systemd.md
Run a python script forever using systemd

Run a python script forever

In this section, we are going to show how to run a python script as a systemd service, allowing you to boot it at the start of a Linux machine and to maintain it alive.

Test method: Telegram Bot

We are going to use a very basic Telegram bot in order to test that our script will:

  1. Automatically start when the machine boot
  2. Automatically restart when it crashes/exits for whichever reason
@snikitin-de
snikitin-de / dotnet-ci-build.yml
Last active August 21, 2021 13:20
Build .Net Framework app, installer and load their to artifacts
name: Build app and installer
on:
push:
paths-ignore:
- 'README.md'
- '.gitattributes'
- '.gitignore'
- '.github/workflows/**'
class ResourceLabel : Label
{
private string resourceKey;
[Category("Appearance")]
[Localizable(true), Browsable(true)]
[Description("Sets the resource key")]
public string ResourceKey
{
get { return resourceKey; }
@snikitin-de
snikitin-de / app-settings.cs
Last active November 21, 2020 18:56
Read/write settings in a config file
class AppSettings
{
private string configPath;
public AppSettings(string appSettingsPath)
{
configPath = appSettingsPath;
}
private Configuration GetConfig()