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 os import PathLike | |
from typing import Iterator | |
def readlines(filename: PathLike) -> Iterator[str]: | |
"""Reads a file line by line, yielding the lines as strings. | |
Unlike Python's file object readlines method, this function does not read the entire file into | |
memory, but reads it on demand. | |
Args: |
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
git filter-branch -f --env-filter \ | |
"GIT_AUTHOR_EMAIL='[email protected]'; GIT_COMMITTER_EMAIL='[email protected]';" \ | |
HEAD |
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 typing import Iterable | |
from functools import reduce | |
def replace_all(text: str, table: Iterable[tuple[str, str]]) -> str: | |
""" Replaces multiple strings in a string. | |
Usage: | |
```python | |
replace_all("Hello World", [("Hello", "Hi"), ("World", "Earth")]) | |
# 'Hi Earth' |
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 typing import Callable, Any | |
from functools import reduce, partial | |
def pipeline(*functions: Callable[[Any], Any]) -> Callable[[Any], Any]: | |
""" Creates a pipeline from a sequence of functions. | |
Usage: | |
processor = pipeline(str.lower, str.split) | |
processor("Hello World") |
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 python3 | |
import boto3 | |
import requests | |
import tqdm | |
from urllib.parse import urlparse | |
def stream_to_s3( | |
source_url, | |
target_url, |
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 functools | |
def lazy_property(func): | |
''' Caches the return value of a function, and turns it into a property. | |
Intended to be used as a function decorator:: | |
>>> class Foo: | |
>>> @lazy_property | |
>>> def bar(self): |
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 gi | |
gi.require_version('Gst', '1.0') | |
gi.require_version('GstRtspServer', '1.0') | |
from gi.repository import GLib, Gst, GstRtspServer | |
Gst.init(None) | |
import argparse | |
parser = argparse.ArgumentParser(description='GStreamer RTSP server test-launch') |
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 panoramasdk | |
from backpack.annotation import ( | |
Point, LabelAnnotation, RectAnnotation, TimestampAnnotation, | |
OpenCVImageAnnotationDriver, | |
PanoramaMediaAnnotationDriver | |
) | |
class Application(panoramasdk.node): | |
def __init__(self): |
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 panoramasdk | |
from backpack.kvs import KVSSkyLine, KVSFileCredentialsHandler | |
# You might want to read these values from Panorama application parameters | |
stream_region = 'us-east-1' | |
stream_name = 'panorama-video' | |
# The example Dockerfile writes static configuration variables to this file | |
# If you change the .env file path in the Dockerfile, you should change it also here | |
DOTENV_PATH = '/panorama/.env' |
NewerOlder