teleren/devto huggingface dataset:
Communication within microservices
Published: 2023-02-02 06:19:15

## Intro
Every microservice has its own bounded context and will not have data is not within it's domain. Lets assume, we have a ecommerce system with below microservices:

- User microservice - Includes APIs to login, log out and user profile
- Product microservice - Include APIs to list, add, edit or delete products
- Billing microservice - Include APIs to generate bill and initiate delivery.

## Why we need to communicate?
If we observe closely, for billing microservice, to generate a bill it will need product price and details. Hence the billing microservice will need to communicate with product microservice and get the full product details.

## How to communicate?
Simple, call the list API in product microservice from billing microservice. Yes, this should be fine and we are not violating the bounded context by accessing product details directly from DB.

#### But ...
But we have to **authenticate** right? Generally frontend will use the user login **token** to authenticate. But how can a microservice get this token? It will not have the user login details. Moreover, this is user token and is meant to be used for APIs that a end user can access. So, its not a good practice to use this token to communicate between microservices.

## Solution
Hence we will need a specific token to authenticate communication between microservices. Token can be anything:

- JWT token
- Firebase token
- Custom token generation logic

We must ensure to follow below process to ensure the communication is secure,

#### Solution 1
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1miy10bjlxo1vqiqoj64.png)
- In the authentication mechanism for all APIs introduce a new API header like "X-MS-TOKEN". When ever this is passed decrypt and verify this token.
- In the billing microservice when calling product microservice for details. Encrypt and attach the token in the "X_MS_TOKEN" API header
This is a very simple way. But this has a **security concern** that if this token is leaked then anyone can easily access the API. We are not refreshing this token at all. This could be a concern when dealing with APIs that involve billing. Anyone could easily generate multiple bills.

#### For more security
- Use a third part service like firebase or create your own token generation service and fetch a token every time you call API to get details from other microservice. This way the token remain fresh each time and even if its leaked it not relevant for single use.
Bite-sized Azure Networking – Public IP
Tags: azure, cloud
Published: 2023-02-02 06:15:54

## Introduction
Unlike many other cloud service providers, Azure virtual machines reside in a virtual network without explicit outbound connectivity setting are assigned a default outbound public IP address. This IP address enables outbound connectivity from the VM to the Internet. This may beg the question – why do we still need to have additional configuration like what we are used to in AWS?


## Benefits
From both security and operational standpoint, it is always suggested to have an explicit outbound connectivity setup because of the: 

1. **Zero trust principle**: Prohibit the virtual network from accessing the internet by default
2. **Better control of traffic**: With the combination of NSG (Network Security Group), network administrators can explicitly allow/deny a certain resource to access the internet
3. **Persistent public IP**: As the default outbound public IP is not owned by the subscription, the IP may change from time to time and could cause dependency issue (e.g., a third-party provider whitelisted your traffic with a public IP, and the connection is corrupted due to the IP change)
4. **Default outbound access IP does not support fragmented packets**


## Examples of explicit outbound connectivity:
- Route traffic to the internet through a NAT Gateway (suggested way)
- Use a load balancer with outbound rules
- Attach a public IP to the NIC of the VM


## Deployment

1. Provision a NAT gateway
2. Attach public IP/public IP prefix to the NAT gateway
3. Associate it to a subnet (usually public subnet)


## Behind the scenes of how multiple VMs can co-use a single public IP
Source Network Address Translation (SNAT) is used to translate the source of a flow to originate from a different IP address and/or port. NAT gateway uses SNAT to translate the private IP address and port of a virtual machine to a static public IP address and port. Traffic is translated before leaving the virtual network for the Internet. Each new connection to the same destination endpoint uses a different SNAT port so that connections can be distinguished from one another.


## Limitation
If multiple public IPs are attached to a NAT gateway, it is currently not possible to explicitly configure a private IP/ IP range to have SNAT to a specific public IP
Basic Cli commands(sudo, apt, touch, cat, less)
Published: 2023-02-02 04:41:19

### Sudo
* It allow a user with proper permissions to execute a command as another user, such as the superuser.

