This file contains 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
""" | |
Calculating hair length with given coords using Newton's Divided Differential interpolation. | |
If interpolated function's shape does not comply with actual hair curve, (i.e. drawn in GeoGebra) | |
Start giving more accurate coordinates. | |
""" | |
from decimal import Decimal | |
from typing import Iterable, Tuple, Sequence | |
from fractions import Fraction | |
# from matplotlib import pyplot |
This file contains 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/local/bin/python3.9 | |
""" | |
Only tested to run on raspberry pi, but shouldn't be limited to it only. | |
Listens for incoming connections and execute received python codes. | |
Obviously this is very dangerous. This is to be run on overlayFS with Raspbian in mind. | |
""" | |
import subprocess |
This file contains 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 <iostream> | |
#include <vector> | |
#include <algorithm> // for_each | |
using namespace std; | |
// forward declaration | |
class A; | |
// forward declaration | |
void friend_function_demo(A a); |
This file contains 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 time | |
import traceback | |
import h5py | |
import queue | |
from typing import Union | |
from watchdog.observers import Observer | |
from watchdog.events import FileSystemEventHandler, DirCreatedEvent, FileCreatedEvent |
This file contains 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
""" | |
Test use-case | |
>>> len(list(file_search_gen("./", "asyncio", file_extensions=(".py",)))) | |
6 | |
>>> for f in file_search_gen("./", "asyncio", "REPLACE_THIS", file_extensions=(".py",)): | |
... print(f.as_posix()) | |
... | |
telethon_examples/interactive_telegram_client.py |
This file contains 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 | |
import pathlib | |
import textwrap | |
from pprint import pprint | |
ROOT = pathlib.Path(__file__).parent | |
async def read_all(r: asyncio.StreamReader): |
This file contains 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 timeit import timeit | |
dataset = ['Not int'] | |
dataset.extend(range(10000)) | |
def if_checking(): | |
for data in dataset: | |
if isinstance(data, int): |
This file contains 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
""" | |
Nursery cancellation demo of websocket | |
""" | |
import itertools | |
import trio | |
import fastapi | |
import hypercorn | |
from hypercorn.trio import serve |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Websocket test</title> | |
</head> | |
<body> | |
<button id="start">Start connection</button> | |
<button id="close" disabled>Close connection</button> | |
<input type="text" id="input_" value="INPUT_YOUR_UUID"> |
This file contains 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
""" | |
Context manager Demo | |
""" | |
from contextlib import contextmanager | |
# generator implementation | |
@contextmanager | |
def mock_open(*args, **kwargs): |
OlderNewer