Skip to content

Instantly share code, notes, and snippets.

✍️
just writing some code

Mosquito mosquito

✍️
just writing some code
Block or report user

Report or block mosquito

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@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 Jun 25, 2019
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)
View thread_pool_simple.py
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):
@mosquito
mosquito / sentry_logger.py
Created Aug 28, 2017
Sentry tornado async client
View sentry_logger.py
# 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):
@mosquito
mosquito / aio_pipe.py
Last active Jun 25, 2019
Asyncio PIPE
View aio_pipe.py
import asyncio
import fcntl
import os
from functools import partial
class AsyncPIPE:
@staticmethod
def create_pipe():
read_fd, write_fd = os.pipe()
You can’t perform that action at this time.