Skip to content

Instantly share code, notes, and snippets.

View goltsevnet's full-sized avatar
😮‍💨
Coding

Mark Goltsev goltsevnet

😮‍💨
Coding
View GitHub Profile
@goltsevnet
goltsevnet / Dockerfile
Created April 7, 2023 18:37
dockerfile for django
FROM python:3.11.2-slim
WORKDIR /opt/project
RUN pip3 install --upgrade pip
RUN apt-get update && apt-get upgrade -y && apt-get autoremove && apt-get autoclean
RUN apt-get install --no-install-recommends -y
RUN pip3 install --no-cache-dir poetry
COPY ./pyproject.toml /opt/project
from django.db import migrations
from main_app.models import Book
def change_author(apps, schema_editor):
Book.objects \
.filter(authors__first_name=['Аркадий', 'Борис'], authors__last_name=['Стругацкий']) \
.update('Суахили')
import os
import shutil
import time
import random
from movies.models import *
from tqdm import tqdm
from users.models import User
from model_bakery import baker
genre_names = [
@goltsevnet
goltsevnet / connections.py
Created May 30, 2021 20:01
aredis manager
from typing import Optional
from aioredis import Redis, create_redis_pool
class RedisCache:
def __init__(self):
self.redis_cache: Optional[Redis] = None
@goltsevnet
goltsevnet / func_collector.py
Last active April 24, 2021 10:38
Сбощик функций
from inspect import getmembers, isfunction
import os
import pkgutil
# for example, let's take all the functions of the os module
# для примера возьмем все функции модуля OS
class CollectFunctions:
def __init__(self):
self.functions = dict()
import {CaseReducer, createSlice, PayloadAction} from "@reduxjs/toolkit";
const ProfileState = {
email: '' as string,
rating: 0 as number,
username: '' as string,
first_name: '' as string,
last_name: null as string | null,
slug: '' as string,
avatar: '/static/user.svg' as string,
@goltsevnet
goltsevnet / yandex_individual_payment.py
Created October 9, 2020 17:44
yandex payment individual react
payHandle(e) {
e.preventDefault();
this.myFormTargets.current.value = 'test'
this.myForm.current.submit()
}
<form ref={this.payHandle} className='pay' method="POST" action='https://money.yandex.ru/quickpay/confirm.xml' onSubmit={this.payHandle}>
<input type="hidden" name="receiver" value="41001261102xxxx"/>
<input type="hidden" name="formcomment" value={boostInfoPay}/>
<input type="hidden" name="short-dest" value={boostInfoPay}/>
@goltsevnet
goltsevnet / init_logging.py
Last active October 5, 2020 05:08
logging
logging.basicConfig(level=logging.DEBUG)
logger = init_logger(__name__, testing_mode=True)
logger.debug('Testing mode = True')
import logging
import colorlog
def init_logger(dunder_name, testing_mode) -> logging.Logger:
class BalanceConsumer(AsyncWebsocketConsumer):
async def connect(self):
self.user = self.scope['user']
if self.user.is_authenticated:
# text_data = json.dumps({
# 'message': '99999999'
# })
self.user_name = str(self.user.username)
await self.channel_layer.group_add(
@goltsevnet
goltsevnet / views.py
Created February 20, 2019 05:05
Костыль
def status_page(request):
if request.method == 'POST':
-Магия-
email = request.POST.get('email')
# сумма которая списана с отправителя
withdraw_amount = request.POST.get('withdraw_amount')
a = f'{notification_type}&{operation_id}&{amount}&{currency}&{datetime}&{sender}&{codepro}&{notification_secret}&{label}'
sha1_hash2 = sha1(f'{a}'.encode('UTF8')).hexdigest()