Skip to content

Instantly share code, notes, and snippets.

View tirinox's full-sized avatar
🎯
Focusing

TRX1 tirinox

🎯
Focusing
View GitHub Profile
@tirinox
tirinox / MaxFeeTxHandler.java
Created October 24, 2020 17:03
This is a solution of week 1 for the Bitcoin and Cryptocurrency Technologies course (scrooge coin)
/**
* This is a solution of week 1 for the Bitcoin and Cryptocurrency Technologies course (scrooge coin)
* https://www.coursera.org/learn/cryptocurrency
* Please, try yourself before looking this code
* I was able to get 100/100 score!
*/
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
@tirinox
tirinox / mandel_animation.py
Created April 29, 2020 11:47
Dive into Mandelbrot fractal (GIF, Python)
from PIL import Image
from tqdm import tqdm
import math
W, H = 200, 200 # размеры картинки
ITER = 255
FRAMES = 100
@tirinox
tirinox / bf.py
Last active April 2, 2020 16:24
Python brainfuck interpreter
import sys
def run(code, mem_size=256):
# 1. этап составим карту скобок
# ключ и значения - индекс байта в коде
# по любой скобке находим ей пару
bracket_map = {}
stack = []
for pos, symbol in enumerate(code):
@tirinox
tirinox / corona.csv
Last active April 15, 2020 18:13
Предсказание числа заболевших коронавирусом из Китая
day infected dead
20.01.2020 278 4
21.01.2020 326 6
22.01.2020 547 8
23.01.2020 639 14
24.01.2020 916 25
25.01.2020 2000 40
26.01.2020 2700 57
27.01.2020 4400 64
28.01.2020 5970 87
# метакласс наследуется от Type
class Final(type):
def __new__(mcls, name, bases, attrs):
"""
:param name: Имя нового класса
:param bases: Список его базовых классов
:param attrs: Набор атрибутов класса
:return: новый класс
"""
for base in bases:
@tirinox
tirinox / commit-ago.py
Created December 26, 2019 12:53
This script allows you to commit in the past!
#!/usr/local/bin/python3
from datetime import datetime, timedelta
import sys
import os
def git_commit_ago(days, message):
date = datetime.now() - timedelta(days=days)
@tirinox
tirinox / Notebook_animation.ipynb
Last active June 23, 2021 10:17
Демонстрация анимаций в Jupyter Notebook
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tirinox
tirinox / class-as-decorator.py
Created October 21, 2019 08:52
Класс в роли декоратора. Для канала PyWay.
# copyright https://t.me/pyway
from functools import wraps
class Repeater:
def __init__(self, n):
self.n = n
def __call__(self, f):
@wraps(f)
def wrapper(*args, **kwargs):
for _ in range(self.n):
@tirinox
tirinox / class-decoratory.py
Last active April 28, 2023 00:49
Декоратор класса. Для канала PyWay.
# copyright https://t.me/pyway
import time
# это вспомогательный декоратор будет декорировать каждый метод класса, см. ниже
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
@tirinox
tirinox / my_tee.py
Created August 2, 2019 08:54
My implementation of itertools.tee function
from itertools import tee
def source():
for i in range(5):
print(f'next is {i}')
yield i