teleren/devto huggingface dataset:
Props drilling 📸 useContext()
Published: 2024-07-08 22:31:11

## Props Drilling 
Passing data from a parent component down through multiple levels of nested child components via props is called props drilling. This can make the code hard to manage and understand as the application grows. It's not a topic but a problem. How it's a problem?

In react, Data flows from top to bottom component. Like this...

`Parent -> Children -> Grand Children `

Now I will show you two cases. Each case represents a different set of data flow.

---

## Case 1 👇

**Description:** A hand-drawn illustration to help visualize props drilling:

![diag_simple_props_drilling](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5qm7ghtu671hl6o8fel.jpg)

**Code**
{% details 👉🏽 TopLevelComponent.jsx %} 
```jsx
// TopLevelComponent.jsx
import React from 'react';
import IntermediateComponent1 from './IntermediateComponent1';

const TopLevelComponent = () => {
  const user = { name: 'Jorjis Hasan', age: 22 };

  return (
    <div>
      <h1>Top-Level Component</h1>
      <IntermediateComponent1 user={user} />
    </div>
  );
};

export default TopLevelComponent;

// IntermediateComponent1.jsx
import React from 'react';
import IntermediateComponent2 from './IntermediateComponent2';

const IntermediateComponent1 = ({ user }) => {
  return (
    <div>
      <h2>Intermediate Component 1</h2>
      <IntermediateComponent2 user={user} />
    </div>
  );
};

export default IntermediateComponent1;

// IntermediateComponent2.jsx
import IntermediateComponent3 from './IntermediateComponent3';

const IntermediateComponent2 = ({ user }) => {
  return (
    <div>
      <h3>Intermediate Component 2</h3>
      <IntermediateComponent3 user={user} />
    </div>
  );
};

export default IntermediateComponent2;

// IntermediateComponent3.jsx
import EndComponent from './EndComponent';

const IntermediateComponent3 = ({ user }) => {
  return (
    <div>
      <h4>Intermediate Component 3</h4>
      <EndComponent user={user} />
    </div>
  );
};

export default IntermediateComponent3;

// EndComponent.jsx
const EndComponent = ({ user }) => {
  return (
    <div>
      <h5>End Component</h5>
      <p>Name: {user.name}</p>
      <p>Age: {user.age}</p>
    </div>
  );
};

export default EndComponent;
```
{% enddetails %}

See how we had to pass data down through layers. For the sake of `EndComponents` needs, we had to pass `user` data through 3 extra components(IntermediateComponent1, IntermediateComponent3, IntermediateComponent3). This is absolutely not clean code. 

---

## Case 2 🔽

**Description:** A hand-drawn illustration to help visualize Case 2 data flow.

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

**Code:** 

Sorry! Sorry! Sorry!
I can't code it up by just passing props. Even though I code, that would not make sense.

Well, let's hand down the best practices. We have 2 consistent solutions that can be used against any complex data flow.

1. React built-in `useContext` Api
2. State Management Library
Ibuprofeno.py💊| #135: Explica este código Python
Tags: python, spanish, learning, beginners
Published: 2024-07-08 11:00:00

## **<center>Explica este código Python</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```py
x = {1,2,3}
y = {3,4,5}

print(x.symmetric_difference(y)) 
```

* **A.** `{}`
* **B.** `{3}`
* **C.** `{1, 2, 4, 5}`
* **D.** `{1, 2, 3, 4, 5}`

---

{% details **Respuesta:** %} 

👉 **C.** `{1, 2, 4, 5}`

En nuestro ejemplo la diferencia simétrica consiste en extraer todos los elementos que esten en `x` o `y` pero que no este en ambos.





 
{% enddetails %}
Ibuprofeno.py💊| #136: Explica este código Python
Tags: spanish, learning, beginners, python
Published: 2024-07-09 11:00:00

## **<center>Explica este código Python</center>**
#### <center>**Dificultad:** <mark>Avanzado</mark></center>

```py
x = {3, 4}
y = frozenset(x)
y.add(5)
print(x)
```

* **A.** `AttributeError`
* **B.** `TypeError`
* **C.** `SyntaxError`
* **D.** `NameError`

---

{% details **Respuesta:** %} 

👉 **A.** `AttributeError`

La función `frozenset()` permite crear conjuntos inmutables, es decir, conjuntos que no podrán modificarse ni agregando ni eliminando nuevos items.

 
{% enddetails %}
Ibuprofeno.py💊| #137: Explica este código Python
Tags: python, learning, spanish, beginners
Published: 2024-07-10 11:00:00

## **<center>Explica este código Python</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```py
def f():
    return (1,2)
    pass
    
