Skip to content

Instantly share code, notes, and snippets.

View brianzelip's full-sized avatar

Brian Zelip brianzelip

View GitHub Profile
@brianzelip
brianzelip / archivesspace_pui_pdf_to_html.md
Created October 31, 2023 16:24
Output the HTML from ArchivesSpace PUI pdf generation

Output the HTML from ArchivesSpace PUI pdf generation

The following snippet was provided by @avatar382 during review of archivesspace/archivesspace#3021.

It helps debug record pdfs generated by the PUI by writing the HTML that goes into the pdf generation to a local file for review after the fact. Yet it was also noted that the pdf generation process is a bit of a mystery box, and so the HTML is just an approximation.

The following snippet was inserted at https://github.com/archivesspace/archivesspace/blob/ba792de563684bc57792372cf3a68e4f53b67bd3/public/app/models/finding_aid_pdf.rb#L90.

STDERR.puts "++++++++++++++++++++++++++++++"
@brianzelip
brianzelip / cherry-pick-remote-commit.md
Last active September 24, 2023 11:22
Cherry pick a commit from a remote repository

Cherry pick a commit from a remote repository

# list remotes
git remote -v

# add remote if needed
git remote add xyz git@github.com:xyz/project.git

# fetch remote data
@brianzelip
brianzelip / co-authored commit.md
Created February 21, 2023 15:50
multi-line co-authored commit message

Co-authored commit

> git commit -m "Refactor interface

- Add translations
- Add npm scripts

Co-authored-by: XXX <xxx@example.com>"
@brianzelip
brianzelip / archivesspace-session.sh
Last active February 8, 2023 15:53
Get ArchivesSpace Session ID
curl -s -F password="admin" "$ASPACE_BACKEND_URL/users/admin/login" | jq -r '.session'
@brianzelip
brianzelip / Checkout a branch on a fork.md
Created November 7, 2022 10:44
Review or extend a feature branch on a fork

Review or extend a feature branch on a fork

Review a feature branch on someone's fork of upstream, not upstream itself

git remote add user git@github.com:theirusername/reponame.git
git checkout theirusername/theirbranch

Make changes to a feature branch on someone's fork of upstream, not upstream itself

@brianzelip
brianzelip / nnlm2021 directory structure
Created April 20, 2022 15:15
nnlm2021 theme file structure
.
├── LICENSE
├── README.md
├── composer.json
├── composer.lock
├── composer.patch
├── config
│   └── sync
│   ├── ...
├── content
@brianzelip
brianzelip / bodleian_print.css
Created March 23, 2022 10:23
Bodleian's ArchivesSpace print stylesheet for public app
/**
* All content below this comment block from https://archives.bodleian.ox.ac.uk/assets/style/bodleian_print.css
*/
/* The following stops search facets, the footer, sidebars, buttons, etc from being printed */
#content div:not(.has-resizable-content):not(#tabs)>.col-sm-3 {
display:none ! important;
}
@brianzelip
brianzelip / fastify-mongoose-plugin.js
Created January 19, 2022 18:28
Use Mongoose.js as Fastify plugin
const dotenv = require('dotenv').config();
const mongoose = require('mongoose');
const fp = require('fastify-plugin');
async function mongooseConnect(fastify, options, done) {
try {
await mongoose.connect(process.env.DB_URI);
console.log('DB connected!');
} catch (err) {
console.log(err);
@brianzelip
brianzelip / modulo-for-slide-show-loop.js
Created February 4, 2021 11:52
Use the modulo operator for a looping slide show
// When making a looping slide show, here's the long way to get at what the modulo operator provides
if (counter < images.length - 1) {
counter++;
} else {
counter = 0;
}
const prevIndex = counter < 1 ? images.length - 1 : counter - 1;
const currIndex = counter;
@brianzelip
brianzelip / custom-js-array-indexOf.js
Created February 4, 2021 11:30
Roll your own Array.prototype.indexOf()
// The long way to Array.prototype.indexOf(), written while making an image slide show
const images = [...document.querySelectorAll('[data-js="carousel-img"]')];
const activeEl = images.filter((img) => img.classList.contains('active'))[0];
const activeElIndex = images.reduce((acc, img, i) => {
return acc != undefined
? acc
: img.classList.contains('active')