#### Flags of sudo
* -V : used to check the version. 
* -l : used to list which we have to print from current host.
* -v : sudo will update the user’s timestamp, prompting for the user’s password if necessary.
* -h : used to help.
* -k : it used to sudo invalidates the user’s timestamp.
* -K : it used to remove the user’s timestamp entirely.
* -b : it tells sudo to run the given command in the background.
* -p : allows you to override the default password prompt and use a custom one.
* -u : user can run the specified command as a user other than root.
* -s : runs the shell specified by the SHELL environment variable if it is set or the shell as specified in the file password. 
* - : indicates that sudo should stop processing command line arguments.

#### Syntax of sudo
```
sudo [command]
```

### apt (Advanced Packaging Tool)
* It perform as installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system.

* Install package
```
sudo apt install <package_name>
```

* Update package in index
```
sudo apt update
```

* Remove a package
```
sudo apt remove <package_name>
```

* Upgrade package
```
sudo apt upgrade
```

### touch
* It is used to create a file, update the modification and access time of each file with the help of touch command.

#### Syntax of touch
```
touch <file_name>
```

#### Flags in touch
* -a : used to change the access time of a file.
* -m : help you to change only the modification time of a file.
* -r : it update time with reference to the other mentioned command.
* -t : we can change the access time of a file by determining a specified time to it.

### cat
* Create a file bye using '>' symbol.
* It can read the data inside the file.

#### Syntax of cat

* create a file
```
cat > 'file_name'
```

* to read a file
```
cat 'file_name'
```

### less
* It automatically adjust with the width and height of the terminal window.
```
less 'file_name'
```
Starting My Web3 Journey: Tips and Suggestions Wanted!
Tags: web3, blockchain, discuss
Published: 2023-02-02 06:10:07

Hi everyone,

I'm excited to announce that I've started my journey into the world of web3 and decentralized technologies! I'm eager to learn more about blockchain, smart contracts, dApps, and more, and I'm hoping to build my own web3 projects in the near future.

I would love to hear from those of you who are experienced in the field. Do you have any tips or suggestions for someone starting out in web3 development? What resources would you recommend for learning? What projects or technologies do you think are most promising for the future?

I'm open to any and all advice, and I appreciate any help or guidance you can provide. Thank you in advance for your suggestions!
Regular Expressions
Published: 2023-02-02 06:07:01

## Regular Expressions

- Regular expression is a sequence of characters that defines a search pattern.
- It is a impressive tool for searching a pattern.

Example
```
string_a = re.search(r'portal', 'portal for folks')
print(string_a)
print(string_a.group())
print('Start from the Index:', string_a.start())
print('Ends at the Index:', string_a.end())
```
output:
```
<re.Match object; span=(0, 6), match='portal'>
portal
Start from the Index: 0
Ends at the Index: 6
```
#### Meta Characters
The below table shows the list of MetaCharacters are used in regex
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5t4k28y8qf2vti91k298.jpg)

#### Applications

#### Data Mining: 
* 
Data mining is the process of sorting large amounts of data to identify patterns and relationships that can help solve business problems through data analysis.

#### Data Validation: 
* Data validation is the process of checking and validating data that is collected before it is used.

#### Basic regular expressions.

#### Character Classes
- 
Character classes allow us to match a single character set against a possible character set. You can also place a character class inside the square brackets.

#### Ranges
- The range provides the versatility to match a text in the range. The hyphen character within the character class represents a range.

#### Shortcuts in RegEx.
- \w – matches a word character
- \d – matches digit character
- \s – matches white space character (space, tab, newline, etc.)
- \b – matches a zero-length character

#### Negation
- Negation inverts character classes. Finds a match excluding the reversed character or range of reversed characters specified in the character class.

#### Ends of String

- The caret character matches the beginning of the string and the $ character matches at the end of the string.

#### Any Character

- The period character represents any single character except the character classes enclosed in parentheses.
Jest test case for custom hook
Published: 2023-02-02 05:54:25

If you have a custom hook, which does not accept parameters, inside that you get some config via some other hooks based on that, you made graphql query and based on that result, you redirect the page by useHistory hook. Now how to pass your values inside that hook(bcz no params). How could you write the jest test case for this hook?
the code base of hook is like below:

`function useCity(){
 const history = useHistory()
 const {user, vehicle} = usePageConfig()
 cosnt {data,error} = getVehicleDetailsQuery({
        variables: { userId: userId, bankerId: userId },
    })
if(data.vehicle.includes('TN')){
    history.push('tnView')
}
if(error){
    history.push('seaView')
}
`
Some Important CLI commands
Tags: cli, linux
Published: 2023-02-02 05:52:28