a, b = f()
print(b)
```

* **A.** `1`
* **B.** `2`
* **C.** `pass`
* **D.** `SyntaxError`

---

{% details **Respuesta:** %} 

👉 **B.** `2`

Las funciones en Python pueden regresar cualquier tipo de dato o estructura de dato, en este caso regresamos una tupla.

Como el valor de retorno es una tupla entonces podemos usar el **desempaquetado de tuplas** usando las variables `a` y `b` para ello.

Finalmente imprimimos el segundo valor de la tupla que es `2`.

Todo código que vaya luego del `return` nunca se ejecuta, por ello `pass` no tiene sentido en este ejemplo y solo se lo uso para distraer.


 
{% enddetails %}
Ibuprofeno.py💊| #138: Explica este código Python
Tags: python, spanish, learning, beginners
Published: 2024-07-11 11:00:00

## **<center>Explica este código Python</center>**
#### <center>**Dificultad:** <mark>Fácil</mark></center>

```py
def f(x, y, z):
    return x * y * z
    
print(f(y=2, x=1, z=4))
```

* **A.** `2`
* **B.** `4`
* **C.** `8`
* **D.** `SyntaxError`

---

{% details **Respuesta:** %} 

👉 **C.** `8`

En la funciones de Python existe el concepto de **argumentos nominales** o **argumentos por nombre** , es una característica muy interesante de Python que nos permite llamar a una función con cada argumento nombrado, esto permite que el orden de los argumentos no importe. 



 
{% enddetails %}
Ibuprofeno.py💊| #139: Explica este código Python
Tags: python, beginners, spanish, learning
Published: 2024-07-12 11:00:00

## **<center>Explica este código Python</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```py
def f(x, y, z):
    return x * y * z
    
print(f(4, z=2, y=2))
```

* **A.** `8`
* **B.** `16`
* **C.** `2`
* **D.** `SyntaxError`

---

{% details **Respuesta:** %} 

👉 **B.** `16`

Es posible mezclar tanto argumentos posicionales como argumentos nombrados en una función.

La única condición es que los **argumentos posicionales** deben ir siempre antes que los **argumentos nombrados**, solo así no se producirá un error.

Por ejemplo, el siguiente código sería incorrecto:

```py
def f(x, y, z):
    return x * y * z
    
