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
package main | |
import ( | |
"fmt" | |
"math/bits" | |
"runtime" | |
"sync/atomic" | |
"time" | |
) |
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 logging | |
import threading | |
import time | |
import typing | |
def generator(): | |
time.sleep(5) | |
yield 123 | |
return 456 |
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 argparse | |
import codecs | |
import dataclasses | |
import json | |
import logging | |
import os | |
import shutil | |
import subprocess | |
import typing | |
import re |
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
[root@li145-5 Sentry]# cat Dockerfile | |
FROM centos/systemd | |
CMD ["/usr/sbin/init"] | |
RUN yum install -y epel-release | |
RUN yum install -y redis | |
RUN systemctl enable redis |
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
# coding: utf-8 | |
import multiprocessing | |
import subprocess | |
import threading | |
import signal | |
import time | |
import os | |
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() |
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 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 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
import select | |
import socket | |
from urllib.parse import urlsplit | |
class Poll: | |
ACTION_READ = 'read' | |
ACTION_WRITE = 'write' |
NewerOlder