Skip to content

Instantly share code, notes, and snippets.

Petr Messner messa

Block or report user

Report or block messa

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
View 2020_02_20_radky.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View vypocet_lhuty_s_hlubokym_zrusenim.py
from datetime import date, datetime, timedelta
def main():
events = [
ZakladniInterval(dt('2020-01-01'), dt('2030-01-01')),
Prodlouzeni(id=222, roky=3),
Zruseni(id=333, zrusit_id=222),
Zruseni(id=444, zrusit_id=333),
Zruseni(id=555, zrusit_id=444),
View pointer_aritm.cc
#include <cstdio>
#include <cstdint>
int main() {
int size = 10;
void *ptr = (void*) 1000;
unsigned *ptr2 = (unsigned*) ptr + size;
printf("ptr: %lu ptr2: %lu \n", (uintptr_t) ptr, (uintptr_t) ptr2);
return 0;
}
View aiohttp_download.py
from aiohttp import ClientSession
from asyncio import run, gather, create_task
url_template = 'https://jsonplaceholder.typicode.com/posts/{post_id}'
worker_count = 10
async def main():
post_ids = list(range(1, 101))
titles = {}
View datetime_lokalizace.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@messa
messa / aiohttp_request_id_logging.py
Last active Jan 15, 2020
Aiohttp request_id logging
View aiohttp_request_id_logging.py
# BTW. I have created a library for this: https://github.com/messa/aiohttp-request-id-logging
from aiohttp import web
from aiohttp.web_log import AccessLogger
import asyncio
from asyncio import CancelledError
from contextvars import ContextVar
import logging
import os
import secrets
@messa
messa / cykly.py
Created Apr 11, 2019
Pyladies opakovani 2019-04-11
View cykly.py
def ruzne_ctverce():
for delka_strany in 2, 5, 7:
ctverec(delka_strany, symbol='O')
def ctverec(n, symbol='X'):
for cislo_radku in range(n):
for cislo_sloupce in range(n):
if (
View aiohttp_graphql_server_minimal_example.py
from aiohttp import web
from aiohttp_graphql import GraphQLView
from graphql.execution.executors.asyncio import AsyncioExecutor
from graphql import (
graphql,
GraphQLSchema,
GraphQLObjectType,
GraphQLField,
GraphQLNonNull,
GraphQLString,
View async_context_stack_example.py
import asyncio
from contextlib import contextmanager, asynccontextmanager, AsyncExitStack
@contextmanager
def stuff(name):
print('Opening', name)
yield
print(f'Closing {name}')
View gist:5ded8deeef4175ca0b016b4244e2f2df
https://docs.google.com/presentation/d/1YUT0WPmqJt1tn4MaqWqVctzslT4wuCNHiaok0Ii665o/edit?usp=sharing
You can’t perform that action at this time.