Skip to content

Instantly share code, notes, and snippets.

View alanorth's full-sized avatar

Alan Orth alanorth

View GitHub Profile
@alanorth
alanorth / 2022-01-26-tac-batch1.md
Last active January 26, 2022 17:36
First batch of potential duplicates of TAC reports on CGSpace (1–200)

Found potential duplicate:

Found potential duplicate:

Found potential duplicate:

  • Title: Integral plan for research, training and technical assistance for protein food production in Central America and the Carribean
@alanorth
alanorth / convert-libaom.sh
Created October 22, 2021 06:50
Script to convert video to constant quality (CRF) mode AV1 attempting to match a target VMAF.
#!/usr/bin/env bash
#
# v2021-10-21
#
# I run it like this (using zsh syntax):
#
# $ for video (~/Pictures/2021/**/*.mp4(ND.)); do ~/Downloads/av1-tests/convert-av1.sh "$video"; done
#
# Reference:
# - https://ffmpeg.org/ffmpeg-codecs.html#libaom_002dav1
@alanorth
alanorth / pre-process-media.sh
Last active February 23, 2024 16:24
Script for preparing media files for long-term archival
#!/usr/bin/env bash
#
# pre-process-media.sh v2021-12-26
#
# Prepare a directory of images and videos for long-term archival by normalizing
# their names, optimizing JPEGs with jpeg-archive, and stripping embedded MP4s
# from Android Motion Photos.
#
# SPDX-License-Identifier: GPL-3.0-only
@alanorth
alanorth / parse_logs.diff
Last active September 28, 2021 06:16
Minor improvement to AbuseIPDB.com parse_logs.py script (remove duplicate IPs, mark regexes as raw strings, use f-strings for readability, and format with black).
14,18c14,23
< description=__doc__,
< formatter_class=argparse.RawDescriptionHelpFormatter)
< parser.add_argument('infile', help="Input file", type=argparse.FileType('r'))
< parser.add_argument('-o', '--outfile', help="Output file",
< default=sys.stdout, type=argparse.FileType('w'))
---
> description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
> )
> parser.add_argument("infile", help="Input file", type=argparse.FileType("r"))
@alanorth
alanorth / clean-snap-sync-external.sh
Last active January 3, 2023 14:24
Clean snapshots created by snap-sync
#!/usr/bin/env bash
#
# clean-snap-sync-external.sh v1.0.1 (2021-07-09)
#
# Changes
# -------
# 2021-07-09:
# - adjust logic to keep latest x, instead of delete oldest x
# - make output cleaner (hide btrfs subvolume delete output)
#
@alanorth
alanorth / purge_haplotigs.log
Created June 21, 2021 09:29
purge_haplotigs test log on HPC
[aorth@hpc: ~]$ module load purge_haplotigs/1.1.1
[aorth@hpc: ~]$ purge_haplotigs test
purge_haplotigs readhist -b aligned.bam -g contigs.fa
[21-06-2021 12:25:50] bedtools OK!
[21-06-2021 12:25:50] Rscript OK!
[21-06-2021 12:25:50] samtools OK!
[21-06-2021 12:25:50] ALL DEPENDENCIES OK
[21-06-2021 12:25:51] Beginning read-depth histogram generation
#!/usr/bin/env bash
#
# v2021-04-29
#
# I run it like this (using zsh syntax):
#
# $ for video (~/Pictures/2021/**/*.mp4(ND.)); do ~/Downloads/av1-tests/convert-av1.sh "$video"; done
#
# Reference:
# - https://ffmpeg.org/ffmpeg-codecs.html#libaom_002dav1
@alanorth
alanorth / doi-to-handle.py
Created January 5, 2021 14:17
DOI to Handle script so we can Tweet some Handles without Altmetric scores and have Altmetric notice them
#!/usr/bin/env python3
#
# doi-to-handle.py 0.0.1
#
# Copyright 2021 Alan Orth.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@alanorth
alanorth / dspace6-post-item-rest.md
Last active November 27, 2023 18:08
POSTing items to the DSpace 6 REST API

POSTing an item to /collections

First log in to get the JSESSIONID cookie and then post the item (I'm using httpie instead of curl):

$ http -f POST https://dspacetest.cgiar.org/rest/login email=aorth@mjanja.ch password=fuuuu
$ http https://dspacetest.cgiar.org/rest/status Cookie:JSESSIONID=EABAC9EFF942028AA52DFDA16DBCAFDE
$ http POST https://dspacetest.cgiar.org/rest/collections/f10ad667-2746-4705-8b16-4439abe61d22/items Cookie:JSESSIONID=EABAC9EFF942028AA52DFDA16DBCAFDE < item-object.json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
@alanorth
alanorth / request.json
Created September 25, 2020 10:08
DSpace Statistics API with POST to /items
{
"limit": 10,
"page": 0,
"dateFrom": "2020-01-01T00:00:00Z",
"dateTo": "2020-09-09T00:00:00Z",
"items": ["f44cf173-2344-4eb2-8f00-ee55df32c76f", "2324aa41-e9de-4a2b-bc36-16241464683e", "8542f9da-9ce1-4614-abf4-f2e3fdb4b305", "0fe573e7-042a-4240-a4d9-753b61233908", "b2c1bbfd-65b0-438c-9e49-d271c49b2696", "000dc7cd-9485-424b-8ecf-78002613cc87", "000e1616-3901-4431-80b1-c6bc67312d8c", "000e61ca-695d-43e5-9ab8-1f3fd7a67a32", "000ea897-5557-49c7-9f54-9fa192c0f83b", "000ec427-97e5-4766-85a5-e8dd62199ab5", "000f60f1-19d6-436a-b607-1573901fbfe4", "0010511b-a15f-496a-93b4-1885e6cf9ad8", "00115034-8e0f-4665-b589-e30ed01378ed", "001289a1-260c-466c-8def-5a786cf06ca7", "0012c0d0-6224-4f8a-84a6-0a4281bd8837", "0013519c-6753-4fe1-afff-22e0060140c7", "00135d25-b5f8-4bea-92ae-9bbecb2b441f", "0013f7e9-8def-45e0-aaf2-16cbc09d3d34", "0014d899-a29e-4472-84aa-e8b42ccaa687", "0015da03-c836-4e58-bfd7-d5bac17f8c3e", "0015e295-18a9-4bd2-ab44-99cf0a5cd4ee", "0016716f-e980-4aa7-b196-13bb9f69215a", "00193a18-dba5-43b