Skip to content

Instantly share code, notes, and snippets.

View brianzelip's full-sized avatar

Brian Zelip brianzelip

View GitHub Profile
@brianzelip
brianzelip / .gitignore
Created February 26, 2020 20:33
WordPress git ignore
# Exclude these files from the git repo
wp-content/backup/*
wp-content/cache/*
wp-content/upgrade/*
wp-content/uploads/*
sitemap.*
wp-config.php
# Hidden system files
*.DS_Store
@brianzelip
brianzelip / rebuild-archivesspace.md
Created May 6, 2020 10:23
Rebuild ArchivesSpace back end

Rebuild ArchivesSpace back end

aka, Merged w/ upstream and have to nuke the temporary database

# 1. nuke
build/run db:nuke

# 2. rerun bootstrap
build/run bootstrap
@brianzelip
brianzelip / merge-upstream.md
Created May 6, 2020 10:26
Merge with upstream/master

Merge with upstream/master

aka, pull in the latest changes from Master into local

git checkout master

git fetch upstream

git merge upstream/master
@brianzelip
brianzelip / rebase-squash.md
Last active October 11, 2022 14:04
Squash many commits into one commit

Squash many commits into one commit

aka, clean up your commit history, but be careful!

# 1. find start of your changes, then copy the commit _prior_ to that
git log

# 2. init rebase
git rebase -i $PRIOR_COMMIT_ID
@brianzelip
brianzelip / cache-busting-CSS-components-in-WordPress.md
Last active August 11, 2020 20:13
Cache busting CSS components imported in a single CSS file in a WordPress project via PostCSS and Nodemon

This gist documents one method for cache busting CSS components imported in a single CSS file in a WordPress project via PostCSS and Nodemon.

  • project.css: shows the CSS componenents imported in a single file
  • package.json: shows the npm dependencies and build scripts
  • postcss.config.js: shows the postcss config
  • functions.php: shows the versioning of the theme's style.css based on the file's last modified date
@brianzelip
brianzelip / modern-favicon.md
Created December 25, 2020 12:35
Snippet on favicon approach as five icons and one json file

Modern favicon html and json

By Andrey Sitnik

<link rel="icon" href="/favicon.ico"><!-- 32×32 -->
<link rel="icon" href="/icon.svg" type="image/svg+xml" sizes="any">
<link rel="apple-touch-icon" href="/apple.png"><!-- 180×180 -->
<link rel="manifest" href="/manifest.webmanifest">
@brianzelip
brianzelip / Indigenous-remembrance.md
Last active January 29, 2021 18:42
Acknowledgement of indigenous people on a website

We acknowledge the Lenape people, the traditional custodians of the land where the studio operates. We pay respect to their Elders past and present and to all indigenous people of this continent.

Frank Chimero, https://studiofrank.co/colophon

@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')
@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 / 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);