teleren/devto huggingface dataset:
Longest Substring With K Distinct Characters
Tags: javascript, leetcode
Published: 2022-09-26 03:14:19

Problem Statement #
Given a string, find the length of the longest substring in it with no more than K distinct characters.

Example 1:

Input: String="araaci", K=2
Output: 4
Explanation: The longest substring with no more than '2' distinct characters is "araa".

```js
const longestSubstringWithKDistinctCharacters = (str, k) => {
  let map = new Map();
  let temp = "";
  let max = 0;
  let stri = "";
  let end = 0;

  while (str.length > end) {
    const nextChar = str[end];

    if (map.size < k && !map.has(nextChar)) {
      map.set(nextChar, 1);
      temp = temp + nextChar;
      end++;
    } else if (map.size <= k && map.has(nextChar)) {
      map.set(nextChar, map.get(nextChar) + 1);
      temp = temp + nextChar;
      end++;
    } else if (map.size === k && !map.has(nextChar)) {
      while (map.size === k) {
        // save the current
        if (temp.length > max) {
          max = temp.length;
          stri = temp;
        }

        let startValue = temp[0];
        map.set(startValue, map.get(startValue) - 1);
        if (map.get(startValue) === 0) {
          map.delete(startValue);
        }
        temp = temp.substring(1);
      }
    }
  }
  return stri;
};

console.log(longestSubstringWithKDistinctCharacters("csbebbbi", 3));
console.log(longestSubstringWithKDistinctCharacters("araaci", 2));
console.log(longestSubstringWithKDistinctCharacters("araaci", 1));
console.log(longestSubstringWithKDistinctCharacters("cbbebi", 3));


```
VSCode Custom Colors Per A Project
Tags: vscode, javascript, productivity, beginners
Published: 2022-09-28 01:27:04

Learn this great productivity tip to quickly identify different VS Code windows(projects). If you have ever worked on several projects you know that it can be pain to quickly identify different open VS Code windows when they all look the same. By applying a distinct color to either the title bar, side bar or status bar you can quickly identify different projects at a glance. 

For example, if you are working on a backend and frontend project you can add a splash of color to the side bar to quickly find the correct project.  

To add color to individual VS Code projects we use the workspace settings to apply custom colors to various aspects of the VS Code window.

Vs Code has 2 types of settings user and workspace. User settings are global and apply to all VS Code windows. Workspace settings apply to individual projects. 

Most settings can be configured in the settings menu for user and workspace. As soon as a workspace settings is added through the VS Code GUI it will create a .vscode folder and settings.json file below that.

The manual process to add workspace settings is as follows. Create a .vscode folder in the root of the VSCode project. In that folder place a settings.json file. Guided by intellisense add customizations.


For more details check out the following video:
{% embed https://youtu.be/AgeMrOPyHzE %}
How to Make Tic Tac Toe Using React
Tags: javascript, react, programming, webdev
Published: 2022-09-26 06:30:06

In this article, we will make a very famous game tic tac toe using react. Since tic tac toe is very famous and cool game which gives some nostalgia of our childhood memory. Also, this game is so popular among the developers, and they have made this game in many other programming languages.

As we know that JavaScript is so popular among developers, we will make this game using ReactJS. In this we will design the board for it and also, it will be two player game. We will add some logic to identify the winning conditions, and we will make a count of the wins for ‘x’ and ‘o’.

What is Tic Tac Toe Game?
Tic Tac Toe is a two-player game in which the objective is to take turns and mark the correct spaces in a 3×3 (or larger) grid. Think on your feet but also be careful, as the first player who places three of their marks in a horizontal, vertical or diagonal row wins the game. So this is the objective of this game, one player have ‘x’ and other one have ‘o’ sign.
[read more](https://reactjsguru.com/how-to-make-tic-tac-toe-using-react/)
Create Azure AD groups in bulk using PowerShell with a CSV input.
Tags: powershell, azure, devops
Published: 2022-09-26 12:48:14

I recently had to replicate an Azure AD group structure from one tenant to another and wrote a super simple script to speed things up. 

## Set up PowerShell 

Firstly you will need to install the Azure AD PowerShell module which allows you to intreact with AAD. 

```powershell
Install-Module AzureADPreview
```
Authenticate to your Azure Active Directory tenant by running

```powershell
Connect-AzureAD -TenantId "<insert tenant id here>"
```

## Retrieve AD Groups

I used a simple command to export the AD groups from the tenant I want to copy from to a csv file

```powershell
Get-AzureADMSGroup | select DisplayName | Export-Csv c:\development\azureadusers.csv -NoTypeInformation
```
You can modify the export path as needed.  

## Create the AD Groups

Now that you have the AD groups exported you can run the script. Make sure you re-authenticate to the new Tenant where you want o set up the groups. Here is an example of what my CV looks like:


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14aor2fhip60zvjbohz0.png)

Note that I am only filtering the Display Names of the AD groups without the descriptions and owners. I haven't had a chance to script this up but it's fairly straight forward to do. 

Run the script to set up the groups: 

```powershell
$Groups = Import-Csv -Path "C:\development\azureadusers.csv"

foreach($Group in $Groups)

{
New-AzureAdGroup -DisplayName $Group.DisplayName -MailEnabled $False -SecurityEnabled $True -MailNickName "NotSet"
}
```
The AD groups are now created!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/paookjm9t9dfrihqqc9d.png)