print(f(z=2, 4, y=2)) # SyntaxError: positional argument follows keyword argument
```

{% enddetails %}
Effective Strategies for MySQL User Management
Tags: security
Published: 2024-07-08 07:00:00

MySQL user management is a vital aspect of database administration. This article explores essential strategies for managing MySQL users, roles, and privileges effectively.

### MySQL User Management examples

MySQL has three primary users by default `mysql.session`, `mysql.sys`, and `root`, their functions are:

- `mysql.session`, access for plugins.
- `mysql.sys`, security backup if `root` is altered.
- `root`, full privileges for all administrative tasks.

Roles help manage user privileges efficiently, here’s an example;

```sql
CREATE ROLE 'admin_role';
GRANT ALL PRIVILEGES ON database.* TO 'admin_role';
GRANT 'admin_role' TO 'admin_user';
```

### FAQ

**What Is User Management in MySQL?**
Managing users and their permissions within MySQL databases.

**How Do I Secure Users in MySQL?**
Utilize strong passwords, appropriate privileges, and MySQL’s security features.

**Where Can I Learn More About MySQL Security?**
Consult MySQL’s official documentation or our detailed blog posts.

### Summary

Managing MySQL users effectively requires knowledge of roles and privileges coupled with strong security measures. For a detailed guide, check out the comprehensive article [MySQL User Management: A Guide.](https://www.dbvis.com/thetable/mysql-user-management-a-guide/)
Streamlining SQL Data Management with Generated Columns
Published: 2024-07-11 07:00:00

Generated columns in SQL automatically compute and store data, simplifying database operations. This article offers a brief overview and practical examples to demonstrate their use.

## Examples of SQL Generated Columns
In SQL, generated columns are defined via `CREATE TABLE` or `ALTER TABLE`. Here’s an example using MySQL:

```sql
ALTER TABLE users
ADD COLUMN fullName VARCHAR(255) AS (CONCAT(name, " ", surname)) STORED;
```

This adds a stored column `fullName` that concatenates `name` and `surname`.

For a virtual column, which doesn’t use storage space:

```sql
ALTER TABLE users
ADD fullNamePoints VARCHAR(255) AS (CONCAT(fullName, " (", points, ")")) VIRTUAL;
```

## FAQs About Generated Columns

**What databases support generated columns?**
Databases like MySQL, MariaDB, PostgreSQL, SQL Server, and Oracle support generated columns.

**What is the difference between a trigger and a generated column?**
Triggers execute scripts on events affecting multiple tables, whereas generated columns store auto-calculated data in one table.

**What are the types of columns generated in SQL?**
SQL has stored (precomputed) and virtual (computed on-the-fly) generated columns.

**What is the difference between a generated column and a regular column?**
Generated columns are auto-calculated and immutable, unlike regular columns which are manually updated.

## Conclusion
SQL generated columns automate data calculations, enhancing database efficiency. For an in-depth guide and more examples, check out [The Ultimate Guide to Generated Columns.](https://www.dbvis.com/thetable/the-ultimate-guide-to-generated-columns/)
test
Published: 2024-07-12 08:54:30

The Indian cricket team has experienced significant growth and success in the last five years, marked by several milestones and achievements. Here are some key highlights:

### 2019-2020: The Rise of Virat Kohli

Virat Kohli took over as the captain of the Indian cricket team in 2014 and has been instrumental in shaping the team's performance. Under his leadership, India has dominated bilateral series, including a historic Test series win in Australia in 2018-2019. Kohli's aggressive batting style and strategic acumen have been crucial in maintaining India's strong performance in international cricket[1][2].

### 2020-2021: The IPL's Global Reach

The Indian Premier League (IPL) has become one of the most popular and lucrative cricket leagues globally. The 2020 IPL season saw a significant increase in crowd participation and financial returns. The IPL's social media presence is also impressive, with the top five cricket clubs on social media being IPL teams[1].

### 2021-2022: Women's Cricket Emerges

The Indian women's cricket team has seen a surge in popularity, thanks to the success of players like Smriti Mandhana, Harmanpreet Kaur, and Jhulan Goswami. The team has been performing well in international tournaments, and the BCCI has been actively promoting women's cricket through various initiatives[3].

### 2022-2023: New Talent and Leadership

The emergence of young talents like Shubman Gill, Yashasvi Jaiswal, and Rishabh Pant has added depth to the Indian team. Rohit Sharma, who took over as captain in 2021, has been instrumental in shaping the team's philosophy and performance. The team has been performing well in bilateral series and is preparing for the 2023 ICC ODI World Cup[2][3].

### 2023-2024: The Future Looks Bright

The future of Indian cricket looks promising with the rise of new talents like Arshdeep Singh and the continued success of established players. The BCCI's efforts to develop domestic cricket and promote young players are expected to bear fruit in the coming years[2][3].

### Conclusion

The last five years have been a period of growth and success for Indian cricket. The team's performance in international cricket, the popularity of the IPL, and the rise of women's cricket are all testament to the sport's increasing popularity and the BCCI's efforts to develop the game. As the team prepares for future challenges, the future looks bright for Indian cricket.

Citations:
[1] https://en.wikipedia.org/wiki/Cricket_in_India
[2] https://www.zapcricket.com/blogs/newsroom/indian-cricket-team
[3] https://www.superprof.co.in/blog/what-makes-the-indian-national-cricket-team-great/
[4] https://economictimes.indiatimes.com/news/sports/the-day-india-cricket-changed/articleshow/101246259.cms
[5] https://eprints.lse.ac.uk/75310/1/blogs.lse.ac.uk-Cricket%20and%20the%20rise%20of%20modern%20India.pdf
What was your win this week?
Tags: weeklyretro
Published: 2024-07-12 13:41:00

👋👋👋👋

Looking back on your week -- what was something you're proud of?

All wins count -- big or small 🎉

Examples of 'wins' include:

- Getting a promotion!
- Starting a new project
- Fixing a tricky bug
- Finally finding the remote control after days of searching 📺

![homer praying to find remote control](https://i.giphy.com/media/v1.Y2lkPTc5MGI3NjExMzZtZ3VidXgyeGZ0cTl0dHEyenU3eWVuaDU1OXpibGUxZm1ncG4wZCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/3orieNQgdcxedKjA3e/giphy.gif)

Happy Friday!
What is different between undefined and null in Java Script
Tags: typescript, javascript, webdev, programming
Published: 2024-07-10 11:47:56

I introduce that what is different between `undefined` and `null` because   it is difficult to describe it exactly.

## Understanding the Difference between undefined and null

In many programming languages, there is usually one way to represent "no value," such as null.
However, in JavaScript, there are two ways to represent "no value": `null` and `undefined`. This can be surprising and confusing for people coming to JavaScript from other languages.


## 💡Basics

### null

`null` doesn't occur unless programmer Intentionally uses it.

### undefined

On the other hand, `undefined` occurs naturally, even if you don't use it explicitly. 

For example, if you declare a variable and it has no initial value, JavaScript will assign `undefined` to it.

```ts
let test;
console.log(test);
// → undefined
```

When accessing the property that doesn't exist in a object or the element that is not in array, it will automatically became undefined.

```ts
const object = {};
console.log(object.foo);
// → undefined

