<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dibo on Medium]]></title>
        <description><![CDATA[Stories by Dibo on Medium]]></description>
        <link>https://medium.com/@its-dibo?source=rss-a064e55bc82b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_1l16MvjM-5ko2Ibc4a-Ng.jpeg</url>
            <title>Stories by Dibo on Medium</title>
            <link>https://medium.com/@its-dibo?source=rss-a064e55bc82b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 11:33:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@its-dibo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to use Python CLI commands]]></title>
            <link>https://its-dibo.medium.com/how-to-use-python-cli-commands-4ef16365b5a5?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ef16365b5a5</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 19:27:10 GMT</pubDate>
            <atom:updated>2025-04-20T19:27:10.120Z</atom:updated>
            <content:encoded><![CDATA[<p>In this mini tutorial we’ll learn how to use basic Python CLI commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mGtpz1fbY06uiMiHs7XuAA.png" /><figcaption>Python series by <a href="https://medium.com/u/a064e55bc82b">Dibo</a></figcaption></figure><p>execute a python (.py) script using python cmd</p><pre># or `py` or `python3`<br>python file.py</pre><h3>Options:</h3><pre>python [-bBdEhiIOPqRsSuvVWx?] [-c command | -m module-name | script | - ] [args]</pre><ul><li>-c &lt;command&gt; execute a command, the statements are separated by new lines.</li><li>-m &lt;module-name&gt; Search sys.path for the named module and execute its contents as the __main__ module (cannot be used with modules written in C).</li><li>- Read commands from standard input</li><li>&lt;script&gt; run the script, it can be a file or a dir containing main.py</li><li>-d enable debugging</li><li>-i interactive mode</li><li>-I run the script in isolated mode</li><li>-O Remove assert statements, -OO also remove docstrings</li><li>-q Don’t display the copyright and version messages</li></ul><h3>Environment vars (PYTHON* vars)</h3><ul><li>PYTHONPATH Augment the default search path for module files</li><li>PYTHONSAFEPATH same as -P flag</li><li>PYTHONPLATLIBDIR</li><li>PYTHONSTARTUP &lt;file&gt; execute the file before running the script</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ef16365b5a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The new way to get dirname in Node v21]]></title>
            <link>https://its-dibo.medium.com/the-new-way-to-get-dirname-in-node-v21-d968e978d8f7?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d968e978d8f7</guid>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Sat, 04 Jan 2025 20:51:55 GMT</pubDate>
            <atom:updated>2025-01-04T20:51:55.793Z</atom:updated>
            <content:encoded><![CDATA[<p>remember CommonJs ages where __dirname and __filename were vailable as built-in variables in NodeJs?</p><p>when ESM came, it removed those built-in variables, and as a workaround we use import.meta.url which obtains the current file’s path as a file protocol.</p><pre>console.log(import.meta.url); // file://path/to/file.js</pre><p>we then need fileURLToPath to convert it into a normal path that nodejs can understand.</p><p>then we need again to pass it to dirname to get the value of __dirname</p><pre>import { dirname } from &#39;node:path&#39;;<br>import { fileURLToPath } from &#39;node:url&#39;;<br>    <br>const __filename = fileURLToPath(import.meta.url);<br>const __dirname = dirname(__filename);</pre><p>NodeJs v21 came to say goodbye to this workaround, now filename and dirname are available directly using import.meta without any workaround</p><pre>const __filename = import.meta.filename<br>const __dirname = import.meta.dirname</pre><p>CHAO 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d968e978d8f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s build great apps together | Docker in depth.]]></title>
            <link>https://its-dibo.medium.com/lets-build-great-apps-together-docker-4c0f0837be06?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c0f0837be06</guid>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Fri, 08 Nov 2024 20:37:27 GMT</pubDate>
            <atom:updated>2024-11-08T20:38:32.008Z</atom:updated>
            <content:encoded><![CDATA[<p>This story is the beginning of a long and exciting journey to build real applications together and gain a deep understanding of many modern and advanced concepts.</p><p>This is the first part of our FREE course on learning Docker in depth, featuring numerous practical examples and hands-on app-building projects.</p><p><a href="https://linkedin.com/build-relation/newsletter-follow?entityUrn=6969599226271928320">I’m waiting for you on my amazing newsletter, and I promise we will learn useful things together</a> and <a href="https://medium.com/@its-dibo">my Medium stories</a>.</p><p><strong>Why do we need to containerize our apps?</strong></p><p>First of all, why would we need Docker at all? Simply put, it’s to build and manage containers. But wait… what exactly are containers?!</p><p>When I say ‘containers,’ the first image that might come to mind is a massive cargo ship 🚢 carrying huge containers stacked on its deck.</p><p>But why do people place their cargo inside containers instead of directly on the ship?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CLy_qKHs05HHU7wx.png" /></figure><p>Back in the time before containers were invented, traders used to place their goods directly on ships without the need to containerize their goods, which led to many issues.</p><p>Goods would get mixed up and sometimes even lost among other items. Additionally, it took a lot of time and effort to load and organize the cargo on the ship, then unload it piece by piece once the ship reached its destination.</p><p>Many items would either get damaged during loading, lost at sea, or, at best, get mixed up with the goods of other traders.</p><p>This is where containers came in to solve the problem. Each trader could now place their goods in a dedicated container, and the containers would simply be stacked side by side on the ship’s deck, without needing to arrange each item individually. This protected each trader’s goods from mixing with others and also safeguarded smaller items from falling into the sea during transport.</p><p>The loading and unloading process became much easier as well. All that was needed was a single crane on the ship’s deck to lift and lower the container, with all its contents, without any hassle.</p><p>Not only that, but since containers are standardized, they can be transported on any vehicle without needing to rearrange the contents. For example, a container can be unloaded from a ship, then loaded onto a train, transferred to a truck, and finally placed directly into storage as-is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y4-6HKCn5mQTjl4t.jpg" /></figure><p>We apply this same philosophy in software. Either we place all our requirements in one container and deploy it anywhere or on any type of server, running it seamlessly, or we risk letting our assets mix with others’ assets, leading to conflicts and spending a lot of time arranging everything to suit the environment where our application will run.</p><p><strong>Using containers offers the following advantages:</strong></p><ol><li>Complete isolation of our software assets without worrying about them mixing with others’ resources.</li><li>Saving time and effort in setting up the runtime environment; we simply deploy our container as it is.</li><li>Ensuring that the runtime environment is identical to the development environment.</li><li>Just like traditional containers, software containers can be unloaded from one server and deployed directly onto another platform without any need for reconfiguration.</li><li>Enhanced security, as unauthorized users cannot directly access our personal container.</li></ol><p><strong>Real-life examples</strong></p><p>Let’s look at some simple real-life examples that we encounter daily in the world of software.</p><p>Imagine someone asking you to complete a tiny project, which involves writing simple content in a Microsoft Word document. This project is so simple that it will take only a few minutes to finish. However, you might face a huge problem that isn’t easily solvable.</p><p>After completing the project perfectly and sending it to the client via email, they call you to say that the program isn’t working.</p><p>After testing it on your side, you respond with the famous phrase, “But it works on my end.”</p><p>The client insists that the program isn’t working, while you insist that you completed it perfectly.</p><p>Of course, the reason the project isn’t working on the client’s machine is simply because the environment they are testing in is different from the one you developed the project in.</p><p>For instance, they might be using an operating system that doesn’t support running Microsoft Word. Or, if they have a Windows system, they might not have installed the Office package. Even if they installed it, they might not have chosen Word as part of the package.</p><p>Even if everything was installed successfully, we can’t guarantee software versions — perhaps they installed slightly older versions of the software you used, which don’t support opening that specific file because it was created with a newer version.</p><p>And even if everything is installed with the exact same versions, we might discover after a lot of searching that the language package used in the file is missing from their system. After installing it, we may realize that we need to install the required fonts. After installing the fonts, we might find… oof, so much effort and so much time wasted just preparing the environment to work.</p><p><strong>Let’s think about possible solutions…</strong></p><p>The first solution might be to give your personal laptop, along with the program, as a gift to the client. Of course, you wouldn’t sacrifice your laptop worth thousands of dollars for a $10 project, so let’s explore cheaper solutions. Think with me.</p><p>What if we tell the client to set up an environment that matches the one on our laptop to ensure the runtime environment matches the development environment?</p><p>This solution might not work at all. What if the client has a MacBook and doesn’t want to replace their system with Windows?</p><p>Even if they are open to using Windows, they might lose access to other applications if they change software versions.</p><p>Let’s assume they are a very kind person and open to all solutions. Would you be willing to waste hours reinstalling the operating system, then reinstalling all the required programs and packages, just to run a simple file?</p><p>While this solution may seem impossible in many cases, it requires an immense amount of effort.</p><p>So, let’s rule that out as well. Let’s think of easier solutions.</p><p><strong>Virtual machines (VMs)</strong></p><p>For this purpose, engineers came up with a very clever idea: virtual machines. The concept behind virtual machines is to create a virtual device within your real device. This allows you to run an entirely separate operating system that is completely isolated from your original system, preventing any conflicts between the system files and packages.</p><p>With this, you can run a Windows operating system on a MacBook completely independently without altering the original system files.</p><p>This solution is great because it doesn’t require the client to delete their original system in order to run our program. However, we still need a lot of time and effort to install the necessary programs and packages required to run our application.</p><p>Aside from this significant effort, VMs have another problem: they consume a lot of system resources. As a result, running virtual machines is very limited.</p><p>What if we wanted to create dozens of systems and run them all at the same time without consuming too many resources from the host machine?</p><p><strong>Containers</strong></p><p>What if we borrowed the concept of containers from ships and brought it into the world of software?</p><p>This is what we will discuss in detail, step by step, throughout this course.</p><p><strong>Think more …</strong></p><p>Let’s quickly look at another example.</p><p>Imagine you’ve been working on a huge project for years, and this project has accumulated many dependencies over time. What if several new developers join your team to work on this project?</p><p>You’ll need to set up each of their machines to exactly match yours. Every time, you’ll discover that there are some dependencies you forgot to install or that you installed the wrong version by mistake.</p><p>Once the project finally works after much effort, you’ll need to repeat the same setup work on the other developers’ machines.</p><p>What we need is a way to provide a development environment identical to the one where the original project is running.</p><p>Of course, the container concept solves this problem, as we simply “ship” the container with all its contents to each developer’s machine. And that’s it.</p><p>Similarly, what if you’re asked to work on another project alongside your huge one, but the two projects have conflicting dependencies? We need a way to isolate each project with its dependencies, so that each one runs in the environment that suits it.</p><p>This is another problem containers can solve, as they provide the feature of isolating each container from the rest of the system and preventing any interference with its contents.</p><p><strong>Ready?</strong></p><p>Are you ready to embark on an exciting journey to deeply understand containerization and practice building amazing applications together? Let’s gooooooo!</p><p><a href="https://linkedin.com/build-relation/newsletter-follow?entityUrn=6969599226271928320">I’m waiting for you on my amazing newsletter, and I promise that we will learn useful things together</a> and <a href="https://medium.com/@its-dibo">my Medium stories</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c0f0837be06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[how to use a method of the parent component?]]></title>
            <link>https://its-dibo.medium.com/how-to-use-a-method-of-the-parent-component-27f225adf400?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/27f225adf400</guid>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Sat, 28 Oct 2023 13:18:58 GMT</pubDate>
            <atom:updated>2023-10-28T13:18:58.966Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently stuck with an issue and want to share the solution with you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BLmQhVjJKgLQwzfHZUem-g.png" /></figure><p>I needed to create a component that uses a method of any other component that uses it.</p><p>you may think we can pass the method as a property to the child component, it is a straightforward solution but introduces a new issue</p><p>the component looks like:</p><pre>&lt;my-component [transform]=&quot;transform&quot;&gt;&lt;/my-component&gt;</pre><p>and the method looks like</p><pre>@component({ /* ... */ })<br>class ParentComponent{<br>  prop = 1 <br> <br>  transform(data){<br>     // sure this.prop has a value<br>    return {...data, prop: this.prop}<br> }<br>}</pre><p><strong>easy, right?</strong></p><p><em>no ..</em></p><p>if you investigated the returned value you will find it looks like</p><pre><br>@component({ /* ... */})<br>class MyComponent{<br> @Input() transform: (data: Data) =&gt; Data;<br>  <br> ngOnInit(){<br>  console.log(data); // {x: 1}<br>  let newData = this.transform?.(data) || data;<br>  console.log(newData); // {x:1, prop: undefined}</pre><p><strong>wait … what?!! undefined!!</strong></p><p>why newData.prop here is undefined, should it have a value?!!</p><p>no other method changed its value.</p><p>let’s debug our parent class by logging the value of this.prop,</p><p>the good news it always has a fixed value of “1”.</p><p>the bad news, it always undefined inside transform() , even it has a value everywhere and inside all methods .. except transform()</p><h3>why?!!</h3><p>simply, because it is executed inside another context i.e. MyComponent therefore this here refers to MyComponent instead of ParentComponent <br>now we can easily offer a solution</p><h3>the solution</h3><p>we can bind this to ParentComponent , or the most simple solution is to use the arrow function, so, this here refers to the outer context i.e ParentComponent which exactly we need.</p><pre>class ParentComponent{<br> this.prop=1;<br><br> // now `this` refers to ParentComponent, <br> // and this.prop has the intersted value<br> transform: (data)=&gt;({...data, prop: this.prop})<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27f225adf400" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[dive more deeply inside Nodejs]]></title>
            <link>https://its-dibo.medium.com/dive-more-deeply-inside-nodejs-8c31b25e7f3d?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c31b25e7f3d</guid>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 15:41:37 GMT</pubDate>
            <atom:updated>2023-07-18T15:41:37.669Z</atom:updated>
            <content:encoded><![CDATA[<p>#Nodejs has two main dependencies:</p><p>- v8: a #javascript engine by #Google to execute js code out of the browser</p><p>- libuv: a c++ library that gives nodejs access to the operating system, and enables the single-threaded nodejs to perform async tasks</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*a9kitLNB5luSlzdw3oUB3w.jpeg" /></figure><p>follow the <a href="https://www.linkedin.com/newsletters/developers-talks-6969599226271928320/">developers talk newsletter</a></p><h3>Understanding the nodejs repo</h3><p><a href="https://github.com/nodejs/node">https://github.com/nodejs/node</a></p><p>the nodejs repo contains tow main folders:</p><p>- lib: contains the js code<br>- src: contains the c++ code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6nq99liBpIMuLvla4F74Uw.jpeg" /></figure><h3>Process &amp; threads</h3><p>the process is an instance of the running code, the process can have multiple threads</p><p>a thread is a task to be executed such as reading a file, connect to db, math calculating</p><p>the OS scheduler decides which thread sould be processed at a point of time</p><p>each core can process multiple threads at a time ( #multithreading )</p><h3>clusters</h3><p>- #clusters are used to create multiple copies of our app.<br>it looks like, but not the same as multi-threading.<br>each copy has its own event loop</p><p>- worker threads use the thread pool from libuv, similar to #webworkers</p><p>- PM2 is a nodejs cluster manager, if a cluster instance crashes it restarts it automatically</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c31b25e7f3d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular changes its template syntax]]></title>
            <link>https://its-dibo.medium.com/angular-changes-its-template-syntax-c6adeab998cc?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6adeab998cc</guid>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Tue, 04 Jul 2023 13:06:21 GMT</pubDate>
            <atom:updated>2023-07-04T13:06:21.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Angular is getting a new control flow. previously we used to use structural directives such as `*ngIf` and `*ngFor`.</p><p>The Angular team started to replace these directives with a new control flow syntax.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bCRa0IkATLqC2OIhOeIosg.png" /></figure><p>## Structural directives<br>the old syntax was based on the structural directives, this is an example of them.</p><p>```<br>&lt;div *ngIf=”data”&gt;<br> &lt;div *ngFor=”let item of data”&gt;<br> {{ item.name }}<br> &lt;/div&gt;<br>&lt;/div&gt;<br>```</p><p># The new control flow<br>here is the same previous example but with the new control flow</p><p>```<br>{#if data}<br> {#for item of data}<br> {{ item.name }}<br> {/for}<br>{/if}<br>```</p><p>but what are the differences?</p><p>- the new control flow is more compatible with the new Signal components, and..<br>- more readable<br>- you don’t need to import CommonModule to use it<br>- and don’t need to introduce a new element in the DOM tree, or even use `ng-container`</p><p>let’s discover the new features introduced with the new control flow</p><p>## Deferred loading<br>you can defer parts of the page to be lazy loaded, by deferred loading</p><p>```<br>{#defer on viewport}<br> &lt;calender-comp /&gt;<br>{/defer}<br>```</p><p>#trackBy<br>trackBy is a function that is used when iterating over large collections to prevent replacing DOM elements except for the truly changed items.<br>it accepts a function, but now it can also accept an item property, so you don’t need to implement an extra method in your component’s class</p><p>old:<br>```<br>&lt;div *ngFor=”let item of items; trackBy: trackByFn”&gt;<br> {{ item.name }}<br>&lt;/div&gt;</p><p>trackByFn(index, item){<br> return item.id<br>}<br>```</p><p>new:</p><p>```<br>{#for item of items; track item.id}<br> {{ item.name }}<br>{/for}<br>```</p><p>## else block</p><p>previously, we used to introduce two blocks, one is a negative case for the other one.<br>or simply use the template reference #elseBlock</p><p>old:<br>```<br>&lt;ng-container *ngIf=”cond; else elseBlock”&gt;<br> true<br>&lt;/ng-container&gt;</p><p>&lt;ng-template #elseBlock&gt;<br> false<br>&lt;/ng-template&gt;<br>```</p><p>new:</p><p>```<br>{#if cond}<br> true<br>{:else}<br> false<br>{/if}<br>```</p><p>## empty block</p><p>previously we have to make two separate conditions, either by using a negative condition statement or by using the #elseBlock<br>this leads us to use `*ngIf` and `*ngFor` together, but as we cannot use them in the same element, we needed to introduce a new element</p><p>old:<br>```<br>&lt;ng-container *ngIf=”data”&gt;<br> &lt;div *ngFor=”let item of data”&gt;<br> {{ item.name }}<br> &lt;/div&gt;<br>&lt;/ng-container&gt;</p><p>&lt;div *ngIf=”!data || data?.length===0&quot;&gt;<br> No data!<br>&lt;/div&gt;<br>```</p><p>new:<br>we don’t even need to use if statements here</p><p>```<br>{#for item of items}<br> {{ item }}<br>{:empty}<br> No data!<br>{/for}<br>```</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6adeab998cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The future of SSR in Angular v16: non-destructive hydration]]></title>
            <link>https://its-dibo.medium.com/the-future-of-ssr-in-angular-v16-non-destructive-hydration-86a5278ae216?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/86a5278ae216</guid>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Sun, 21 May 2023 14:08:51 GMT</pubDate>
            <atom:updated>2023-05-21T14:08:51.586Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGy1oBPXfZP48w9ZcmHk6A.png" /></figure><p>Angular apps that rely on server-side rendering are facing a major challenge, hydration</p><p><strong>what is destructive hydration?</strong><br>your app renders on the server-side and then re-rendering again on the client-side</p><p>now Angular team works on a new technique for server-side rendering, full hydration.</p><p>in full hydration mode, Angular reuses the already-rendered app as much as possible instead of re-rendering it from scratch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86a5278ae216" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[git] How to recover deleted commits from deleted branches?]]></title>
            <link>https://its-dibo.medium.com/git-how-to-recover-deleted-commits-from-deleted-branches-57be9a3c3125?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/57be9a3c3125</guid>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Sat, 20 May 2023 20:43:44 GMT</pubDate>
            <atom:updated>2023-05-20T20:43:44.368Z</atom:updated>
            <content:encoded><![CDATA[<p>I run git push --force against a non-protected branch, this caused some non-pushed commits to be deleted<br>unfortunately both the local and the remote branches are deleted</p><p>this is how I recover the deleted commits</p><p>1- run git reflog, this lists the latest commits including the delete once, select the head number of the latest commit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*vgUXvUUuRSwAHGz7t90qyg.png" /><figcaption>git reflog</figcaption></figure><p>2- run git reset --hard e0814474, where &#39;e0814474&#39; is the head number of the previous step</p><p>3- push the recovered commits as usual</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57be9a3c3125" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular v15 is here … do more, code less]]></title>
            <link>https://its-dibo.medium.com/angular-v15-is-here-do-more-code-less-8c6d67f24d89?source=rss-a064e55bc82b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c6d67f24d89</guid>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[material-design]]></category>
            <dc:creator><![CDATA[Dibo]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 11:19:46 GMT</pubDate>
            <atom:updated>2022-11-21T11:24:39.046Z</atom:updated>
            <content:encoded><![CDATA[<h3>Angular v15 is here … do more, code less</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3kUrD0uG81vheF2w.jpg" /></figure><p>Angular issues two major versions yearly, this year it introduced v14 and v15.</p><p>most updates in v15 were introduced already in v14 as experimental but became stable APIs.</p><p>in addition some new interesting features.</p><p>make sure you follow our pretty newsletter <a href="https://linkedin.com/newsletters/developers-talks-6969599226271928320">developers talks</a> on LinkedIn</p><h3>RIP NgModule</h3><p>Angular was born with its famous NgModule, all parts of Angular including Components always tied with Angular modules.</p><p>Angular 14 came with a module-less component feature known as stand-alone components.</p><p>this feature was experimental in v14 and became stable in v15.</p><p>the stand-alone component behaves as if it is a 2-in-1 NgModule and a component.</p><p>it can import modules and even another stand-alone component.</p><pre>@Component({<br>  selector: &#39;app-my-component&#39;,<br>  standalone: true,<br>  imports: [CommonModule, OtherComponent]<br>  template: `<br>    &lt;h2&gt;Today is {{today | date}}&lt;/h2&gt;&#39;<br>    &lt;app-other-component&gt;&lt;/app-other-component&gt;<br>  `<br>})<br>export class MyComponent {}</pre><h3>bye bye class-based Router Guards</h3><p>as you start your journey with Angular, you find classes everywhere as if Angular doesn’t know about functions.</p><p>everything in Angular is a class. Router Guards are not an exception.</p><p>Angular v15 introduces the new functional Router Guards.</p><p>not only this, but also you can pass data to it directly without the need to use ActivatedRouteSnapshot to obtain it.</p><p>you may ask “how then we can inject the dependencies without classes”?! see the example below.</p><p>the old-school Guards.</p><pre>@NgModule({<br>  imports: [<br>    RouterModule.forRoot(<br>      [      <br>        { path: &#39;/home&#39;, component: HomeComponet, canActivate: [LoggedInGuard] }       <br>      ]<br>    ),<br>  ],<br>  exports: [RouterModule],<br>})<br>export class AppRoutingModule {}</pre><pre>// ----&gt; Guards are classes<br>@Injectable({ providedIn: &#39;root&#39; })<br>export class LoggedInGuard implements CanActivate {<br>  constructor(<br>    private readonly authService: AuthService,<br>    private readonly router: Router<br>  ) {}</pre><pre>// ----&gt; we need ActivatedRouteSnapshot to read the data<br>  async canActivate(route: ActivatedRouteSnapshot): Promise&lt;boolean&gt; {<br>    if (!await this.authService.isLoggedIn()) {<br>      return true;<br>    }<br>    return this.router.navigateByUrl(&#39;/home&#39;);<br>  }<br>}</pre><p>the new-style Guards:</p><pre>provideRouter([<br>  { path: &#39;/home&#39;, component: HomeComponet, canActivate: [isLoggedIn([&#39;LOGGED_IN&#39;])] }<br>])</pre><pre>// --&gt; now we can access `data` directly without ActivatedRouteSnapshot<br>function isLoggedIn(data: string[]) { <br>// --&gt; also, we can inject dependencies with `inject()`<br>  if (!await inject(AuthService).isLoggedIn()) {<br>    return true;<br>  }<br>  return inject(Router).navigateByUrl(&#39;/home&#39;)</pre><h3>automatic directives</h3><p>imagine you created a RoundedCorners directive, and you need to apply it to all MyComp instances, you need to do so manually.</p><pre>&lt;my-comp RoundedCorners&gt;&lt;/my-comp&gt;<br>&lt;my-comp RoundedCorners&gt;&lt;/my-comp&gt;<br>&lt;my-comp RoundedCorners&gt;&lt;/my-comp&gt;</pre><p>in Angular v15 you can do it automatically, by instructing the component to automatically apply all directives you like.</p><pre>@Component({<br>  selector: &#39;my-comp&#39;,<br>  standalone: true,<br>  imports: [RoundedCornersDirective],<br>  // 👇 This is how you assign directives to the component in Angular 15<br>  hostDirectives: [RoundedCornersDirective],<br>  template: &#39;&lt;button&gt;Hello World&lt;/button&gt;&#39;;<br>})<br>export class MyComponent {}</pre><p>now, each time you call &lt;my-comp&gt;&lt;/my-comp&gt; the RoundedCorners applied automatically.</p><p>you even can combine multiple directives into a single directive and add your own species by extending their functionality</p><pre>@Directive({<br>  selector: &#39;[applyStyles]&#39;,<br>  hostDirectives: [RoundedCornersDirective, HighlightDirective, UnderlineDirective]<br>})<br>export class ApplyStylesDirective {}</pre><p>instead of &lt;my-comp roundedCorners highlight underLine&gt;, just do &lt;my-comp applyStyles&gt;</p><h3>Optimized images directive</h3><p>Angular and Aurora (the chrome team) collaboration resulted in a new images directive that can optimize and lazy-load images on web pages.</p><p>all you need to replace the attribute src with the directive ngSrc</p><pre>@Component({<br>  standalone: true,<br>  // 👇src -&gt; ngSrc<br>  template: &#39;&lt;img [ngSrc]=&quot;src&quot;/&gt;&#39;<br>  imports: [NgOptimizedImage],<br>})<br>class MyComponent {<br>  @Input() src: string;<br>  }</pre><h3>we will miss the fucking messy Stack Trace</h3><p>one of the most painful dilemmas in Angular is its stack trace, most developers never understand what the trace tries to tell them !!</p><p>‘Finally, Angular felt the people’s pain!</p><p>all traces that come from node_modules and we never concern about are gone away.</p><p>only errors in your own code base are shown up.</p><pre>// Error from Angular 14<br>ERROR Error: Uncaught (in promise): Error<br>Error<br>    at app.component.ts:18:11<br>    at Generator.next (&lt;anonymous&gt;)<br>    at asyncGeneratorStep (asyncToGenerator.js:3:1)<br>    at _next (asyncToGenerator.js:25:1)<br>    at _ZoneDelegate.invoke (zone.js:372:26)<br>    at Object.onInvoke (core.mjs:26378:33)<br>    at _ZoneDelegate.invoke (zone.js:371:52)<br>    at Zone.run (zone.js:134:43)<br>    at zone.js:1275:36<br>    at _ZoneDelegate.invokeTask (zone.js:406:31)<br>    at resolvePromise (zone.js:1211:31)<br>    at zone.js:1118:17<br>    at zone.js:1134:33</pre><p>here we can know that zone.js complains about something, but only God knows what exactly is it.</p><pre>// The same Error from Angular 15<br>ERROR Error: Uncaught (in promise): Error<br>Error<br>    at app.component.ts:18:11<br>    at fetch (async)  <br>    at (anonymous) (app.component.ts:4)<br>    at request (app.component.ts:4)<br>    at (anonymous) (app.component.ts:17)<br>    at submit (app.component.ts:15)<br>    at AppComponent_click_3_listener (app.component.html:4)</pre><p>now we can know that the click listener in line 4 of our AppComponent’s template has a problem.</p><h3>Material MDC</h3><p>Material design and CDK toolkits also received updates.</p><p>Angular Material components were refactored based on <a href="https://github.com/material-components/material-components-web">Material Design Components for Web (MDC)</a> to be aligned with the Material Design specifications.</p><p>most components are rewritten from scratch.</p><p>Due to the new DOM and CSS, you will likely find that some styles in your application need to be adjusted, especially if you override the styles of the internal classes too much.</p><p>to migrate your material into v15 via the schematics tool run ng update @angular/material^15`` then, run the migrating tool ng generate @angular/material:mdc-migration`</p><p>CDK offered the new Listbox module that provides directives to help create custom Listbox interactions based on the WAI-ARIA Listbox pattern.</p><h3>es-build support</h3><p>now, Angular support using es-build to build the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*blUn8G3sOBCEUd6K" /></figure><p>you just need to make a slight modification to your builder configuration in the angular.json file</p><p>from:</p><pre>&quot;builder&quot;: &quot;@angular-devkit/build-angular:browser&quot;</pre><p>to:</p><pre>&quot;builder&quot;: &quot;@angular-devkit/build-angular:browser-esbuild&quot;</pre><h3>TypeScript 4.9</h3><p>Angular v15 now supports <strong>TypeScript 4.9.</strong></p><p>the new features and updates of Typescript will be covered in the next newsletter vol. follow me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c6d67f24d89" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>