Skip to content

Instantly share code, notes, and snippets.

View DoctorDerek's full-sized avatar
☀️
https://linkedin.com/in/derek-austin Read my blog https://DoctorDerek.medium.com

Dr. Derek Austin DoctorDerek

☀️
https://linkedin.com/in/derek-austin Read my blog https://DoctorDerek.medium.com
View GitHub Profile
@DoctorDerek
DoctorDerek / .gitignore
Created November 8, 2020 19:06
.gitignore file
# Markdown files managed by DatoCMS
src/pages/
# Secret API keys for Auth0 testing locally
.env.development
@DoctorDerek
DoctorDerek / gatsby-config.js
Created November 8, 2020 19:17
Modified Gatsby config file part 2
},
{
resolve: `gatsby-theme-auth0`,
options: {
domain: process.env.AUTH0_DOMAIN,
clientID: process.env.AUTH0_CLIENT_ID,
redirectUri: process.env.AUTH0_CALLBACK_URL,
// Optional fields:
// audience: process.env.AUTH0_AUDIENCE,
// responseType: process.env.AUTH0_RESPONSE_TYPE,
@DoctorDerek
DoctorDerek / gatsy-config.js
Created November 8, 2020 19:22
Modified Gatsby config file part 2
require("dotenv").config({
path: `.env.${process.env.NODE_ENV}`,
})
@DoctorDerek
DoctorDerek / Method 1 - Use Set to Find Unique Strings.js
Created November 11, 2020 21:22
Using Set to Filter an Array For Unique Strings in JavaScript ES6
const strings = ["👌", "👌", "👌", "🐱‍👤", "🐱‍👤", "🐱‍🚀", "🐱‍🚀"]
const stringsSet = new Set(strings)
const uniqueStrings = [...stringsSet]
console.log(uniqueStrings)
// Output: Array(3) [ "👌", "🐱‍👤", "🐱‍🚀" ]
// One-liner using the method Array.from():
console.log(Array.from(new Set(strings)))
// Output: Array(3) [ "👌", "🐱‍👤", "🐱‍🚀" ]
@DoctorDerek
DoctorDerek / Method 2 - Unique Strings with a for...of Loop + an Object.js
Created November 11, 2020 21:26
Finding Unique Strings using a JavaScript Object
const myStrings = ["👌", "👌", "👌", "🐱‍👤", "🐱‍👤", "🐱‍🚀", "🐱‍🚀"]
const myUniqueStrings = []
const myStringObject = {} // Used to check for uniqueness
for (const string of myStrings) {
// Object keys that aren't yet set are undefined,
// and undefined is a falsy value in JavaScript.
if (!myStringObject[string]) {
myUniqueStrings.push(string)
myStringObject[string] = true
@DoctorDerek
DoctorDerek / Method 3 - Unique Strings with ES5.js
Created November 11, 2020 21:27
ES5 Internet Explorer 9 version of Finding Unique Strings in JavaScript
var stringsES5 = ["👌", "👌", "👌", "🐱‍👤", "🐱‍👤", "🐱‍🚀", "🐱‍🚀"]
var uniqueStringsES5 = []
var stringObjectES5 = {}
// Since JavaScript objects must have unique properties
// (keys), you can find unique strings using an object.
for (var i = 0; i < stringsES5.length; i++) {
var string = stringsES5[i]
// Object keys that haven't been set are undefined,
// which is one of JavaScript's falsy values.
@DoctorDerek
DoctorDerek / recommended-settings.json
Last active March 31, 2024 07:31
Recommended settings.json file for new web developers setting up VS Code according to https://medium.com/p/65aaa5788c0d/ by Dr. Derek Austin 🥳
"files.autoSave": "onFocusChange",
"editor.tabSize": 2,
"prettier.requireConfig": false,
"prettier.semi": false,
"editor.codeActionsOnSave": { "source.fixAll": true },
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"html.format.enable": false,
"eslint.alwaysShowStatus": true,
"htmlhint.enable": true,
"editor.fontLigatures": true,
"editor.fontFamily": "Fira Code SemiBold, Consolas, 'Courier New', monospace",
"editor.fontSize": 20,