Skip to content

Instantly share code, notes, and snippets.

View Hammer2900's full-sized avatar
🌲
___

Yevhen Ts. Hammer2900

🌲
___
View GitHub Profile
@Hammer2900
Hammer2900 / __init__.py
Created October 19, 2025 21:03
esper numpy
"""
Esper-Numpy - высокопроизводительная Entity Component System (ECS) для Python на базе NumPy.
ИСПРАВЛЕНА проблема с копированием данных при индексации.
"""
import time as _time
import numpy as np
import inspect as _inspect
from dataclasses import is_dataclass, fields as _dataclass_fields
from types import MethodType as _MethodType
@Hammer2900
Hammer2900 / __init__.py
Last active October 19, 2025 12:19
python esper speed test
"""Optimized esper - faster Entity System (ECS) for Python
Key optimizations:
1. Lazy cache invalidation
2. Faster component lookups with cached min sets
3. Direct entity component dict access
4. Optimized dead entity cleanup
5. Fast processor lookup dict
"""
import time as _time
@Hammer2900
Hammer2900 / main.py
Created October 18, 2025 08:02
umpacking test speed
import timeit
from dataclasses import dataclass, replace
# ============================================================
# Исходные данные
# ============================================================
color = (0, 121, 241, 255)
new_alpha = 128
EXPECTED = (0, 121, 241, 128)
@Hammer2900
Hammer2900 / db_service.py
Last active October 9, 2025 19:30
Асинхронный SQLite
import os
import sqlite3
import unittest
from typing import Dict, List, Union, Any, Optional, Tuple
import threading
import queue
from concurrent.futures import Future
import asyncio
@Hammer2900
Hammer2900 / get-discord-token-from-browser.md
Created August 23, 2025 17:22 — forked from MarvNC/get-discord-token-from-browser.md
How to Get Your Discord Token From the Browser Developer Console

How to Get Your Discord Token From the Browser Console

New method (contributed by youyoumu)

  • Open the browser console with F12 or Ctrl + Shift + I.
  • Enable mobile device emulation with Ctrl + Shift + M.
  • Paste the following code into the console and press Enter:
const iframe = document.createElement('iframe');
@Hammer2900
Hammer2900 / 1.sh
Created July 28, 2025 07:29
show max app using memory
ps -eo pid,comm,%mem,rss --sort=-%mem | head -n 11 | awk "NR==1{printf \"%-8s %-25s %-10s %s\n\", \$1, \$2, \$3, \"RAM(MB)\"} NR>1{printf \"%-8s %-25s %-10s %.2f\n\", \$1, \$2, \$3, \$4/1024}"
@Hammer2900
Hammer2900 / index.html
Created June 29, 2025 15:05
Упрощение работы с URL в Django 5.1 с помощью {% querystring %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Django 5.1 {% querystring %} Study Guide</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
max-width: 900px;
@Hammer2900
Hammer2900 / main.py
Created June 16, 2025 08:32
Как превратить случайное вещественное число (обычно 0..1) в случайное целое число между a и b.
import json
import random
from collections import Counter
def random_int_from_float(a, b, float_val=None):
"""
Превращает случайное вещественное число (0..1) в случайное целое число между a и b (включительно).
Args:
a (int): Нижняя граница диапазона.
@Hammer2900
Hammer2900 / IAcommit.py
Last active May 28, 2025 07:41 — forked from tailot/IAcommit.py
This Python script analyzes the commit history of a specified Git repository using a locally running Ollama instance and a user-selected AI model. It takes the repository path, an Ollama model name, and an optional commit limit as command-line arguments. For each selected commit, the script extracts the changes (diff) and prompts the AI to gener…
import subprocess
import ollama
import os
_OLLAMA_SYSTEM_PROMPT = 'You are an assistant that analyzes Git commits and their diffs to generate improved commit messages according to the Conventional Commits standard.'
_COMMIT_ANALYSIS_PROMPT_TEMPLATE = """Analyze the following 'git show' output, which includes the original commit message and the diff of the changes.
Your task is to generate a new, concise, and well-written commit message following Conventional Commits standards,
based ONLY ON THE CHANGES (the diff). Ignore the original commit message present in the input.
Provide only the commit message itself, without any introductory or concluding phrases.
The message should start with a type (e.g., feat, fix, docs, style, refactor, test, chore),
@Hammer2900
Hammer2900 / random_walk_dungeon.lobster
Created May 18, 2025 13:41
procedural dungeon generator using random walk in lobster
import vec
import color
import gl
import std
let screen_width = 800
let screen_height = 600
let tile_size = 20
let map_width = screen_width / tile_size