- DP for beginners by @wh0ami - https://leetcode.com/discuss/general-discussion/662866/dp-for-beginners-problems-patterns-sample-solutions || [LIST - https://leetcode.com/list/x1k8lxi5]
- Graph for beginners by @wh0ami - https://leetcode.com/discuss/general-discussion/655708/graph-for-beginners-problems-pattern-sample-solutions/562734 || [LIST - https://leetcode.com/list/x1wy4de7]
- Sliding window for beginners by @wh0ami - https://leetcode.com/discuss/general-discussion/657507/sliding-window-for-beginners-problems-template-sample-solutions/562721 || [LIST - https://leetcode.com/list/x1lbzfk3]
- DP Patterns by @aatalyk - https://leetcode.com/discuss/general-discussion/458695/dynamic-programming-patterns Leetcode patterns from edu_cative_dot_io by @late_riser - https://leetcode.com/discuss/general-discussion/457546/LeetCode-Problem-Patterns-from-***
- List of questions sorted by common patterns by @Maverick2594 - https://leetcode.com/discuss/career/448285/List-of-q
Don't force the reader of your code to scroll past the minutiae.
function makeBreakfast() {
const ingredients = fetchIngredients();
const friedBacon = fryBacon(ingredients.bacon);
const cookedScrambledEggs = whiskEggsAndFryThem(ingredients.eggs);
const preparedMeal = plateAndSeasonMeal(friedBacon, cookedScrambledEggs);
// create a bookmark and use this code as the URL, you can now toggle the css on/off | |
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3 | |
javascript: (function() { | |
var domStyle = document.createElement("style"); | |
domStyle.append( | |
'* { color:#0f0!important;outline:solid #f00 1px!important; background-color: rgba(255,0,0,.2) !important; }\ | |
* * { background-color: rgba(0,255,0,.2) !important; }\ | |
* * * { background-color: rgba(0,0,255,.2) !important; }\ | |
* * * * { background-color: rgba(255,0,255,.2) !important; }\ | |
* * * * * { background-color: rgba(0,255,255,.2) !important; }\ |
// create a bookmark and use this code as the URL, you can now toggle the css on/off | |
// thanks+credit: https://dev.to/gajus/my-favorite-css-hack-32g3 | |
javascript: (function() { | |
var styleEl = document.getElementById('css-layout-hack'); | |
if (styleEl) { | |
styleEl.remove(); | |
return; | |
} | |
styleEl = document.createElement('style'); | |
styleEl.id = 'css-layout-hack'; |
/* | |
* By designing the Customer as an Aggregate Root and including a reference all of the | |
* movies that it rented, we can place the validation logic for renting movies | |
* directly on the customer entity. | |
* | |
* Advantages: More declarative-reading code. The operation is a lot closer to the | |
* entity itself, which improves the discoverability and understanding what a customer | |
* can do. | |
* | |
* Disadvantages: Additional overhead. Having to pull the ids of rented movie everytime we |
If you use server rendering, keep in mind that neither useLayoutEffect
nor useEffect
can run until the JavaScript is downloaded.
You might see a warning if you try to useLayoutEffect
on the server. Here's two common ways to fix it.
If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect
instead.
function MyComponent() {
- You need to have the latest version of Node. Preferably, you're using 9.8.0, but the latest LTS should work as well.
- You should have
npx
installed usingnpm install -g npx
. - Install the React Developer Tools.
function inheritsObject(baseObject, superObject) { | |
Object.setPrototypeOf(baseObject, superObject); | |
} | |
function inheritsMultipleObjects(baseObject, superObjects) { | |
inheritsObject( | |
baseObject, | |
new Proxy({}, { | |
get(target, key, rec) { |
module.exports = { | |
root: true, // make to not take in any user specified rules in parent folders | |
parser: 'babel-eslint', | |
extends: ['airbnb', 'prettier', 'prettier/flowtype', 'prettier/react'], | |
env: { | |
browser: true, | |
node: true, | |
jest: true, | |
}, | |
plugins: ['flowtype'], |
Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".
Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).
Let's dig in: