teleren/devto huggingface dataset:
Day 28: Throttling
Tags: day28, javascript, 100daysofcode
Published: 2023-08-17 13:30:00


Throttling ensures that a function is executed at a certain maximum frequency, regardless of how frequently it's called. This is especially useful when dealing with functions that can be invoked rapidly, such as event handlers tied to user interactions like scrolling or resizing the window. Without throttling, these functions might overload the system and lead to performance issues.

### Benefits of Throttling:
1. **Performance**: Throttling prevents the execution of a function too many times in a short span, reducing the strain on the system and improving overall performance.
2. **Responsiveness**: By limiting the execution frequency, throttling maintains the responsiveness of your web application, ensuring it remains smooth and interactive.
3. **Bandwidth Savings**: Throttling can also be applied to network-related functions, conserving bandwidth by reducing the number of requests made to the server.

### Question
Now, let's get our hands dirty and implement a throttle function from scratch. 

```javascript
function throttle(func, delay) {
// Todo add your code
}

function expensiveCalculation(scrollPos) {
  // Perform the expensive calculations here
  console.log("Calculating for scroll position:", scrollPos);
}

const throttledCalculation = throttle(expensiveCalculation, 300);

window.addEventListener("scroll", function () {
  throttledCalculation(window.scrollY);
});
```

**Hint:** We'll use the concept of a timestamp to keep track of the last execution time.


🤫 Check the comment below to see answer.
Today I Learned... WTF, Kafka?
Tags: kafka
Published: 2023-12-04 10:37:35

---
title: Today I Learned... WTF, Kafka?
published: true
date: 2023-08-17 00:00:00 UTC
tags: kafka
canonical_url: http://aivarsk.com/2023/08/17/wtf-kafka/
---

