Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View DonRichards's full-sized avatar

Don Richards DonRichards

View GitHub Profile
@DonRichards
DonRichards / check_port.sh
Created April 10, 2024 17:57
Troubleshooting isle-dc build conflicts.
#!/bin/bash
DOCKER_COMPOSE_FILE="docker-compose.yml"
# Check if docker-compose file exists
if [ ! -f "$DOCKER_COMPOSE_FILE" ]; then
echo "Docker Compose file not found at $DOCKER_COMPOSE_FILE"
exit 1
fi
# Extract ports from the 'ports' section of 'traefik' service
#!/bin/bash
# DRAFT: untested at the moment
# FITS File Processor for Dataverse Upload
# -----------------------------------------
# This script iterates through each .fits file in the specified directory, extracts the star number from
# the file name, and uses this information to construct a JSON payload. It then executes a curl command
# to upload each file to a specified Dataverse server using the provided API token and Persistent ID.
# The output of each curl command, along with relevant data, is logged to 'log.txt' for record-keeping
# and debugging purposes.
@DonRichards
DonRichards / dspace_queries.md
Last active September 25, 2023 20:56
Useful DSpace sql queries

Recently Created (within 30 days) that are missing TN files

SELECT 
    h.handle
FROM 
    handle h
JOIN
    item i
ON
    h.resource_id = i.uuid
@DonRichards
DonRichards / Grab_media_file_url_paths.md
Last active September 12, 2023 18:27
Use IDC's Metadata export CSV file to find and pull the Original File's URL path into the CSV.

Grab.py retrieves URLs for either "Intermediate Files" or "Original Files" and appends them to a CSV file.

The script includes a feature for resuming its progress in case of an interruption or error. As a precaution, it adjusts the URLs from the production server to redirect them to a staging server.

Additionally, the script incorporates error-handling mechanisms, utilizing a try-catch-retry approach, to gracefully manage timeouts.

Setup to run

python3 -m venv .venv
source .venv/bin/activate
@DonRichards
DonRichards / get_all_taxonomy_terms.sh
Last active March 20, 2023 18:07
Export all taxonomy terms for Islandora 2.x
#!/usr/bin/env bash
# This generates the header bases by what terms were returned.
# This makes merging them complicated.
curl https://islandora.traefik.me/content/taxonomy-terms/export > taxonomy_terms_000.csv
for i in {1..10000..100}
do
echo "Loop $i"
Starting diagnostics
[PASS] DD0027: is there available disk space on the host?
[PASS] DD0028: is there available VM disk space?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[PASS] DD0017: can a VM be started?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0004: is the Docker engine running?
@DonRichards
DonRichards / log
Last active December 19, 2022 21:52
make up
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5600 100 5600 0 0 13078 0 --:--:-- --:--:-- --:--:-- 13053
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1704 100 1704 0 0 5063 0 --:--:-- --:--:-- --:--:-- 5071
Building Drupal image with base: ghcr.io/jhu-sheridan-libraries/idc-isle-dc/drupal:upstream-20200824-f8d1e8e-83-g8c8a6b4
[+] Building 43.9s (13/13) FINISHED
=> [internal] load build definition from Dockerfile 0
Starting diagnostics
[PASS] DD0027: is there available disk space on the host?
[PASS] DD0028: is there available VM disk space?
[PASS] DD0018: does the host support virtualization?
[PASS] DD0001: is the application running?
[PASS] DD0017: can a VM be started?
[PASS] DD0016: is the LinuxKit VM running?
[PASS] DD0011: are the LinuxKit services running?
[PASS] DD0004: is the Docker engine running?
@DonRichards
DonRichards / Prewarn_IIIF_Cache.md
Last active October 2, 2023 20:01
Script to warm the IIIF cache by PID. This looks is a specific viewer is on the page to fetch the URL to start preheating (warming) the cache.

urls_to_prewarm.py

This script is designed to "pre-warm" the cache of a Cantaloupe IIIF server by sending requests to specified image URLs with multiple IIIF endpoints. The script reads image URLs from a provided text file, combines each URL with a set of IIIF endpoints, and then sends concurrent requests to the server to access and cache these images. By doing so, it ensures that the specified images are readily available in the server's cache for faster subsequent access. The script also includes error handling for missing or empty input files and provides a help menu for user guidance.

preheat.sh

More or less the same as the python script.

Review

To fetch a list of frequently accessed IIIF assets. (Untested)

cat access.log | grep "/iiif/2/" | awk '{print $7}' | sort | uniq -c | sort -n
@DonRichards
DonRichards / github_rate_limit.sh
Last active November 11, 2022 15:27
Github Rate Limited Checker / Delayer
#!/usr/bin/env bash
set -e
: '
author :DonRichards
date :20221020
usage :bash github_rate_limit.sh
Description:
This is an example of how to check Githubs rate limit and wait for it to reset.
This is really useful for those rare cases where you are running a script that