Skip to content

Instantly share code, notes, and snippets.

View ricealexander's full-sized avatar

Alex Rice ricealexander

View GitHub Profile
@ricealexander
ricealexander / emoji-list.md
Last active September 5, 2025 01:43 — forked from rxaviers/gist:7360908
Comprehensive list of GitHub-supported emojis
@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 / gallery-class.js
Created December 28, 2019 16:43
/exercises/58 - Gallery/gallery.js Refactor of Gallery to use Class syntax
@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 / 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 / array-quiz.md
Last active November 29, 2019 18:20
Arrays Quiz

(1.) Which of the following are valid arrays (Answer all that apply)

const A = ["Harder", "Better", "Faster", "Stronger"];
const B = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89];
const C = [
  "Urban Chestnut",
  2009,
  "4Hands",
 2011,
@ricealexander
ricealexander / regex-plan.md
Last active November 22, 2019 17:58
RegEx lesson plan

I'm going to go over a quick overview of Regular Expressions. I'll try to make the syntax fast, because using them is the fun stuff.

We'll be working with https://regex101.com

What Are RegEx?

RegEx stands for Regular Expression. A Regular Expression is a pattern-matching scheme. We use it to determine whether a string follows certain patterns. We'll often see these used to validate form input, and Single Page Applications may use them to compare the URL with patterns tell it what pages to serve.

@ricealexander
ricealexander / tidy-deep-clone.js
Created July 26, 2019 20:32
Creates a deepClone of an object without null, undefined, or empty indexes
// deepCopy from
// https://stackoverflow.com/questions/38416020/deep-copy-in-es6-using-the-spread-syntax#answer-53771927
function tidyCopy(obj) {
if(typeof obj !== 'object' || obj === null) {
return obj;
}
if(obj instanceof Date) {
@ricealexander
ricealexander / generate-1-to-100.js
Last active September 12, 2020 08:09
One liners that generate an array of values from 1 to 100
// As a thought experiment, what is he shortest bit of code that
// can generate an array of numbers from 1 to 100?
// Object.keys
/// when applied to a string, Object.keys returns an array of
/// 0 to the string's length - 1
Object.keys(' '.repeat(100)).map(v => Number(v) + 1)
Object.keys(' '.repeat(100)).map(v => +v + 1)
// Array.from
@ricealexander
ricealexander / click_disk.js
Last active March 11, 2019 19:52
Indicates where a user clicked with a circle that flashes out
// Stylesheet dependency builds custom stylesheets
function Stylesheet(id) {
this.sheet = id;
document.head.insertAdjacentHTML("beforeend", '<style id="'+ this.sheet +'"></style>');
this.add = function(rules) {
document.getElementById(this.sheet).insertAdjacentText("beforeend", rules);
}
};