Skip to content

Instantly share code, notes, and snippets.

View Mohammed-Nasif's full-sized avatar
:shipit:
Focusing

Mohammed Nasif Mohammed-Nasif

:shipit:
Focusing
View GitHub Profile
@me2resh
me2resh / replace_multiple_words.js
Last active May 30, 2022 13:39
Replace multiple substrings in a string using reducer
const originalString = "I would love to eat apple and banana."
const wordsMap = {
'apple' : "mango",
'banana' : "grapes",
}
const replaceStrings = (value) => {
return Object.keys(wordsMap).reduce((result, oldString) => result.replace(new RegExp(oldString, 'g'), wordsMap[oldString]), value)
}
@wojteklu
wojteklu / clean_code.md
Last active March 13, 2025 19:37
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules