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
| How to push an image to Docker Hub? | |
| //get the images: | |
| docker images | |
| REPOSITORY TAG IMAGE ID CREATED SIZE | |
| verse_gapminder_gsl latest 023ab91c6291 3 minutes ago 1.975 GB | |
| verse_gapminder latest bb38976d03cf 13 minutes ago 1.955 GB | |
| rocker/verse latest 0168d115f220 3 days ago 1.954 GB | |
| //give a tag name: |
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
| Create your cert | |
| openssl req -nodes -new -x509 -keyout server.key -out server.cert | |
| // https-json-server.js | |
| import jsonServer from 'json-server'; | |
| import https from 'https'; | |
| import path from 'path'; | |
| import fs from 'fs'; | |
| const server = jsonServer.create(); |
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
| shutdown /r /fw /f /t 0 |
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
| You can use findIndex to find the index in the array of the object and replace it as required: | |
| var item = {...} | |
| var items = [{id:2}, {id:2}, {id:2}]; | |
| var foundIndex = items.findIndex(x => x.id == item.id); | |
| items[foundIndex] = item; | |
| This assumes unique IDs. If your IDs are duplicated (as in your example), it's probably better if you use forEach: | |
| items.forEach((element, index) => { |
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
| Array.includes compares by object identity just like obj === obj2, so sadly this doesn't work unless the two items are references to the same object. | |
| You can often use Array.prototype.some() instead which takes a function: | |
| const arr = [{a: 'b'}] | |
| console.log(arr.some(item => item.a === 'b')) |
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
| console.log(Number(String(num).slice(-1))) |
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
| let string = "hello"; | |
| let newString = "" | |
| var i = string.length; | |
| while(i--)newString += string[i] |
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
| const filteredArray = array1.filter(value => array2.includes(value)); |
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
| function getWindowDimensions() { | |
| const { innerWidth: width, innerHeight: height } = window; | |
| return { | |
| width, | |
| height | |
| }; | |
| } |
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
| var myArray = ['a', 1, 'a', 2, '1']; | |
| let unique = [...new Set(myArray)]; | |
| console.log(unique); // unique is ['a', 1, 2, '1'] |
NewerOlder