Skip to content

Instantly share code, notes, and snippets.

View ricealexander's full-sized avatar

Alex Rice ricealexander

View GitHub Profile
@ricealexander
ricealexander / recursiveMap.js
Created October 10, 2020 19:32
Deconstructing a recursive map from Reddit user tarley_apologizer, with an alternative
function map (array, mapFunction) {
if (array.length === 0) return []
return [
mapFunction(array[0]),
...map(array.slice(1), mapFunction)
]
}
map([1, 2, 3], x => x * 2) // [2, 4, 6]
@ricealexander
ricealexander / streamguys-platform-totals.js
Last active May 9, 2022 14:39
A fix for StreamGuys platforms reports, fixing the broken downloads total field
// StreamGuys Platforms Report Fix
// In the StreamGuys platform, all "Total" fields on tables are empty.
// This script can be run in the console and populates the "Total" field
// for all tables on the current page.
// Tables have an id following pattern /re\d+:table/
const tables = document.querySelectorAll('table[id^="re"][id$=":table"]')
for (const table of tables) {
const downloadsCells = table.querySelectorAll('tr:not(.standard-re-row-total) td.txt + td')
@ricealexander
ricealexander / .htmlhintrc
Created September 11, 2020 16:24
HTMLHint Configuration
{
// Enabled Rules
"doctype-first": true, // require doctype declaration at the very top of the HTML document
"doctype-html5": true, // require doctype to be HTML5’s <!DOCTYPE html>
"style-disabled": true, // prefer definining styles in external stylesheets
"title-require": true, // require <title> element in the <head>
"attr-lowercase": true, // disallow capital letters in attribute names
"attr-no-duplication": true, // disallow duplicate attributes on an element
"attr-no-unnecessary-whitespace": true, // disallow whitespace around attribute assignment operator =
@ricealexander
ricealexander / multilineStrings.js
Last active September 11, 2020 16:20
Comparison of Multiline-String Techniques in JavaScript
const modalTemplateLiteral = speaker => {
const { name, title, photo, altText, bio } = speaker
return `
<div class="speaker_modal_container">
<div class="speaker_modal">
<span class="sm_close" onclick="destroyModal()"><i class="fas fa-times"></i></span>
<h3 class="sm_speaker">
<span class="sm_name">${name}</span>
<span class="sm_title">${title}</span>
</h3>
@ricealexander
ricealexander / 2020 DNS Records.txt
Last active March 21, 2022 15:24
DNS records affiliated with STLPR's cPanel Account
Name TTL Class Type Record
--------------------------------------- ------- ----- ------- ----------------------------
kwmu.org. 14400 IN A 192.250.238.14
kwmu.org. 14400 IN TXT google-site-verification=eTVEmqxK4w9WDzPwz6hLF9ewHpRyD6DqxQQUiPP_-wU
kwmu.org. 14400 IN TXT v=spf1 +a +mx +ip4:192.250.238.14 ?all
kwmu.org. 14400 IN MX Priority: 0 Destination: mail.kwmu.org
cpanel.kwmu.org. 14400 IN A 192.250.238.14
cpcalendars.kwmu.org. 14400 IN A 192.250.238.14
cpcontacts.kwmu.org. 14400 IN A 192.250.238.14
@ricealexander
ricealexander / when-internet-explorer.scss
Created April 15, 2020 21:28
IE-11 Specific Media Query Mixin for SCSS
@mixin when-internet-explorer {
@media (-ms-high-contrast: active), (-ms-high-contrast: none) { @content; }
}
@ricealexander
ricealexander / long-selector.css
Created April 15, 2020 21:26
Longest CSS Selector I've written. Adds focus effects to custom radio buttons.
#theme #ctl00_AllegMain_MODETABLE td:focus-within input[type="radio"] + label::before,
#theme #ctl00_AllegMain_UPGRADETABLE td:focus-within input:not([value="ALLEGOTHER"]) + label,
#theme #ctl00_AllegMain_UPGRADETABLE td:focus-within input[value="ALLEGOTHER"] + label::before {
border-color: #222;
}
@ricealexander
ricealexander / stlpr-analytics-bundle.js
Last active February 14, 2020 20:07
Bundle Analytics
(function(){
var scriptOrder = 0
function loadScript (src) {
// create script
var script = document.createElement("script")
script.async = true
script.src = src
// insert script into the top of the document
@ricealexander
ricealexander / real_javascript_names.js
Last active January 2, 2021 00:29
A collection of prototype methods that have a different name than their original proposal
// Array.prototype.contains: https://esdiscuss.org/topic/having-a-non-enumerable-array-prototype-contains-may-not-be-web-compatible
// Array.prototype.flatten: https://developers.google.com/web/updates/2018/03/smooshgate
// String.prototype.contains: https://bugzilla.mozilla.org/show_bug.cgi?id=1102219
// globalThis: https://github.com/tc39/proposal-global/blob/master/NAMING.md
Array.prototype.all = Array.prototype.every
Array.prototype.any = Array.prototype.some
Array.prototype.contains = Array.prototype.includes
Array.prototype.flatten = Array.prototype.flat
@ricealexander
ricealexander / getCommitsByWeekday.js
Created January 19, 2020 01:35
Run on a Github profile to get commit counts by day of week
function getCommits () {
const days = Array.from(document.querySelectorAll('rect.day'))
return days
.map(({dataset}) => {
const date = new Date(`${dataset.date} 00:00:00`)
return {
count: dataset.count,
weekday: date.toLocaleDateString('en-US', { weekday: 'long' }),