teleren/devto huggingface dataset:
Manual DOM Rendering with JavaScript vs. React's Virtual DOM
Tags: webdev, javascript, react, programming
Published: 2024-07-03 17:43:12

## Introduction
This documentation explains how to manually create and render DOM elements using plain JavaScript. We will cover the implementation of a custom rendering function and its comparison to how JSX is processed in React.

**creating a custom render function**
we created a customRender function which takes two parameters 
  1. `imgTag` : object which specifies the property
  2. `root` : parent element where the element is to be appended

Inside function definition we created img tag and added attributes to it 
and in the end we appended it in the root div 

- overall we made the manually created the DOM and rendered it on the web page  

## manual insertion

```
let imgtag = {
    type:'img',
    props:{
        src:'https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png',
        alt:'image of google'
    }
}
function IMGrender(imgtag,root){
    let div = document.createElement(imgtag.type)
    for (const key in imgtag.props) {
        if(key === "children") continue;
        div.setAttribute(key,imgtag.props[key])
    }
 
    root.appendChild(div)
}

IMGrender(imgtag,root)
```

## Comparison to React
The customRender function manually performs tasks that React handles automatically when processing JSX. React uses a virtual DOM to efficiently manage and update the actual DOM.

 - here in react we can use JSX to make a component (html tags) which 
   later get converted into the object like a object in a customRender   
   function 

**Vite uses esbuild as its bundler to parse JSX code into JavaScript objects (AST - Abstract Syntax Tree).**

## using react

```
import React from 'react'
import ReactDOM from 'react-dom/client'
function Img(){
  return(
    <img src='https://www.google.com/images/branding/googlelogo/1x/googlelogo_light_color_272x92dp.png' alt='img'></img>
  )
}


```


## Summary
The custom render function demonstrates manual DOM manipulation, where you directly create and update elements. In contrast, React abstracts these details away using JSX and the virtual DOM, which allows for more efficient updates and simpler, more declarative UI code.
tshirt manufacturer in ludhiana
Tags: programming, beginners, react, tutorial
Published: 2024-07-03 17:40:58

"In the bustling city of Ludhiana, where the pulse of fashion beats fervently, there lies a hidden gem in the realm of apparel – Ludhiana T-shirt Manufacturer. Renowned as the best T-shirt manufacturer in Ludhiana, our establishment stands as a beacon of quality, creativity, and reliability in the world of clothing. Ludhiana T-shirt Manufacturer At Ludhiana T-shirt Manufacturer, we take pride in our commitment to crafting excellence. Our state-of-the-art facility is equipped with cutting-edge technology and manned by skilled artisans who breathe life into every thread. From classic cotton tees to trendy polyester blends, we offer a diverse range of fabrics to suit every taste and style. Ludhiana tshirt manufacturer. Best tshirt manufacturer in ludhiana, jacket manufacturer in ludhiana.
https://g.co/kgs/RixKGhF
https://g.co/kgs/RixKGhF
https://tshirtfactorie.com
Episode 24/26: TinyConf, ng-Belgrade, Why always upgrade?
Tags: webdev, javascript, programming, angular
Published: 2024-07-03 17:08:59

Sonu Kapoor explains why always updating to the latest version is so important. TinyConf took place and the recordings are available on YouTube. Playwright introduces a clock feature in its latest release.

