Skip to content

Instantly share code, notes, and snippets.

View a-severin's full-sized avatar

Anatoliy Severin a-severin

View GitHub Profile
@a-severin
a-severin / HowTo.md
Created May 9, 2026 19:36
Dotnet update dependencies

Bulk Updates using Global Tools

The native CLI does not have a single command to "update all" packages.

Developers commonly use the third-party dotnet-outdated tool for this purpose.

Install the tool:

dotnet tool install -g dotnet-outdated-tool

Run the update:

@a-severin
a-severin / dynamic_format.py
Created July 5, 2024 14:17
[Python] dynamic format
>>> total = 123456.99
>>> # Formatting values
>>> width = 30
>>> align = ">"
>>> fill = "."
>>> precision = 2
>>> sep = ","
>>> f"Total{total:{fill}{align}{width}{sep}.{precision}f}"
@a-severin
a-severin / float_bits.py
Last active June 20, 2024 10:54
[Python] Print bits of the float
import struct
num = 123.456
pack32 = struct.pack("!f", num)
bits = ''.join(f"{c:0>8b}" for c in pack32)
sign = bits[0]
exp = bits[1:9]
mantissa = bits[9:]
print("- exponent mantissa")
print(f"{sign} {exp} {mantissa}")
@a-severin
a-severin / vectorize.py
Created June 10, 2024 13:51
[Python] Decorator to vectorize function call
from functools import wraps
from collections.abc import Sequence
def vectorize(fn):
@wraps(fn)
def inner(*args):
if len(args) > 1:
return fn(*args)
elif isinstance(args[0], Sequence):
@a-severin
a-severin / print_month_calendar.py
Last active June 10, 2024 13:52
[Python] Print calendar
from calendar import TextCalendar
TextCalendar().prmonth(2024, 4, w = 5)
@a-severin
a-severin / subclasses.py
Last active June 10, 2024 13:52
[Python] Get subclasses as tree
def asciiDocTree(cls, level=1):
print(f"{'*' * level} {cls.__module__}.{cls.__name__}")
for i in cls.__subclasses__():
asciiDocTree(i, level+1)
asciiDocTree(BaseException)
@a-severin
a-severin / csharp_win_print_pdf.cs
Created March 29, 2024 13:38 — forked from xxami/csharp_win_print_pdf.cs
C# example of printing pdf - Windows
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing.Printing;
using System.Diagnostics;
using System.Printing;
using System.IO;
using System.Threading;
@a-severin
a-severin / EnumDescription.cs
Created May 1, 2021 17:42
Display Description of enums in a ComboBox
public class EnumDescriptionTypeConverter : EnumConverter
{
public EnumDescriptionTypeConverter(Type type)
: base(type)
{
}
public override object ConvertTo(
ITypeDescriptorContext context,
CultureInfo culture,
@a-severin
a-severin / ItemsCollection.cs
Created October 14, 2020 14:20
WPF ObservableCollection with ViewSource/Filter
class ItemsCollection : ObservableCollection<Item>{
public ICollectionView View { get; } // do binding to this property
public ItemsCollection(){
View = CollectionViewSource.GetDefaultView(this);
}
public void ClearFilter()
{
View.Filter = null;
}
public void Filter(string value)
@a-severin
a-severin / Test task
Last active September 20, 2021 06:52
# Тестовое задание
Данное задание представляет типичные задачи по автоматизации работы с инженерными данными:
- с какими форматами и структурами данных выполняется работа;
- какие алгоритмы необходимо кодировать;
- как представить результат работы программы.
Задание упрощённое и утрированное, но суть отражает.