Skip to content

Instantly share code, notes, and snippets.

View stevekinney's full-sized avatar

Steve Kinney stevekinney

View GitHub Profile
const logEnhancer = (createStore) => (reducer, initialState, enhancer) => {
// Do stuff like wrap the reducer in a higher-order function.
const reducerWithConsoleLogs = (previousState, action) => {
const nextState = reducer(previousState, action);
console.log({ action, previousState, nextState });
return nextState;
};
return createStore(reducerWithConsoleLogs, initialState, enhancer);
};
@stevekinney
stevekinney / README.md
Last active April 11, 2021 17:23
The frequency and wavelengths of musical notes.

An engineering manager that I have the privilege of working with just asked me for three expectations of a principal engineer for a project that he is working on to mentor senior engineers at Twilio. Here is the list that I came up with.

  • Skate to where the puck is going: Are you waiting to be told what to do or are you getting a sense for our product vision and making concrete suggestions for what technical work needs to be done to get us in a good place when it becomes time to execute?
  • Act like an owner: Are you complaining about what's broken or offering solutions and/or alternative ways of thinking that makes it clear to engineers close to the problem that they can play an important role in solving those problems? Do you accept the world as it is or are you willing to provide a compelling vision for how it could be?
  • Teach and lead: You're not getting more hours in the day. Taking on all of the hard work not only makes you a single point of failure, it robs your colleagues of the ability
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Array Prototype Methods

I understand that functions in JavaScript can take any number of arguments.

I can describe the similarity between blocks in Ruby and anonymous functions in JavaScript.

Where are the methods available to all arrays (e.g. forEach, map, etc.) defined?

I can explain the difference between using a for loop and the forEach method.

Step One: Watch Mary Rose Cook Live Codes Space Invaders from Front-Trends. (The second worst conference name ever?)

Step Two: Fork this gist.

Step Three: Respond to this question in your fork: What is one approach you can take from this Mary's code and implement in your project?

Step Four: Totally Optional: take a look at some of the other forks and comment if the spirit moves you.

@stevekinney
stevekinney / method_missing.js
Last active February 27, 2020 08:11
Ruby's `method_missing` implemented in JavaScript using ES6 proxies.
// This will only work in environments that support ES6 Proxies.
// As of right now, that's pretty much only Firefox.
function Refrigerator(foods) {
this.foods = foods;
return new Proxy(this, {
get: function (receiver, name) {
if (name in receiver) {
/* HSL */
$teal: hsla(180%, 78%, 62%, 1);
$black: hsla(96%, 20%, 5%, 1);
$pink: hsla(339%, 100%, 56%, 1);
$yellow: hsla(61%, 100%, 54%, 1);
$white: hsla(0%, 0%, 100%, 1);
/* RGB */
$teal: rgba(81, 234, 234, 1);
$black: rgba(12, 15, 10, 1);