There are some limitations with the Azure AD module. It doesn't support all parameters so for example you can't enable groups to be assignable to roles. You can achieve the same by using the Az.Resources [module](https://learn.microsoft.com/en-us/powershell/module/az.resources/new-azadgroup?view=azps-8.3.0)

You can also expand the script to add descriptions to the AD groups and replicate/assign owners.

Hope this helps.
display: inline magic space!
Published: 2022-09-26 15:41:01

Ever wondered when you adding a image to a HTML, you might find little space around it. It's not border, margin, padding, width or height; than what is it.

In html, images are treated as inline by default, so image's are generally text in mind of html and as usual text has spacing between them. The addition height is because of the line height, which can be removed by adding this `line-height: 0` or making the image tag to display: block. I personally like the first approach as this doesn't change the flow of the element.
DAY 6: FIZZ-BUZZ-MULTITHREADED
Tags: java, codereview
Published: 2022-09-26 22:43:03

Hey! it's day 6 of 10 days of coding challenge with I4G. Today's task was to write a code that executes fizz buzz multitreaded output.

**Thought process:**
**Understanding of the problem:** The first approach was to understand the task and the constraint attached. Here we writing a code that takes in an integer and prints fizz if the number is divisible by 3, Buzz if the number is divisible by 5, FizzBuzz if the number is divisible by both 3 and 5 or print out the number meets none of the above condition. 
**Solution:** To achieve this, we need another that will be used to iterate through the given integer. For each iteration the conditions above are tested and the function that meet the condition is executed.

**Algorithm:**

1. initialize an integer count to 1
2. Set a while loop for each function with condition: count < n (the given integer)
3. If count is divisible by 3 but not by 5, call the printFizz function
4. If count is divisible by 5 but not by 3, call the printBuzz function
5. If count is divisible by both 3 and 5 call the printFizzBuzz function
6. If count is not divisible by both 3 and 5, call the printNumber function

checkout the code here: https://leetcode.com/problems/fizz-buzz-multithreaded/submissions/
Free Comprehensive Webinar: Ways on How to Optimize JavaScript Apps
Tags: javascript, frontend, webdev, filestack
Published: 2022-09-27 07:42:03

Were you thinking of improving your JavaScript applications’ performance? [Join Dmytro Mezhenskyi](https://register.gotowebinar.com/register/347587937260509964?utm_source=PressRelease&utm_medium=Leads%20Acquisition&utm_content=webinar0922), Developer Expert of [Decoded Frontend](https://www.youtube.com/c/DecodedFrontend), on **September 30, 2022 — at 11 AM CT**, and learn about various optimization techniques you can use to speed up your apps.

## The webinar will cover a wide range of topics, including:

- Web graphic optimizations
- Network optimizations
- Page loading
- JavaScript runtime optimizations
- Tools to measure performance
- Team performance

Because of its broad scope, optimizing applications can be challenging even for experienced developers.

Developers spend a lot of time improving the performance of their apps due to heavy research that sometimes leads to more confusion.

Learning about optimization might be overwhelming for some, but you don’t have to scour the internet and collate all the necessary information.

Dmytro has gathered some practical strategies to help you keep your JavaScript applications in their best shape.

The webinar aims to let you discover the different ways you can speed up your apps in a clear and organized manner.

Maintaining applications can be exhausting enough. Enhancing their performance for the experience users will enjoy doesn’t have to be complicated. This webinar is brought to you by [Filestack](https://www.filestack.com/).

Are you interested? [Click here](https://register.gotowebinar.com/register/347587937260509964?utm_source=PressRelease&utm_medium=Leads%20Acquisition&utm_content=webinar0922) to register now; see you there!
Nhập khẩu Trung Quốc Đại Dương
Published: 2022-09-28 06:31:32

Với nhiều năm hoạt động trong lĩnh vực nhập hàng, chúng tôi cam kết đem lại cho khách hàng dịch vụ nhập hàng Trung Quốc với nhiều phương thức và linh hoạt trong cách thanh toán, đảm bảo đem lại cho khách hàng các dịch vụ tốt nhưng giá vô cùng hợp lý.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9xiqnhr7frcjqved10dr.png)
START: Developing an A/B testing platform for a streaming service
Tags: testing, webdev, react, writing
Published: 2022-09-28 11:46:24

START is an online cinema partly owned by Megafon. In 2021, START turned to Evrone with the task of creating a separate service for A/B testing. Its function is to accept a request with a user ID, distribute it among current experiments, and give this information back.

START needed a user-friendly interface where analysts could set parameters themselves, make groups, and start and end experiments at a given time. It had to be connected to a service that collects the necessary data about users, on the basis of which it would be possible to collect groups for testing. [Read the full case study here.](https://evrone.com/start)
My first pull request!
Tags: opensource, beginners, git, github
Published: 2022-09-29 03:48:11

## Hello everyone!

Today, I worked on developing an extra feature on my friend's [tool Rohan-SSG](https://github.com/rokaicker/StaticSiteGenerator). For that, I had to go through multiple steps in order to ensure that all of my changes are done safely following the best practices.

First of all, I had to file an issue on his repo stating my enhancement intentions. I had to explain the goal and my solution idea. After that, I forked his repo to make the changes in a copy of his work under my profile instead of the original. I also created a new branch which had a self-explanatory name such as an issue number. I made all of my changes on that branch locally, pushed them back on GitHub and opened a pull request. 

My [issue](https://github.com/rokaicker/StaticSiteGenerator/issues/23) was about adding support for markdown syntax features such as italics and bold. The heading 1, heading 2, and a link features were already developed, so I had to integrate my new implementation into existing code. I looked through the file system, found where the logic was located for my part, understood the general coding and commenting style and followed it. I also updated the files used for testing to contain italicized and bold markdown text, so that my new featured could be tested. I made sure everything worked before committing. Lastly, I checked the documentation to see if I had to update any information, but there was nothing about currently supported syntax features. 

My friend reviewed the changes and everything looked good. However, he requested for me to add a line in the documentation to state all of the supported markdown styles. I did that and the [pull request](https://github.com/rokaicker/StaticSiteGenerator/pull/24) was accepted and merged to the main brunch. 

Generally, the experience was great! It was interesting to check out other's code and collaborate. Moreover, I was extremely excited to see my profile picture and name under the contributors tab. So proud. 

_______________________________________________

Besides that, today was also the day when someone has contributed to my repo for the first time! My friend added a markdown capability for italicized text to my repo and [requested a pull](https://github.com/gulyapulya/SSGulnur/pull/7). I thoroughly went through all of the changed lines and reviewed the code. It was lovely to see that the other person has followed all of my styling and coding conventions. So respectfully. I forgot to request to change the documentation so I did it myself as it was not a big deal. 

So far, I am getting much more comfortable with Git and Github. Cool!
React js project shows vulnerabilities when executing "npm install"
Published: 2022-09-29 05:20:15

I got a  project from my client in which the backend is lumen and the front end is reactjs and I want to do the enhancements on that.

Lumen gets installed successfully.  But I failed to install the reactjs project. 

When I executed "npm install" inside the folder  It shows 33 vulnerabilities. And when executing the npm audit I found that the issue is for the module "node-saas 5.0.0" 

First I executed the project in node 16.15.0 and after that realized that node-saas 5.0.0 is compatible with node 15

So I switched to node 15.0.0. Again it shows other vulnerabilities for the modules like jest and more.

Every time I resolve the problem that getting from the npm audit, the new one arises. How can I solve this issue?
Day 9 I4G 10daysofcodechallenge
Tags: javascript, leetcode
Published: 2022-09-29 22:51:11

You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.

Merge all the linked-lists into one sorted linked-list and return it.

 

Example 1:

Input: lists = [[1,4,5],[1,3,4],[2,6]]
Output: [1,1,2,3,4,4,5,6]
Explanation: The linked-lists are:
[
  1->4->5,
  1->3->4,
  2->6
]
merging them into one sorted list:
1->1->2->3->4->4->5->6

Problem Category Hard!!!, Omo

The first idea I got was to merge the lists to a single list and the sort the whole merged lists, using a sorting algorithm, like merge sort.
Think I think of complexity and how to simplify it.
Which is why should I merge the list all.
I then get the first list,
combine the first with second link sorted,
continuously until I reach the end of the list.

Complexity is O(n+k)
Space Complexity O(k) 

[Problem inn leetcode](https://leetcode.com/problems/merge-k-sorted-lists/)
[Solution Implementation in js](https://github.com/ismaelsadeeq/I4G_coding_challenge/blob/main/mergeList.js)
My first merge!
Tags: opensource, beginners, git, github
Published: 2022-09-30 02:25:28

##Hello everyone!

Today, I tried both fast-forward and three-way recursive merges as I was working on two different additional features for my SSG command-line tool, SSGulnur. 

First feature that I was interested in implementing was adding [markdown bold and link syntax features support](https://github.com/gulyapulya/SSGulnur/issues/8). As always, I created an issue about my solution and a branch in which I worked on it. 

I also followed the same steps for my second feature which was adding [markdown heading syntax features support](https://github.com/gulyapulya/SSGulnur/issues/9). 

I worked on them one by one. So, after I had been satisfied with my new code in one branch, I would commit it with a descriptive name stating which issue would get fixed and then switch into another branch and do the same. At the end though I had to combine all of them together. Therefore, I went back to my main and started merging the new branches one by one. The first one went smoothly through a fast-forward merge, but the second one was a three-way recursive merge and required me to resolve the conflicts, as I worked on the same lines of code in both of them. I combined the code accepting both and committed the changes.

When, I pushed my updates back into the GitHub, I could see that the issues were closed and also contained the commit references automatically for me, as I used `fixes #(issue number)` in my commit descriptions. 

For my first issue the commit number was [1d14563](https://github.com/gulyapulya/SSGulnur/commit/1d14563aae145d8b25dbd1e716ac4ef93571f255) and or my second issue it was [f966533](https://github.com/gulyapulya/SSGulnur/commit/f966533753cab49033655c78d1bb9b24b0a0fd0e). 

Probably, this ability to have many simultaneous branches is very useful when multiple developers are working on the same code, but it still helps to combine the code even if you are working alone and want to split some project implementations.

Overall, great.
Bonita online documentation needs some Hacktoberfest 2022 love!
Tags: hacktoberfest, contributorswanted, design, javascript
Published: 2022-10-05 08:01:14

## What?

Bonitasoft is taking part in **[Hacktoberfest](https://hacktoberfest.com/),** a month-long celebration of open source software, where developers are encouraged to - and rewarded for - contributing to open source projects like Bonita.

In this friendly, worldwide event, maintainers are invited to guide would-be contributors towards issues that will help move their projects forward, and contributors get the opportunity to give back - to projects they like, and to others they've just discovered.

This year, we propose work on the design of the [online Bonita documentation web site](https://documentation.bonitasoft.com/) 🔥.

For example, there is an opportunity to improve the light and dark themes 🎨, improve the look and feel for mobile, and much more 😍.

## Who?

**This project is open to everyone** and no contribution is too small — bug fixes and documentation updates are valid ways of participating ✨.

## How?

It's easy! Register on [Hacktoberfest](https://hacktoberfest.com/) with your GitHub account, search for issues to contribute, and send at least 4 pull requests ... After the 4th validated PR, you win the Hacktoberfest 2022 👕 or a 🌲 is planted in your name (first 40,000 participants, so get in there early!). 

To contribute to the design (a.k.a _bonita-documentation-theme_) of the Bonita documentation site:

* Check the [opened issues](https://github.com/bonitasoft/bonita-documentation-theme/issues?q=is%3Aissue+is%3Aopen+label%3Ahacktoberfest+) available for Hacktoberfest.
* Find one that you are interested in and which is not already assigned to someone.
* Post a comment to mention you are willing to work on this topic. We will acknowledge and will assign it to you to inform the world!
* Work on a Pull Request. Ask any question if you are blocked or you need more details to complete your task.
* Submit your Pull Request. We will review it quickly and will work with you to ensure it is merged and visible on the documentation site

We are looking forward to your contributions 👋!
NestJS Micro-services 101 Part 1 - Try to communicate btw two services
Tags: microservices, nestjs, javascript, rabbitmq
Published: 2022-10-01 16:50:05

I try to learn NestJS Framework to make micro-services

## Objective in Part 1
send simple message from one service to another service

```bash
// Project 1 api-gateway
nest new api-gateway

// Project ที่ 2 user-service
nest new user
```
---
User Request (http://localhost:3000) -> API Gateway -> User

---
Difference btw bootstrap in `api-gateway` and `user`

api-gateway `main.ts`
![api-gateway](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4b59it9jxalrl84cotsx.png)

user `main.ts`
![user](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3xzvawff44t2aqiewlth.png)

---

api-gateway service will know user service by register in api-gateway module

![api-gateway-module](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ri96oduucdgog7uuwdtb.png)

---

so you can declare user service proxy in constructor to send data into it, by
`hello` is event pattern

![user-service-send](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tl7pbp0f7imj5vlf996v.png)

---

user service controller will receive event pattern name `hello` by use `EventPattern` decorator

![user-controller](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jydd42ign4xaykhsqwd3.png)

---

So, this is response
![response](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hgysjsct5tu2fmd0sgv.png)

---

Full code [https://github.com/mossnana/nestjs/tree/microservices](https://github.com/mossnana/nestjs/tree/microservices)