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
| [package] | |
| name = "processing_stream" | |
| version = "0.1.0" | |
| edition = "2021" | |
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
| [dependencies] | |
| futures = "0.3.24" | |
| tokio = { version = "1.21.0", features = ["full"] } |
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
| package main | |
| // Demonstrates how to constraint a generic type to implement an interface with a pointer receiver | |
| // inspired by this SO answer: https://stackoverflow.com/a/71444968 | |
| import ( | |
| "fmt" | |
| "strconv" | |
| "strings" | |
| ) |
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
| import asyncio | |
| from typing import Awaitable, Callable, Coroutine, Iterator | |
| from asyncio_pool import AioPool | |
| import pytest as pytest | |
| from more_itertools import peekable | |
| """ | |
| Different approaches to "How to limit concurrency with Python asyncio?" | |
| https://stackoverflow.com/questions/48483348/how-to-limit-concurrency-with-python-asyncio/48484593#48484593 |
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
| import random | |
| from concurrent.futures import ThreadPoolExecutor | |
| from queue import Queue | |
| from time import sleep | |
| class ThreadPoolExecutorWithQueueSizeLimit(ThreadPoolExecutor): | |
| # limiting queue size allows to keep under control the memory used by the producer | |
| # inspired by https://stackoverflow.com/a/48327162/34871 | |
| def __init__(self, max_queue_size: int, *args, **kwargs): |
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
| /target |
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
| /* | |
| solution to the second part of https://adventofcode.com/2020/day/23 | |
| it executes in less than a minute in release mode, but it ain't pretty | |
| main points: | |
| - double linked list to easily insert/split/remove | |
| - the nodes are not individual values, but ranges instead | |
| - because looking up a value in a linked list takes so long, there is a hashmap pointing to the | |
| slices for each value. everytime a slice is added or changed, all the values of the slice |
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
| package com.company; | |
| /** | |
| java -cp . com.company.Main "4" "3" "2" | |
| 4 is even | |
| 3 is not even | |
| 2 is even | |
| */ |
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
| import dateutil.parser | |
| import re | |
| import sys | |
| import pytz | |
| tz = pytz.timezone("Europe/Vienna") | |
| res = [] | |
| for line in sys.stdin: |
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
| #!/usr/bin/env python | |
| # -*- coding: UTF-8 -*- | |
| import re | |
| from collections import defaultdict | |
| from functools import partial | |
| i = """jio a, +18 | |
| inc a | |
| tpl a |
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 reply_sysex(self, message): | |
| from array import array | |
| try: | |
| raw = array('B') | |
| raw.fromstring(message.encode('utf-16-le')) | |
| raw = raw.tolist() | |
| raw.insert(0, 240) | |
| raw.append(247) | |
| self._send_midi(tuple(raw), False) |