Skip to content

Instantly share code, notes, and snippets.

View Cguilliman's full-sized avatar
🐯
#TiggerForm

Ihor Bondarenko Cguilliman

🐯
#TiggerForm
  • Madgicx
  • Kiev, Ukraine
View GitHub Profile
@Cguilliman
Cguilliman / attribute`s models
Last active May 8, 2018 10:40
models for dynamic attributes
# models
from django import models
from django.utils.translation import ugettext_lazy as _
class RowAttribute(models.Model):
"""Product/look row attribute model."""
product = models.ForeignKey(
'ModelWithAttribute', verbose_name=_('Product'),
on_delete=models.CASCADE, null=True,
# run.py file
from app.app import init
if __name__ == "__main__":
init()
# app/app.py file
from sanic import Sanic
# HANDLER
from django.utils.translation import ugettext_lazy as _
from rest_framework.exceptions import ErrorDetail
from rest_framework.views import exception_handler
non_field_errors = 'non_field_errors'
def set_custome_errors(errors):
# PROXY MODEL
class Proxy(models.Model):
host = models.CharField(
verbose_name='Host',
max_length=255
)
is_valid = models.BooleanField(
verbose_name='Is valid',
default=True
)
from typing import Dict, Any
from django.http.response import JsonResponse
from rest_framework.response import Response
BASE_RESPONSE_MESSAGE = {
'code': 200,
'meta': {},
'data': {}
from typing import Dict, Type
from rest_framework.generics import ListAPIView
from rest_framework.response import Response
from ..paginator import PageNumberPagination
from .response_format import RestGetResponseMixin
__all__ = ('ListAPIViewPagination', )
from collections import OrderedDict
from rest_framework.pagination import PageNumberPagination as BasePageNumberPagination
from rest_framework.response import Response
__all__ = (
'PageNumberPagination',
'paginator_generate',
)
import requests
from bs4 import BeautifulSoup as bs
from apps.proxy.models import Proxy
PROXY_URL = "https://www.sslproxies.org/"
TEST_URL = "https://www.google.com/"
@Cguilliman
Cguilliman / Cacher
Last active March 26, 2021 13:36
Cache all stuff
from typing import *
import time
from django.core.cache import cache
TICKET_AMOUNT = 10
TICK_SIZE = 0.1