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 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 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 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 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 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 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): |
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 asyncio | |
import fcntl | |
import os | |
from functools import partial | |
class AsyncPIPE: | |
@staticmethod | |
def create_pipe(): | |
read_fd, write_fd = os.pipe() |