# IMPORTANT CLI COMMANDS AND THEIR USES

Some of the most commonly used CLI commands :

1. **more** :more command is used to view large text files one page at a time.User can scroll up and down through the text using this command.


 **Syntax**
 more [ options] -filename 

**Options** 
 -m  : It limits the line displayed in a single page. 
 -d   : displays user message at right corner. 
 -s   :Squeezes blank line. 
+/string_name :To find a given string. 
+num:  To display contents from a specific line.  
more can also be used using pipes:
```command
cat filename | more
```
* **tail** : tail is used to print the last n lines of the given file. 

**Syntax** 
tail -[ number of lines] file_name
```command 
tail -10 hpt.txt
```
* **rsync** : rsync is used to sync files between two hosts or machines.

**Syntax** 
rsync [ option ] source [ destination ] 
**Options** 
-a : Archive mode includes all necessary options like copying file recursively. 
-v : Gives a brief information about files being transferred and the gives brief summary of data transferred at the end. 
-h : Outputs in a human readable format. 
-z : Compresses file data during transfer.
* **grep**: grep is used to search the file for a particular string. 

**Syntax** 
grep [ option ] string_to_be searched filename 
**Some of the options** 
-c : prints the count of lines matching the given string 
-h : Displays the matched lines only not the file name. 
-i :Ignores the cases 
-l :Displays file name list only 
-n :Display the matched lines and their number. 
-v :Prints all the line that don't match the given string.
```command
grep -c ball a.txt
```
* **find**: find command is used to find files and directories. 
**Syntax** 
find [ where to find ] [ options ] [ what to find] 

**Options** 
-name : Searches the file for a given name. 
-user : Search the file with given user name. 
-perm : Searches the file for a given file permission.
```command
find ~ -name abc.txt
``` 
We can also use wild card characters if we only know the partial file name.* is used to for more than one character. 

Example:
```command
find . -name  *java*
```
Prime Male - Ingredients, Results, Pros, Cons, Benefits & Price?
Tags: webdev, javascript, beginners, programming
Published: 2023-02-02 05:49:50

Prime Male There'll also plenty of herbaceous plants which chance to be proven to employ a positive mark.  For example, horny goat weed is a cool and effective herb which 's shown coordinator.   You discover this herb in many health or men retail institutions.
https://www.outlookindia.com/outlook-spotlight/prime-male-reviews-2023-scam-or-legit-primemale-ingredients-and-fake-complaints-exposed--news-258281?place&people&test
https://www.youtube.com/watch?v=HkpPa0-glD0
https://www.indiaforums.com/forum/topic/5318613
https://www.click.in/noida/prime-male-supplement-benefits-reviews-and-side-effects-c75-v51246840 
https://primemalefacts.wixsite.com/prime-male 
https://wsakhygsa.podbean.com/ 
https://soundcloud.com/prime-male
https://www.facebook.com/events/5757277537654540/ 
https://www.pinterest.com/pin/1056657131299905701/
https://www.scoop.it/topic/prime-male-facts
https://twitter.com/PrimeMale3
https://www.sportsblog.com/primemalebuys/prime-male-ingredients/
Build a responsive three columns chat layout with HTML/CSS/JS
Tags: css, html, javascript, tutorial
Published: 2023-02-02 05:47:27

---
title: Build a responsive three columns chat layout with HTML/CSS/JS
published: true
description: 
tags: CSS, HTML, JavaScript, tutorial
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w9f0cepq4fzepiondme9.jpeg
---

In this short tutorial, I show you how to create a fully responsive three columns chat layout.

