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 requests | |
import re | |
import random | |
from rich.console import Console | |
from rich.panel import Panel | |
from rich.text import Text | |
url = "https://raw.githubusercontent.com/nrrb/tao-te-ching/master/Ursula%20K%20Le%20Guin.md" | |
def get_random_chapter(): |
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 os import fspath | |
import numpy as np | |
from osgeo import gdal | |
from dolphin import io, stitching, utils | |
def compute_boi(ifg_file1: str, ifg_file2: str, looks: tuple[int, int] = (1, 1)) -> np.ndarray: | |
assert io.get_raster_crs(ifg_file1) == io.get_raster_crs(ifg_file2) | |
(left, bottom, right, top), nodata = stitching.get_combined_bounds_nodata( | |
ifg_file1, ifg_file2 |
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/bin/env python3 | |
from numba import njit | |
@njit | |
def f(arr): | |
s = 0 | |
i = 0 | |
while i < len(arr): | |
s += arr[i] |
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/bin/env python | |
# requirements: h5py, rich | |
import sys | |
import h5py | |
from rich.console import Console | |
from rich.table import Table | |
def _get_object_metadata(obj) -> tuple[str, float, float] | None: |
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/bin/env bash | |
set -e | |
set -x | |
# Check if INSTALL_PREFIX is set; otherwise, error | |
if [ -z "$INSTALL_PREFIX" ]; then | |
echo "INSTALL_PREFIX is not set" | |
echo "Example usage: INSTALL_PREFIX='~/.local/bin' bash $0" | |
exit 1 | |
fi |
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 datetime | |
import re | |
from pathlib import Path | |
from typing import Union | |
import pandas as pd | |
import xarray as xr | |
Filename = Union[str, Path] |
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/bin/env python | |
# pip install requests rich beautifulsoup4 | |
import sys | |
import requests | |
from bs4 import BeautifulSoup | |
from rich.console import Console | |
from rich.panel import Panel | |
URL = "https://dailytao.org/" |
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/bin/env python | |
import argparse | |
from pathlib import Path | |
def split_file(filename: str | Path, lines_per_file: int, output_prefix: str): | |
"""Split a text file into multiple files. | |
Parameters | |
---------- |
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 requests | |
from concurrent.futures import ThreadPoolExecutor | |
def get_s3_direct_urls( | |
safe_names: list[str], max_workers: int = 5 | |
) -> str | None: | |
"""Get the S3 urls for a list of SAFE granules.""" | |
def _get_url(safe_name): |
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 subprocess | |
import time | |
from pathlib import Path | |
import h5py | |
import numpy as np | |
from dolphin import io | |
class GDALStackReader: |
NewerOlder