Skip to content

Instantly share code, notes, and snippets.

View sethdavis512's full-sized avatar
🤖

Seth Davis sethdavis512

🤖
View GitHub Profile
# VARIABLES ==========
defaultCommitMessage="Add all changed files."
# FUNCTIONS ==========
gitAddAllAndCommit() {
git add . && git commit -m "${1:-defaultCommitMessage}"
}
@sethdavis512
sethdavis512 / filterWithParams.js
Last active August 4, 2022 06:29
Filter array based on object key value pairs.
const valuesMatch = (sourceObj, matchObj) => {
let matches = true;
Object.keys(matchObj).forEach(matchKey => {
if (sourceObj[matchKey] !== matchObj[matchKey]) {
matches = false;
}
});
return matches;
};
@sethdavis512
sethdavis512 / easy-temperature-conversion.js
Created January 17, 2019 16:25
Fahrenheit to Celsius
const celsius = [-15, -5, 0, 10, 16, 20, 24, 32];
const fahrenheit = celsius.map(t => t * 1.8 + 32);
const groupBy = (array, groupKey) => {
return array.reduce((acc, cur) => {
if (acc[cur[groupKey]]) {
acc[cur[groupKey]].push(cur);
} else {
acc[cur[groupKey]] = [cur];
}
return acc;
}, {});
};
@sethdavis512
sethdavis512 / interview-questions-web-developer.txt
Last active December 20, 2018 17:29
Interview questions to ask a web developer.
Have you worked in an agile or scrum environment? Tell us about your experience.
Have you lead teams before and if so what is your approach to leadership?
What do you expect from a team that you are apart of?
Any experience pair programming?
What is your biggest strength you can contribute to a team?
What is a recent technical challenge you experienced and how did you solve it?
How are you keeping up with the latest developments in web development?
Design vs. Implementation what is your process?
const keyBy = (arr, objKey) => arr.reduce(
(acc, cur) => (
{ ...acc, [cur[objKey]]: cur }
), {});
function toDollar(n) {
const numWithCommas = n.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return `$${numWithCommas}`;
}
export const composePromise = (...fns) => initialValue =>
fns.reduceRight((res, fn) => Promise.resolve(res).then(fn), initialValue);
// Individual Promises
const saveAppFee = () => saveFees(a, b, c);
const saveLnpFee = () => saveFees(x, y, z);
// Composed Promises
const saveAppAndLnp = composePromise(saveAppFee, saveLnpFee);
const saveApp = composePromise(saveAppFee);
// Arrow
const buildMockArray = <T>(num: number, content: T): T[] => Array(num).fill(null).map(() => content);
// Traditional
function buildMockArray<T>(num: number, content: T): T[] {
return Array(num).fill(null).map(() => content);
}
{
"Stateless Functional Component": {
"prefix": "stateless",
"body": [
"import React from 'react';",
"import PropTypes from 'prop-types';",
"",
"const ${TM_FILENAME_BASE/(.*)\\..+$/$1/} = () => {",
" return <div className=\"\"></div>;",
"}",