I was reading about [offset retention](https://cwiki.apache.org/confluence/display/KAFKA/KIP-186%3A+Increase+offsets+retention+default+to+7+days) and was mentally prepared for losing consumer offsets when the consumer has been offline for 7+ days. But I realized that it’s 7+ days since the last update of offsets. This means if a topic did not receive any new message for 7+ days, there is no reason to update the offsets and they will be lost as well.

WTF, Kafka? How about the [Principle of least astonishment](https://en.wikipedia.org/wiki/Principle_of_least_astonishment)?

It’s So Over.

Ok, ok. We had [changes for consumer groups](https://cwiki.apache.org/confluence/display/KAFKA/KIP-211%3A+Revise+Expiration+Semantics+of+Consumer+Group+Offsets) but not the simple consumers. Then we had [updates for consumer groups](https://cwiki.apache.org/confluence/display/KAFKA/KIP-496%3A+Administrative+API+to+delete+consumer+offsets) to delete *some* offsets. Which lead to [a bug during rebalance](https://issues.apache.org/jira/browse/KAFKA-13636) that made my brain spin for almost a month.
GamerNet
Tags: webdev, react, vite, javascript
Published: 2023-08-17 13:16:46

## Application Overview
This application is designed to provide a platform for gamers to connect, interact, and manage their profiles within a gaming community. It offers features such as user registration, user profiles, friend lists, chat functionality, and interaction with gaming-related content.

## Core Features
* ### Profile Creation
Users are able to create an account with an email and password. Upon account creation, users can add information to a profile page, such as preferred gaming platforms, a username, timezone, and avatar.

* ### Searching and Adding Video Games
Users can select from various lists of video games displayed on the homepage, ordered by popularity, release date, etc. Users can also perform a search to find specific games. These games can be added and removed from a list of favorites that will appear on the users' profile.

* ### Adding Friends
Users can search for friends by selecting a video game. Upon doing so, a user will be taken to a page of search results, displaying all other users who have added that particular game to their favorites. Here, users are able to view profile information from the other users and send them a friend request. This page also displays details about the selected video game in more depth.

* ### Messaging
After adding friends, users are able to send and receive messages from their friends. 

## Technologies
React, using Vite as a build tool, provides a framework for the frontend and Supabase provides the services necessary for the backend. Both CSS and Tailwind were used to style the application.

## Resources
All of the data pertaining to video games in this application comes from the RAWG API [Link](https://rawg.io/apidocs).

## Development Process
This application was developed by four people over the course of roughly two weeks. Initial priorities involved establishing table relations in Supabase to make retrieving data intuitive and logical, implementing account creation and authentication, and preliminary styling. Mock data was used in all parts of the application before functionality was completed in order to accelerate the design process. Basic functionality and Supabase implementation was mostly complete by the end of the first week, as well as a visual layout. The remaining time was spent adding more functionality (friend requests, messaging), debugging, and styling the application to give it a more professional appearance.

## Final Thoughts
This application was created to demonstrate fluency in various web-development technologies, such as React, JavaScript, HTML, and CSS. Implementing backend functionality was both thorough and simplified through the use of Supabase, offering a fast and effective way to manage PostgreSQL database functionality. Developing this application provided valuable experience for all who contributed.

## Contributors
* Maxwell Conway https://github.com/MaxwellConway
* Kim Wells https://github.com/kimwells00
* Daniel Baron https://github.com/dbaron5
* Dustin Beckford https://github.com/dustinbeckford
Kubernetes (RKE2)
Published: 2023-08-17 13:08:00

This guide will help you quickly launch a cluster with default options for Rancher Kubernetes Engine

## Prerequisites

Make sure your environment fulfills the requirements. If NetworkManager is installed and enabled on your hosts, ensure that it is configured to ignore CNI-managed interfaces.

`NOTE:` For RKE2 versions 1.21 and higher, if the host kernel supports AppArmor, the AppArmor tools (usually available via the apparmor-parser package) must also be present prior to installing RKE2.

The RKE2 installation process must be run as the root user or through sudo.

## Server Node Installation

RKE2 provides an installation script that is a convenient way to install it as a service on systemd based systems. This script is available at https://get.rke2.io. To install RKE2 using this method do the following:

### 1. Run the installer
```bash
curl -sfL https://get.rke2.io | sh -
```

This will install the rke2-server service and the rke2 binary onto your machine. Due to its nature, It will fail unless it runs as the root user or through sudo.

### 2. Enable the rke2-server service
```bash
systemctl enable rke2-server.service
```

### 3. Start the service
```bash
systemctl start rke2-server.service
```

### 4. Follow the logs, if you like
```bash
journalctl -u rke2-server -f
```

## Conclusion:

The rke2-server service will be installed. The rke2-server service will be configured to automatically restart after node reboots or if the process crashes or is killed.
Additional utilities will be installed at /var/lib/rancher/rke2/bin/. 

They include: kubectl, crictl, and ctr. Note that these are not on your path by default.

Two cleanup scripts, rke2-killall.sh and rke2-uninstall.sh, will be installed to the path at:

/usr/local/bin for regular file systems

/opt/rke2/bin for read-only and brtfs file systems

INSTALL_RKE2_TAR_PREFIX/bin if INSTALL_RKE2_TAR_PREFIX is set

A kubeconfig file will be written to /etc/rancher/rke2/rke2.yaml.

A token that can be used to register other servers or agent nodes will be created at /var/lib/rancher/rke2/server/node-token
Specify Node Version in package.json
Tags: javascript, beginners, tutorial, programming
Published: 2023-08-17 13:06:17

Have you ever downloaded a project that uses javascript and wondered what version of npm or node you need to run?

Or did you need to inform the node version and didn't know where to put it?

There is a very simple and easy solution for this.

## Example

Open your package.json, add the "engines" field and specify the node version.

You can enter the version directly:
```json
{
  "engines": {
    "node": "16"
  }
}
```

And you can use semver to include specific ranges or version limits:

```json
{
  "engines": {
    "node": ">=17.0.0 <18.0.0"
  }
}
```


***

## Thanks for reading!

If you have any questions, complaints or tips, you can leave them here in the comments. I will be happy to answer!

😊😊 See you later! 😊😊

***

## Support Me

[Youtube - WalterNascimentoBarroso](https://www.youtube.com/channel/UCXm0xRtDRrdnvkW24WmkBqA)
[Github - WalterNascimentoBarroso](https://github.com/walternascimentobarroso)
[Codepen - WalterNascimentoBarroso](https://codepen.io)
Getting started with building in public
Tags: newbie, opensource, webcomponents, beginners
Published: 2023-08-17 12:42:30

I have always been shy to show off what I am learning or creating in public because I thought it wasn't of quality and worthy to be seen by others. This is the mindset I had until I came across the concept of **Building in Public**. Building in public involves sharing your process of learning, creating, or problem-solving openly with a community or audience. One good thing is that it doesn't have to be perfect. Here are the basic things I did to get started:

**- Accept the Learning Process:**I came to understand
that learning is a process, and it's okay to be a  novice in the journey. So take Every challenge and mistake as valuable learning opportunity.

**- Set Achievable Goals:** I had defined goals for building in public. You could be aiming to learn a given programming language, be accountable, share what you have learnt in a previous course or contribute to open-source projects. Go from small to big goals 

**- Select a Platform:** Pick a platform to share your progress,this could any of the social media platforms or even an online community.

**conclusion:**
I believe you are good to go once you have these. Just start sharing. Remember to be consistent, be open to feedbacks, encourage others.In all, have fun; enjoy the process, connect with like minds, and learn. Celebrate your wins and enjoy the process of growth.
A Beginner’s Guide to Chrome Extension Development
Tags: javascript, extensions, web, webdev
Published: 2023-08-17 12:39:36

In the ever-evolving digital landscape, where web browsers have become the gateway to our online experiences, the role of browser extensions has grown immensely. Chrome extensions, in particular, have gained prominence for their ability to enhance and customize the browsing journey. In this extensive guide, we will delve deep into the world of Chrome extension development, providing you with a comprehensive understanding, detailed steps, and hands-on code examples to empower you to create powerful and tailored browser enhancements.
[Read more...](https://amlogy.com/chrome-extension-development/)
JavaScript is Extraordinarily Weird! Hear Me Out! 👨‍💻📢🔥
Tags: javascript, programming, node, learning
Published: 2023-08-17 12:28:35

Last night, I found an interesting JavaScript question, and I bet you won't be able to answer this without cheating.

### What do you think is the output of this code snippet?
Let me know in the comments!

```js
("b" + "a" + + "a" + "a").toLowerCase()
```

The Options are given as following
- baaa
- ba01100001a
- baa
- ba1a

The question does look simple, but the answer will definitely blow your mind.

Did you get any of these? The interesting thing is - all the options provided above are wrong!

![Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrlkb5jxx8pueu8hgigh.gif)

Answer in 5.

4.

3.

2.

1.

and...

### The answer is **_"banana"_**

> JAVASCRIPT IS JUST CRAZY 🤐🔥

Before you get freaked out and ask me "Are you mad?", let me tell you this is the reason why _"JavaScript is Extraordinarily Weird"_. You see its beauty lies within its complexity!

### Working
Let's break down the code step by step to understand WHY!:

- `"b" + "a"` concatenates the strings resulting in `"ba"`.

- `+ + "a"` is trying to convert the string `"a"` to a number and then concatenating it with the above string `"ba"`. Since `"a"` is not a valid numeric representation, the result of this conversion is `NaN` ("Not-a-Number").

- `"ba" + NaN` concatenates the string `"ba"` with the value `NaN`, resulting in the string `"baNaN"`.

- `"baNaN" + "a"` concatenates the string `"baNaN"` with the string `"a"`, resulting in the string `"baNaNa"`.

- `.toLowerCase()` is then called on the string `"baNaNa"`. This method converts all characters in the string to lowercase, which further results in the string `"banana"`.

So, the final output of the code is "banana".

Tell me how long it took you to answer this simple question in the comments!
What are your plans for AI?
Tags: ai
Published: 2023-08-17 12:24:32

AI is going to change everything.  What are your plans for it?

When consulting businesses, this is one of the questions I love to ask.  It starts a conversation around how it might disrupt their industry and leads to a brainstorming session on what opportunities we see for leveraging AI to create a competitive advantage.  

“Identify a talent or a need, produce the product, shepherd it to market, monitor it and pivot when necessary, has been the common theme through my career… The idea of identifying talent or trends, seeing where things are going and looking for the opportunity that your skill set meets has been consistent for me and I have been able to feed my family for the last 30 years.” - Don Donahue 

ref: Thriving in the Face of Dsruption (with Don Donahue), The Accidental Creative Podcast Aug 14.
Discover Simplicity and Fun in Tech with Dev Hots on LinkedIn!
Tags: news, webdev, programming, computerscience
Published: 2023-08-17 12:19:56

I'm thrilled to share some exciting news with you all. Drumroll, please… 🥁 I've launched a brand new LinkedIn page called [Dev Hots](linkedin.com/company/devhots/) and We can't wait for you to join me on this tech-filled adventure! 🚀

### What's the Big Idea?

Ever felt lost in a sea of tech jargon? Trust me, I've been there too. That's why I've created Dev Hots – a place where we break down all those complicated tech terms into simple way possible. We're talking about everything from computers to websites and all the cool stuff in between.

### Why You Should Click That Follow Button?

#### 🌟 Stay in the Know
Let's face it, the tech world changes faster than you can blink. But fear not! By following [Dev Hots](linkedin.com/company/devhots/) on LinkedIn, you'll always be in the loop about the latest and greatest tech trends. No more feeling left behind!

#### 🧠 Tech Learning, Minus the Confusion
Have you ever tried reading a tech article and thought it was written in a different language? I'm here to translate all that tech mumbo-jumbo into plain and simple English. Learning about tech should be exciting, not overwhelming!

#### ⏱️ Fits Your Schedule
Life can get pretty busy, right? That's why I'm committed to delivering bite-sized tech goodness. Whether you've got a few minutes during your coffee break or a longer chunk of time, you can dive into tech learning at your own pace.

### Exciting News: Our Upcoming Newsletter on LinkedIn!

But wait, there's more! 💌 We're taking things to the next level with our upcoming newsletter. Imagine getting a dose of tech awesomeness right in your inbox. It's like having a tech-savvy friend who's always ready to share the latest and greatest in the tech world.

### Let's Get Connected on LinkedIn!

I'm inviting you to be a part of this awesome tech-loving community on LinkedIn. Just hit that **Follow** button on the Dev Hots page, and you'll unlock a treasure trove of fun and informative post and short articles. 



🔗 [Follow Dev Hots on LinkedIn](linkedin.com/company/devhots/)

So, are you ready to dive into the world of tech simplicity and fun? Let's learn, share, and connect on LinkedIn. And get ready for our upcoming newsletter – it's going to be tech-tastic!

Stay curious and tech-happy.

We have launched a new repository [CodeGlossary](https://github.com/devhots/CodeGlossary). You can contribute to it and give it a ⭐.
{% github https://github.com/devhots/CodeGlossary %}

To know more about CodeGlossary: [Click Here ](https://dev.to/j471n/introducing-codeglossary-your-go-to-resource-for-programming-terminology-22ml)
Adding Material-UI to Your React Project
Tags: uidesign, react
Published: 2023-08-17 12:02:41

1.Install Dependencies:
Open your terminal and navigate to your project directory. Run the following command to install Material-UI along with required dependencies:

```
npm install @mui/material @emotion/react @emotion/styled
```
If you prefer using styled-components, you can use the following command instead:

```
npm install @mui/material @mui/styled-engine-sc styled-components
```
2.Configure Peer Dependencies:
In your package.json file, add the following peerDependencies to ensure compatibility:

```
"peerDependencies": {
  "react": "^17.0.0 || ^18.0.0",
  "react-dom": "^17.0.0 || ^18.0.0"
}
```
3.Using Material-UI Icons:
Material-UI also provides a wide range of icons to enhance your application's visual appeal. To include these icons in your project, use the following command:

```
npm install @mui/icons-material
```
4.Using Material-UI Components:
With Material-UI installed, you can begin using its components to craft your user interfaces. Import components like buttons, text fields, and more as needed, and integrate them into your React application.

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

Output:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0mofycufki7aoeyoxvib.png)
PSQL - Superset - k8s
Published: 2023-08-17 11:59:55

What privileges are necessary for an Apache Superset user for configuring Superset? 

Specifically, I'm interested in establishing a read-only user within PostgreSQL. This user should have the capability to connect to the database through Superset and obtain read-only access. Importantly, this user should not possess the ability to perform actions like dropping or truncating tables.
Setup React with Vite
Tags: webdev, javascript, tutorial, react
Published: 2023-08-17 11:44:42

Hello guys and tech enthusiasts,
Recently I setup React with Vite. But I could only run it once the setup was over, and after I restart my vscode now I cannot run it, I dont know which port it works and besides it, I create a new component file inside src folder and imported it inside App file but no result on the browser. So please guys just help me on how to start my own project once I setup react with vite and delete the default code inside App.jsx, what must be the next step? And what is the main file I should run in order to get the result on browser, I am completely new with vite.
Java Programming intelliJ Basics (AND , OR operator)
Tags: java
Published: 2023-08-17 11:42:49

## AND operator:
The && (AND) operator returns true, only if **both** the expressions are true, and returns false otherwise.
`Example code: True condition`

``` 
public class SecondClass {

    public static void main(String[] args) 
    {
    int TopScore = 100;score = 90;

        if ((score == 90) && TopScore == 100)
        {
            System.out.println("the score is 90 and 100");
        } else {
            System.out.println("The score is not 90 and 100");
        }
```
In the above code, the variable name **_TopScore_** is assigned to 100 and the variable name **_Score_** is assigned to 90, in which both the conditions are true, so it returns the output as **the score is 90 and 100**. Suppose if the any one of the condition doesn't match, it prints the statements which are written in else block, which is **the score is not 90 and 100**.

`Example code: False condition`

```
public class SecondClass {

    public static void main(String[] args) {

    int score = 90;

    int TopScore = 100;

        if ((score != 90) && TopScore == 100)
        { 
            System.out.println("the score is 90 and 100");
        } else {
            System.out.println("The score is not 90 and 100");
        }
```

## OR operator:
The || (OR) operator will result in true, if any **one** of the condition is true.

`Example code`

```
public class SecondClass {

    public static void main(String[] args) {

    int TopScore = 100;
    
    int HighScore = 150;

        if ((TopScore != 100) || (HighScore == 150))
        {
            System.out.println("the score is 150");
        } else {
            System.out.println("the score is 100");
        }
```
In the above code displayed, the variable _**TopScore**_ is set to 100 and the variable **_HighScore_** is set to 150. Here the first condition ,**_TopScore_** is not equal (!=) to 100. which is false, so it produces the output as **the score is 150**.or if the second condition, which is **_HighScore_** is equal to 150 is matched, then it results in **the score is 150**. In simple words, it checks whether any **one** of the condition is true and produces the output.
My Experience with a Top-Notch Law Assignment Writing Service
Tags: lawassignmenthelp, lawassignment, lawassignmentwriting, lawassignmenthelper
Published: 2023-08-17 11:31:47

Greetings, students!

I simply wanted to share my most recent experience with an outstanding **[law assignment writing service](https://phdlawwriters.com/law-assignment-writing-help/)** of O'Connor-PhDLawWriters that significantly impacted my academic career! As we are all aware, managing numerous assignments, tests, and daily obligations can be challenging. This outstanding service saved me in that situation.

When I first contacted them, their staff was helpful and sympathetic to my needs. They matched me with a talented writer who was well-versed in legal ideas and paid close attention to detail.

The degree of personalisation they provided was what I found to be most impressive. I could talk with my designated writer about the details of my assignment, exchange papers and notes, and even brainstorm ideas. It appeared to be a genuine team effort.

Excellent writing was used throughout. The information was thoroughly researched, logically organised and written authoritatively. It was clear from the writing that the author was knowledgeable about the subject and skilled at explaining complex concepts.

Their dedication to deadlines was another factor that distinguished out. We understand the need for timely submissions as students; this service did not disappoint. They sent my job well beforehand, giving me time to review and make changes.

The reasonable prices were the natural cherry on top, though. Budget is usually an issue for students. Therefore I was pleasantly surprised by their affordable prices. Finding an affordable service without sacrificing quality is such a relief.

In conclusion, I heartily recommend trying this writing service if you're having trouble with your law assignments and need some assistance. They have consistently surpassed my expectations, and I do not doubt they will do so for you. Congratulations to their team for reducing stress and making academic life much more manageable!

Best wishes
Frederick Wilson