teleren/devto huggingface dataset:
Vector Databases for Data-Centric AI (Part 2)
Tags: programming, nlp, machinelearning, opensource
Published: 2022-08-26 13:36:00

Building applications with QDrant, Hugging-Face and Streamlit.

This article also lives here:
* https://medium.com/@george.pearse

QDrant have created an excellent vector database and I suspect ML Engineers are only beginning to scratch its potential applications.

Vector databases support hybrid similarity search and provide a CRUD API to run updates to your datasets. They are a significant improvement upon first-wave Approximate Nearest Neighbour tools like Faiss and Annoy which enable very high performance in-memory vector search but little in the way of support for update flows, nor metadata filters.

> Hybrid search is vector or "semantic" search combined with attribute filtering.

The semantic search implemented by QDrant requires a list of positive and negative examples. Each positive datapoint is an example of what you want the responses to be similar to, each negative datapoint is an example of what you want the responses to be different to.

This allows you to build up arbitrarily complex decision boundaries within your feature space.
An example QDrant query:

```
{"positive": [0],    
"negative": [1],    
"top": 10,   
"with_payload": true}
```

**This enables the interactive definition of classes**:

1. Start with a single positive datapoint.
2. Look through the responses.
3. Add those that you consider to be similar to the list of positives
4. Add those you consider to be different to the list of negatives
5. Run that new query, and repeat.

