Start up a lambda-like docker container:
docker run -i -t -v /tmp:/var/task lambci/lambda:build /bin/bash
Install some dependencies inside the container:
yum install gperf freetype-devel libxml2-devel git libtool -y
easy_install pip
| """ | |
| This script demonstrates how to run multiple subprocesses in Python using asyncio, | |
| capturing their outputs, and processing them in real-time. It can be run with an | |
| output file or with `-` to capture outputs directly in the console, and will then | |
| create subprocesses that generate output asynchronously by calling itself with | |
| task IDs. | |
| """ | |
| import asyncio | |
| import random |
| """ | |
| An experimental tokenizer for bash syntax. | |
| This is an alternative to shlex from the standard library for tokenizing posix | |
| style command line statements. | |
| On top of the word-splitting and quote removal functionality of shlex, this | |
| library also makes it possilbe to tell which glob characters are escaped, and | |
| preserves semantics for variable & arithmetic expansions. |
| """ | |
| A utility for running non-async code concurrently using threads and asyncio. | |
| # Call a function as async in a background thread | |
| ```python | |
| import asyncio | |
| asyncify = AsyncThread() |
| from collections.abc import Set | |
| from numpy import packbits | |
| import math | |
| import random | |
| from typing import Any, Callable, Collection, Iterable, Iterator | |
| class ImmutableBitSet(Set): | |
| _content: bytes |
| from magic_glue import create_grpc_handler, rpc_method | |
| from .generated_code.mypackage import MyRequest, MyResponse | |
| # Create a servicer class with the rpc methods we want to implement | |
| class MyServicer: | |
| # grpcio needs to know the fully qualified name of the service | |
| # It would be better if this was available from the betterproto generated classes | |
| # to save having to copy it from the proto file manually | |
| service_name = "mypackage.MyService" |
| import asyncio | |
| class Worker: | |
| def __init__(self, cmd, limit=None, separator=b"\n"): | |
| self.cmd = cmd | |
| self.limit = limit | |
| self.separator = separator | |
| async def send(self, data): |
| from typing import List, Tuple | |
| def encode(number: int) -> bytes: | |
| assert number >= 0, "Can only encode positive integers" | |
| flag_mask = 0b10000000 | |
| value_mask = 0b01111111 | |
| bytes_buffer = [number & value_mask] | |
| number = number >> 7 | |
| while number: |
| window.animate = (function () { | |
| function animate(initialValue, finalValue, duration, callback, ease, startTime, currentTime) { | |
| if (startTime) { | |
| if (currentTime - startTime >= duration) { | |
| callback(finalValue); | |
| return; | |
| } | |
| callback(ease(currentTime - startTime, initialValue, finalValue - initialValue, duration)); | |
| } |
| public struct CircularBuffer<T>: Collection, CustomStringConvertible { | |
| private var cursor: Int = 0 | |
| private var contents: [T] = [] | |
| let capacity: Int | |
| public init(capacity: Int) { | |
| self.capacity = capacity | |
| } | |
| public subscript(i: Int) -> T { |