Skip to main content

Posts

Showing posts from April, 2021

SEO with Angular, add title, meta keywords, a must-do thing for your website

  For those who don't know what SEO is, SEO stands for Search Engine Optimization, it helps people discover your site through search engines like Google, Bing, ... Take a look at the below picture: To let search engines discover your site, you must let search engines know your site, for google you can use Google Search Console  but that's another topic, I assume search engines already know your site. The 3 most important factors are URL, title tag, and meta tag (description, keyword,...). Search engines will look for those 3 things (and many other factors) to compare with the search query and decide whether your site is relevant or not. Url Try to use meaningful URLs. For example, instead of using a URL like https://yoursite.com/products/1 use https://yoursite.com/products/iphone or even better https://yoursite.com/iphone . You can achieve this by configuring your rooting modules. To make slug URLs you can strip accents your product names and join them with a hyphen (-). For e...

What have I learned as a developer, a tech lead, a project manager and a CTO

I started my career as a data analyst since then I have worked in many positions like data engineer, full-stack developer, data scientist, project manager, tech lead, and currently as a CTO. Let me share with you some of my experiences which I think might be helpful for IT workers. Of course,  it's might not true for you, if it is not, tell me what you think, I'll be happy to read that. Skill Let's begin with skills, whatever you are working on, keep going forward, seek knowledge. Master your programming languages, learn best practices, structures, patterns, get certifications,... You want to advance in your career you must be an expert if not the best when it comes to your professional skills, you want to be a wise man in the meeting, not a fool. I don't think I need to explain much about this. Attitude You gotta be a good guy. Think for other people, be happy, be energetic that's what you want your colleagues to be so you must be one first. That's easier to sa...

How to create Windows service run periodically with .Net Core BackgroundService

  In this post: Create a windows service project with appsetting.json, connect database, and dependency injection. Create and install windows service. Code of this project. Create a windows service project with appsetting.json, connect database, and dependency injection. Create a new project. Select Worker Service. Select Next. Provide a project name in the Project name field or accept the default project name. Select Create. In the Create a new Worker service dialog, select Create. You the project is created you will see a file named Worker.cs. DoWork method is where you going to implement your service logic. private   async   Task   DoWork ( CancellationToken   stoppingToken ) But because Worker implemented BackgroundService so you can not inject singletons into the worker directly. So the workaround way is to implement DoWork method in a different service and use IServiceProvider to create a scope to put it back in Worker.cs. It's a little hard to unders...

How to use Angular RouteReuseStrategy to create snapshots so you can back to previous pages without reloading data

Github of this  exmaple.  There are a lot of practical scenarios when you load a list of items then go to the detail of an item, when you hit the back button you don't want to reload the item list again. Angular provides you a method to do exactly that. With RouteReuseStrategy when you hit the back button it takes you right back to where you were before without reloading anything. Of course, you can choose to do this or not for any page and it super easy to set up. To do this you need to create a class implement RouteReuseStrategy from @angular/router. There are 5 methods you need to implement: shouldDetach, store, shouldAttach, retrieve, shouldReuseRoute. Let's take a closer look at these methods. shouldDetach shouldDetach ( route :  ActivatedRouteSnapshot ):  boolean When you go to the next page, this method will be trigged, it decides whether the current route (a page) should be detached. In other words, Angular takes a snapshot of it and saves it in memory ...

Create and deploy multi language (i18n) website with Angular 8+

This guide should work with Angular 8+.  In  this post: 1. Create an angular web project. 2. Set up i18n and translate. 3. Deploy the website on Windows using IIS. In this guide, I am using 2 languages, the setup for more than 2 languages should be similar. You can find the code of this guide in my github . 1. Create an angular web project. To create an angular app, in command  prompt type: ng new multiLanguageApp Open "app.component.html" delete the default code and paste this code : < div >    < a   href = "/" > de </ a > &nbsp;    < a   href = "/en" > en </ a > </ div > < div > Danke! </ div > Run "ng serve" to serve your app. Go to localhost:4200 you should see: I am creating an app with German as the default language and English as the second language. "Danke" is a word in German means "Thank you". When we click "de" or "en" in the UI to switch langu...