Skip to content

Instantly share code, notes, and snippets.

@agostof
agostof / find_and_rsync_files_by_mod_time.sh
Last active July 25, 2024 16:28
find_and_rsync_files_by_mod_time
# purpose: using the find utility to find files after a given modification time.
# This list could then be used to construct and rysync `--inclue-files-from` list.
find -mindepth 5 -type d -newermt 2023-09-14 -exec echo "{}" \; > ~/data_list_09142023_07242024.txt
# e.g.
#
# rsync -apuv --progress --include-from=rsync_include.txt user@host:/data_path/ data_path/
# note --include-from vs --files-from functionality
@agostof
agostof / quarto_install_jupyterhub.sh
Last active February 17, 2024 21:00
Quarto Install on JupyterHub
pip install jupyterlab-quarto
sudo -E mamba install quarto
sudo -E mamba install r-quarto
# quarto executable has issues finding several dendencies.
# We need to either add these to the environment or edit the quarto script and add these at the top
#!/bin/bash
export QUARTO_SHARE_PATH=/opt/tljh/user/share/quarto
@agostof
agostof / IP_to_ISP_CIDR_Ranges_Registry_Lookup.py
Last active February 3, 2024 17:33
Fetches ISP CIDR ranges from IP addresses using ARIN RDAP, aiding network analysis, useful for setting up firewall rules.
# There are resources
# https://www.arin.net/resources/registry/whois/rdap/
# +
# There are several ways to getting the CIDR that one IP belongs to.
# A quick way is by using whois for a given a IP. # The CIRD will be on the record:
# For example for IP Address 8.8.8.1:
# whois 8.8.8.1
# ... LINES OMITTED ...
@agostof
agostof / run_speedtest_with_docker.sh
Created January 28, 2024 18:05
Run speedtest-cli on a Docker container
#!/usr/bin/env bash
# simple command to run the speedtest-cli using docker
# it will sleep for 3 secs before starting the test
docker run --rm -it ubuntu /bin/bash -c "apt update && apt install -y speedtest-cli && sleep 3 && speedtest-cli"

Testing docker permissions

Ilustrate Host permissions mappings into a container.

# Create a directory that we are going to use to test our VOLUME
mkdir TEST; cd TEST
mkdir -pv DOCKER_VOLUME/{data,users,jhub}

Check contents

@agostof
agostof / check_pip_dependencies.py
Last active April 12, 2023 14:35
List dependencies for a specific pip package without downloading it.
import requests
import sys
script_name = sys.argv[0]
USAGE = f'''Lists package dependencies for a pip package without downloading it.
Usage:
{script_name} package_name (or package_name==version)
e.g.
To print all versions and depenencies of a given package.
{script_name} pandas