Tuesday, June 21, 2022

How to manage multiple git account in windows

I have two github account, One just for fun - my personal account and another one for work. 
To switch between two account, involves quite few number of steps.
 
1)Generate ssh key
2)Config the ssh key in your github account 
3)Set up the ssh configuration in your local system
4)Clone the code with alias name

Generate ssh key:
                     Generate the ssh key for both account one by one through  ssh-keygen tool 

Enter the following command in git bash to create ssh-key , One for personal  email and another for official email 

ssh-keygen -t ed25519 -C "mypersonalemail@com"
ssh-keygen -t ed25519 -C "myofficialmail@com"


Then enter the file location where you wants to generate keys. It should be inside the .ssh folder under your name ( Be caution don't override the existing file)
Next it will ask to enter the passphrase. Enter blank. And then again it will ask for confirmation. Enter blank 

Two file will get generated one contains private key and another contains public key. Copy the public key , which we will use later

Config the ssh key in your github account
                       To update the ssh in github, navigate to the following path  (setting >  SSH and GPG keys) and update the key as shown below






Set up the ssh configuration in your local system
                     Third step would be configuration of ssh in your local machine so that ssh client  uses correct key to authenticate with respective your github account. 

Create a file named as "config" under the .ssh folder. and paste new configuration

Host <#ALIAS NAME FOR PERSONAL WHICH WE USE LATER TO CLONE#> github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/<#FILE NAME OF PERSONAL KEY FILE#>

Host <#ALIAS NAME FOR OFFICIAL WHICH WE USE TO CLONE#> github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/<#FILE NAME OF OFFICIAL KEY FILE#>


Clone the code with alias name
                  Go to your repository in github and copy the SSH url path to clone the repository, it would look like similar to below
git@github.com:shedev/HandOn.git
Replace the github.com with alias name,  then url would look like 
git@<#ALIAS NAME#>:shedev/HandOn.git
To clone the code, use the following command in git bash
git clone git@<#ALIAS NAME#>:shedev/HandOn.git

Friday, June 10, 2022

C# Pattern

Patterns and Its type

C# introduced pattern matching in C# 7.0. Since then, each major C# version extends pattern matching capabilities.      

  • Declaration pattern
  • Type pattern 
  • Constant pattern
  • Relational patterns
  • Logical patterns
  • Property pattern
  • Positional pattern
  • var pattern
  • Discard pattern

Declaration pattern   

                     With a declaration pattern, you can also declare a new local variable. When a declaration pattern matches an expression, that variable is assigned a converted expression result, as the following example shows:



Type pattern   

                      Introduced in C# 9.0, Type pattern checks the run-time type of an expression as shown below:                    
                  
Constant pattern   

                      Introduced in C# 7.0, test if an expression result equals a specified constant as shown below:                    
                  
Relational pattern   

                    Beginning with C# 9.0, you use a relational pattern to compare an expression result with a constant, as the following example shows:                    
                  
Logical pattern   

                    Beginning with C# 9.0, you use the not, and, and or pattern combinators to create the following logical patterns:                  
                  
Property pattern   

                   Beginning with C# 8.0, you use a property pattern to match an expression's properties or fields against nested patterns, as the following example shows                 
                  

Positional pattern   

                   Beginning with C# 8.0, you use a positional pattern to deconstruct an expression result and match the resulting values against the corresponding nested patterns, as the following example shows:                
                  
Var pattern   

                  Beginning with C# 7.0, you use a var pattern to match any expression, including null, and assign its result to a new local variable, as the following example shows            
                  

Discard pattern   

               Beginning with C# 8.0, you use a discard pattern _ to match any expression, including null, as the following example shows                
                  


Source code : HandOn/Pattern at main · shedev/HandOn (github.com)











 








Duende IdentityServer ClientCredential flow

  Duende (Identity server)  is an OpenID Connect and OAuth 2.0 framework for ASP.NET Core. Duende Identity Server enables the following secu...