Skip to content

Instantly share code, notes, and snippets.

View ricealexander's full-sized avatar

Alex Rice ricealexander

View GitHub Profile
@ricealexander
ricealexander / transcript-extractor.js
Created March 25, 2021 19:02
Rigging a Shared Module for Transcripts
// Transcripts
// One possible way to associate transcripts with Grove posts may involve Shared Modules
// 1. Insert a Module at the bottom of the news post.
// 2. Select Shared Module and create a new Shared Module.
// 3. Select RichText Module and give it a subhead at the top titled "Transcript".
// 4. Copy/Paste the transcript from Google Docs into the RichText body.
// 5. Publish!
//
// This provides some benefits for us over other strategies:
// * Text is the most accessible format for our audience.
@ricealexander
ricealexander / grove-embeddable-audio-player.html
Created February 5, 2021 18:26
A demo, built for Grove, that creates an audio player that can be embedded on websites
<!doctype html>
<html>
<head>
<title>Audio Player</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/aplayer/1.10.1/APlayer.min.js"></script>
</head>
<body>
<!--
This demo is built on top of APlayer
@ricealexander
ricealexander / talk-toast-taste-ticket-table.html
Last active January 25, 2021 21:00
Talk Toast Taste Ticket Table for Allegiance (TTTTT)
<table id="talk-toast-tickets-table" border="1">
<style>
#talk-toast-tickets-table {
background-color: white;
border: 1px solid #d5dce1;
margin: 1rem 0;
}
#talk-toast-tickets-table th {
background-color: #e1e6ea;
@ricealexander
ricealexander / un-allcaps-ifier.js
Created December 24, 2020 21:55
When you receive a list of sponsors in ALL CAPS
const sponsors = [
'BARNES JEWISH HOSPITAL',
'BARNES JEWISH WEST COUNTY HOSPITAL',
'BELLEVILLE NEWS DEMOCRAT',
'BESPOKE APPAREL',
'BETTER BUSINESS BUREAU',
'BIG BOW EVENTS',
'BIG O LIQUEUR',
]
@ricealexander
ricealexander / grove.css
Last active December 9, 2020 00:46
Grove doesn't support links in image captions. This workaround converts Markdown-style links into HTML links
.Figure-content .Link {
color: var(--linkColor);
}
.Figure-content .Link:hover {
color: var(--linkHoverColor);
}
@ricealexander
ricealexander / transcript-instructions-template.html
Last active December 4, 2020 21:52
A template for Transcript Instructions for STLPR Podcasts
<div class="box">
<h3>Request a Transcript</h3>
<p>
Transcripts for St. Louis Public Radio produced programming are available upon request.
<br><br>
To request a transcript for <em>{PROGRAM NAME}</em>,
let us know the episode date and contact {CONTACT NAME}
at <a href="mailto:{CONTACT EMAIL}">{CONTACT EMAIL}</a>.
</p>
@ricealexander
ricealexander / getFacebookStats.js
Created December 2, 2020 22:29
Given Facebook Insights Reactions/Comments/Shares State, return an object with their sums
// This function simplifies totalling up Reactions, Comments, and Shares in Facebook Insights
// To get the Reactions/Comments/Shares state, you must have the React Developer Tools Extension
// 1. Navigate to Page Insights > Reach
// 2. Set the date range at the top right of the view to the target range
// 3. Inspect the "Reactions, Comments, Shares and More" chart
// 4. In the React Components tool, navigate to c [from HubbleAreaLineChart] within HubbleChart
// 5. In the props, right click on "lines" and "Copy value to clipboard"
// The state of Reactions/Comments/Shares is now a nested array within your clipboard
@ricealexander
ricealexander / getItem.js
Last active December 2, 2020 00:02
Gets an item from an array by its index. For indexes outside of the array, it loops the index.
function getItem (array, index) {
if (typeof index !== 'number' || Number.isNaN(index)) {
throw new TypeError(`Expected index to be a Number. Instead got "${index}"`)
}
if (Math.abs(index) === Infinity) {
throw new ReferenceError(`Cannot access item at index "${index}"`)
}
const {length} = array
let wrappedIndex = index
@ricealexander
ricealexander / semicolon-indentation.js
Last active November 27, 2020 22:12
Indent 30 lines of code with four semicolons instead of tabs or spaces
{
;;;;// Helper Functions
;;;;async function asyncMap (array, callback) {
;;;;;;;;const results = []
;;;;;;;;for (const item of array) {
;;;;;;;;;;;;results.push(await callback(item))
;;;;;;;;}
;;;;;;;;return results
;;;;}
;
@ricealexander
ricealexander / grove-reddit-sharing.js
Created November 23, 2020 10:19
Grove Posts share on Facebook, Twitter, LinkedIn, Email. Here's some logic for a Reddit Share link
function redditShareLink () {
const { storyTitle } = window.Glade.getMetadata()
const title = storyTitle ?? document.title
const url = document.location.href
return `https://www.reddit.com/submit?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}`
}