Skip to content

Instantly share code, notes, and snippets.

View goltsevnet's full-sized avatar
:shipit:
Coding

Mark Goltsev goltsevnet

:shipit:
Coding
View GitHub Profile
@goltsevnet
goltsevnet / forms.py
Last active June 18, 2018 16:50
Костяк комментов
from django import forms
from comments.models import Comment
class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ('__all__')
class Species(models.Model):
class Meta:
verbose_name = 'Вид'
verbose_name_plural = 'Вид'
species = models
class Genus(models.Model):
class Meta:
function add_tag(type) {
var data = {
'button_id': type
};
console.log(type)
$.ajax({
url: window.location.href,
data: data,
dataType: 'json',
@goltsevnet
goltsevnet / .py
Created December 3, 2018 11:57
конвертация xls в xlxs
'''пересохраняем все файлы в xlsx'''
for i in get_price:
split, file_extension = os.path.splitext(i)
import pyexcel as p
'''пересохраняем xls в xlsx'''
p.save_book_as(file_name=os.path.normpath(base_dir_price + i),
dest_file_name=os.path.normpath(convert_base_dir_price + f'{split}.xlsx'))
<h2>{{ user.get_full_name }}</h2>
<ul>
<li>Имя пользователя: {{ user.username }}</li>
<li>Местоположение: {{ user.profile.location }}</li>
<li>Дата рождения: {{ user.profile.birth_date }}</li>
</ul>
from django.contrib.auth.models import User
from allauth.account.models import EmailAccount
from allauth.exceptions import ImmediateHttpResponse
from allauth.socialaccount.adapter import DefaultSocialAccountAdapter
class MyAdapter(DefaultSocialAccountAdapter):
def pre_social_login(self, request, sociallogin):
# This isn't tested, but should work
import threading
import time
main_queue = queue.Queue()
thread_number = 10
thread_list = []
def thread_func(name):
while True:
time.sleep(0.5)
@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()
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 / 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: