Skip to content

Instantly share code, notes, and snippets.

View anthonybrown's full-sized avatar
🎯
Focusing

Tony Brown anthonybrown

🎯
Focusing
View GitHub Profile
@anthonybrown
anthonybrown / remove-node-modules.md
Created May 16, 2022 20:34 — forked from lmcneel/remove-node-modules.md
How to remove node_modules after they have been added to a repo

How to remove node_modules

Create a .gitignore file

  1. Check for an existing .gitignore file in the project directory
ls -a
@anthonybrown
anthonybrown / index.md
Created February 16, 2021 19:29 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom
@anthonybrown
anthonybrown / Enhance.js
Created October 16, 2020 10:28 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@anthonybrown
anthonybrown / twittermute.txt
Created January 24, 2020 16:04 — forked from IanColdwater/twittermute.txt
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@anthonybrown
anthonybrown / getFirstLast.js
Created September 14, 2019 15:16
Object destructuring
function getFirstLast(array) {
const {
0: first,
length: len,
[len - 1]: last
} = array
return {first, last}
}
@anthonybrown
anthonybrown / App.js
Created September 3, 2019 09:09
React Cheat Sheet: --> Context, Refs, Memo, Lazy, Suspense
// createContext
const WeatherContext = React.createContext({ day: 3 })
const App = ({ children }) => {
const [weather, setWeather] = React.useState(null)
const [error, setError] = React.useState(null)
React.useEffect(() => {
api.getWeather(...)
.then(setWeather)
.catch(setError)
}, [])
@anthonybrown
anthonybrown / bigArr.js
Created September 2, 2019 11:12
Shorter code isn't always better code.
const bigArr = new Array(1000000).fill(1).map((_, i) => i);
bigArr[100] = 5;
const allUnique = arr => {
const all = new Set();
for (let el of arr) {
if (all.has(el)) {
return false;
}
@anthonybrown
anthonybrown / learn-curry.js
Last active August 30, 2019 13:11
example of using curried functions
/** Store Data */
const prices = {
game: 59.95,
nintendo: 399.99,
controller: 49.99,
xbox: 299.99,
ps1: 349.99
}
const basket = [
@anthonybrown
anthonybrown / curried.js
Last active August 30, 2019 09:59
A simple example of currying in functional JavaScript
function greetCurried(greeting) {
return function(name) {
if (typeof(greeting) !== 'string') {
return ('Greetings!')
} else if (typeof(name) !== 'string') {
return (greeting)
}
return (`${greeting}, ${name}`)
}