Skip to content

Instantly share code, notes, and snippets.


Block or report user

Report or block Sraw

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
Sraw / index.js
Last active Dec 28, 2017
Use plain javascript to generate bmp file.
View index.js
function drawArray(arr) {
Thanks original author @vukicevic
Pass a two-dimensional arrary.
The first dimonsion is rows, the second one is columns.
Note that in columns, each pixel is represented by four nums as BGRA, so the columns' length is four times as image's length.
return image's base64 code.
Sraw /
Created Dec 25, 2017
Run asyncio event loop in sub-thread

asyncio won't automatically create event loop for sub-thread, so to run async tasks in sub-thread, we need to manually create an event loop first.

loop = asyncio.new_event_loop()
Sraw /
Last active Dec 25, 2017
Make tornado works with asyncio

tornado has its own event loop which is incompatible with asyncio's event loop. But it can be solved.

First, create a BaseHandler extended from tornado.web.RequestHandler:

class BaseHandler(tornado.web.RequestHandler):

    def asyncio_task(method):
        async def wrapper(self, *args, **kwargs):
You can’t perform that action at this time.