This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from dataclasses import dataclass, field | |
| from itertools import count | |
| from datetime import datetime | |
| counter = count() | |
| @dataclass | |
| class Event: | |
| message: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| """ | |
| Copyright 2018-09-09, Wolfgang Kühn | |
| Fast inter-process communication (ipc) for Python (CPython, PyPy, 2.7, 3.6+) on MS-Windows. | |
| It uses shared memory and eventing. | |
| Example rpc style synchronization: | |
| Server (rpc provider): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $include rle.gms | |
| Set T / 1*5 /; | |
| * Test series without additional domain. | |
| Parameter a(T), a_rle(T) / 1 1, 3 EPS, 5 2 / | |
| a_expected(T) / 1 1, 2 1, 5 2 /; | |
| a(T) = a_rle(T); | |
| rle_decode_1(a, T); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def topological(nodes:set, get_successors) -> deque: | |
| """ | |
| Returs a topologically sorted queue using DFS and gray/black colors. | |
| get_successors(node) an accessor function for the successors of each node. | |
| Code based on https://gist.github.com/kachayev/5910538 | |
| """ | |
| GRAY, BLACK = 0, 1 | |
| order, state = deque(), {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Python Cheat Sheet | |
| # List Comprehension | |
| some_items = [{'index':i, 'value':i*i} for i in range(0,10)] | |
| filtered_items = [item for item in some_items if item['index']%2 == 1 ] | |
| # Dict Comprehension |
NewerOlder