├── CNAME ├── css ├── highlight.css ├── fontello.css └── style.css ├── img ├── avatar.jpg ├── favicon.jpg ├── node-cli.jpg └── chrome-vs-firefox.jpg ├── font ├── fontello.eot ├── fontello.ttf ├── fontello.woff ├── fontello.woff2 └── fontello.svg ├── sitemap.xml ├── blog ├── 2018 │ ├── 12 │ │ └── index.html │ └── index.html ├── 2019 │ ├── index.html │ └── 05 │ │ └── index.html ├── index.html ├── firefox-vs-chrome-memory-usage │ └── index.html └── how-to-create-a-node-cli-and-publish-it-to-npm │ └── index.html ├── index.html └── projects └── index.html /CNAME: -------------------------------------------------------------------------------- 1 | mokhnache.com -------------------------------------------------------------------------------- /css/highlight.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /img/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/img/avatar.jpg -------------------------------------------------------------------------------- /img/favicon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/img/favicon.jpg -------------------------------------------------------------------------------- /font/fontello.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/font/fontello.eot -------------------------------------------------------------------------------- /font/fontello.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/font/fontello.ttf -------------------------------------------------------------------------------- /font/fontello.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/font/fontello.woff -------------------------------------------------------------------------------- /img/node-cli.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/img/node-cli.jpg -------------------------------------------------------------------------------- /font/fontello.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/font/fontello.woff2 -------------------------------------------------------------------------------- /img/chrome-vs-firefox.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abdelaziz18003/abdelaziz18003.github.io/master/img/chrome-vs-firefox.jpg -------------------------------------------------------------------------------- /sitemap.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | https://mokhnache.com/projects/index.html 6 | 7 | 2019-10-30T08:38:07.429Z 8 | 9 | 10 | 11 | 12 | https://mokhnache.com/blog/how-to-create-a-node-cli-and-publish-it-to-npm/ 13 | 14 | 2019-10-27T18:12:05.219Z 15 | 16 | 17 | 18 | 19 | https://mokhnache.com/blog/index.html 20 | 21 | 2019-09-01T21:07:16.576Z 22 | 23 | 24 | 25 | 26 | https://mokhnache.com/blog/firefox-vs-chrome-memory-usage/ 27 | 28 | 2019-05-26T13:22:55.714Z 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /blog/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

Blog

57 | 70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /blog/2018/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

Blog

57 | 70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /blog/2019/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

Blog

57 | 70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /blog/2018/12/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

Blog

57 | 70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /blog/2019/05/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

Blog

57 | 70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /css/fontello.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'fontello'; 3 | src: url('../font/fontello.eot?36871989'); 4 | src: url('../font/fontello.eot?36871989#iefix') format('embedded-opentype'), 5 | url('../font/fontello.woff2?36871989') format('woff2'), 6 | url('../font/fontello.woff?36871989') format('woff'), 7 | url('../font/fontello.ttf?36871989') format('truetype'), 8 | url('../font/fontello.svg?36871989#fontello') format('svg'); 9 | font-weight: normal; 10 | font-style: normal; 11 | } 12 | /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ 13 | /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ 14 | /* 15 | @media screen and (-webkit-min-device-pixel-ratio:0) { 16 | @font-face { 17 | font-family: 'fontello'; 18 | src: url('../font/fontello.svg?36871989#fontello') format('svg'); 19 | } 20 | } 21 | */ 22 | 23 | [class^="icon-"]:before, [class*=" icon-"]:before { 24 | font-family: "fontello"; 25 | font-style: normal; 26 | font-weight: normal; 27 | speak: none; 28 | 29 | display: inline-block; 30 | text-decoration: inherit; 31 | width: 1em; 32 | margin-right: .2em; 33 | text-align: center; 34 | /* opacity: .8; */ 35 | 36 | /* For safety - reset parent styles, that can break glyph codes*/ 37 | font-variant: normal; 38 | text-transform: none; 39 | 40 | /* fix buttons height, for twitter bootstrap */ 41 | line-height: 1em; 42 | 43 | /* Animation center compensation - margins should be symmetric */ 44 | /* remove if not needed */ 45 | margin-left: .2em; 46 | 47 | /* you can be more comfortable with increased icons size */ 48 | /* font-size: 120%; */ 49 | 50 | /* Font smoothing. That was taken from TWBS */ 51 | -webkit-font-smoothing: antialiased; 52 | -moz-osx-font-smoothing: grayscale; 53 | 54 | /* Uncomment for 3D effect */ 55 | /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ 56 | } 57 | 58 | .icon-twitter:before { content: '\f099'; } /* '' */ 59 | .icon-linkedin:before { content: '\f0e1'; } /* '' */ 60 | .icon-github:before { content: '\f113'; } /* '' */ 61 | .icon-youtube:before { content: '\f167'; } /* '' */ 62 | .icon-stackoverflow:before { content: '\f16c'; } /* '' */ 63 | .icon-bitbucket:before { content: '\f171'; } /* '' */ 64 | .icon-facebook-official:before { content: '\f230'; } /* '' */ -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |
57 |
58 | avatar image 59 |
60 | 61 |

