teleren/devto huggingface dataset:
Single Responsibility Principle
Tags: java, solidprinciples, design, tutorial
Published: 2023-10-28 03:11:28

> The Single Responsibility Principle means that in your code, each "job" or class should do one thing and do it well. This makes your code easier to understand, fix, and use in different parts of your program. Just like tools in a toolbox have specific purposes, your code should have clear and specific responsibilities.

Let's break down the explanation of the Single Responsibility Principle (SRP) into step-by-step actions with a Java code example.

**Step 1: Create a Class without a Single Responsibility (Initial Design):**

Start with a class that has multiple responsibilities:

```java
public class Employee {
    private String name;
    private double salary;

    public Employee(String name, double salary) {
        this.name = name;
        this.salary = salary;
    }

    public void calculateSalary() {
        // Calculate the employee's salary
        this.salary = /* complex calculation */;
    }

    public void saveToDatabase() {
        // Save employee data to a database
        Database.saveEmployee(this);
    }
}
```

**Step 2: Identify the Problem:**

Recognize that the class violates the Single Responsibility Principle by having more than one responsibility:

- It calculates the employee's salary.
- It saves employee data to a database.

**Step 3: Apply the Single Responsibility Principle (Solution):**

To adhere to the SRP, you need to separate these responsibilities. Here's how:

**Step 4: Create Classes with Single Responsibilities (Solution):**

**Part 1: Create a class responsible for calculating the salary:**

```java
public class Employee {
    private String name;
    private double salary;

    public Employee(String name, double salary) {
        this.name = name;
        this.salary = salary;
    }

    public double calculateSalary() {
        // Calculate the employee's salary
        return /* complex calculation */;
    }
}
```

**Part 2: Create a class responsible for saving employee data to a database:**

```java
public class EmployeeDatabase {
    public void saveToDatabase(Employee employee) {
        // Save employee data to a database
        Database.saveEmployee(employee);
    }
}
```

**Step 5: Benefits of the Solution:**

By adhering to the Single Responsibility Principle, you've achieved the following benefits:

- The code is more organized and easier to understand.
- Each class has a clear and single purpose, making it easier to maintain and modify.
- Changes in one responsibility (e.g., salary calculation) won't affect the other (e.g., database interaction).
- Testing is simplified, as you can focus on testing each responsibility independently.

This separation of responsibilities enhances code quality and maintainability.

> "Your feedback and ideas are invaluable – drop a comment, and let's make this even better!"

