Default aiohttp static handler doesn't support any modification on the fly.
This handler helps to serve static files from directory ./static as is and convert JSX for ReactJS if needed.
import asyncio
import logging
from aiohttp import web
import os| # https://stackoverflow.com/questions/36384353/generate-pixel-matrices-from-characters-in-string | |
| # FONT: https://fontstruct.com/fontstructions/show/1404190/cg-pixel-4x5-1 | |
| from PIL import Image | |
| from PIL import ImageFont | |
| from PIL import ImageDraw | |
| import numpy as np | |
| def char_to_pixels(text, path, fontsize): | |
| font = ImageFont.truetype(path, fontsize) |
| import psutil | |
| import requests | |
| def open_files(): | |
| proc = psutil.Process() | |
| return proc.open_files() | |
| print 'on start:', open_files() |
| # coding: utf8 | |
| def dijkstra_shortest_path(graph, start, paths={}, visited=[]): | |
| if len(paths) == 0: | |
| paths[start] = {'dist': 0, 'parent': None} # инициализация начального пути | |
| # print "start V: %d, " % (start) | |
| for x in graph[start]: | |
| if (x not in visited and x != start): | |
| if (x not in paths.keys() or (graph[start][x] + paths[start]['dist']) < paths[x]['dist']): | |
| paths.setdefault(x, {'dist': 0, 'parent': None}) | |
| paths[x]['dist'] = graph[start][x] + paths[start]['dist'] |
| from rx import Observable, AnonymousObservable | |
| from rx.concurrency import current_thread_scheduler | |
| from rx.internal import extensionclassmethod | |
| @extensionclassmethod(Observable) | |
| def from_iterable_with_interval(cls, period, iterable, scheduler=None): | |
| """Creates an Observable that polls iterator made from iterable every period millis.""" | |
| iterator = iter(iterable) | |
| return Observable.interval(period, scheduler=scheduler).map(lambda v: next(iterator)) |
| engine = DjangoTemplates( | |
| { | |
| 'NAME': 'mail', | |
| 'APP_DIRS': False, | |
| 'DIRS': [], | |
| 'OPTIONS': { | |
| 'loaders': [ | |
| 'events.loaders.MyLoader', | |
| ], | |
| }, |
Default aiohttp static handler doesn't support any modification on the fly.
This handler helps to serve static files from directory ./static as is and convert JSX for ReactJS if needed.
import asyncio
import logging
from aiohttp import web
import os| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
| import socket, threading | |
| host = "127.0.0.2" | |
| server = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP) | |
| remote, peer = None, None | |
| server.bind((host, 0)) | |
| server_addr = server.getsockname() |
| class A(object): | |
| def m(self): | |
| print 'A1' | |
| try: | |
| super(A, self).m() | |
| except AttributeError: | |
| print 'A has no super.m()!' | |
| print 'A2' | |
| class B(object): |
| LIBRARY ieee; | |
| USE ieee.std_logic_1164.all; | |
| LIBRARY work; | |
| ENTITY Custom_FSM IS | |
| PORT | |
| ( | |
| clk : IN STD_LOGIC; | |
| init : IN STD_LOGIC; |