This file contains hidden or 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 asyncio | |
| from concurrent.futures._base import Executor | |
| from multiprocessing import Pool, cpu_count | |
| class ProcessPoolExecutor(Executor): | |
| def __init__(self, max_workers=max((cpu_count(), 4)), **kwargs): | |
| self.__futures = set() | |
| self.__pool = Pool(processes=max_workers, **kwargs) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 colorize(text, fg=None, bg=None): | |
| result = '' | |
| def parse_hex(h): | |
| h = h.strip("#").ljust(6, '0') | |
| return [int(h[i+i:i+i+2], 16) for i in range(3)] | |
| if bg: | |
| result += '\x1b[48;2;{};{};{}m'.format(*parse_hex(bg)) |
This file contains hidden or 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
| # cat /etc/nginx/sites-enabled/00-default.conf | |
| server { | |
| listen 80 default deferred; | |
| include default.d/*.conf; | |
| location / { | |
| rewrite ^/(.*)$ https://$host/$1 redirect; | |
| } | |
| } |
This file contains hidden or 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 platform | |
| import unittest | |
| from http import HTTPStatus | |
| from urllib.parse import urlencode, unquote | |
| import aiohttp | |
| import asynctest | |
| from aiohttp import web | |
| from aiohttp.test_utils import TestClient | |
| from multidict import MultiDict |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| from ast import literal_eval | |
| from contextlib import contextmanager | |
| from subprocess import check_output | |
| import re | |
| import sys | |
| def parse_output(input_string): | |
| input_string = input_string.replace("\"", '\'') | |
| input_string = re.sub('([a-zA-Z\@\<\>\_\"\']+)', r'"\1"', input_string) |
This file contains hidden or 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 | |
| from concurrent.futures import Executor | |
| from functools import partial | |
| from multiprocessing.pool import ThreadPool as ThreadPoolBase | |
| log = logging.getLogger() | |
| class ThreadPool(ThreadPoolBase, Executor): |
This file contains hidden or 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
| # encoding: utf-8 | |
| from tornado.gen import Return, coroutine | |
| from tornado.ioloop import IOLoop | |
| import tornado.web | |
| from raven.contrib.tornado import SentryMixin | |
| class SentryHandler(SentryMixin, tornado.web.RequestHandler): | |
| @coroutine | |
| def _execute(self, transforms, *args, **kwargs): |