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 _get_flatten_wsdl(self, url): | |
""" | |
Выполняет загрузку wsdl-схемы и зависимых файлов и объединяет их | |
в единый файл. | |
Ускоряет загрузку wsdl-схемы для клиента. | |
TODO: реализовать. | |
:type url: unicode |
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 profile(func): | |
from functools import wraps | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
from line_profiler import LineProfiler | |
prof = LineProfiler() | |
try: | |
return prof(func)(*args, **kwargs) | |
finally: |
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
#!/bin/sh | |
LOCKFILE="/tmp/script.lock" | |
LOGFILE="/tmp/script.log" | |
COMMAND="/usr/bin/php7 /home/rinat/myscript.php" | |
( | |
if flock -n 200 | |
then | |
echo "["$(date)"] Running command $COMMAND" | tee -a $LOGFILE |
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 select | |
import socket | |
from urllib.parse import urlsplit | |
class Loop: | |
ACTION_READ = 'read' | |
ACTION_WRITE = 'write' | |
ACTION_READY = 'ready' |
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 select | |
import socket | |
import typing | |
from urllib.parse import urlsplit | |
class Task: | |
def __init__(self, url): | |
self.split = urlsplit(url) |
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 select | |
import socket | |
from urllib.parse import urlsplit | |
class Poll: | |
ACTION_READ = 'read' | |
ACTION_WRITE = 'write' |
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 RawJoin(Join): | |
u"""Позволяет внедрить в QuerySet произвольный JOIN. | |
banners_qs = Banner.objects.extra(where=['my_join_table.status = 123']) | |
Join('LEFT JOIN (XXX) b1 ON b1.id = abcd ', ()).inject(banners_qs) | |
""" | |
def __init__(self, raw_sql, params): | |
# Используемые опции. |
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 matrix(side_width): | |
for y in xrange(side_width): | |
for x in xrange(side_width): | |
ring_number = min(x, y, side_width - 1 - x, side_width - 1 - y) | |
ring_serial = x + y - 2 * ring_number | |
if x >= y: | |
ring_base = 4 * ring_number * (side_width - ring_number) | |
result = ring_base + ring_serial | |
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
class FlamegraphMiddleware(object): | |
def __init__(self): | |
import os, socket, datetime | |
arguments = os.getpid(), socket.gethostname() | |
filename = '/tmp/flamegraph.%s.%s.log' % arguments | |
self.profiler = self.create_profiler(filename) | |
print('FlameGraph started: %s' % filename) | |
def __del__(self): |
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 profile(func): | |
from line_profiler import LineProfiler | |
def wrapper(*args, **kwargs): | |
profiler = LineProfiler(func) | |
try: | |
return profiler.runcall(func, *args, **kwargs) | |
finally: | |
profiler.print_stats() |
OlderNewer