Abdelaziz Mokhnache

62 |

PhD Student & Fullstack Javascript Developer

63 | 64 | 81 |
82 |
83 |
84 | 85 | -------------------------------------------------------------------------------- /font/fontello.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Copyright (C) 2019 by original authors @ fontello.com 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /projects/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache | projects 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

Flex Generator

Flex Generator is an online CSS flexbox generation tool. It was written in JavaScript and created for developers wanting to learn CSS Flex or those who just want to see how it works in action without having to write any code.

Website: https://flexgenerator.com

57 |
58 | 59 |

vscode-quasar-snippets

A VSCode extension that provides snippets with the basic usage syntax for quasar-framework components making writing quasar applications easy and fun.

Github: https://github.com/Abdelaziz18003/vscode-quasar-snippets
Marketplace: https://marketplace.visualstudio.com/items?itemName=abdelaziz18003.quasar-snippets

60 |
61 | 62 |

ndarray-imhist

📊 A package to plot images’ histograms using node.js and Gnuplot inspired by Matlab imhist command.

Github: https://github.com/Abdelaziz18003/ndarray-imhist
NPM: https://www.npmjs.com/package/ndarray-imhist

63 |
64 | 65 |

gnuplot-imshow

A tool to display an ndarray of pixels as an image using gnuplot

Github: https://github.com/Abdelaziz18003/gnuplot-imshow
NPM: https://www.npmjs.com/package/gnuplot-imshow

66 |
67 | 68 |

plotbd

📈 A tool to plot bifurcation diagrams using Node.js and Gnuplot.

Github: https://github.com/Abdelaziz18003/plotbd
NPM: https://www.npmjs.com/package/plotbd

69 |
70 | 71 |

ndarray-entropy

Calculate the entropy of an intensity image, inspired by Matlab “entropy” function.

Github: https://github.com/Abdelaziz18003/ndarray-entropy
NPM: https://www.npmjs.com/package/ndarray-entropy

72 |
73 | 74 |

ndarray-corr2

Calculate 2-D correlation coefficient between two ndarrays inspired by Matlab “corr2” function.

Github: https://github.com/Abdelaziz18003/ndarray-corr2
NPM: https://www.npmjs.com/package/ndarray-corr2

