Skip to content

Instantly share code, notes, and snippets.

View ricealexander's full-sized avatar

Alex Rice ricealexander

View GitHub Profile
@ricealexander
ricealexander / project_settings.json
Last active August 18, 2021 20:44
VSCode settings with rationale
// Project settings should contain only settings that have an impact on the codebase
// These settings may change how editor interacts with files. All settings that have to do
// with UI or opinionated editor behavior that doesn't affect code should go in user settings
// Editor Settings
// editor.insertSpaces, editor.tabSize: Prefer 2️⃣space indentation
// ESLint Settings
// editor.codeActionsOnSave Auto-correct ESLint code
@ricealexander
ricealexander / getFormData.js
Created December 11, 2019 01:00
Ways to get values of form elements
const form = document.querySelector('form')
// Our hypothetical form has the following elements:
// input[type="text"][name="fname"]
// input[type="text"][name="lname"]
// input[type="text"][name="zip"]
// input[type="email"][name="email"]
// Ways to Get Form Values:
@ricealexander
ricealexander / gallery-class.js
Created December 28, 2019 16:43
/exercises/58 - Gallery/gallery.js Refactor of Gallery to use Class syntax
@ricealexander
ricealexander / objectHasProperty.js
Created December 29, 2019 22:01
Ways to determine if an object has a property
const colors = {
seashell: '#FFF5EE',
cornsilk: '#FFF8DC',
lemonchiffon: '#FFFACD',
floralwhite: '#FFFAF0',
snow: '#FFFAFA',
lightyellow: '#FFFFE0',
ivory: '#FFFFF0',
}
const target = 'ivory'
@ricealexander
ricealexander / emoji-list.md
Last active January 14, 2026 19:21 — forked from rxaviers/gist:7360908
Comprehensive list of GitHub-supported emojis
@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' }),
@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 / 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 / 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 / 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; }
}