Skip to content

Instantly share code, notes, and snippets.

Avatar
✍️
just writing some code

Mosquito mosquito

✍️
just writing some code
View GitHub Profile
View python-resource.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View setup.py
long_description_content_type='text/markdown'
View process_pool_executor.py
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)
@mosquito
mosquito / demo.ipynb
Last active Feb 18, 2019
LOSSY SOUNDS
View demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mosquito
mosquito / aiofile.ipynb
Last active Dec 24, 2018
aiofile tests
View aiofile.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mosquito
mosquito / rgb_color_console.py
Created Oct 5, 2017
Set RGB color to string in terminal
View rgb_color_console.py
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))
@mosquito
mosquito / 00-default.conf
Created Oct 4, 2017
Nginx Letsencrypt Config
View 00-default.conf
# cat /etc/nginx/sites-enabled/00-default.conf
server {
listen 80 default deferred;
include default.d/*.conf;
location / {
rewrite ^/(.*)$ https://$host/$1 redirect;
}
}
@mosquito
mosquito / proxy.py
Last active Apr 5, 2021
AIOHTTP async proxy streaming
View proxy.py
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
View async-pipe.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mosquito
mosquito / check-rabbitmq.py
Last active Sep 27, 2017
Check status of rabbitmq node
View check-rabbitmq.py
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)