This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author Ondrej Barta | |
# [email protected] | |
# Copyright 2023 | |
from thumbor.filters import BaseFilter, filter_method | |
from thumbor.utils import logger | |
# http://css.nothrem.cz/jak-urcit-kvalitu-a-kompresi-jpg-obrazku/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from datetime import datetime | |
TOKENS = 1000 | |
TELEGRAM_API = "https://api.telegram.org/botXY" # Telegra api bot token | |
TELEGRAM_CHAT_ID = 0 # Telegram chat ID | |
def get_price(): | |
url = "https://monorepo-mainnet-prod.minswap.org/graphql?CandlestickSeries" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mediaJSON = { "categories" : [ { "name" : "Movies", | |
"videos" : [ | |
{ "description" : "Big Buck Bunny tells the story of a giant rabbit with a heart bigger than himself. When one sunny day three rodents rudely harass him, something snaps... and the rabbit ain't no bunny anymore! In the typical cartoon tradition he prepares the nasty rodents a comical revenge.\n\nLicensed under the Creative Commons Attribution license\nhttp://www.bigbuckbunny.org", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" ], | |
"subtitle" : "By Blender Foundation", | |
"thumb" : "images/BigBuckBunny.jpg", | |
"title" : "Big Buck Bunny" | |
}, | |
{ "description" : "The first Blender Open Movie from 2006", | |
"sources" : [ "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" ], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CachedPaginator(Paginator): | |
""" | |
Paginator that does not count the rows in the table. | |
""" | |
@cached_property | |
def count(self): | |
"""Return the total number of objects, across all pages.""" | |
try: | |
md5 = hashlib.md5(str(self.object_list.query).encode("utf-8")).hexdigest() | |
cache_key = "admin_paginator:{0}".format(md5) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PermissionVersionAdmin(VersionAdmin): | |
def _reversion_revisionform_view(self, request, version, *args, **kwargs): | |
if not request.user.is_superuser: | |
messages.error(request, "Revert is supported only super user.") | |
return redirect("{}:{}_{}_change".format(self.admin_site.name, self.opts.app_label, self.opts.model_name), object_id=version.object_id) | |
else: | |
return super()._reversion_revisionform_view(request, version, *args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search(query): | |
try: | |
query.encode("ascii") | |
except UnicodeEncodeError: | |
galleries = Gallery.objects.published().filter( | |
fulltext__full_ts=SearchQuery(query, config="czech") | |
) | |
if not galleries: | |
galleries = Gallery.objects.published().filter(title__icontains=query) | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author Ondrej Barta | |
# [email protected] | |
# Copyright 2017 | |
import av | |
from PIL import Image | |
video_path = "/home/ondrej/Pictures/sample/video/video.mp4" | |
intro_path = "/home/ondrej/Pictures/sample/video/video2.mp4" | |
output_path = "/home/ondrej/OUTPUT.mp4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author Ondrej Barta | |
# [email protected] | |
# Copyright 2017 | |
from django.conf import settings | |
from rest_framework import authentication, permissions | |
class BasicAuthentication(authentication.BasicAuthentication): | |
def authenticate_credentials(self, userid, password): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def auth_check(func=None, realm="private", text="Access denied"): | |
"""Wrapper na basic/token/IP autorizaci""" | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
# FIXME otestovat o proti nginx a caddy | |
remote_ip = IP(request.get_header("X-Real-IP", request.remote_addr)) | |
local_ip = IPSet([IP("10.0.0.0/8"), IP("172.16.0.0/12"), IP("192.168.0.0/16")]) | |
if remote_ip in local_ip: | |
return func(*args, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base64(BaseStorage): | |
""" | |
Trida reprezentujici cteni a vraceni z base64 | |
""" | |
def copy(self, output_url, delete=False): | |
output_storage = storage_driver(output_url) | |
data = self.read() | |
output_storage.upload(data) |
NewerOlder