teleren/devto huggingface dataset:
ChatGPT - Complex Coding Challenges: 6 KYU
Tags: javascript, c, haskell, chatgpt
Published: 2023-03-07 20:16:13

Hello and welcome back to this series where we put ChatGPT through its paces!

We have a slight change in direction this time around because we have swapped out SQL with Haskell.

So before we start, here is the challenge [Array.diff](https://www.codewars.com/kata/523f5d21c841566fde000009/train/javascript)

The instructions and description is as follows:

```
Your goal in this kata is to implement a difference function, which subtracts one list from another and returns the result.

It should remove all values from list a, which are present in list b keeping their order.

arrayDiff([1,2],[1]) == [2]

If a value is present in b, all of its occurrences must be removed from the other:

arrayDiff([1,2,2,2,3],[2]) == [1,3]
```

Lets get started.

**Solving it in JavaScript**

```js
function arrayDiff(a, b) {
  return a.filter((value) => !b.includes(value));
}
```

A very concise and simple solution, that passes all tests.

**Solving it in C**

```c
#include <stdlib.h>

int* array_diff(const int* arr1, size_t n1, const int* arr2, size_t n2, size_t* z) {
    int* result = malloc(n1 * sizeof(int));
    size_t count = 0;
    for (size_t i = 0; i < n1; i++) {
        int found = 0;
        for (size_t j = 0; j < n2; j++) {
            if (arr1[i] == arr2[j]) {
                found = 1;
                break;
            }
        }
        if (!found) {
            result[count++] = arr1[i];
        }
    }
    *z = count;
    return realloc(result, count * sizeof(int));
}

```

The solution for C is very verbose in comparison, however, it too passes all of the tests.

**Solving it in Haskell**

```haskell
module Difference where

difference :: Eq a => [a] -> [a] -> [a]
difference a b = filter (`notElem` b) a

```

Another more concise solution and more passed tests!

It feels like it has been a bit easier this time around even though the level of difficulty has been increased.

I wonder if it is due to my questioning getting better and more refined or if something else is at play here.
Weird Things about the Internet and lies about JavaScript
Tags: internet, html, javascript, webdev
Published: 2023-03-07 20:06:01

Sometimes it's important to take a break from JavaScript and just find out weird things about the internet. Sooo...lettuce dive in a bit. So sure, JavaScript is cool but what does it do? Well, thats a challenging thing to say with the rise of NodeJS and the developments of HTML5. For example, many will say you need JS for validating input values of a form before the data is sent to a web server, but HTML5 is also doing great work with [form validation](https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation). So it would be a big rotten lie to say JS is the only way to do form validation on the world wide web and people are really leaning into shipping less JS these days so maybe it's time to dive [even deeper into html form vaildation](https://blog.logrocket.com/when-how-to-choose-html-form-validation/).
Anyways, weird internet things. Let's go!

1. Before internet, there was ARPANET and packet switching.
2. The word Internet was first used in 1974 and is short for internetwork.
3. Internet used to be capitalized more, lol.
4. CERN, creators of the Large Hadron Collider(LHC), is credited with the first highspeed T1 (1.5 Mbit/s) link, which connected CERN to Cornell University.
Mockando a propriedade window.screen com Jest
Tags: javascript, typescript, jest, react
Published: 2023-03-07 20:02:09

Para realizar um mock da propriedade window.screen e definir um valor padrão para realizar algum teste, basta usar utilizar a função `jest.spyOn`, disponibilizada pela lib de testes **[jest](https://jestjs.io/pt-BR/)**.

**Por exemplo:**
```
jest.spyOn(window.screen, "width", "get").mockReturnValue(1000);
console.log(window.screen.width);
```

O resultado para o console.log acima irá retornar `1000`.

O mesmo pode ser feito para a propriedade height.

**Vamos ao exemplo:**
```
jest.spyOn(window.screen, "height", "get").mockReturnValue(500);
console.log(window.screen.height);
```

O resultado para o console.log acima irá retornar `500`.

A seguir deixo um exemplo completo em React de uma implementação mockando a instância width da propriedade **[Screen](https://developer.mozilla.org/en-US/docs/Web/API/Screen)**.

### React:
```
export const Menu = () => {
  const showMenuDesktop = window.screen.width > 400;

  return (
    <>
      {showMenuDesktop && (
        <MenuDesktop getByTestId="component-MenuDesktop" />
      )}
    </>
  );
};
```

### Teste unitário:
```
describe("Component MenuDesktop", () => {
  it("NÃO deve renderizar MenuDesktop em tela pequena", () => {
    jest.spyOn(window.screen, "width", "get").mockReturnValue(300);
    const { getByTestId } = render(<Menu/>);
    expect(getByTestId("component-MenuDesktop")).toBeFalsy();
  });

  it("Deve renderizar MenuDesktop em tela grande", () => {
    jest.spyOn(window.screen, "width", "get").mockReturnValue(1024);
    const { getByTestId } = render(<Menu/>);
    expect(getByTestId("component-MenuDesktop")).toBeTruthy();
  });
});
```

💬 Dúvidas, sugestões ou críticas, utilize os comentários abaixo! 😉
Ruby Arrays: Access, Insert, Count, and Include
Published: 2023-03-07 19:57:27

array_list = ["milk", "eggs", "bread", "ice cream", "pie", "potatoes"]

Accessing "milk" and assigning it to variable named "item"
`item = array[0]`

Printing first item in array:
`puts.array.first`

Printing out last item in array:
`puts array[-1]`
`puts array.last`

Return the number of items in an array:
`array.length`
`array.count`

Return the number of items in the array based on the matches found:
`array.count("eggs") # => 1`

To find out if a specific item is on the array list:
`array.include?("eggs") # => true`
Essential SQL Commands for Data Science
Tags: datascience, database, sql, beginners
Published: 2023-03-07 18:42:06

SQL (Structured Query Language) is a powerful tool for managing and manipulating relational databases. It is an essential skill for data scientists, as it allows them to extract, clean, and analyze large datasets. Here are some essential SQL commands for data science:

1. SELECT: This command is used to select data from one or more tables. The syntax is as follows:

```sql
SELECT column1, column2, ... FROM table_name;
```
2. WHERE: This command is used to filter data based on certain conditions. The syntax is as follows:


```
SELECT column1, column2, ... FROM table_name WHERE condition;

```
3. GROUP BY: This command is used to group data based on one or more columns. The syntax is as follows:

```
SELECT column1, column2, ... FROM table_name GROUP BY column1, column2, ...;
```

4. ORDER BY: This command is used to sort data based on one or more columns. The syntax is as follows:

```
SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... [ASC | DESC];
```

5. JOIN: This command is used to combine data from two or more tables based on a common column. The syntax is as follows:

```
SELECT column1, column2, ... FROM table1 JOIN table2 ON table1.column = table2.column;
```

6. DISTINCT: This command is used to select unique values from a column. The syntax is as follows:

```
SELECT DISTINCT column1 FROM table_name;

```
7. COUNT: This command is used to count the number of rows or non-null values in a column. The syntax is as follows:

```
SELECT COUNT(*) FROM table_name;
SELECT COUNT(column1) FROM table_name;
```

8. SUM, AVG, MAX, MIN: These commands are used to perform mathematical operations on a column. The syntax is as follows:

```
SELECT SUM(column1) FROM table_name;
SELECT AVG(column1) FROM table_name;
SELECT MAX(column1) FROM table_name;
SELECT MIN(column1) FROM table_name;
```

9. LIMIT: This command is used to limit the number of rows returned by a query. The syntax is as follows:

```
SELECT column1, column2, ... FROM table_name LIMIT n;

```

These are just some of the essential SQL commands for data science. There are many more commands and functions available in SQL, but these should be enough to get you started with data analysis.

Thank Hope you enjoyed reading Keep tuned for me from 
[Roy Wanyoike](https://twitter.com/WanyoikeRoy)
Ruby: Creating an Array and Addition Functions
Published: 2023-03-07 18:30:36

Create an array:
`array_name = []`
`array_name = Array.new`

Adding items to the array:
`array = ["milk", "eggs", "bread"]`
`array = %w(milk eggs bread)`

Adding "carrots" to the end of the array:
`array << "carrots"`

Adding the string "potatoes" to the end of the array:
`array.push("potatoes")`

Adding the string "celery" to the beginning of the array:
`array.unshift("celery")`

Adding "ice cream" and "pie" to the end of the array"
`array += ["ice cream", "pie"]`

Adding the number 1 to the end of the array:
`array << 1`
Customization using Matplotlib in Python.
Tags: beginners, programming, tutorial, python
Published: 2023-03-07 18:17:00

**1. What is Matplotlib**
Matplotlib is a popular data visualization library in Python widely used for creating static, interactive, and animated visualizations in Python. We can represent our data in many interactive ways like Graphs, Histograms, Pie Chart, etc.

**2. Why Matplotlib**
It provides a wide range of customization options to make your graphs more informative and visually appealing. Here are some of the customization options available in Matplotlib:

- Adding markers
- Changing kind of graph
- Adding labels and titles
- Adding legends

**3. Using markers in graphs**
Markers in Matplotlib are used to represent data points on a plot with a symbol, such as a circle, square, or triangle. We can perform various function and customizations using keyword **marker ** like:

- Changing the marker size
- Changing the marker color
- Changing the marker edge color and width

**Syntax**

```
import matplotlib.pyplot as plt
import pandas as pd

ypoints = [10,20,34,40,15]

plt.plot(ypoints, marker = 'o', markeredgecolor='black', markersize=7, markerfacecolor='red')
plt.show()
```
**Output**


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

**4. Different kind to represent our data**
We can represent our data in many interactive forms like:
Pie charts, Histograms, BarCharts, etc. using a keyword **kind**. 
**Note**
Kind of graph is written as a string.

**Syntax**

```
import matplotlib.pyplot as plt
import pandas as pd

data = {'x': [1, 2, 3, 4, 5], 'y': [2, 4, 6, 8, 10]}
df = pd.DataFrame(data)
graph = df.plot(kind="bar")
plt.show(graph)
```
**Output**:

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

**5. Labels and titles**
Labels and titles are most important components of a Matplotlib plot, as they provide information about the data being visualized. They make the plot easier to understand. We can add labels both on x and y axis while title provides the plot to a name which becomes more informative.
**Syntax**

```
import matplotlib.pyplot as plt
import pandas as pd

data = {'x': [1, 2, 3, 4, 5], 'y': [2, 4, 6, 8, 10]}
df = pd.DataFrame(data)
graph = df.plot(kind="bar")
plt.title("Monthly Sales")
plt.xlabel("Years")
plt.ylabel("Sales")
plt.show(graph)
```
**Output**

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

**6. Customization using Legend**
Legend is used to identify and distinguish between different plots in a figure. We can change the color of multiple bars which makes our plot more interactive and easier to understand.
**Syntax**

```
import matplotlib.pyplot as plt
import pandas as pd

data = {'x': [1, 2, 3, 4, 9], 'y': [2, 5, 6, 8, 10]}
df = pd.DataFrame(data)
graph = df.plot(kind="bar")
plt.legend(["blue","orange"])
plt.show(graph)
```
**Output**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/549mzmkni5eo1m2lc4mr.png)
Beyond Google: How to Ask Good Questions as a Developer
Tags: beginners, codenewbie, tutorial, webdev
Published: 2023-03-07 18:09:18

![underrated skill as a programmer - knowing when to ask for help](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xksst4d49fnm6y652wqn.png)

As junior developer, asking for help can be hard.

But it's also a low effort way to level up IMO.

In this article, sharing a 4-step checklist that I have refined over the years in my software career.

By putting these checks before asking questions will:
- Improve quality of your questions.
- Get you more responses.
- Build credebility in community.  

Let's dive in :rocket:

---

## TL;DR

[✔️ Did I try googling?](#---did-i-try-googling-)
[✔️ Have I provided enough context?](#---have-i-provided-enough-context-)
[✔️ Have I shared what I have tried?](#---have-i-shared-what-i-have-tried-)
[✔️ Is the question specific and readable?](#---is-the-question-specific-and-readable-)

### ✔️ Did I try googling?

Why wait for someone else to respond when you can help yourself. 

Being able to find answers on your own will make you more independent and instill confidence in your skill.

### ✔️ Have I provided enough context?

Without enough background, there's a high chance your question will be misunderstood.

By giving detailed context you will invite more helpful responses and better feedback.

### ✔️ Have I shared what I have tried?

Others will be more willing to help you if they see you putting effort. 

With your examples, people will get a better understanding of your problem and suggest solutions which you haven't already tried.

### ✔️ Is the question specific and readable?

Specific and readable questions will get you a faster and more accurate response.

It shows professionalism and attention to detail which builds positive rapport in the developer community.

---

## Wrapping Up

![wrapping up](https://media.giphy.com/media/l0IycQmt79g9XzOWQ/giphy.gif)

Hope you found this checklist helpful.

If you liked this post, follow me for more of these 🙂

Also, would love to hear if anything you would like to add or remove in it 👇
Tidelift can help with legal support for lifters
Published: 2023-03-07 17:53:54

Hi, all! A lifter recently received a DMCA notice, asking that they take their package down. We reached out to offer support. Thankfully, our support was not needed. It did remind me, though, that it's been a long time since we mentioned to you that—just like we [help you with security](https://support.tidelift.com/hc/en-us/articles/4406287910036-Security-process)—we can also help if your package receives a legal question of some sort.

## Why?

This is probably obvious, but part of why our customers pay us is to make sure your package stays available, and ensure that they can use it legally. Both Tidelift and our customers are happy to help if you get legally challenged!

## Examples, including how we can help

Here are a few situations where we can help you out.

- **Licensing:** Don't understand how a copyleft dependency impacts you? Need to know how multiple permissive licenses work together? Or why GitHub's scanner isn't seeing your license information? Let us know and we can help you promptly.

- **DMCA:** The Digital Millennium Copyright Act provides a way for copyright owners to get infringing materials taken off hosting services, often called "takedown notices". It isn't common, but these notices can be directed at package hosting services like PyPi. If you get one of these, let us know—we may be able to help directly, or to put you in touch with other attorneys or with the package ecosystem's legal team.

- **Patents:** Claims of patent infringement by open source projects are thankfully quite rare, but are impactful when they do happen—for both you and customers who use your software. Please let us know when and if this happens to you. Among other things, we are a member of the [Open Invention Network](https://openinventionnetwork.com/) and can help you connect with them or other community resources.

If you get other legal questions about your package that don't fall into one of these buckets, reach out and we’ll do our best to assist you.

## Limitations
Tidelift can't be your attorney, so that may sometimes limit how we can work with you. If we need, we can always help you match up with other attorneys, and we may be able to help support your costs in a legal defense as well.

## How to reach out?

If you do find yourself in a legal  situation, the best way to reach out is to simply tell **lifter@tidelift.com** that you’d like to check in with Tidelift about a legal question. (If the issue is public, like many licensing issues are, feel free to include a link!) The team will figure out the best way for you to talk to us, making sure we do our best to protect your confidentiality.
I tried making this reflective UI using HTML CSS and Javascript
Tags: webdev, javascript, showdev, programming
Published: 2023-03-07 17:53:40

Have you ever seen a website with a reflective user interface? 

Recently, I decided to take on the challenge of creating a reflective UI using only these three technologies: HTML, CSS and JavaScript. And after some experimentation and tweaking, I'm happy to share my results with you all.

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

you can check it out at: [https://demo-gg.vercel.app/](https://demo-gg.vercel.app/)

Also it you like it please follow me on Twitter: [@gitrevert](https://twitter.com/gitrevert)

{% embed https://twitter.com/gitrevert/status/1633057413312987136 %}
CodePen Designs - 44 : Newton's Light Bulbs 💡😎
Tags: codepen, css, design, webdev
Published: 2023-03-07 17:48:46


### We are excited to introduce our new series that will explore the best design ideas from the Codepen community. 

We will be publishing these each day and hope you find them insightful and inspiring as we showcase some of the most talented designers in this space.

---

---

## Video Tutorial

Don't miss the amazing video we've embedded in this post! Click the play button to be inspired

{% youtube  PnqDy99p3EA %}

---
### Codepen Design - 44
---
<p>Saw an animation of a Newton's cradle made of light bulbs so figured I'd try create my own with GreenSock 👍</p>

<p><strong>EASTER EGG</strong> 🥚: Type numbers to update the hue of the bulbs!</p>

<p>Enjoy! </p>

{% codepen https://codepen.io/jh3y/pen/abzeaWJ %}


---
## For more information

1. Check my GitHub profile
[https://github.com/amitSharma7741](https://github.com/amitSharma7741)

2. Check out my Fiver profile if you need any freelancing work
[https://www.fiverr.com/amit_sharma77](https://www.fiverr.com/amit_sharma77)

3. Check out my Instagram
[https://www.instagram.com/fromgoodthings/](https://www.instagram.com/fromgoodthings/)

4. Linktree
[https://linktr.ee/jonSnow77](https://linktr.ee/jonSnow77)

5. Check my project

- EVSTART: Electric Vehicle is the Future
[https://evstart.netlify.app/](https://evstart.netlify.app/)
-  News Website in react
 [https://newsmon.netlify.app/](https://newsmon.netlify.app/)
-  Hindi jokes API
 [https://hindi-jokes-api.onrender.com/](https://hindi-jokes-api.onrender.com/)
- Sudoku Game And API
[https://sudoku-game-and-api.netlify.app/](https://sudoku-game-and-api.netlify.app/)

---
---

---

## Video Tutorial

Don't miss the amazing video we've embedded in this post! Click the play button to be inspired

{% youtube  PnqDy99p3EA %}

---
Top 5 Programming Languages to Learn in 2023 for Career Growth and Job Opportunities
Tags: javascript, rust, kotlin, python
Published: 2023-03-07 17:44:02

[](https://youtu.be/7QsdlME77eU)link
Use this link for more information 

Programming languages are essential tools for developers, enabling them to create applications, software, and websites. With the increasing demand for programming skills, it is essential to learn the right language to fit your needs. Here are the top 5 programming languages in 2023:

Python

Python is a high-level, general-purpose programming language that is popular for its simplicity and ease of use. It is widely used in scientific computing, data analysis, machine learning, and web development. Python's readability and easy-to-learn syntax make it a preferred language for beginners. It has a vast collection of libraries and frameworks that allow developers to complete complex tasks quickly.

JavaScript

JavaScript is a scripting language used primarily for web development. It is the backbone of front-end development, allowing developers to create interactive user interfaces and dynamic web applications. JavaScript's versatility and popularity have led to its use in back-end development and mobile app development. It has a vast collection of libraries and frameworks that make it easy to develop applications.

Rust

Rust is a system programming language that is popular for its performance, reliability, and memory safety. It is designed for speed, concurrency, and safety, making it an ideal language for building high-performance systems, operating systems, and web applications. Rust's advanced features make it a suitable choice for developers who want to build high-performance and reliable systems.

Kotlin

Kotlin is a modern, open-source programming language that is gaining popularity as a preferred language for developing Android applications. It is designed to be concise, expressive, and safe, making it an excellent language for developers who want to build robust and efficient applications. Kotlin has a wide range of libraries and frameworks that make it easy to build applications for Android, web, and desktop.

Swift

Swift is a powerful, modern, and intuitive programming language developed by Apple. It is designed to be fast, safe, and easy to learn, making it an ideal language for developing iOS, macOS, watchOS, and tvOS applications. Swift's syntax is concise and expressive, making it easy to write and read code. It has a large collection of frameworks and libraries that make it easy to develop applications for Apple's ecosystem.

In conclusion, these programming languages are in high demand and offer various benefits for developers. Each language has its strengths and weaknesses, and the choice of programming language depends on the developer's needs, the project requirements, and the platform they are targeting.