In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
-
check for updates in mac OS
defaults write com.apple.dock autohide-delay -float 0; defaults write com.apple.dock autohide-time-modifier -int 0;killall Dock
- show hide folders & files
defaults write com.apple.finder AppleShowAllFiles -bool YES && killall Finder
# copy from line 3 to 12 and paste in terminal | |
sudo mkdir -p /Users/$USER/mongo/db; # to ask for a password at the beginning | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; # install homebrew | |
brew install wget; wget https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.2.1.tgz; | |
tar -zxvf mongodb-macos-x86_64-4.2.1.tgz; | |
cd mongodb-macos-x86_64-4.2.1; | |
sudo cp ./bin/* /usr/local/bin/; sudo ln -s ./bin/* /usr/local/bin/; | |
cd ..; rm -rf mongodb-macos-x86_64-4.2.1 mongodb-macos-x86_64-4.2.1.tgz; |
import React from 'react' | |
import { ClassNames, CSSObject } from '@emotion/react' | |
import { Column, useTable } from 'react-table' | |
import TextByScale from './TextByScale' | |
interface Props { | |
columns: Array<Column> | |
data: Array<any> | |
} |
// Similar to JSON.stringify but limited to a specified depth (default 1) | |
// The approach is to prune the object first, then just call JSON.stringify to do the formatting | |
const prune = (obj, depth = 1) => { | |
if (Array.isArray(obj) && obj.length > 0) { | |
return (depth === 0) ? ['???'] : obj.map(e => prune(e, depth - 1)) | |
} else if (obj && typeof obj === 'object' && Object.keys(obj).length > 0) { | |
return (depth === 0) ? {'???':''} : Object.keys(obj).reduce((acc, key) => ({ ...acc, [key]: prune(obj[key], depth - 1)}), {}) | |
} else { | |
return obj |
To add a simulator | |
Choose Hardware > Device > Manage Devices. | |
Xcode opens the Devices window. | |
At the bottom of the left column, click the Add button (+). | |
In the dialog that appears, enter a name in the Simulator Name text field and choose the device from the Device Type pop-up menu. | |
//by default |
Revert the full commit
Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.
git revert {commit_id}
About History Rewriting
Delete the last commit
Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:
/* http://meyerweb.com/eric/tools/css/reset/ | |
v2.0-modified | 20110126 | |
License: none (public domain) | |
*/ | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, |
Folder Structure
Please note
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.