{% embed https://youtu.be/yxvu3TC5U1A %}

## Importance of upgrading frameworks

Given Angular's current state, staying up to date is often a technical challenge. The main challenge, though, is persuading your manager and colleagues to change.

Sonu Kapoor wrote an article that presents arguments for upgrading and provides examples, such as potential security breaches, better developer experience, and performance improvements - Ivy, but also Signals, zoneless, hydration, etc.


Sonu's article serves as a good foundation for your next discussion. If that's still not enough, you can always bring up Google as an example.

According to Minko Gechev, Google runs around 4,500 Angular applications internally on the latest version.

{% embed https://dev.to/this-is-angular/the-importance-of-upgrading-frameworks-a-case-for-angular-5c91 %}

## TinyConf

TinyConf, a remote-only conference about Angular, took place. The conference lasted one day, and the talks were around 25 minutes long. In total, there were 23 talks, and given that amount, every topic was covered. The recording is available on YouTube.

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

## Ng-Belgrade

Another conference, ng-Belgrade, started publishing its recordings on YouTube as well—not all at once but over the next weeks. Ng-Belgrade happened already in May. 

{% embed https://www.youtube.com/@AngularBelgrade/videos %}

## Playwright 1.45

Playwright, a popular E2E testing framework, was released in 1.45. Like TypeScript, it does not follow schematic versioning.

Playwright comes with a new feature called clock that allows you to control time. Clock overrides the Date class and common timing functions like setInterval, requestIdleCallback, and more.

https://github.com/microsoft/playwright/releases
** Devsonket: **Enhanced, Simplified and Detailed: A Ultimate Library for the Bangla Speaking Developers.**
Tags: developercommunity, banglacheatsheet, devsonket, programming
Published: 2024-07-03 16:56:21



I would like to introduce Devsonket(https://devsonket.com/), quite an exceptional site built by, and for developers exclusively in Bangla. Being one of the biggest repositories of cheat sheets in our native language, it is a rather useful site for developers.

Many articles on Devsonket discuss almost all the programming languages, frameworks, and tools you can think of. Starting from HTML, CSS, and JavaScript, leading up to the use of React, and Node. JS, PHP, and Python scripts, as well as Java, are a part of such a typology, thus web application development encompasses a broad range of important technologies. Besides, it gives specific information on cloud platforms like Amazon Web Services, Microsoft Azure, and Google Cloud.

From the information found, the Devsonket was extremely valuable for practical use in terms of reference, where one can quickly find information on specific programming concepts, tools, or technologies. A relatively large pool of knowledge is available regardless of one’s level of experience with development work.

I highly recommend visiting [Devsonket](You can visit this website at (https://www. devsonket. com/) ) to learn more about this wonderful effort to enhance and encourage the Bangla-speaking developer community.

Best regards,
Syed Md Abu Horaira
How to Install Bootstrap in React JS A Step-by-Step Guide.
Tags: javascript, beginners, programming, webdev
Published: 2024-07-03 16:53:49

**Bootstrap **is a powerful, open-source **front-end framework** designed to streamline the development of responsive and mobile-first web projects. Developed by Twitter, it offers a collection of pre-styled HTML, CSS, and JavaScript components, making it easier for developers to create clean, modern interfaces quickly. 

**Step 1: Create a React Application**
If you don’t already have a React application, you can create one using Create React App. Open your terminal and run the following command:

```
npx create-react-app myapp
cd myapp
```
**Step 2: Install Bootstrap**
There are two main ways to install Bootstrap in a React project: using npm (Node Package Manager) or including it via a CDN (Content Delivery Network). We’ll cover both methods.

```
npm install bootstrap
```
**Step 3: Import Bootstrap CSS file in your `src/App.js`:**

```
import React from 'react';
import 'bootstrap/dist/css/bootstrap.min.css'; // Import Bootstrap CSS
import 'bootstrap/dist/js/bootstrap.bundle.min'; // Import Bootstrap JS

const App = () => {
  return (
    <div className="container">
      <h1 className="my-4">Hello, Sudhanshu..!</h1>
      <button className="btn btn-primary">Click Me</button>
    </div>
  );
};

export default App;
```
**Step 4: Use Bootstrap Components in Your React App**
Now that Bootstrap is installed, you can start using its components in your React app. Here’s an example of how to use a Bootstrap button:

```
import React from 'react';

const Home= () => {
  return (
    <div className="container">
      <h1 className="my-4">This is a Home Page ...!</h1>
      <button className="btn btn-primary">Home Page</button>
    </div>
  );
};

export default Home;
```
**Step 5: Run your React application:**
Start your React app by running:

```
npm start
```
**🌟 Mastering the Java Collections Framework 🌟**
Tags: webdev, programming, beginners, java
Published: 2024-07-03 16:41:43



Are you ready to take your Java skills to the next level? Dive into the powerful Collections Framework! 🚀

**Why Collections Framework?**
- **Efficiency:** Collections provide data structures like Lists, Sets, and Maps, allowing efficient data storage and manipulation.
- **Flexibility:** Use different implementations based on your needs, like `ArrayList`, `HashSet`, and `HashMap`.
- **Ease of Use:** Simplifies complex algorithms and data management with built-in methods.

**Key Components:**
1. **List:**
   - Ordered and allows duplicates.
   - Common implementations: `ArrayList`, `LinkedList`.
   - Example:
     ```java
     List<String> list = new ArrayList<>();
     list.add("Java");
     list.add("Python");
     list.add("JavaScript");
     ```

2. **Set:**
   - Unordered and does not allow duplicates.
   - Common implementations: `HashSet`, `TreeSet`.
   - Example:
     ```java
     Set<String> set = new HashSet<>();
     set.add("Java");
     set.add("Python");
     set.add("Java"); // Duplicate entry, will not be added.
     ```

3. **Map:**
   - Stores key-value pairs.
   - Common implementations: `HashMap`, `TreeMap`.
   - Example:
     ```java
     Map<Integer, String> map = new HashMap<>();
     map.put(1, "Java");
     map.put(2, "Python");
     ```

**Pro Tips:**
- Always choose the right collection type for your specific needs.
- Be aware of thread safety. Use synchronized collections or `java.util.concurrent` for concurrent operations.
- Explore Java 8+ enhancements, like Streams and Lambda expressions, to make your code more readable and efficient.

Embark on your journey with Java Collections today and watch your productivity soar! 🚀✨
How to use CSS in Media Queries with styled components in React js
Tags: webcomponents, css, programming, react
Published: 2024-07-03 16:37:55

**Step 1: Install Styled Components**
First, make sure you have `styled-components` installed in your project. If not, you can install it using npm or yarn:

```
npm install styled-components
```
**Step 2: Create a Styled Component with Media Queries**
You can create a styled component and use media queries within it. Here’s an example of a responsive Container component that changes its background color based on the screen width:

```
import React from 'react';
import styled from 'styled-components';

// Define the styled component with media queries
const Container = styled.div`
  width: 100%;
  height: 100vh;
  background-color: lightblue;

  @media (max-width: 768px) {
    background-color: lightcoral;
  }

  @media (max-width: 480px) {
    background-color: lightgreen;
  }
`;

const App = () => {
  return (
    <Container>
      <h1>Hello, World!</h1>
    </Container>
  );
};

export default App;
```
**Explanation**
**Import Styled Components:** Import the styled object from `styled-components`.
**Create a Styled Component:** Define a styled Container component. The Container will have a default background color of lightblue.
**Add Media Queries:**
For screens with a maximum width of 768px, change the background color to lightcoral.
For screens with a maximum width of 480px, change the background color to lightgreen.
**Use the Styled Component:** Use the Container component in your App component. Any content inside the Container will have the styles applied to it, including the media queries.

**Step 3: Render the App**
When you run your React application, you should see the Container change its background color based on the screen width:

**Default: lightblue**
`Max-width 768px: lightcoral
Max-width 480px: lightgreen`
This way, you can easily add responsive styles to your React components using CSS Media Queries with Styled Components.

**Additional Tips**
You can add more complex styles and media queries as needed.
Combining media queries with other styled-component features (e.g., themes) can make your styles even more powerful and maintainable.
# 🌳 Dive into Decision Trees: A Fun Guide! 🌳
Tags: ai, python, tensorflow, machinelearning
Published: 2024-07-03 16:35:51

Hey there, fellow data enthusiasts! 👋 Are you ready to dive into the world of Decision Trees? 🌲 Let's make it interactive and fun with emojis! 🎉

## What is a Decision Tree? 🤔

A Decision Tree is like a flowchart that helps us make decisions based on data. Each node represents a decision point, and the branches show the possible outcomes. It's a powerful tool in the world of Machine Learning! 🚀

## Why Use Decision Trees? 🤷‍♂️

1. **Simplicity**: Easy to understand and interpret. 🧠
2. **Versatility**: Can handle both numerical and categorical data. 🔢🔤
3. **No Need for Data Normalization**: Works well with raw data. 🌟
4. **Feature Importance**: Helps identify the most important features. 🔍

## How Does It Work? 🛠️

1. **Start at the Root**: Begin with the entire dataset. 🌱
2. **Split the Data**: Based on a feature, split the data into branches. 🌿
3. **Repeat**: Continue splitting until each leaf (end node) contains a single class or meets stopping criteria. 🍂

### Example Time! 📝

Imagine we have data about fruits, and we want to classify them based on features like color, size, and shape. 🍎🍌🍊

1. **Root Node**: Is the fruit color red?
   - Yes: 🍎
   - No: Go to next question.

2. **Next Node**: Is the fruit shape long?
   - Yes: 🍌
   - No: 🍊

And voila! We have our decision tree! 🌳

## Pros and Cons 🆚

### Pros 👍

- **Easy to Understand**: Visual representation makes it intuitive.
- **No Data Scaling Needed**: Works with raw data.
- **Handles Both Types of Data**: Numerical and categorical.

### Cons 👎

- **Overfitting**: Can create overly complex trees.
- **Sensitive to Data Variations**: Small changes can alter the tree.
- **Less Accurate**: Compared to ensemble methods.

## Visualizing Decision Trees 👀

Visualizations make it easier to interpret decision trees. Tools like Graphviz and libraries like Scikit-learn in Python can help create these visualizations. 🖼️

```python
from sklearn import tree
import matplotlib.pyplot as plt

# Example Code to Visualize a Decision Tree
model = tree.DecisionTreeClassifier()
model.fit(X_train, y_train)

plt.figure(figsize=(12,8))
tree.plot_tree(model, filled=True)
plt.show()
```

## Let's Play! 🎮

Ready to try out Decision Trees? Here's a challenge for you:

- **Dataset**: Use the Iris dataset (a classic in ML).
- **Goal**: Classify the species of Iris flowers based on sepal/petal length and width.

Share your results in the comments below! 💬

## Conclusion 🎬

Decision Trees are a fantastic starting point in the world of Machine Learning. They're simple yet powerful and can handle a variety of data types. So, go ahead and plant your Decision Tree today! 🌳🌟

Happy coding! 💻✨
🚀 Top 5 DevOps Tools to Supercharge Your Workflow in 2024!
Tags: devops, terraform, kubernetes, docker
Published: 2024-07-03 16:32:11

In the rapidly evolving world of DevOps, staying ahead with the right tools is crucial for efficiency and productivity. As we step into 2024, here are the top 5 DevOps tools you should definitely have in your toolkit:

**Docker** 🐳

Why Use It: Simplifies containerization, enabling seamless deployment across different environments.

Key Features: Lightweight containers, easy integration with CI/CD pipelines, and a vast library of pre-built images.

**Kubernetes** ☸️

Why Use It: Manages containerized applications at scale, ensuring high availability and scalability.

Key Features: Automated deployment, scaling, and management of containerized applications.

**Jenkins** 🤖

Why Use It: Automates the CI/CD process, making it easier to integrate changes and deploy code quickly.

Key Features: Extensive plugin ecosystem, easy configuration, and robust pipeline as code support.

**Terraform** 🌍

Why Use It: Facilitates infrastructure as code, allowing you to provision and manage infrastructure efficiently.

Key Features: Declarative configuration files, supports multiple cloud providers, and ensures reproducibility.

**Prometheus** 📊

Why Use It: Powerful monitoring and alerting toolkit designed for reliability and scalability.

Key Features: Flexible querying, robust time-series data storage, and seamless integration with Grafana for visualization.

These tools are game-changers for DevOps engineers, helping to streamline workflows, enhance collaboration, and maintain high standards of performance and security. Embrace these technologies in 2024 to take your DevOps practices to the next level!
𝐓𝐡𝐞 𝐏𝐬𝐲𝐜𝐡𝐨𝐥𝐨𝐠𝐲 𝐨𝐟 𝐒𝐨𝐜𝐢𝐚𝐥 𝐄𝐧𝐠𝐢𝐧𝐞𝐞𝐫𝐢𝐧𝐠: 𝐇𝐨𝐰 𝐭𝐨 𝐏𝐫𝐨𝐭𝐞𝐜𝐭 𝐘𝐨𝐮𝐫𝐬𝐞𝐥𝐟 𝐚𝐧𝐝 𝐘𝐨𝐮𝐫 𝐃𝐚𝐭𝐚
Tags: security, datasecurity
Published: 2024-07-03 16:29:56

Social engineering remains one of the most effective methods of cyber attacks, often bypassing technical defenses through manipulation of the human factor. It's crucial to understand the methods used by malicious actors and steps you can take to defend against them.

🔍 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐒𝐨𝐜𝐢𝐚𝐥 𝐄𝐧𝐠𝐢𝐧𝐞𝐞𝐫𝐢𝐧𝐠?
Social engineering is the process of manipulating people to gain access to confidential information or systems. Attackers employ various techniques such as phishing via email, social media scams, and fraudulent phone calls to deceive their victims.

💡 𝐇𝐨𝐰 𝐭𝐨 𝐏𝐫𝐨𝐭𝐞𝐜𝐭 𝐘𝐨𝐮𝐫𝐬𝐞𝐥𝐟?

   •  𝐄𝐝𝐮𝐜𝐚𝐭𝐢𝐨𝐧 𝐚𝐧𝐝 𝐀𝐰𝐚𝐫𝐞𝐧𝐞𝐬𝐬: Conduct regular security training for employees to help them recognize signs of social engineering attacks.
•     𝐂𝐚𝐮𝐭𝐢𝐨𝐧 𝐢𝐧 𝐂𝐨𝐦𝐦𝐮𝐧𝐢𝐜𝐚𝐭𝐢𝐨𝐧𝐬: Be vigilant of unexpected requests for information or financial transactions, especially if they come via email or social media.
•     𝐓𝐰𝐨-𝐅𝐚𝐜𝐭𝐨𝐫 𝐀𝐮𝐭𝐡𝐞𝐧𝐭𝐢𝐜𝐚𝐭𝐢𝐨𝐧: Use two-factor authentication to protect your accounts from unauthorized access.

🚀 𝐑𝐨𝐥𝐞 𝐨𝐟 𝐄𝐝𝐮𝐜𝐚𝐭𝐢𝐨𝐧 𝐚𝐧𝐝 𝐀𝐰𝐚𝐫𝐞𝐧𝐞𝐬𝐬
A key factor in combating social engineering is educating your staff. The more informed employees are, the lower the likelihood of successful attacks.

Protecting against social engineering requires a comprehensive approach that includes both technology and education. Let's work together to make our data and systems more secure!
1509. Minimum Difference Between Largest and Smallest Value in Three Moves
Tags: php, leetcode, algorithms, programming
Published: 2024-07-03 16:27:48

1509\. Minimum Difference Between Largest and Smallest Value in Three Moves

Medium

You are given an integer array `nums`.

In one move, you can choose one element of `nums` and change it to **any value**.

Return _the minimum difference between the largest and smallest value of `nums` **after performing at most three moves**_.

**Example 1:**

- **Input:** nums = [5,3,2,4]
- **Output:** 0
- **Explanation:** We can make at most 3 moves.
```
  In the first move, change 2 to 3. nums becomes [5,3,3,4].
  In the second move, change 4 to 3. nums becomes [5,3,3,3].
  In the third move, change 5 to 3. nums becomes [3,3,3,3].
  After performing 3 moves, the difference between the minimum and maximum is 3 - 3 = 0.
```

**Example 2:**

- **Input:** nums = [1,5,0,10,14]
- **Output:** 1
- **Explanation:** We can make at most 3 moves.
```
  In the first move, change 5 to 0. nums becomes [1,0,0,10,14].
  In the second move, change 10 to 0. nums becomes [1,0,0,0,14].
  In the third move, change 14 to 1. nums becomes [1,0,0,0,1].
  After performing 3 moves, the difference between the minimum and maximum is 1 - 0 = 1.
  It can be shown that there is no way to make the difference 0 in 3 moves.
```

**Example 3:**

- **Input:** nums = [3,100,20]
- **Output:** 0
- **Explanation:** We can make at most 3 moves.
```
  In the first move, change 100 to 7. nums becomes [3,7,20].
  In the second move, change 20 to 7. nums becomes [3,7,7].
  In the third move, change 3 to 7. nums becomes [7,7,7].
  After performing 3 moves, the difference between the minimum and maximum is 7 - 7 = 0.
```


**Constraints:**

- <code>1 <= nums.length <= 10<sup>5</sup></code>
- <code>-10<sup>9</sup> <= nums[i] <= 10<sup>9</sup></code>


**Solution:**

```
class Solution {

    /**
     * @param Integer[] $nums
     * @return Integer
     */
    function minDifference($nums) {
        $n = count($nums);

        // If the array has 4 or fewer elements, the difference is zero because we can remove all but one element.
        if ($n <= 4) {
            return 0;
        }

        // Sort the array to facilitate the calculation of differences after removals.
        sort($nums);

        // We consider removing 0, 1, 2, or 3 elements from the start or the end.
        // Calculate the differences:
        // 1. Remove 3 from start: nums[n-1] - nums[3]
        // 2. Remove 2 from start, 1 from end: nums[n-2] - nums[2]
        // 3. Remove 1 from start, 2 from end: nums[n-3] - nums[1]
        // 4. Remove 3 from end: nums[n-4] - nums[0]
        $differences = [
            $nums[$n - 1] - $nums[3],
            $nums[$n - 2] - $nums[2],
            $nums[$n - 3] - $nums[1],
            $nums[$n - 4] - $nums[0]
        ];

        // Return the minimum difference.
        return min($differences);
    }
}
```



**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**