Skip to content

Instantly share code, notes, and snippets.

@rupython
rupython / 1.py
Created May 29, 2021 14:57
From: Djimbo
import sys
import importlib
import asyncio
import binascii
from bitstring import BitArray, ConstBitStream
import protocol
import random
import html
import time
from time import mktime
@rupython
rupython / 1.py
Created May 29, 2021 14:54
From: nwexx
import sys
import importlib
import asyncio
import binascii
from bitstring import BitArray, ConstBitStream
import protocol
import random
import html
import time
from time import mktime
@rupython
rupython / main.py
Created May 23, 2021 13:26
From: Sorin
Привет, есть 3 модельки, как сформировать запрос чтобы выбести все LocationCompany с определеном city или sector, + DomainService domain + Service service_type, name
class Service(models.Model):
name = models.CharField(max_length=20, blank=True, null=True)
service_type = models.ForeignKey(Service_type, on_delete=models.CASCADE)
price = models.DecimalField(max_digits=10, decimal_places=0)
slug = models.SlugField(max_length=30)
class DomainService(models.Model):
@rupython
rupython / main.py
Created May 20, 2021 13:36
From: GirdimaN
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a == c - 1 or a == c + 1 or a == c:
print("YES")
elif b == d - 1 or b == d + 1 or b == d:
@rupython
rupython / main.py
Created May 8, 2021 08:33
From: Павел
In [14]: class LazyInit(type):
...: def __new__(mcs, name, bases, namespace):
...: namespace["__init__"] = lambda self, *args, **kwargs: vars(self).update(kwargs)
...: return super().__new__(mcs, name, bases, namespace)
...:
In [15]: class Foo(metaclass=LazyInit):
...: def __init__(self, name):
...: pass
...:
@rupython
rupython / main.py
Created May 8, 2021 08:10
From: Павел
In [1]: class LazyInit:
...: def __new__(cls, **kwargs):
...: instance = super().__new__(cls)
...: for t in instance.__init__.__code__.co_varnames[1:]:
...: setattr(instance, t, kwargs[t])
...: return instance
...:
In [2]: class Foo(LazyInit):
...: def __init__(self, name):
@rupython
rupython / main.py
Created May 5, 2021 09:23
From: Мr. Ληdеrsση
from http.server import BaseHTTPRequestHandler, HTTPServer
import time, ssl
hostName = "localhost"
hostPort = 9000
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-type", "text/html")
@rupython
rupython / parser.py
Created May 4, 2021 12:01
From: Yaroslav
# -*- coding: utf-8 -*-
# импортируем библиотеки
import sys
from PySide2 import QtWidgets
from PySide2.QtCore import (QCoreApplication, QMetaObject, QRect)
from PySide2.QtWidgets import *
from telethon import TelegramClient, events
from pars_conf import account, list_all, key_words # импортируем данные из файл конфигурации
@rupython
rupython / main.py
Created May 4, 2021 11:23
From: Artyom
def save_all(*values: Any) -> List[Any]:
res = [] # not all cases have hashable objects
for i in values:
if i is not None and i not in res:
res.append(i)
return res
def submerge(*values: Any) -> List[Any]:
res = []
for value in values:
@rupython
rupython / test_panel.py
Created April 29, 2021 15:09
From: Александр
import unittest
import panel as p
class AngleTestCase(unittest.TestCase):
def setUp(self):
self.ang = p.Angle()
def test_get_angle_type(self):
self.assertEqual(self.ang.angle_type, 0)