After a batch of labelling you would also be in a position to improve your embeddings and continue the process with a 'better' separated dataset (I'll be experimenting more with this next).

I've built a mini Streamlit application to support this flow and enable you to save each query once complete along with a CSV containing its results.


## QDrant-NLP. A short demo

{% embed https://vimeo.com/743387784 %}

## How to Run

Just clone the repo [QDrant-NLP](https://github.com/GeorgePearse/QDrant-NLP)
and run:
`docker-compose up
`
I would like to increase the number of datasets this can be tried on, either with GPU backed lambda functions or by saving many example datasets to S3. So far I've only made a 6K subset of ag_news available. ag_news · Datasets at Hugging Face
This is the code snippet used to generate the embeddings via hugging-face:

The embeddings were generated with this code snippet. 

{% embed https://gist.github.com/GeorgePearse/e0949fb4dac9008169c6969e866615a4 %}

## Where to Use
Shout out to both Kern.AI (an excellent open-source NLP labelling tool)
https://github.com/code-kern-ai/refinery
and Voxel51 (an excellent open-source Computer Vision analysis tool)
https://github.com/voxel51/fiftyone
for being early adopters of the technology in their platforms, but I don't believe either have yet made use of all of the value it can provide.
Using the embeddable Pricing Table to build a pricing page
Tags: stripe, saas, payments, webdev
Published: 2022-08-26 13:32:03

{% youtube https://www.youtube.com/watch?v=tY8fVEoPHIc %}

## What you’ll learn

In this episode, you'll learn about the brand new [embeddable pricing table](https://stripe.com/docs/payments/checkout/pricing-table). Now you can configure a pricing page directly from the Stripe Dashboard, copy a snippet and paste it into any site that supports HTML embeds. Building a SaaS app has never been easier. We'll look at a few no-code and low-code examples, then dive deeper to see a full integration with a Ruby on Rails application.

**Topics**:
([00:53](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=53s)) Review and update Products and Prices
([01:12](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=72s)) Update the feature list for Product
([02:33](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=153s)) Create a pricing table
([05:50](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=350s)) Copy the embeddable widget into codepen, bubble, and typedream
([07:33](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=453s)) Integrate the pricing table with Ruby on Rails
([09:33](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=573s)) Associate pricing table with current user using client-reference-id
([11:17](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=677s)) Review webhook automations
([13:37](https://www.youtube.com/watch?v=tY8fVEoPHIc&t=817s)) Integrate the customer portal


## Who this video is for

This video guide is primarily for developers new to Stripe, but developers familiar with Stripe might learn some new things as well. This is a great video for learning how to create a pricing page using the embeddable pricing table.

## How to follow along

If you want to work alongside the video, you’ll need a [Stripe account](https://dashboard.stripe.com/register) and a Ruby on Rails environment to work in. 

## Resources
- [Embeddable pricing table for SaaS businesses](https://stripe.com/docs/payments/checkout/pricing-table)
- [Code for this episode](https://github.com/cjavilla-stripe/saas-rails-pricing-table/blob/main/app/views/pricings/show.html.erb)

## What to watch next
- [SaaS in a Tweet - Payment Links and the no-code customer portal beta](https://www.youtube.com/watch?v=gA2Fla6mvWQ)


## Stay connected

**You can stay up to date with Stripe** **Developer updates** **in a few ways:**

- 📣Follow [@StripeDev](https://twitter.com/stripedev) and [our team](https://twitter.com/i/lists/1459720002567868418) on [Twitter](https://twitter.com/StripeDev)
- 📺 Subscribe to our [Youtube channel](https://www.youtube.com/StripeDevelopers)
- 💬 Join the official [Discord server](https://discord.com/invite/RuJnSBXrQn)
- 📧 Sign up for the [Dev Digest](https://go.stripe.global/dev-digest)
[ ازاي تكون مهندس برمجيات جامد ]
Published: 2022-08-26 13:31:40


‏‎ازيكم يا شباب .. في شباب كتيرة كلمتني عن الموضوع دا .. عشان تكون ديفلوبر شاطر زي ما قال الكتاب .. انا بشوف ٣ نقط مهمة جدا .. مبديًا الكلام دا مش عشان تعدي انترفيو شركة وتشتغل .. الكلام دا لو عايز تبقا شاطر ومتمكن .. بسم الله:

اول نقطة هي ‏‎ال computer science knowledge .. هنا انت مطلوب منك تكون ملم بمواضيع ال software engineering بشكل عام:

- اتعلم اي لغة برمجة واتعلم من خلالها مبادئ البرمجة بشكل عام واللي هي ثابتة وهتفيدك في كل اللغات.

- اتعلم ال OOP ومبادئه كويس.

- ‏‎اساسيات ال database بشكل عام ولو عايز الليفل الحلو اوي شوف ال file structure وازاي الدنيا بتشتغل جوا كمان.

- افهم المصطلحات العامة في ال software engineering زي ال layering وال hashing وال cloud وال caching وال modularity وال concurrency وال library وايه الفرق بينها وبين ال framework وال IDE وال principle وال pattern وال platform والحاجات دي كلها .. حاول تعمل سيرش عن software engineering keywords وتفهم المصطلحات دي هتساعدك في ال communication وتوضيح افكارك كويس.

- اتعلم data structures واعرف انواعها والفرق بينهم وتستخدم ايه امتي.

- اتعلم algorithms واعرف كل algorithm بيحل مشكلة ايه وايه ال trade off لكل واحد فيهم .. يعني هو كويس في ايه وايه ال side effects ليه .. لان في حاجات بتكون اسرع واحسن في الاعداد الاصغر بغض النظر إنها أبطأ في العموم.

- مارس شوية problem solving بحيث تعود نفسك علي التفكير وازاي تستخدم معرفتك بال data structures وال algorithms في كود معين.

- اقراء عن ال SDLC وخطوات بناء ال software.

- اتعلم clean code والقواعد العامة لكتابة كود كويس.

- اقراء عن ال ١٢ مبدأ لل agile وتطبيقهم في framework معينة زي ال scrum مثلا وازاي الادوار بتكون متقسمة في الفريق ودور كل واحد.

- اتعلم version control وازاي تقدروا كفريق كامل تشتغلوا مع بعض .. شوف ال git workflows وكل workflow بيستخدم امتي .. في كورس علي coursera من atlassian بيتكلم عن ال git version control روعة.

- افهم ال SOLID لانهم بياثروا في اي كود وبيخلوك تقدر تعرف الكود بتاعك دا صح ولا غلط .. اي نقاش بدخله بركز هل الكود بيعمل violation للمبادئ دي ولا لا.

اخر واحد فيهم ال dependency inversion principle وكلمة principle هنا معناها ان دا الصح لكن مبيقولش ليك تعمله ازاي عشان كده في pattern بيشرح طريقة تطبيق المبدا دا وهو ال inversion of control ودا ليه كذا implementation زي ال dependency injection وال service locator .. حبيت اذكره بالتحديد عشان فيه لغبطة علي النت كتيرة اوي.

- اعرف يعني ايه CI/CD وايه علاقتها بال unit testing وليه هي مهمة اوي كده في كل الشركات الكبيرة.

- اقراء عن ال design patterns وانواعها والفرق بينهم وبين ال architecture patterns.

- ازاي تتعامل مع كود موجود .. دي مهارة قوية جدا جدا ممكن تطورها .. انا مرتبي بقا الضعف في شركة قديمة عشان بس قدرت احل مشكلة في ال payment مكنش حد عارف يتعامل في الكود نهائيا .. مش كل مشروع لازم انت تبدا فيه من الصفر لان دا مش وارد خالص في الشركات الكبيرة.

يارب اكون وضحت النقط المهمة وياريت لو نسيت حاجة .. تكتبوها في الكومنتات .. بالتوفيق.

#سوق_البرمجة_في_مصر
Handling errors: best practices?
Tags: beginners, discuss, help, codenewbie
Published: 2022-08-26 13:30:41

I'll often find myself having to handle a few api calls, and I'm not really sure what the best error handling practices are.

Below is an example of a pattern I find myself writing a lot — treating throws like returns and allowing the errors to "bubble up."

Generally, it works for me, but I'm not sure if there is a better way to handle them. Or some standard practices.

Any advice or thoughts would be appreciated!

```js
async function someApiReq(id) {
  try {
    const resp = fetch('https://foo.com/api' { body: JSON.stringify(id) });
    if(!resp.ok) throw resp;
    return await resp.json().data
  } catch(e) {
    if(e instanceof ApiError) {
      throw e.apiMessage
    }
    throw e
  }
}

async function someOtherApiReq(id) {
  try {
    const resp = fetch('https://bar.com/api' { body: JSON.stringify(id) });
    if(!resp.ok) throw resp;
    return await resp.json().data
  } catch(e) {
    throw e
  }
}

(async () => {
  try {
    const id = 1;
    const data = someApiReq(id);
    const otherData = someOtherApiReq(data.id);
    console.log(otherData);
  } catch(e) {
    console.error(e)
  }
})();
```
Setup your M1 MacBook Pro for .NET and iOS development
Tags: dotnet, ios, devjournal, productivity
Published: 2022-08-26 13:28:03

In this article we will look on how we can step up an M1 MacBook Pro for development.

You can watch the full video on YouTube
{% embed https://youtu.be/HFPRL-OZDK8 %}

To get started after the initial setup of the laptop the main items that I change from the configuration are the following 

- Finder ⇒ Show Status Bar
- Finder ⇒ Show Path Bar
- Customise Toolbar ⇒ add the New folder
- Dock & Menu Bar customisation ⇒
    - make it smaller
    - show hide
    - remove spotlight from menu bar

Once that is done, the next step is installing the IDEs that I would be using on daily basis.

- Rider (https://www.jetbrains.com/rider/)
- Xcode (https://developer.apple.com/xcode/)
- VSCode (https://code.visualstudio.com)

Next we need to install the Dev Tools

- Docker (https://docs.docker.com/get-docker/)
- Homebrew (https://brew.sh)

Now that we have installed homebrew we can utilise it to install the rest of the packages/apps that we need
- iTerm (https://formulae.brew.sh/cask/iterm2)
   - oh-my-zsh (https://ohmyz.sh)
   - Powerlevel10k (https://github.com/romkatv/powerlevel10k#oh-my-zsh)
- rectangle (https://formulae.brew.sh/cask/rectangle)
- git (https://formulae.brew.sh/formula/git#default)

Now its time for some cloud CLIs
- azure-cli (https://formulae.brew.sh/formula/azure-cli#default)
- awscli (https://formulae.brew.sh/formula/awscli#default)

Next step if you are a web developer you will need to have all major browsers installed to test your code

- Microsoft Edge (https://formulae.brew.sh/cask/microsoft-edge#default)
- Firefox (https://formulae.brew.sh/cask/firefox#default)
- Google Chrome (https://formulae.brew.sh/formula/chroma#default)

Being .NET dev we need to have the .NET sdk installed and since .NET 6 support ARM architecture natively, this is what we will be using.
- .Net SDK https://formulae.brew.sh/cask/dotnet-sdk#default

If you build API's or deal with API's you will need a tool which will allow you to test, group and utilise all endpoints any of the below should be fine

- Insomnia (https://formulae.brew.sh/cask/insomnia#default)
- Postman (https://formulae.brew.sh/cask/postman#default)

If you have any suggestion or other applications that you use please mention it in the comments down below.
python
Published: 2022-08-26 13:24:21

من الحاجات اللي ساعدتني جدا في اني احسن من نفسي في problem solving علي leetcode
هي اني اتعلمت الاساسيات كويس و بعدين طبقت عليها كتير بايدي
الاساسيات هي :
loops
conditions
functions
lists
variables
data types
dictionary

لو حد هنا لسه هيبدأ انا برشح لغة python لانها من اللغات السهلة اللي ممكن تبدأ بيها و ليها مصادر كتير ممكن تتعلم منها و دا لينك القناة اللي اتعلمت منها https://lnkd.in/ehcGWPcu


و بعد ما حليت كتير علي الأساسيات بدأت اذاكر data structures و algorithms و احل عليهم و دي ال links اللي ذاكرت منها

https://lnkd.in/edJhZtAH
https://lnkd.in/eeC5gjr5

و لو انت عندك انترفيو و محتاج تجهزله اللينك دا هيفيدك جدا اللينك في ١٥٠ مسألة بافكار مختلفة بالحل بتاعها

https://neetcode.io/

و لو حد عنده resources ممكن استفاد بيها ممكن يحطها في كومنت


#datastructures #algorithms #problemsolving #leetcode

Codezilla - YouTube
Build an Awesome Barber Website Using HTML CSS JavaScript
Tags: css, javascript, beginners, tutorial
Published: 2022-08-26 13:09:18

{% youtube pIgMTd8ZFxY %}

Build an Awesome Barber Website Using HTML CSS JavaScript

This video will show you how to build an awesome barber website using html css javascript

[Github Repo](https://github.com/codewithsadee/barber)

---

HI 👋
I'm Sadee (webdev)
In this channel I make videos about Complete Responsive website.
You can checkout my channel 👇

📺 My Channel : [codewithsadee](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g)
🔔 Subscribe : [subscribe now](https://www.youtube.com/channel/UC1PZHWV6VvICTL1LgFUZq6g?sub_confirmation=1)

---

🔗 Essential links
-----------------------------
[Download the starter file to practice](https://drive.google.com/file/d/11-IE4NRxbcKMHiCXm4IE4fdBY8tQqSa0/view?usp=sharing)

---

⏱️ Timestamps
-----------------------------
0:00 - Demo
5:47 - File structure
6:20 - Project initial
13:00 - Header
31:13 - Hero section
38:58 - Service section
46:47 - Pricing section
1:07:50 - Gallery section
1:16:05 - Appointment section
1:30:09 - Footer
1:53:29 - Media queries

---

[![Become a patreon](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fnjl14kdm5qf08hu5lop.png)](https://www.patreon.com/bePatron?u=62535867)
All Device Repair Service Center, USA
Published: 2022-08-26 13:07:04

You are presumed to have fully accepted this notice if you visit any portion of the website. You must leave the website right away if you do not agree to this notice in full.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a78anlgf5ixhdt1m471.png)
In the US, CA, and the UK, The [Repair Service Center ](https://www.repair-service-center.com/)is an independent third-party business that offers top-notch repair and maintenance services for numerous brands and manufacturers. We are not affiliated with any corporation or brand name.



Our goal is to provide the best repair, maintenance, and equipment correction services possible by identifying problems and resolving technical difficulties with a wide range of products from different manufacturers, including printers, laptops, computers, Mac devices, etc., using our knowledgeable and skilled technicians. By keeping them updated, we hope to improve the customer's experience using gadgets.
How to Install Docker on Raspberry Pi 4 with Raspbian Buster
Tags: docker, raspberrypi, linux
Published: 2022-08-26 13:07:00

This is a simple guide to creating a [Docker](https://www.docker.com/) development environment with your [Raspberry Pi 4](https://www.raspberrypi.org/).

This has been tested on a _Raspberry Pi 4 Model B Rev 1.1_ using _Raspbian Buster_.

You can check your Raspberry Pi model by running the following command in the Raspberry Pi terminal:

```
cat /proc/cpuinfo
```

![Check cpu info in raspbian](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jcmmzxxe8760x1huxjim.png)

You can also check your Raspbian OS version by running the following command in the Raspberry Pi terminal:

```
cat /etc/os-release
```

![Check OS info in raspbian](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ktzvmljaftsnq3gltbj.png)

---

## Steps

1. Install Docker

```
curl -sSl https://get.docker.com | sh
```

2. Install dependencies

```
sudo apt-get install -y python python-pip

sudo apt-get install libffi-dev libssl-dev
```

3. Add permissions for Pi User to run Docker Commands

```
sudo usermod -aG docker $USER
```

4. Install Docker Compose

```
sudo pip install docker-compose

```

5. Test Docker installation

```
docker run hello-world
```

_Note: you might need to restart your Raspberry Pi to use docker without sudo persissions._

![docker hello-world](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hzssqt862k9429lmxjf.png)

If the installation was completed successfully, you will get the "Hello from Docker!" message. You can then check out [Docker Hub](https://hub.docker.com/search?q=&type=image&architecture=arm) for _arm_ based images to run on your Raspberry Pi.
𝗡𝗼𝗱𝗲 𝗩𝗲𝗿𝘀𝗶𝗼𝗻 𝗠𝗮𝗻𝗮𝗴𝗲𝗿 for macOS
Tags: javascript, node, programming
Published: 2022-08-26 13:02:07

𝗡𝗼𝗱𝗲 𝗩𝗲𝗿𝘀𝗶𝗼𝗻 𝗠𝗮𝗻𝗮𝗴𝗲𝗿:
NVM (Node Version Manager) is a shell script used for installing and managing Node.js. Node version manager is primarily used to develop node applications in different versions.

𝗣𝗿𝗲𝗿𝗲𝗾𝘂𝗶𝘀𝗶𝘁𝗲:
macOS users can install NVM via homebrew as it’s the most recommended approach, once installed you can go ahead and install NVM on your macOS

𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀:
brew install nvm

It is required to create a directory and register it in our .zshrc

nvm)/nvm.sh" >> .zshrc
source ~/.zshrc

𝗣𝗼𝘀𝘁 𝗜𝗻𝘀𝘁𝗮𝗹𝗹𝗮𝘁𝗶𝗼𝗻:
After that you can use nvm -v to show the version of nvm you have installed.

𝗚𝘂𝗶𝗱𝗲:
We've followed this guide while configuring nvm on our Mac, I hope it'll cover the purpose.
[https://medium.com/devops-techable/how-to-install-nvm-node-version-manager-on-macos-with-homebrew-1bc10626181
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dj5l2r7gkncrrzxry3qz.png)](https://medium.com/devops-techable/how-to-install-nvm-node-version-manager-on-macos-with-homebrew-1bc10626181)

Thank you for stopping by and feel free to drop a link to a resource you thought more useful!

:: Follow me on linkedin [https://www.linkedin.com/in/imhamad/](https://www.linkedin.com/in/imhamad/) and here to stay updated with more engaging content.
tsParticles 2.2.4 Released
Tags: javascript, typescript, webdev, showdev
Published: 2022-08-26 12:49:00

## tsParticles 2.2.4 Changelog

### Bug Fixes

- Fixed issue on container guard check, fixes #4679

---

## Social links

- [Discord](https://discord.gg/hACwv45Hme)
- [Slack](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI)
- [Telegram](https://t.me/tsparticles)
- [Reddit](https://www.reddit.com/r/tsParticles/)

---

{% github matteobruni/tsparticles %}
Best operating system for programmer or tester - part 1
Tags: beginners, programming, windows, os
Published: 2022-08-26 12:47:52

When you only start your way to becoming professional programmer or tester you might not know which operating system you should use.

Would it make sense to "follow the mob" and use Apple laptops, as other "cool developers" do?

Or perhaps you should do it hard way and try Linux instead?

Or maybe Windows isn't that bad after all?

In today's video I am exploring all pros and cons of Windows, but there're going to be videos on Mac and Linux as well

https://youtu.be/YqoAi5XvTtw
[Redis Hackathon Submission Post Placeholder Title]
Tags: redishackathon
Published: 2022-08-26 12:20:52

[Instructions]: # (To submit to the Redis Hackathon on DEV, please fill out all sections. DELETE ALL NOTES, reminders, and guidelines before publishing.)


### Overview of My Submission
[Note]: # (Share what you built, how you built it, and the inspiration behind the idea! Please make sure the project links to the appropriate GitHub repository, and includes the [MIT](https://choosealicense.com/licenses/mit/), [Apache](https://www.apache.org/licenses/), [BSD-2](https://opensource.org/licenses/BSD-2-Clause), [BSD-3](https://opensource.org/licenses/BSD-3-Clause), or [Commons Clause](https://commonsclause.com/) license and a README.)


### Submission Category: 

[Note]: # (Select between Minimalism Magicians, Microservice Mavens, MEAN/MERN Mavericks, Wacky Wildcards – Descriptions of requirements listed in the announcement post.)

### [Optional: Video Explainer of My Project]

[Note]: # (This is where you can embed the optional bonus video you created to accompany your submission. Ensure your video is published publicly to YouTube and you’ve used the embed tag here to share it with us. By opting to include a video, you will be eligible for BONUS prizes. Learn more in the announcement post.)

### Language Used
[Note]: # (Select the language you used for your project – must be one of the following: C#/ASP.NET Core, Java/Spring, JS/TS/Node.js, Python)


### Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% embed link_to_your_repo %}` to share a GitHub repository)

BTW, your Github code’s README file should contain the details as [per this template](https://github.com/redis-developer/hackathon-docs/blob/main/README.md).

### Additional Resources / Info

[Note:] # (Be sure to link to any open source projects that are using your workflow!)

[Note:] # Screenshots/demo videos are encouraged!

### Collaborators

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any. Prizes for winning projects with multiple collaborators will be sent ONLY to the person who posts this submission and they will distribute the prize evenly.)

[Note]: # (All collaborators with DEV profiles listed here will receive a badge, however, prizes including sticker packs will only be sent to the member who publishes the post, with the person expected to distribute the prizes evenly amongst their collaborators.)

[Reminder]: # (Submissions are due on August 29th, 2022 @ 11:59 PM UTC).

- - - 

[Note]: # (Please ensure  that the footer content below is part of your post when publishing. Please delete this note in parentheses but do not delete the content below.)


* _Check out [Redis OM](https://redis.io/docs/stack/get-started/clients/#high-level-client-libraries), client libraries for working with Redis as a multi-model database._
* _Use [RedisInsight](https://redis.info/redisinsight) to visualize your data in Redis._
* _Sign up for a [free Redis database](https://redis.info/try-free-dev-to)._
learn sliding window algorithm easily in Hindi | maximum sum subarray of size k with sliding window
Tags: javascript, beginners, tutorial, programming
Published: 2022-08-26 12:18:03

{% youtube Omq50xmSi4w%}
in this video i have explained how to learn sliding window algorithm easily in **Hindi**

for those of you who don't want to watch video here is the code:

```js
//find the maximum sum of size ‘k’ consecutive elements in the array.

let a = [4, 2, 3, 5, 1, 2];
//       0  1  2  3  4  5
let n = a.length; // 6
let k = 3;

let maxSum = -Infinity;
let windowStart = 0;
let windowSum = 0;

for (let windowEnd = 0; windowEnd < n; windowEnd++) {
  windowSum = windowSum + a[windowEnd];
  if (windowEnd - windowStart + 1 == k) {
    maxSum = Math.max(maxSum, windowSum);
    windowSum = windowSum - a[windowStart];
    windowStart++;
  }
}

console.log(maxSum);
```