Skip to content

Instantly share code, notes, and snippets.

View joshua-koehler's full-sized avatar

Joshua Koehler joshua-koehler

View GitHub Profile
@joshua-koehler
joshua-koehler / mdcopy.sh
Last active September 14, 2024 15:45
Copy Markdown from stdin to clipboard in RTF format - OSX
alias mdcopy="pandoc --from markdown --to html | textutil -convert rtf -stdin -stdout -format html | sed -e \"s/..e2..80..99/'/g\" | pbcopy -Prefer rtf"
@joshua-koehler
joshua-koehler / closed-on-sabbath.js
Created August 16, 2024 02:45
If the user's time is Sabbath, or it's Sabbath in us-east, then replace the DOM content with a closed page and stop loading other resources. Use this script just underneath the opening html tag so it evaluates first.
const style=`.container {
display: flex;
justify-content: center; /* horizontal centering */
align-items: center; /* vertical centering */
height: 2em; /* define a height for demonstration purposes */
}`
const sabbath_closed_html=`
<html>
<style>${style}</style>
@joshua-koehler
joshua-koehler / website-closed-on-sabbath.js
Created July 25, 2023 02:37
Close website on Christian Sabbath on the client side
<script>
function replacelinks() {
document.querySelectorAll('a').forEach(el => el.href = "/resources-links/website-closed-for-the-sabbath");
}
function close() {
const closedOnSabbathUrl = "https://gisbornefpchurch.org.nz/resources-links/website-closed-for-the-sabbath";
const d = new Date();
// is Sabbath in local time or in NZ
const isSabbath = d.getDay() === 0 || (d.getUTCDay() === 6 && d.getUTCHours() >= 12) || (d.getUTCDay() === 0 && d.getUTCHours() < 12)
if(window.location.href != closedOnSabbathUrl && isSabbath){