Demo: [click](https://dom-the-dev.github.io/three-columns-chat-layout/)

If you have any questions [hit me up von Twitter](https://twitter.com/Dom_TheDev)


- GitHub Files: https://github.com/dom-the-dev/three-columns-chat-layout
- CodePen: https://codepen.io/dom-the-dev/pen/RwBqbWr

> [Subscribe to my YouTube Channel](https://www.youtube.com/channel/UCAa2t4QIxlaUuPO2FKq5TDw?sub_confirmation=1)


{% youtube LfrhwzzEtds %}


I'm happy about any feedback! :)
Sed- 10 Practical Uses of Sed
Tags: linux, beginners, bash, programming
Published: 2023-02-02 05:44:10

## sed
> This command is used in order to searches through, replaces, adds, and deletes lines in a text file.

## 10 Practical Uses of Sed
* Replace a specific word in a text file.
 ```
 sed 's/oldword/newword/g' file.txt
 ```
> The `s` command stands for Replace and `g` stands for global. This command will replace all the `oldword` with `newword` in file.txt.

* Remove blank lines from a file.
 ```
 sed '/^$/d' file.txt
 ```
> `^$` will match the blank lines and `d` represents delete the line it will delete all the blank lines in file.txt.

* Replace characters in specific line numbers.
 ```
 sed '2s/oldchar/newchar/g' file.txt
 ```
> '2' represents line number and on this line, command will replace all `oldchar` with `newchar` in file.txt.

* Delete specific character in a file.
 ```
 sed 's/char//g' file.txt
 ```
> `char` specify character to delete and `//g` will delete all the specified characters in file.txt.

* Replace multiple characters in a file
```
sed 's/[char1char2]//g' file.txt
```
> Inside square brackets specify all the characters that need to be deleted in file.txt.

*  Delete the last line of a file.
```
sed '$d' file.txt
```
> `$d` delete the last line of a file.txt, where `$` matches the last line.
 
* Delete a range of lines in a file.
```
sed '10,20d' file.txt
```
> This command deletes all the lines from 10 - 20 both lines included.

* Print first 10 lines of file.
```
sed -n '1,10p' file.txt
```
The `-n` option suppresses automatic output, and `1,10p` print lines from 1 to 10 inclusive.

* Delete a range of lines in file.
```
sed '10,20d' file.txt
```
> The `10,20d` command deletes lines 10 to 20 inclusive in the file.

* Insert a line before the first line of a file.
```
sed '1i\new-line' file.txt
```
>`1i` insert the text "new-line" before the first line of the file.
Git failure after updating to macOS Ventura
Tags: git
Published: 2023-02-02 05:36:33

# Environment

- macOS Ventura
- MacBook Air with M1 chip

# Problem

I faced the following error after updating macOS Ventura from Monterey.

```bash
$ git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
```

# Solution

One of the solutions for the error is to execute the command as follows.

```bash
$ xcode-select --reset
```

# Reference

- [Git failure after Ventura upgrade : mac](https://www.reddit.com/r/mac/comments/ye6prp/git_failure_after_ventura_upgrade/)
Gross Revenue Retention vs Net Revenue Retention
Tags: startup
Published: 2023-02-02 05:35:21

**Startups often use terms such as "net retention" and "gross retention" interchangeably. Entrepreneurs should understand the difference between the two.**

Gross retention is the percentage of customers who remain active over time. In essence, it measures how many customers are still using your product or service after a certain period of time.

On the other hand, net retention considers both gross retention and churn (the percentage of customers who stop using your product or service). Instead of measuring how many customers are still active, net retention measures how many you are actually gaining over time.

Generally, you want your net retention to be higher than your gross retention. If you don't do this, you'll lose more customers than you gain, and that's not sustainable.

**What is net retention?**
An organization's revenue is measured by how much it generates and loses in a given month or year. Subscription businesses measure the income they retain from their customers over time. It is effective for a company to retain and grow its customers when it has a high net retention rate.

**How to calculate net retention revenue?**
To calculate net retention, take the total revenue at the end of a period and subtract any churned revenue. During a period, churned revenue refers to revenue lost due to customer attrition.

**For example:**
Company ABC had $100,000 in recurring revenue at the end of January. Three customers canceled their subscriptions in February, resulting in $10,000 in churned revenue. Company ABC’s net retention rate for February would be 90% (($100,000 - $10,000) / $100,000).

**[Read more](https://churnfree.com/blog/gross-vs-net-which-is-more-important-for-your-business/)**
Restful Fast Request 2023.1.1 have been released
Tags: api, plugin, springboot, intellij
Published: 2023-02-02 05:33:52

[Release log](https://dromara.org/fast-request/en/guide/history.html#v2023-1-1)

1. 🚀 Supports fast config domain directly from the YML or Properties file. [detail](https://dromara.gitee.io/fast-request/en/guide/features/projectLevelDomainConfig.html)

![Auto config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dkysrrbpfp7myvzclk3r.png)

2. 🥇 Add project-level domain config

![domain config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ktzzg40aizszhvko132n.png)
How To Install Sweetalert2 In Laravel 9
Tags: laravel, php, jquery, sweetalert
Published: 2023-02-02 05:30:00

In this article, we will see how to install sweetalert2 in laravel 9. Here, we will learn how to use sweetalert2 in laravel 8 and laravel 9 and display a modern and beautiful alert box. sweetalert2 is used to create different types of the custom alert box like success messages, error messages, warning modals, confirm modals, custom notifications, etc.

So, let's see how to use sweetalert2 in laravel 9, sweetalert2 cdn, laravel 9 sweetalert2, sweet alert 2 laravel 8, and sweetaler2 modal popup.

Sweetalert2 is a beautiful, responsive, customizable javascript popup with zero dependencies.
CSS tutorial series: CSS functions part-2
Tags: beginners, webdev, tutorial, css
Published: 2023-02-02 05:28:47

After going through the first part of the CSS functions tutorial [CSS tutorial series: CSS functions part-1](https://dev.to/fullstackjo/css-tutorial-series-css-functions-part-1-4cg5), we can proceed to talk about a couple of more functions. 

## transform property
This property allows you to modify an element by rotating or moving it and even applying some 2D or 3D transformation.

### rotate()
This function rotates an element without distorting it as it rotates on its center axis. You can rotate an element on a specific axis by using `rotateX()` to rotate on the `x-axis`, `rotateY()` for the `y-axis` and `rotateZ()` for the `z-axis` and each of these functions takes an argument that is degrees.

```CSS
div1 {
  transform: rotateX(60deg);
}

div2 {
  transform: rotateY(45deg);
}

div3 {
  transform: rotateZ(90deg);
}

```

**Additional info**
research **rotation3d()**

### scale()
This function resizes an element width and height proportionally. The `scale()` functions takes two arguments representing the width and height respectively. For example, say we have a `<div>` of height `200px` and width `200px` and we want this `<div>`'s width to be 2 times its original width and 4 times its original height. 

```CSS
 div {
  transform: scale(2,4);
}

```
`scale()` is a shorthand for `scaleX()` and `scaleY()`. To Scale an element on a specific axis `scaleX`, `scaleY()` and `scaleZ()` can be used.

**Additional info**
research **scale3d()**

### skew()
The `skew()` takes angles as arguments. This function drags your element along the X or Y axis if one argument was passed. If both arguments were passed both axes will be affect. `skew()` is a shorthand for `skewX()` and `skewY()` which affect x-axis and y-axis independently.

```CSS
div {
  transform: skew(30deg, 10deg);
}

```
### translate()
When using the translate() functions, an element is moved while keeping its place in the document flow. Both length and percentage values are accepted as arguments. Much like the `skew()` function if one of the arguments to the translate() function is defined an element is translated along the X axis. If both arguments are defined, an element is translated along the X and Y axes.


{% codepen https://codepen.io/fullstackjo/pen/vYaQwOB %}
TIL CSS
Tags: css, beginners, html, devjournal
Published: 2023-02-02 04:37:12

Today was a follow up from yesterday's lesson on html and css was the follow up. it definitely felt a bit more tedious and sort of clutter-ish when writing the code within the html from my perspective at first but by the end it felt almost natural adding and adding until it feels like it assimilates practicing/working on a muscle.
Resolve Angular - error TS2339: Property 'ncDisplay' does not exist on type 'Object'
Published: 2023-02-02 05:25:13

res.body is coming from api response
`if (res.status == 200) {
        const data: any = res.body;
        this.ncDisplay = data.ncDisplay;
      }`
This code is checking the status of the res object to see if it is equal to 200. If the status is 200, it is assumed that the response was successful and the data was returned in the body property of the res object. The body property is then assigned to a variable named data of type any. The code then accesses the ncDisplay property of the data object and assigns it to the ncDisplay property of the current object.

If you are still encountering the error "Property 'ncDisplay' does not exist on type 'Object'", make sure that the data object actually has a property named ncDisplay. You can also add type-checking to ensure that the data object has the required property before trying to access it.