free -h
total used free shared buff/cache available
Mem: 125Gi 12Gi 109Gi 186Mi 4.9Gi 113Gi
Swap: 4.0Gi 154Mi 3.8Gi
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 stream_download(url:str, output_filepath:Path, desc:str='Item Download'): | |
| response = requests.get(url, stream=True) | |
| total = int(response.headers.get('content-length', 0)) | |
| with open(output_filepath, 'wb') as f, tqdm(desc=desc,total=total,unit='iB',unit_scale=True,unit_divisor=1024,) as bar: | |
| for data in response.iter_content(chunk_size=1024): | |
| size = f.write(data) | |
| bar.update(size) |
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 geoplot | |
| import contextily as cx | |
| import geopandas as gpd | |
| import matplotlib.pyplot as plt | |
| from pathlib import Path | |
| from shapely.geometry import shape | |
| def display_geometries(list_geometries:list[dict], output_filepath:Path): |
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 time | |
| import torch | |
| from torch.utils.data import Dataset, DataLoader | |
| from tqdm import tqdm | |
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| from fourm.data.dummy_dataset import DummyDataset | |
| def check_dataloader_speed(dataset:Dataset, |
du -sh ./* | sort -h-sGives only the total of each element-hHuman readable values./*all element in your current location (you can change that part for a specific locationsort -hSort the element by size (bottom = largest)
docker run --rm -v "$PWD:/pwd" busybox rm -rf /pwd/<element>- Create a small linux docker (
busybox) - Make the current terminal location a volume binded to
/pwdin the container - Remove an element from that location (
/pwd/<element>) - Erase the launched container (
--rm)
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 logging | |
| logger = logging.getLogger(__name__) | |
| def extract_json_from_string(text:str) -> dict: | |
| """Convert a text containing a JSON or python dict into a python dict. | |
| :param str text: | |
| :raises ValueError: If the string does not contains a valid json | |
| :return dict: |
Flask
Flask-SocketIO
gunicorn[gevent]
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 time | |
| import ntplib | |
| import logging | |
| logger = logging.getLogger(__name__) | |
| def get_current_utc_time() -> float: | |
| logger.debug('Requesting current UTC time') | |
| response = ntplib.NTPClient().request('pool.ntp.org') | |
| logger.debug(f'UTC time : {response.tx_time} | {time.strftime('%Y-%m-%dT%H-%M-%S',time.gmtime(response.tx_time))}') |
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 argparse | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('minute_threshold', type=int) | |
| args = parser.parse_args() | |
| minute_threshold:int = args.minute_threshold |