Skip to content

Instantly share code, notes, and snippets.

View LifeMoroz's full-sized avatar

Galimov Ruslan LifeMoroz

View GitHub Profile
class A(object): pass
a = A()
a.x = 1
setattr(a, 'y', 2)
a.__dict__ # {'y': 2, 'x': 1}
a.__setattr__('z', 3)
a.__dict__ # {'y': 2, 'x': 1, 'z': 3}
class User:
def __init__(self, login=None, password=None, first_name=None, last_name=None, phone=None):
self.login = login
self.password = password
self.first_name = first_name
self.last_name = last_name
self.phone = phone
class Hotel:
class Database1:
def get_connection(self, host, port, db, user='', password=''):
pass
def execute(self, conn, sql, params, unescaped=None):
pass
class MysqlDatabase(Database1):
import base64
import copy
import json
import logging
import uuid
from decimal import Decimal
from django.conf import settings
from django.http import HttpRequest
from django.utils.encoding import force_bytes
@LifeMoroz
LifeMoroz / gist:352c87f65273a171248da0bfc0dd4baf
Created August 7, 2023 13:28
Nekoton get pubkey by account
import asyncio
from nekoton import JrpcTransport, Address, PublicKey, Cell
def get_rpc(blockchain) -> JrpcTransport:
rpc = {
1: "https://jrpc.everwallet.net/rpc",
2: "https://jrpc-testnet.venom.foundation/rpc",
}[blockchain]
@LifeMoroz
LifeMoroz / log_extra.py
Last active August 21, 2023 15:09
logger decorator for async app
"""
Adds async context to a Python logger.
"""
import asyncio
import functools
import inspect
import logging
from contextvars import ContextVar
from typing import Any, Callable