Skip to content

Instantly share code, notes, and snippets.

View Hammer2900's full-sized avatar
🌲
___

Yevhen Ts. Hammer2900

🌲
___
View GitHub Profile
@Hammer2900
Hammer2900 / Dockerfile
Created April 19, 2025 05:50
compile go to arm64
# Этап 1: Сборка приложения
FROM golang:latest AS builder
# Создаем директорию для исходников
RUN mkdir /src
WORKDIR /src
# Клонируем репозиторий в текущую директорию (/src)
RUN git clone --depth 1 https://github.com/aculix/bitplay.git .
@Hammer2900
Hammer2900 / main.sh
Last active April 17, 2025 21:07
Synology DS218 (на базе RTD1296, ARM) компиляция для nim
nim c -d:release \
--cpu:arm64 \
--os:linux \
--cc:gcc \
--gcc.exe:/storage/ROMs/usr/local/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-gcc \
--gcc.linkerexe:/storage/ROMs/usr/local/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-gcc \
--passC:--sysroot=/storage/ROMs/usr/local/sysroot \
--passL:--sysroot=/storage/ROMs/usr/local/sysroot \
--passC:-march=armv8-a \
--passL:-static \
@Hammer2900
Hammer2900 / fabfile.py
Last active April 14, 2025 12:15
fabric config default vars 2025
import os
import sys
from invoke import Config, Local, Context, FailingResponder, StreamWatcher
# --- Демонстрация ВСЕХ стандартных ключей конфигурации Invoke ---
# Создадим словарь, который будет содержать примеры для всех
# стандартных ключей конфигурации. Мы передадим его в `defaults`.
# В реальном приложении эти значения могут быть установлены в файлах
# конфигурации, переменных окружения или через флаги командной строки.
@Hammer2900
Hammer2900 / main.py
Created March 30, 2025 16:08
find wi-fi in linux pc
import subprocess
import shlex
import re # Import regular expressions module for parsing
from typing import Dict, List, Union, Any # Updated type hints
def get_wifi_networks_sorted() -> List[Dict[str, Union[str, int]]]:
"""
Retrieves available Wi-Fi networks including BSSID and signal strength,
sorted by signal strength (descending).
@Hammer2900
Hammer2900 / async_executor.py
Last active February 10, 2025 16:38
A simple asynchronous executor based on asyncio. Similar to concurrent.futures.ThreadPoolExecutor, but uses tasks instead of threads. Allows you to run asynchronous functions in a pool, limiting the number of concurrent tasks. Supports initializer for workers and graceful shutdown. I wrote it for myself, but maybe it will be useful to someone.
import asyncio
import contextvars
from typing import Callable, Awaitable, Iterable, Any, AsyncIterator, Protocol, runtime_checkable
@runtime_checkable
class Initializer(Protocol):
async def __call__(self, *args: Any) -> None: ...
@Hammer2900
Hammer2900 / mount_clonezilla.md
Created February 4, 2025 14:18 — forked from vasi/mount_clonezilla.md
Mounting Clonezilla images with FUSE

Mounting Clonezilla images with FUSE

I love to make backups with Clonezilla. But often, I'll back up my system, wipe my Linux partition and try another distro—only to realize that I need access to just one file from the old installation. For example, maybe I made an interesting change to my .zshrc or Samba configuration, which I want to re-use on the new system.

The obvious solutions aren't my favorites. It's easy to restore an image to a spare disk, but it takes a long time, and requires a spare disk I'm willing to wipe. I [could extract an entire image][extract_image], but that also takes lots of time and space. Wouldn't it be nice to just look inside my compressed Clonezilla image, just like I can do with a zip file or squashfs archive?

It turns out it's possible, with clever use of [user-space filesystems][fuse]!

@Hammer2900
Hammer2900 / main.py
Created February 2, 2025 08:35
fast copy paste with pynput for key ctrl alt and mouse
import os
import time
from dataclasses import dataclass
from typing import Callable, Optional, Dict
import logging
import multiprocessing
import fire
from pynput import keyboard, mouse
import sh
@Hammer2900
Hammer2900 / qt.nim
Last active November 29, 2024 23:29
Quadtrees are trees used to efficiently store data of points on a two-dimensional space. In this tree, each node has at most four children. In nim language.
import std/math
type
Point* = object
x*, y*: float
Node* = object
pos*: Point
data*: int
radius*: float
@Hammer2900
Hammer2900 / main.py
Last active October 8, 2024 07:19
Animated Heap Sort
import pyray as pr
from random import randint
import math
WIDTH = 800
HEIGHT = 600
CELL_SIZE = 40
SPACE = 10
ANIMATION_SPEED = 0.005
@Hammer2900
Hammer2900 / main.py
Created October 8, 2024 07:03
The code animates the process of sorting a list using the bubble sorting method, displaying the changes visually each time the elements are swapped.
import pyray as pr
from random import randint
import math
WIDTH = 800
HEIGHT = 600
CELL_SIZE = 40
SPACE = 10
ANIMATION_SPEED = 0.05