75 | 76 |
77 |
78 | 79 | -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | .row { 2 | display: flex; 3 | } 4 | .column { 5 | display: flex; 6 | flex-direction: column; 7 | } 8 | .justify-start { 9 | justify-content: start; 10 | } 11 | .justify-center { 12 | justify-content: center; 13 | } 14 | .justify-end { 15 | justify-content: end; 16 | } 17 | .items-center { 18 | align-items: center; 19 | } 20 | .text-center { 21 | text-align: center; 22 | } 23 | .pt-sm { 24 | padding-top: 10px; 25 | } 26 | .mt-sm { 27 | margin-top: 10px; 28 | } 29 | .pb-sm { 30 | padding-bottom: 10px; 31 | } 32 | .mb-sm { 33 | margin-bottom: 10px; 34 | } 35 | .pl-sm { 36 | padding-left: 10px; 37 | } 38 | .ml-sm { 39 | margin-left: 10px; 40 | } 41 | .pr-sm { 42 | padding-right: 10px; 43 | } 44 | .mr-sm { 45 | margin-right: 10px; 46 | } 47 | .pt-md { 48 | padding-top: 20px; 49 | } 50 | .mt-md { 51 | margin-top: 20px; 52 | } 53 | .pb-md { 54 | padding-bottom: 20px; 55 | } 56 | .mb-md { 57 | margin-bottom: 20px; 58 | } 59 | .pl-md { 60 | padding-left: 20px; 61 | } 62 | .ml-md { 63 | margin-left: 20px; 64 | } 65 | .pr-md { 66 | padding-right: 20px; 67 | } 68 | .mr-md { 69 | margin-right: 20px; 70 | } 71 | .pt-lg { 72 | padding-top: 30px; 73 | } 74 | .mt-lg { 75 | margin-top: 30px; 76 | } 77 | .pb-lg { 78 | padding-bottom: 30px; 79 | } 80 | .mb-lg { 81 | margin-bottom: 30px; 82 | } 83 | .pl-lg { 84 | padding-left: 30px; 85 | } 86 | .ml-lg { 87 | margin-left: 30px; 88 | } 89 | .pr-lg { 90 | padding-right: 30px; 91 | } 92 | .mr-lg { 93 | margin-right: 30px; 94 | } 95 | pre, 96 | .highlight { 97 | background: #2d2d2d; 98 | margin: 0; 99 | padding: 15px 20px; 100 | border-style: solid; 101 | border-color: #ddd; 102 | border-width: 1px 0; 103 | overflow: auto; 104 | color: #ccc; 105 | line-height: 22.400000000000002px; 106 | } 107 | .highlight .gutter pre, 108 | .gist .gist-file .gist-data .line-numbers { 109 | color: #666; 110 | font-size: 0.85em; 111 | } 112 | pre, 113 | code { 114 | font-family: "Source Code Pro", Consolas, Monaco, Menlo, Consolas, monospace; 115 | } 116 | code { 117 | background: #ccc; 118 | text-shadow: 0 1px #fff; 119 | padding: 0 0.3em; 120 | } 121 | pre code { 122 | background: none; 123 | text-shadow: none; 124 | padding: 0; 125 | } 126 | .highlight pre { 127 | border: none; 128 | margin: 0; 129 | padding: 0; 130 | } 131 | .highlight table { 132 | margin: 0; 133 | width: auto; 134 | } 135 | .highlight td { 136 | border: none; 137 | padding: 0; 138 | } 139 | .highlight figcaption { 140 | font-size: 0.85em; 141 | color: #999; 142 | line-height: 1em; 143 | margin-bottom: 1em; 144 | } 145 | .highlight figcaption a { 146 | float: right; 147 | } 148 | .highlight .gutter pre { 149 | text-align: right; 150 | padding-right: 20px; 151 | } 152 | .highlight .line { 153 | height: 22.400000000000002px; 154 | } 155 | .highlight .line.marked { 156 | background: #515151; 157 | } 158 | .gist { 159 | margin: 0 -20px; 160 | border-style: solid; 161 | border-color: #ddd; 162 | border-width: 1px 0; 163 | background: #2d2d2d; 164 | padding: 15px 20px 15px 0; 165 | } 166 | .gist .gist-file { 167 | border: none; 168 | font-family: "Source Code Pro", Consolas, Monaco, Menlo, Consolas, monospace; 169 | margin: 0; 170 | } 171 | .gist .gist-file .gist-data { 172 | background: none; 173 | border: none; 174 | } 175 | .gist .gist-file .gist-data .line-numbers { 176 | background: none; 177 | border: none; 178 | padding: 0 20px 0 0; 179 | } 180 | .gist .gist-file .gist-data .line-data { 181 | padding: 0 !important; 182 | } 183 | .gist .gist-file .highlight { 184 | margin: 0; 185 | padding: 0; 186 | border: none; 187 | } 188 | .gist .gist-file .gist-meta { 189 | background: #2d2d2d; 190 | color: #999; 191 | font: 0.85em -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; 192 | text-shadow: 0 0; 193 | padding: 0; 194 | margin-top: 1em; 195 | margin-left: 20px; 196 | } 197 | .gist .gist-file .gist-meta a { 198 | color: #258fb8; 199 | font-weight: normal; 200 | } 201 | .gist .gist-file .gist-meta a:hover { 202 | text-decoration: underline; 203 | } 204 | pre .comment, 205 | pre .title { 206 | color: #999; 207 | } 208 | pre .variable, 209 | pre .attribute, 210 | pre .tag, 211 | pre .regexp, 212 | pre .ruby .constant, 213 | pre .xml .tag .title, 214 | pre .xml .pi, 215 | pre .xml .doctype, 216 | pre .html .doctype, 217 | pre .css .id, 218 | pre .css .class, 219 | pre .css .pseudo { 220 | color: #f2777a; 221 | } 222 | pre .number, 223 | pre .preprocessor, 224 | pre .built_in, 225 | pre .literal, 226 | pre .params, 227 | pre .constant { 228 | color: #f99157; 229 | } 230 | pre .class, 231 | pre .ruby .class .title, 232 | pre .css .rules .attribute { 233 | color: #9c9; 234 | } 235 | pre .string, 236 | pre .value, 237 | pre .inheritance, 238 | pre .header, 239 | pre .ruby .symbol, 240 | pre .xml .cdata { 241 | color: #9c9; 242 | } 243 | pre .css .hexcolor { 244 | color: #6cc; 245 | } 246 | pre .function, 247 | pre .python .decorator, 248 | pre .python .title, 249 | pre .ruby .function .title, 250 | pre .ruby .title .keyword, 251 | pre .perl .sub, 252 | pre .javascript .title, 253 | pre .coffeescript .title { 254 | color: #69c; 255 | } 256 | pre .keyword, 257 | pre .javascript .function { 258 | color: #c9c; 259 | } 260 | * { 261 | box-sizing: border-box; 262 | } 263 | html, 264 | body { 265 | height: 100%; 266 | margin: 0px; 267 | padding: 0px; 268 | } 269 | html { 270 | font-size: 10px; 271 | } 272 | body { 273 | color: #333; 274 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; 275 | font-size: 1.8rem; 276 | line-height: 1.5; 277 | } 278 | h1 { 279 | font-size: calc(2rem + 0.6vw); 280 | } 281 | .container { 282 | height: 100%; 283 | display: flex; 284 | flex-direction: column; 285 | max-width: 700px; 286 | margin: 0px auto; 287 | padding: 0.4em; 288 | } 289 | a { 290 | color: #333; 291 | } 292 | .homepage { 293 | flex: 1; 294 | display: flex; 295 | justify-content: center; 296 | align-items: center; 297 | } 298 | .homepage h1 { 299 | font-weight: 400; 300 | margin: 30px 0px 0px 0px; 301 | } 302 | .homepage .description { 303 | margin: 10px 0px; 304 | } 305 | .homepage .social { 306 | font-size: 2.4rem; 307 | } 308 | .navbar ul { 309 | display: flex; 310 | justify-content: flex-end; 311 | padding: 0px; 312 | } 313 | .navbar ul li { 314 | list-style: none; 315 | line-height: 1.5; 316 | } 317 | .avatar { 318 | border-radius: 50%; 319 | max-width: 128px; 320 | max-height: 128px; 321 | overflow: hidden; 322 | } 323 | .avatar.small { 324 | max-width: 50px; 325 | max-height: 50px; 326 | } 327 | img { 328 | max-width: 100%; 329 | } 330 | .post { 331 | font-size: 1.8rem; 332 | line-height: 1.6; 333 | padding-bottom: 2.5rem; 334 | } 335 | .post h1 { 336 | font-size: calc(1.3em + 1vw); 337 | } 338 | .post h2 { 339 | font-size: calc(1em + 1vw); 340 | } 341 | article > table { 342 | width: 100%; 343 | border-collapse: collapse; 344 | } 345 | article > table, 346 | article > table th, 347 | article > table td { 348 | border: 1px solid #000; 349 | } 350 | .blog ul { 351 | list-style-type: none; 352 | padding: 0px; 353 | } 354 | .blog ul li { 355 | display: flex; 356 | justify-content: space-between; 357 | margin: 10px 0px; 358 | } 359 | -------------------------------------------------------------------------------- /blog/firefox-vs-chrome-memory-usage/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache | Firefox vs Chrome: Memory usage 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

Firefox vs Chrome: Memory usage

57 | 58 | 59 |
60 | Published 17 Dec 2018 61 | 3 min. read 62 |
63 | 64 | 65 |

Chrome vs Firefox image

66 |

At the end of 2017, Mozilla introduced Firefox Quantum the blazing fast, completely reinvented Firefox. It was shipped with a new beautiful look and the speed compared to it’s previous versions was obvious. One of Mozilla’s claims too was the less usage of memory compared to Google Chrome. For a Firefox user like me, this was great news. I was able to notice the speed and enjoy the new design. But, I didn’t pay attention to how it compares to Chrome in memory usage.

67 |

Recently I read a blog post saying that Firefox consumes more RAM than Chrome. This was not what Mozilla claimed a year ago, I felt betrayed. I started searching for other blog posts with other benchmarks. But, I found different answers with different results. So, I decided to do my own tests.

68 |

Making some tests

These tests are made in the following environment.

69 |
1
2
3
4
OS: Ubuntu 18.04
RAM: 8 GB
Firefox: 64
Chrome: 70
70 | 71 |

After closing all the third party applicatins on my computer, I opened the Ubuntu System Monitor to see how much memory was in use. The initial memory usage was:

72 |
1
memory: 2.1 GiB
73 | 74 |

Then I opened 30 tabs of 3 different websites in each browser while the other is closed. I used the Guest Mode in chrome and the Safe Mode in Firefox ( by going to menu > help > Restart with add-ons disabled) in order to get rid of any effects of installed add-ons.

75 |

The opened tabs was the following:

76 | 86 |

Results

After the complete loading of the 30 tabs each time, I was opening the System Monitor to see the total memory usage. knowing the total memory makes it easy to deduce the consumption of each browser. It is as easy as subtracting the initial value of used memory from the new one (I calculated it this way because Chrome opens a lot of processes in Ubuntu and it is hard to keep adding them up). The consumed memory values corresponding to each browser are shown in the table below.

87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 |
FirefoxChrome
Test 11.0 GiB1.3 GiB
Test 21.3 GiB2.7 GiB
Test 31.2 GiB2.1 GiB
Test 40.9 GiB1.3 GiB
116 |

Summary

The results above demonstrates that Firefox Quantum really uses less memory than Google Chrome, at least in my case. That supports Mozilla’s claims about it’s new kid. I shared here the results I got. But, I can not garantee that everybody else will get the same thing. Concerning the speed, I didn’t make a real comparaison between the two. They are comparable in speed and I could not notice any difference in usage. Firefox nowadays is not the same Firefox couple of years ago.

117 |
118 |
119 |
120 | 121 | -------------------------------------------------------------------------------- /blog/how-to-create-a-node-cli-and-publish-it-to-npm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Abdelaziz Mokhnache | How to create a node.js CLI and publish it to NPM 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
42 |
43 | 54 |
55 |
56 |

How to create a node.js CLI and publish it to NPM

57 | 58 | 59 |
60 | Published 26 May 2019 61 | 7 min. read 62 |
63 | 64 | 65 |

node-cli

66 |

The toy programming language that Brendan Eich created back in the 90s, has became recently one of the most powerful and popular programming languages in the world. One of the big reasons that led to that progress is the invention of Node.js in 2009 by Ryan Dahl. Node.js and its large package management system NPM took Javascript from just being a simple scripting language for web browsers to be a full featured language that runs everywhere and helps building all kinds of cool pieces of software.

67 |

In this article, we will see together how to create a basic node.js CLI and share it with the world using NPM.

68 |

Let it be simple

The CLI that we are going to build is the simplest CLI that could ever exist. We don’t need to spend our energy building a complex one, because we have more important things to discuss. All what our CLI will do is taking a name and printing Hello {name}, welcome to node.js! to the console, as shown below.

69 |
1
2
$ hello Mohammed
Hello Mohammed, welcome to node.js!
70 | 71 |

Let’s make it

First, let’s make a folder called hello. Inside it, let’s create a cli.js file that will contain all our code. Yes of course! you can name it as you want as long as you stay consistent with the name you chose. Here is all the code we need to be written to cli.js.

72 |
1
2
3
// cli.js
let name = process.argv[2];
console.log(`Hello ${name}, welcome to node.js!`);
73 | 74 |

let’s now run the script by typing node cli.js Mohammed and there you go. You should get Hello Mohammed, welcome to node.js! printed to the console.

75 |
1
2
$ node cli.js Mohammed
Hello Mohammed, welcome to node.js!
76 | 77 |

In case you are wondering what process.argv means, it is simply an array that contains all the options that are passed in the command line when excuting the script. The first element of the array argv[0] is the path to the node command in the filesystem, the second argv[1] is the path to the script file path/to/cli.js that we want to execute while the third argv[2] is the name that we want to print.

78 |

Great, the script now is printing the message that we are expecting. But, Didn’t we say above that the usage should be hello {name} not node cli.js {name}? Yes, we did. And this is what we are going to do together right now.

79 |

It is just Shebang not Magic

Have you ever seen this comment #!/usr/bin/env node at the very top of a Javascript file and wondered what this is for? We all were in the same situation. This is called the Shebang. It is a comment that tells the Operating System what interpreter to use for this file if it is ran as an executable. We need to add it to the very top of our cli.js.

80 |
1
2
3
#!/usr/bin/env node
let name = process.argv[2];
console.log(`Hello ${name}, welcome to node.js!`);
81 | 82 |

This means for the OS that this file should be executed using the default node.js version installed on your system (the version that you get by typing node in your terminal).

83 |

Please give it a name

At this moment it is time to turn our CLI to an NPM package. All we need is creating a package.json file that will contain information about the package. You can create it manually or automatically using npm init -y command (feel free to modify the default properties as you want).

84 |

The last step is telling NPM the command’s name that we want to use. As we said before we want to replace node cli.js {name} by hello {name}. To achieve this, we simply add a bin property to package.json that contains the command’s name and the corresponding file to execute.

85 |
1
2
3
4
//package.json
"bin": {
"hello": "cli.js"
}
86 | 87 |

By reaching this point, our CLI is finished and it is ready to be published on NPM. But first let’s test it locally to see if everything is working as expected.

88 |

Test it locally first

To test the CLI locally we need it to be installed globally, so the hello command will be available everywhere. But we haven’t publish it yet, how can it be installed globally? Here we need to run the npm link command.

89 |
1
2
cd hello
npm link
90 | 91 |

when you run this command inside a package folder, it will make it available in the global scope as if it was installed with the -g flag.

92 |

Now, let’s test the CLI by typing hello {name}. Note that you can run hello from any location on your system, you are not limited to the package folder.

93 |
1
2
hello Mohammed
Hello Mohammed, welcome to node.js!
94 | 95 |

Congratulations!! You’ve made your first node.js CLI. If you want to publish it to NPM and show it to the world, you’re almost there.

96 |

Publish it to NPM

This is the easiest part as you may not expected. First, you need to create an account on npmjs.com. Then login to it from you terminal using npm login.

97 |
1
2
3
4
5
$ npm login
Username: npmuser
Password:
Email: (this IS public) npmuser@gmail.com
Logged in as npmuser on https://registry.npmjs.org/.
98 | 99 |

It will ask you for your username, password & email and you should provide the correct credentials. Once you are logged in successfully, you will be able to publish your CLI and share with the world by running npm publish from the package folder.

100 |
1
2
cd hello
npm publish
101 | 102 |

If there is no NPM package already published which have the same name as yours, after some second you can see your package live. Otherwise, you have to change the name property in package.json to an available value.

103 |

Now, everyone on planet earth with access to internet can install your package using npm i -g {yourPackageName} and execute it on there own machines. Thus, you’ve made your first contribution to a big and awesome community. Finally, don’t forget to share your code for good.

104 |
105 |
106 |
107 | 108 | --------------------------------------------------------------------------------