😍 If you enjoy the content, please 👍 like, 🔄 share, and 👣 follow for more updates!
Join me on a professional journey through my LinkedIn profile: [Linkedin Profile](https://www.linkedin.com/in/kurmivivek295/)
Securing the Digital Realm in Cybersecurity
Published: 2023-10-28 03:10:46

In today's fast-paced digital landscape, the role of cybersecurity professionals has never been more critical. As businesses become increasingly reliant on technology, the need for experts proficient in Advanced Incident Response, Risk Management, and Enterprise Security Operations has become paramount. These three pillars form the foundation of modern cybersecurity practices, ensuring organizations can navigate the complex world of digital threats with resilience and confidence.

1. Advanced Incident Response: Swift Action in the Face of Threats

Incident Response is akin to a digital firefighting team. Cybersecurity experts trained in Advanced Incident Response techniques are the first responders to cyber threats. They swiftly detect security breaches, analyze the attack's nature, contain the incident, and initiate recovery procedures. Through their expertise, they mitigate potential damage, minimizing downtime, and ensuring business continuity. Their ability to respond rapidly to incidents is crucial in minimizing data loss and maintaining the integrity of critical systems.

2. Risk Management: Balancing Innovation and Security

Innovation drives progress, but it also introduces new risks. Cybersecurity professionals well-versed in Risk Management evaluate potential threats and vulnerabilities. They develop strategies to mitigate these risks effectively, ensuring that innovation can coexist with robust security measures. By striking a delicate balance between fostering innovation and preserving security, these experts enable businesses to innovate fearlessly, confident that their digital initiatives are shielded by comprehensive risk management protocols.

3. Enterprise Security Operations: The Guardians of Digital Infrastructure

Enterprise Security Operations form the backbone of a resilient cybersecurity posture. Professionals proficient in this domain oversee security assessments, implement robust security solutions, and conduct ongoing security operations. They integrate security measures seamlessly into the organization's architecture, ensuring that networks, applications, and data are shielded from evolving threats. These experts act as vigilant guardians, employing a combination of expertise and technology to maintain an impenetrable security posture.

Conclusion: Mastering the Digital Battlefield

In the ever-evolving digital landscape, cybersecurity professionals skilled in Advanced Incident Response, Risk Management, and Enterprise Security Operations are the unsung heroes. Their expertise ensures that businesses can navigate the intricate landscape of digital threats with confidence. By swiftly responding to incidents, balancing innovation with security, and safeguarding the core of organizations through robust security operations, these experts pave the way for a secure digital future. As businesses continue to innovate and expand, these cybersecurity professionals remain at the forefront, fortifying the digital realm against adversities and enabling a world where innovation and security thrive harmoniously.
Placeholder Contributor
Tags: hack23contributor
Published: 2023-10-27 14:29:47

### Intro
Hello reader, My name is Chitresh Gyanani and this is my first Hacktoberfest, I learned and started contributing to open source for the first time and it has been amazing.
The amount of fun it is to code something which really affects something in real life rather than writing code in to practice.
My github profile became better and I got an opportunity to visit DevFest New Delhi.
Here's my GitHub Profile:
{% embed https://github.com/Chitresh-code %} 

### Highs and Lows
Learning Git and GitHub was a little bit challanging and it was hard to learn as a begginer, picking where to contribute and learning the basics of creating Issues and merging PRs took a little used to, but at the end with some help from YouTube videos and friendly maintainers it was a fun experience to learn.

### Growth
Before Hacktoberfest I was not that much experienced with debugging and it was never a strong suit for me as I didn't understood why and what I am changing, but in Open Source seeing how after removing a bug it showed changes on the websites or apps, it helped me learn and understand debugging on a new level.
SOLID Principles with Examples
Tags: java, programming, design, solidprinciples
Published: 2023-10-28 03:08:54

The **SOLID** principles are a set of five fundamental principles in software development that help in designing clean, maintainable, and extensible code. These principles are meant to guide developers in creating high-quality, flexible, and easy-to-understand software. The basics of these are as follows:

> _We are going to discuss each one in detail with step by step guide and code examples._

1. **Single Responsibility Principle (SRP)**:
   - A class should have one clear responsibility or purpose.
   - This makes code easier to understand, maintain, and modify.
[Step by step guide with code example](https://dev.to/kurmivivek295/single-responsibility-principle-2m0)

2. **Open/Closed Principle (OCP)**:
   - Software entities should be open for extension but closed for modification.
   - New features can be added without altering existing code, reducing the risk of introducing bugs.
[Step by step guide with code example](https://dev.to/kurmivivek295/openclosed-principle-4bjd)

3. **Liskov Substitution Principle (LSP)**:
   - Subclasses should be usable in place of their base classes without causing issues.
   - Derived classes should honor the contracts of their base classes.
[Step by step guide with code example](https://dev.to/kurmivivek295/liskov-substitution-principle-lsp-49fa)

4. **Interface Segregation Principle (ISP)**:
   - Interfaces should be small and specific, containing only methods relevant to their clients.
   - Clients (implementing classes) should not be forced to implement methods they don't need.
[Step by step guide with code example](https://dev.to/kurmivivek295/interface-segregation-principle-isp-4j96)

5. **Dependency Inversion Principle (DIP)**:
   - High-level modules should not depend on low-level modules; both should depend on abstractions (interfaces or abstract classes).
   - Details (concrete implementations) should depend on abstractions.
   - This reduces coupling and enhances code flexibility and maintainability.
[Step by step guide with code example](https://dev.to/kurmivivek295/dependency-inversion-principle-dip-25b3)

These principles are fundamental for writing clean, maintainable, and flexible software and serve as a guide for software developers to produce high-quality code.

> "Your feedback and ideas are invaluable – drop a comment, and let's make this even better!"

😍 If you enjoy the content, please 👍 like, 🔄 share, and 👣 follow for more updates!
Join me on a professional journey through my LinkedIn profile: [Linkedin Profile](https://www.linkedin.com/in/kurmivivek295/)
K8s Exercise : Labels and Annotations
Tags: kubernetes, devops, beginners
Published: 2023-10-28 01:53:03

**Introduction**
Hi, I am Akshay Rao, will be starting a exercise series on k8s.
In this blog there will not explanation only problems and solutions.if you want explanation have a look at this series:-
https://dev.to/aksrao1998/series/24887

**Pre-requisite**
have minikube or kind running in the local machine.

Note:- k is alias for kubectl.

**Let's Start**
**Problem**
1. Create 3 pods with names nginx1,nginx2,nginx3. All of them should have the label app=v1.
2. Show all labels of the pods.
3. Change the labels of pod 'nginx2' to be app=v2.
4. Get the label 'app' for the pods (show a column with APP labels).
5. Get only the 'app=v2' pods
6. Add a new label tier=web to all pods having 'app=v2' or 'app=v1' labels.
7. Add an annotation 'owner: marketing' to all pods having 'app=v2' label.
8. Remove the 'app' label from the pods we created before.
9. Annotate pods nginx1, nginx2, nginx3 with "description='mydescription'" value.
10. Check the annotations for pod nginx1.
11. Remove the annotations for these three pods.

**Solution**
```
#1 Soln
[ ~ (⎈|minikube:mynamespace)]$ k run nginx1 --image=nginx -l app=v1
pod/nginx1 created
[~ (⎈|minikube:mynamespace)]$ k run nginx2 --image=nginx -l app=v1
pod/nginx2 created
[~ (⎈|minikube:mynamespace)]$ k run nginx3 --image=nginx -l app=v1
pod/nginx3 created

#2 Soln
[~ (⎈|minikube:mynamespace)]$ k get po -l app=v1
NAME     READY   STATUS    RESTARTS   AGE
nginx1   1/1     Running   0          2m11s
nginx2   1/1     Running   0          2m4s
nginx3   1/1     Running   0          115s

#3 Soln
[~ (⎈|minikube:mynamespace)]$ k label pod nginx2 app=v2 --overwrite
pod/nginx2 labeled

#4 Soln
[ ~ (⎈|minikube:mynamespace)]$ k get po -l app
NAME     READY   STATUS    RESTARTS   AGE
nginx1   1/1     Running   0          16m
nginx2   1/1     Running   0          16m
nginx3   1/1     Running   0          16m

#5 Soln
[ ~ (⎈|minikube:mynamespace)]$ k get po -l app=v2
NAME     READY   STATUS    RESTARTS   AGE
nginx2   1/1     Running   0          14m

#6 Soln
[~ (⎈|minikube:mynamespace)]$ k label po -l "app in (v1.v2)" teir=web

#7 Soln
[~ (⎈|minikube:mynamespace)]$ k annotate po -l "app=v2" owner=marketing
pod/nginx2 annotated

#8 Soln
[~ (⎈|minikube:mynamespace)]$ k label po nginx{1..3} app-
pod/nginx1 unlabeled
pod/nginx2 unlabeled
pod/nginx3 unlabeled

#9 Soln
[~ (⎈|minikube:mynamespace)]$ k annotate po nginx{1..3} description=mydescription
pod/nginx1 annotated
pod/nginx2 annotated
pod/nginx3 annotated

#10 Soln
[~ (⎈|minikube:mynamespace)]$ k annotate po nginx1 --list
description=mydescription

#11 Soln
[ts-akshay.rao@JP-FVFZ91DHL414 ~ (⎈|minikube:mynamespace)]$ k annotate po nginx{1..3} description-
pod/nginx1 annotated
pod/nginx2 annotated
pod/nginx3 annotated

```
Synchronize a remote Dropbox directory with a local one in Python
Tags: dropbox, synchronizer
Published: 2023-10-28 01:36:22

<p>After the last post, in which a simple local synchronizer were implemented in Python making use of the Watchdog library to detect the local changes and propagate them to a remote directory in Dropbox, I've decided to implement a reciprocal sychronizer that does the exact opposite - synchronizes continuously a remote Dropbox location to a local one.
It's using the same Dropbox Python SDK as the latter post, and of course you'll need to register an app of yours in order to create a access token to acess the Dropbox API.
In this particular case, a cursor is created every 30 seconds to poll for changes on the remote location and if that is the case, the API returns the name of involved file, and replicates locally what has happenned remotely.
Again, in this case, the program does not perform a global synchronization between remote and local directories, only listens to modifications in real time and propagates them one-way from remote to local.</p>
<p>The code is below:</p>
{% embed https://gist.github.com/digfish/2c550c31f89bf6e73f777c525399f0a9.js %}
Placeholder Contributor
Tags: hack23contributor
Published: 2023-10-28 01:25:56

<!-- ✨This template is only meant to get your ideas going, so please feel free to write your own title, structure, and words! ✨ -->

### Intro
<!-- Share a bit about yourself as a contributor. Is this your first Hacktoberfest, or have you contributed to others? Feel free to embed your GitHub account by using {% embed LINK %} -->

### Highs and Lows
<!-- What were some of your biggest accomplishments or light-bulb moments this month? Did any problems come up that seemed impossible to fix? How did you adapt in those cases?  -->

### Growth
<!-- What was your skillset before Hacktoberfest 2023 and how did it improve? Have your learning or career goals changed since working on these new projects? -->
How and when to use keys in React
Tags: react, javascript
Published: 2023-10-28 00:39:27

---
title: How and when to use keys in React
published: true
description: When you render lists in React, you need to use keys.
tags: react, javascript
cover_image: https://images.unsplash.com/photo-1579728866437-6397f3d89ec3?auto=format&fit=crop&q=80&w=2913&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D
canonical_url: https://blog.cassidoo.co/post/react-keys/
---

Whenever you want to render a list of something in React, you need to add a `key` attribute to it. This helps the renderer know how to keep track of that element, kind of like an ID. That `key` _can_ be pretty much anything (a number or a string or whatever), but there's some high-level rules you should follow when using them.

1. **Keys have to be unique** - when React is differentiating things across renders, keys shouldn't be the same as something else.
2. **Keys should not be random IDs** - if an ID is a random number generated during a render, then your items will have all new keys every time the state in your component changes. That being said, if you generate unique IDs when creating the data, that's different and okay.
3. **Keys should probably not be just the item's `index`** - if you plan on changing the order of your list, or adding or deleting items, then the indices will change whenever the list changes, and that will throw React off.

Here's a good example of a `key` being set properly, using an `id` in the list:

```jsx
const CityList = () => {
  const cities = [
    { id: 1, name: 'New York', description: 'The Big Apple' },
    { id: 2, name: 'Chicago', description: 'The Windy City' },
    { id: 3, name: 'San Francisco', description: 'The Golden City' },
    { id: 4, name: 'Los Angeles', description: 'The City of Angels' },
  ];

  return (
    <div>
      <h1>U.S. cities</h1>
      <ul>
        {cities.map(city => (
          <li key={city.id}>
            <h2>{city.name}</h2>
            <p>{city.description}</p>
          </li>
        ))}
      </ul>
    </div>
  );
};
```

Here's some further reading if you'd like to learn more!

- [React documentation on rendering lists](https://react.dev/learn/rendering-lists)
- [Real-life example on Stack Overflow](https://stackoverflow.com/questions/56235483/material-ui-popover-is-thrown-to-the-top-left-when-used-on-an-inline-button-in-a)
Unused Childhood Lessons - Share Yours!
Tags: discuss, codenewbie, beginner
Published: 2023-10-28 00:00:00

---
published_at : 2023-10-28 00:00 +0000
---
What's something you were told or taught as a child that you've found to be utterly unnecessary or irrelevant as an adult? 

Follow the [CodeNewbie Org](https://dev.to/codenewbieteam) and [#codenewbie](https://dev.to/t/codenewbie) for more discussions and online camaraderie!

*{% embed* https://dev.to/codenewbieteam *%}*
La IA
Tags: machinelearning, spanish
Published: 2023-10-27 22:51:49

La inteligencia artificial nace a partir de un conjunto de datos (dataset) de hecho es la base principal y primordial, acá hay algo muy importante al tener en cuenta, que no caigamos en un sesgo de información.

Recientemente estaba leyendo en la revista del MIT que los modelos entrenados para detectar el rostro de una persona funciona de mejor manera con personas que tiene tes blanca, cabello rubio y rasgos británicos, y esto no es una casualidad sino que la gran mayoría datasets, esta compuesto por este tipo de personas. Esto nos lleva al dilema ético ¿alguna inteligencia artificial pudiera a llegarse a considerar racista?.

La ética en la inteligencia artificial es un tema muy nuevo y ciertamente no estamos seguros cual es el camino "correcto", ya que es eso una inteligencia que no funciona de la misma manera como la de nosotros, todo para ella es una probabilidad y es un resultado estadístico.

Estamos en un punto de nuestra historia como humanidad que hemos desarrollado entes no vivos que pueden tomar decisiones pero estas decisiones se pueden ver sesgadas por las cosas que nosotros mismos suministramos.
My Hacktoberfest23 journey
Tags: hacktoberfest, hacktoberfest23, opensource
Published: 2023-10-27 20:08:58

After a month of learning and experimentation, I've successfully completed four Hacktoberfest23 tasks.
1. [My First Pull Request in Hacktoberfest23](https://dev.to/wanggithub0/my-first-pull-request-in-hacktoberfest23-34d5)
2. [My second hacktoberfest PR](https://dev.to/wanggithub0/my-second-hacktoberfest-pr-158a)
3. [My third Pull Request in Hacktoberfest23](https://dev.to/wanggithub0/third-pull-request-in-hacktoberfest23-4oic)
4. [My forth Pull Request in Hacktoberfest23](https://dev.to/wanggithub0/my-forth-pull-request-in-hacktoberfest23-5gf8)

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


Throughout the four tasks I undertook during Hacktoberfest23, I embarked on a significant learning journey. Beginning with my first task in Mojo, a programming language for AI, I contributed by updating content related to new features and advancements. This was a motivating initiation into the open-source community. For my second task in Movex, I encountered a Git-related issue, learning the importance of correctly signing commits for my Pull Requests. My third task took me to the Klaw-docs project where I was introduced to Vale for spell checking, enhancing the documentation quality. The final task was a more ambitious project, Qwik-X, where I worked on integrating user profile links in post lists. This endeavor introduced me to technologies like Postgres, Neon, and Qwik, expanding my technical repertoire significantly. Each task served as a stepping stone, enriching my understanding of software development and reinforcing the value of meticulousness in coding and collaboration within an open-source environment.


As I progressed through different projects, I explored numerous facets of open source contributions. Each endeavor, whether it was Klaw-docs, Qwik-X, Movex, or even Mojo, provided distinct insights. Along this journey, I encountered various technologies and implementation challenges that contributed to my growth. The challenges encountered in each project differed significantly, whether it was dealing with installation complexities, resolving errors, or gaining a better grasp of writing tools like Vale.

The culmination of these experiences marked a crucial point in my growth within the open source community. Each project served as a stepping stone, teaching me invaluable lessons, and refining my problem-solving skills, technical understanding, and collaborative nature. These experiences paved the way for a more comprehensive knowledge base, motivating me to take on more complex challenges and further expand my contributions in the world of open source.