const array = [];
console.log(array[0]);
// → undefined
```


## 🔍JSON

### undefined
When you use `undefined` for the value of an object's property and then convert that object to JSON using JSON.stringify, the property is removed from the JSON output.

```ts
console.log(JSON.stringify({ name: undefined }));
// → {}
```

### null
On the other hand, when the value of property is `null`, it will retained .

```ts
console.log(JSON.stringify({ name: null }));
// → {"name": null}
```


## 👀Conclusion

It is easier to unify with `undefined` because `undefined ` occurs naturally everywhere.

Happy Coding☀️
First STAG Game Post Mortem
Tags: gamedev, programming
Published: 2024-07-11 00:01:54

Over the past few months the game studio I'm a part of, [STAG](https://saythatagaingames.itch.io/) has created and now released their first game, [Cheese Clout](https://saythatagaingames.itch.io/cheese-clout). I only just released it, but I thought I would already do a post mortem, as I feel I have a lot to reflect on.

## Deadlines
There are 4 people in the studio (give or take), which may sound like plenty to develop a game, but we are all extremely busy people, so between us we aren't able to get much work done.
From what I can gather, I have the most free hours out of anyone, but I've learned that just because I have more time doesn't mean more can be done. I was often in a position where I wanted to add more, but didn't have the assets from the team to add it. That's not to say anything bad, people are simply busy, so it's not always that easy. We originally planned to develop the game in a single month, which we did on purpose, we scoped it so that the deadline was possible.

## Error Handling
Something I'm proud of from making Cheese Clout is the error handling (that I know of). I created a module called "stagerror," which behaves differently depending on how the game is being played. I set a flag called `IS_RELEASE` to control this. If we're not in release mode, we want to catch every single error as it comes, so we use `panic` to get the developer's attention. However, as a user, this is a terrible way to play a game, having it crash all the time. Because of this, in release mode we don't hard error, we just write to a log file in the background and try to continue on as best we can. Cheese Clout has a primitive version of this, and I'm still getting better at using this module, but a great example for its use would be images. If the game is missing one image, I don't want it to crash and be unplayable, instead, it should log out that it's missing an image.

## Level Editor
Right now, I haven't released the level editor for Cheese Clout. I will have that out soon (if I remember), especially since it's a great part of the game to be able to make and play your own levels. The level editor isn't that great. It works, but I wish I had spent more time making it nicer, such as making the text boxes more convenient, and just a bunch of other ease of use features.
to specialise or not to specialise?
Tags: career, discuss
Published: 2024-07-08 11:17:47

As a self-taught developer currently working in IT with multiple interests in tech such as web- and application-development, machine-learning and IoT, I've run in a recent hurdle of whether or not I should specialise. 

A little more information: I've been in the tech industry for a little over a year which can be considered a junior developer (please correct me if I'm mistaken), and the programming languages that I'm most familiar with include JavaScript and Go. My academic qualifications are unrelated to engineering or computer science although I am in process of getting an AWS foundational certificate. I am also currently based in Singapore if it's of any relevance.

If you're a seasoned developer, please give me some advice on whether I should pick a field or niche in tech to specialise in, and if so, which field(s) have a slightly lower than average barrier of entry.
What is ASP.Net MVC?
Tags: mvc
Published: 2024-07-10 06:45:05

MVC is one of the architectural pattern for implementing user interfaces. 

**MVC components :-**
**Model :** Application data and behaviour in terms of its domain and independent of the UI.

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

**View :** The HTML markup that we display to the user.

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

**Controller :** Responsible for handling HTTP request. Get data from database through the model, put them in the view and return the view to the client or the browser.

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

There is one more piece to this architecture which is not in the acronym "MVC" but it is nearly always there. It's router. When a request comes in an application, a controller will be selected for handling that request. Selecting the right controller is the responsibility of the router. 

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

Router : Selects the right controller to handle a request.

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

A router based on some rules knows that the request with a URL should be handled by a class. More accurately it should be handled by one of the methods in the class because a class can have many different methods. 
In ASP.NET MVC we refer to method of a controller as actions. So it is more accurate to say with, an action in a controller is responsible for handling a request.
 
 **Benefit of MVC :-**
Better separation of concern : With this architecture each component has distinct responsibility and this results in better separation of concerns and more maintainable application.
🔀 Semantic Router w. ollama/gemma2 : real life 10ms hotline challenge 🤯
Tags: opensource, ai, showdev, python
Published: 2024-07-10 23:27:11

## ❔ About `CCaaS` (aka. Contact Center as a Service)

Cf [Gartner](https://www.gartner.com/reviews/market/contact-center-as-a-service) : 

> "Gartner defines contact center as a service (`CCaaS`) as solutions offering SaaS-based applications that enable customer service departments to manage multichannel customer interactions holistically from both a customer-experience and employee-experience perspective. CCaaS solutions offer an adaptive, flexible delivery model with native capabilities across the four functional components of the technology reference model for customer service and support. CCaaS providers also offer productized integrations with partner solutions through application marketplaces."

👉 Today, we'll cover some of these aspects by **focusing on how to efficiently route a huge number and variety of questions into a ridiculuous little amount of topics** so they can be efficiently managed by the proper adequate services.

To achieve that, we'll use 100% Open Source software, on **locally running LLMs**, thanks to the following stack : 

- **📘 A custom hand-made** dataset
- [`🦙 ollama`](https://ollama.com/)
- [`🤖 gemma2`](https://huggingface.co/docs/transformers/main/en/model_doc/gemma2)
- [🔀 Semantic Router | Aurelio AI](https://www.aurelio.ai/semantic-router)

## 💰 Expected benefits

- Save a lot of **human time**
- Save a lot of **money** (less LLM/GPU calls)
- **Dispatch tasks** according to their kind or complexity on different channels
- Keep (Kanban-like) swimlanes clean to **get an optimal throughput**

## 🍿 Demo for impatients

{% youtube QHqti5NprX8 %}


## 📚 Data sources

- **Public Facebook** human moderations
- **Corporate** websites


Below some real life datasources I used:

- [Je déménage et je souhaite que mon fixe et mon Internet me suivent](https://www.opt.nc/particuliers/telephonie-fixe/je-demenage-et-je-souhaite-que-mon-fixe-et-mon-internet-me-suivent)
- [Je déménage et je suis client CCP](https://www.opt.nc/particuliers/services-financiers/je-demenage-et-je-suis-client-ccp)
- [Pour toutes assistance concernant une coupure ou une perturbation de ma ligne Fixe ou Internet](https://www.opt.nc/assistance/assistance-coupure-et-perturbation-internet-fixe)
- [Bien entretenir ma ligne de téléphonie fixe ](https://www.opt.nc/particuliers/telephonie-fixe/bien-entretenir-ma-ligne-de-telephonie-fixe) 

## 🗣️ Real life Q&A interactions examples

Below some real life customer Q&As:

> "Je déménage et je souhaite que mon fixe et mon Internet me suivent"

**💡 Answer** : Go to https://www.opt.nc/particuliers/telephonie-fixe/je-demenage-et-je-souhaite-que-mon-fixe-et-mon-internet-me-suivent

> "Je déménage et je suis client CCP"

**💡 Answer** : Go to https://www.opt.nc/particuliers/services-financiers/je-demenage-et-je-suis-client-ccp

## 🔖 Resources

Source code is available below : 

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o3wce9vis025t0oe2xb5.png)](https://www.kaggle.com/code/adriensales/semantic-router-ollama-gemma2-hotline)