Skip to content

Instantly share code, notes, and snippets.

@sbreker
sbreker / powerstat-result-formatter.py
Last active September 7, 2023 21:02
Convert powerstat output to CSV
import argparse
import re
def process_file(input_file_path, output_file_path):
try:
# Open the input file for reading
with open(input_file_path, 'r') as input_file:
# Read all lines from the input file
lines = input_file.readlines()
@sbreker
sbreker / test_atom_with_docker_theme_testing.md
Last active August 14, 2023 18:18
Testing AtoM client repo themes locally using Docker

Testing AtoM 2.7.x BS2 themes locally using Docker & Docker Compose:

This procedure will create a folder called 'atom' into your current directory.

  1. Clone the client repo:

     git clone git@gitlab.artefactual.com:clients/site/atom.git
    
  2. cd into the atom folder:

@sbreker
sbreker / atom.conf
Created July 14, 2023 21:10
AtoM NGinx config
upstream atom {
server unix:/run/php7.4-fpm.atom.sock;
}
server {
listen 80;
root /usr/share/nginx/atom;
# http://wiki.nginx.org/HttpCoreModule#server_name
@sbreker
sbreker / entity_audit_report.php
Last active June 18, 2021 00:20
This script will output a quoted CSV containing all information objects in the AtoM db sorted by Identifier. Digital objects are excluded. Columns included: io.title, io.identifier, slug, io.id.
<?php
// VERSION: 0.5.0
//
// The intent of this script is to output a quoted CSV report
// containing all entities of a given type from an AtoM database.
//
// Information object export:
// - Columns included: io.title, io.identifier, slug, io.id.
// - report sorted by Identifier
// - Digital objects are excluded
@sbreker
sbreker / remove_digital_object_rights.php
Created November 14, 2020 01:02
This script will delete any rights records that are related to digital object records - Make backups of your DB before running.
<?php
// VERSION: 0.1.0
//
// This script will delete all digital object linked rights from AtoM.
//
// Command: php symfony tools:run <full_path_to_this_file>
$sql = 'select rights.id, object.class_name, slug.slug, ioslug.slug as ios from rights
inner join relation on relation.object_id = rights.id
inner join object on object.id = relation.subject_id
@sbreker
sbreker / gist:6ef33d2a37d8330f55f78edcb51de0e1
Last active March 5, 2020 04:14
Purple Haze software notes
Purple Haze software notes
==========================
Some next steps to get moving on for the software:
1) Integrate PID logic/drivebase logic so it is used when driving
2) Work on CLP classes. I've added some notes and pseudocode below - this is just some ideas I had as to
how to structure it. Do not feel compelled to stick with this if you think of a better way of organizing things!
@sbreker
sbreker / get_slug_from_id.php
Created July 8, 2019 17:18
A simple script to grab the slug from an AtoM object when all you have is an object ID value.
<?php
// VERSION: 0.1
//
// This script can be used to get an AtoM slug value from an object ID.
//
// Command: php symfony tools:run <full_path_to_this_file>
// Set this ID value to the value you want to look up then save the file
// and run as above command.
@sbreker
sbreker / delete_orphaned_descriptions.php
Last active July 10, 2019 15:28
Symptom: When performing a search:populate in AtoM, the final counts do not match once indexing has completed. This likely means that there are information_object records that do not have a valid parentId. This script will search for and delete these records. These records will be inaccessible from the user interface.
<?php
// VERSION: 0.1
//
// This script can be used to fix the CLI ES indexing task
// 'search:populate' count mismatch:
//
// [InformationObject] inserted (187.31s) (8999/9012)
// [InformationObject] inserted (187.32s) (9000/9012)
// [InformationObject] inserted (187.33s) (9001/9012)
// [InformationObject] inserted (187.34s) (9002/9012)
@sbreker
sbreker / fix_indexing_errors.php
Last active September 17, 2020 23:13
Script to try to correct information object table corruption where there are 'empty' information object records. These records are identified by missing any corresponding i18n records. These records may have other issue like missing slug, or status. These records can be safely deleted since there is no content to them anyways. After cleanup, sea…
<?php
// VERSION: 0.5
//
// This script can be used to fix the CLI ES indexing task
// 'search:populate' errors:
//
// The following errors have been encountered:
// Couldn't find information object (id: 27964)
// Couldn't find information object (id: 28029)
// Couldn't find information object (id: 28087)
@sbreker
sbreker / delete_non_event_linked_actors.php
Last active November 9, 2018 23:51
Delete Authority records not linked to an Information Object via the events table. This will preserve actors if they are a creator or other actor linked via the events table. This script will ALSO permanently delete authority records that may be linked to descriptions via the relations table as "Name access points".
<?php
// VERSION: 0.10
// Delete actors that are not users or repos and:
// - are not linked via the events table - e.g. not a creator
//
// This script can be used to DELETE authority records.
//
// It will output a list of slugs that the script
// will delete. This is great for testing! The slug can be
// appended to your base URL to look at the Actor in question. e.g.