Skip to content

Instantly share code, notes, and snippets.

View megantaylor's full-sized avatar

Megan Taylor megantaylor

View GitHub Profile
@geddski
geddski / Brewfile
Last active November 13, 2022 13:28
Dave Geddes' Brewfile for awesome mac automation
cask_args appdir: "/Applications"
tap "homebrew/bundle"
tap "homebrew/cask"
tap "homebrew/cask-drivers"
tap "homebrew/cask-fonts"
tap "homebrew/core"
brew "fish"
brew "git"
brew "httpie"
brew "github/gh/gh"
@mikowl
mikowl / oneliners.js
Last active March 28, 2024 20:52
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@tracker1
tracker1 / MyComponent.jsx
Last active July 8, 2019 12:48
Simple pattern for loading async data with react, redux and redux-thunk middleware
import React, { Component } from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as Actions from './action';
const mapStateToProps = ({ loaded, loading, error, data }) = ({ loaded, loading, error, data });
const mapDispatchToProps = dispatch => ({ action: bindActionCreators(Actions, dispatch) });
export class MyComponent extends Component {
load = _ => this.props.action.load(this.props.id);
@gaearon
gaearon / modern_js.md
Last active April 18, 2024 15:01
Modern JavaScript in React Documentation

If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:

  • We define variables with let and const statements. For the purposes of the React documentation, you can consider them equivalent to var.
  • We use the class keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav
@alexeychikk
alexeychikk / actions.js
Created December 27, 2017 11:27
Cancellation middleware for redux-axios-middleware
import {
CANCEL_ACTION_REQUESTS,
CANCEL_ALL_ACTION_REQUESTS
} from './constants';
export function cancelActionRequest(actionType) {
return { type: CANCEL_ACTION_REQUESTS, actionType };
}
export function cancelAllActionRequests() {

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@milmazz
milmazz / imposter-handbook-links.md
Last active April 1, 2024 10:31
Useful links found in The Imposter's Handbook by Rob Conery
@jesstelford
jesstelford / event-loop.md
Last active April 3, 2024 13:57
What is the JS Event Loop and Call Stack?

Regular Event Loop

This shows the execution order given JavaScript's Call Stack, Event Loop, and any asynchronous APIs provided in the JS execution environment (in this example; Web APIs in a Browser environment)


Given the code

@ericelliott
ericelliott / class-constructor-factory-examples.js
Last active August 28, 2023 18:18
Class, Constructor, Factory
// class
class ClassCar {
drive () {
console.log('Vroom!');
}
}
const car1 = new ClassCar();
car1.drive();
@paulirish
paulirish / what-forces-layout.md
Last active April 26, 2024 17:33
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.

Generally, all APIs that synchronously provide layout metrics will trigger forced reflow / layout. Read on for additional cases and details.

Element APIs

Getting box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent