Last active
February 21, 2018 07:35
-
-
Save web2ls/9f5441140a91abb85060705acf79fbb2 to your computer and use it in GitHub Desktop.
Usefull notes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Save previously received compute result in function(for increase perfomance) | |
| function isPrime(value) { | |
| if (!isPrime.answers) { | |
| isPrime.answers = {}; | |
| } | |
| if (isPrime.asnwers[value] !== undefined) { | |
| return isPrime.answers[value]; | |
| } | |
| var prime = value !== 0 && value !== 1; | |
| for (var i = 2; i < value; i++) { | |
| if (value % i === 0) { | |
| prime = false; | |
| break; | |
| } | |
| } | |
| return isPrime.answers[value] = prime; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Store function in cache object only if it is unique function | |
| var store = { | |
| nextId: 1, | |
| cache: {}, | |
| add: function(fn) { | |
| if (!fn.id) { | |
| fn.id = nexId++; | |
| this.cache[fn.id] = fn; | |
| return true; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Set n-digits after comma for float number without rounding | |
| (f - 0.005).toFixed(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) Get all keys in object and works with them | |
| const keys = Objects.keys(myObject); | |
| keys.forEach(function(key) { | |
| console.log(`${key}: ${myObject[key}`) | |
| }); | |
| 2) Convert value to another notation | |
| const a = 'ff'; //value in hexidecimal | |
| const b = parseInt(a, 10); //convert it into decimal | |
| 3) Deploy dist folder from master branch to github pages | |
| -Remove dist folder from local .gitignore file | |
| -git add dist && git commit -m "Add dist subtree" | |
| -git subtree push --prefix dist origin gh-pages | |
| Also need check base tag in index.html file in dist folder. By default it has value = '/', but for correct work it must be equal '/repository_name/' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment