Skip to content

Instantly share code, notes, and snippets.

@jalal246
jalal246 / change.bash
Created February 17, 2020 20:35
changing author info in git history
git filter-branch --env-filter '
OLD_EMAIL=""
CORRECT_NAME=""
CORRECT_EMAIL=""

Motivation

Which is best way to execute scope of code inside loop? Splitting it into functions. Calling nested functions as inner functions or calling function outside loop?

Conclusion

  • test without functions took: 158.88999996241182 ms
  • test with calling functions inside took: 170.85500003304332 ms
  • test with calling functions outside took: 165.08999996585771 ms
  • test with calling functions inside depending on global parm took: 310.6550000375137 ms
@jalal246
jalal246 / conclusion.md
Created October 11, 2019 15:56
JavaScript Performance Test: if/else VS switch

Motivation

Let's assume I have to check three different cases. Is it better to use if/else or switch?

Conclusion

  • switch took: 21.1999999883119 ms
  • if/else took: 14.66499999514781 ms
@jalal246
jalal246 / conclusion.md
Last active October 11, 2019 14:42
JavaScript Performance Test: conditional object VS regular if/else

Motivation

I've worked on function that requires a heavy usage of if/else statement. I came up with an idea. Object with keys return the result.

const condition = {
  up: x1 > x2 && y1 > y2,
  down: x1 < x2 && y1 < y2
};
@jalal246
jalal246 / common.bash
Last active January 27, 2020 15:13
Most Common Git Instructions
# Renaming Git Branch
git checkout <old_name> # Swhitch to the local branch you want to rename
git branch -m <new_name> # Rename it
git push origin --delete <old_name> # Delete the <old_name> remote branch
git push origin -u <new_name> # Push the <new_name>
# Pull from master into the development branch
git checkout dev # gets you on branch development
git fetch origin # gets you up to date with origin
git merge origin/master