teleren/devto huggingface dataset:
TIL: From test to Testing Playground
Tags: webdev, javascript, testing, frontend
Published: 2023-08-27 13:15:27

Testing the frontend is not that hard!

Some people dread frontend testing, others think it’s a chore because they can see it already working. Not to mention people who don’t test at all.

One of the problems I had while testing the frontend, where mostly because of the framework I had to use. It’s all `div`s everywhere, lots of portals and attributes that go who knows where.

When a query fails, it gives the HTML being rendered so you can inspect it. But we are not robots, so it’s easier to see WHAT it looks like.

Enters: https://testing-playground.com/

You can just copy the HTML and paste it there so it will show what the test “is seeing”. This makes it easier to find out why the query is not working.

Instead of waiting for the errors, you can also use [`screen.debug()`](https://testing-library.com/docs/dom-testing-library/api-debugging/#screendebug) to print the current HTML.

It also has browser extensions that you can use directly on the websites. For example, you can just start your frontend and check everything there with the extension.

This is where this little big helper comes:

[`screen.logTestingPlaygroundURL()`](https://testing-library.com/docs/dom-testing-library/api-debugging/#screenlogtestingplaygroundurl)

You can just put that on the test and it prints a link to the playground with the whole thing for you to test.

Styles aside, you can probably use it even as a way of doing TDD! On each step, you can see exactly what’s being rendered. This way, you could probably develop everything without running `start` or `dev` once! Afterward, all that would remain would be styling! 

Some people who don’t test might say or think it’s “slow”. But, when you have a lot of logic in your application, you have to do the same thing a lot of times just to get to that one part you’re having trouble with for one more try.

With tests, you let it do all the steps and more! Instead of trusting you’re not breaking something else when you make the fix, you know it’s still all working.

It’s been around for more than a while, I learned about it recently and it’s already changed how I’m doing tests!
Transfer files from Mobile to PC for free using FTP.( Without USB )
Tags: linux, android, ios, tutorial
Published: 2023-08-27 13:11:43

You're at home or at the office and you quickly need to transfer or access files on your Mobile device from your PC. 
No USB cable ? Fine . I know its 2023 , but ftp is still here to save the day !

1.**Install an FTP Server App:**
On your mobile device, use file Manager with support for FTP sharing eg. CX File Explorer or install an FTP server app from your app store, e.g."AndFTP" for Android or "FTPManager" for iOS.

2.**Connect to the Same Wi-Fi Network:**
Ensure that both your mobile device and PC are connected to the same Wi-Fi network. This step is essential for devices to communicate with each other.

3.**Launch FTP Server App:**
Open the FTP server app on your mobile device. Configure the app settings, including the username, password, and the folder you want to share.

4.**Start FTP Server:**
Start the FTP server within the mobile app. It will provide you with an FTP address (usually an IP address and port number).

![Phone Screenshot FTP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hcjuxpt5bppks1pbg0zv.png)
5.**Use FTP Client on PC:**
On your PC,use the default File Manager as FTP Client or built-in command-line FTP tool or  download and install an FTP client software like "FileZilla". Open the FTP client and enter the FTP address provided by the mobile app (Step 4).

6.**Connect and Transfer Files:**
In the FTP client, enter the username and password you set in the mobile app (Step 3). Connect to the FTP server. You'll see your mobile device's shared folder. From here, you can drag and drop files between your PC and mobile device.

![PC Screenshot FTP](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4cvw9h46jw8t64eqyz3k.png)
PHP Servidor Web
Published: 2023-08-27 13:02:42

Nesse pequeno artigo, vou ensinar a vocês como utilizar o servidor interno do próprio **PHP** para vocês testarem o projeto que estão construindo sem precisa instalar o famigerado **xampp**. 

Para isso precisamos que vocês tenham instalado no seu computador de vocês, o famoso **PHP**, se caso não tenha feito isso, precisará fazer. 

Para galera que usa o Windows precisa ir até no site do [PHP](https://windows.php.net/download/) baixar a versão thread safe e descompactar no seu **C:**  e colocar na variável de ambiente e após isso você abra seu prompt de comando e testa o comando **php --version** que mostra a versão do seu PHP.

Já pra quem usa o linux, principalmente pra quem usa o Ubuntu ou derivado, eu recomendo que adicione o ppa da própria linguagem, veja a seguir:

```
sudo add-apt-repository ppa:ondrej/php

Depois vamos atualizar e instalar o php com os seguintes comandos:

sudo apt update 

sudo apt install -y php
```

Após isso para verificar se o php foi instalado com sucesso vamos utilizar o comando **php --version** para checar a versão instalada.

Já com tudo instalado, já poderemos usar o servidor interndo do **PHP** com o seguinte comando:

```
php -S localhost:8000
```

o parâmentro **-S** indica que estamos chamando servidor interno, o **localhost** é maquina que será usada como servidor e porta **8000** é entrada para acessar a nossa página. Antes de você usaram o servidor, cria uma pasta a qual onde ficará os arquivos php, por padrão o **index.php** é a primeira página que o servidor tentará buscar, caso não hajá vai dar um erro incrivel uaheuhe, porém se tiver outra página com outro nome podemos acessar mesmo utilizando o **/nome_da_pagina.php**.


![Criação da estrutura do projeto para utilizar o servidor web PH](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91ceipmyzizl33701o7c.png)


![Mostrando a página index do servidor criado](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/veu0dekdm623vtiz72c4.png)

Aí está tudo configurado e pronto pra você usar e é isso! Até a próxima
#### Referências

[PHP Web Server](https://www.php.net/manual/en/features.commandline.webserver.php)
Music Monday — What are you listening to? (Favorite Lyricists Edition)
Tags: watercooler, music, discuss
Published: 2023-08-27 13:00:00

_cover image source: [Giphy](https://giphy.com/gifs/dmasmusic-mom-pop-dmas-music-xT8qBcttNlMaUmIwkE)_

**Happy Monday folks! For this edition, we're focusing on lyricists and I wanna hear who some of your faves are. Whether you're into hip hop, rock, indie, pop, folk, or something else entirely, there are no genre limits here. The main thing is we're focused on the lyrical side more so than the music. Granted the two go hand-in-hand, and I really love it when a song is crafted such that the music fits the lyrics or vice versa... in any case, let's hear it! I'm siked to learn about y'all's favorite lyricists!**


![A clip from Bob Dylan's "Subterranean Homesick Blues" music video. He's holding up a sign that says "Dig yourself"](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/acsu78tuetrqe3q5h2cj.gif)

***

## How we do 

In this weekly series, folks can chime in and drop links to whatever it is they've been listening to recently + browse others suggestions. You can follow the suggested genre if you'd like, but don't feel confined to it; you're free to suggest whatever you wanna. 🙌  

If you're interested in having other discussions about music, consider following the aptly named [#music discussions](https://dev.to/music-discussions) organization.

{% embed https://dev.to/music-discussions %}  

***

Let's listen to some lyrics! _Note: you can embed a link to your song using the following syntax `{% embed https://... %}`. This should work for most common platforms!_

Looking forward to listening to y'all's suggestions! 🎶
Javascript inbuilt Methods list
Tags: javascript, webdev, beginners, tutorial
Published: 2023-08-27 12:55:27

JavaScript is a powerful and versatile programming language used to add interactivity and functionality to websites. Its unique syntax and flexibility make it a popular choice among developers for both client-side and server-side programming. With JavaScript, you can dynamically manipulate and update web page content, validate forms, create animations, handle events, and much more. It supports object-oriented programming principles and has a wide range of built-in methods and functions that make it easy to work with arrays, strings, numbers, and objects. Whether you are a beginner or an experienced developer, JavaScript offers endless possibilities for creating engaging and interactive web applications.

Some commonly used JavaScript methods are:

- String Methods:
  - `length()`: returns the length of a string.
  - `toUpperCase()`: converts a string to uppercase.
  - `toLowerCase()`: converts a string to lowercase.
  - `concat()`: concatenates two strings.
  - `charAt(index)`: returns the character at the specified index.
  - `split(separator)`: splits a string into an array of substrings based on the specified separator.

- Array Methods:
  - `length()`: returns the number of elements in an array.
  - `push(element)`: adds an element to the end of an array.
  - `pop()`: removes the last element from an array.
  - `join(separator)`: joins all elements of an array into a string, separated by the specified separator.
  - `indexOf(element)`: returns the first index at which the specified element is found in an array.

- Number Methods:
  - `toFixed(decimalPlaces)`: formats a number with a specified number of decimal places.
  - `toPrecision(precision)`: formats a number with a specified length.
  - `parseInt(string)`: parses a string and returns an integer.
  - `parseFloat(string)`: parses a string and returns a floating-point number.
  - `isNaN(value)`: determines whether a value is NaN (Not-a-Number).

- Object Methods:
  - `hasOwnProperty(property)`: returns a boolean indicating whether an object has the specified property.
  - `keys()`: returns an array of a given object's own enumerable property names.
  - `values()`: returns an array of a given object's own enumerable property values.
  - `assign(target, ...sources)`: copies the values of all enumerable properties from one or more source objects to a target object.

These are just a few examples of the many methods available in JavaScript. There are many more methods and each object type has its own set of methods. Additionally, you can also create your own custom methods in JavaScript.
Java - 🔄 `reverse()`: Turning Your Singly Linked List World Upside Down 🙃
Tags: java, computerscience, dsa, singlylinkedlist
Published: 2023-08-27 12:22:57

Hello Dev.to enthusiasts! 🌟

Ever wished to rewind time? (Well, u know...every now and than...) Maybe to re-live a moment or just to see things from a new perspective. In the realm of data structures, we can indeed turn back time – or at least our lists.🙃 Say hello to (drum-roool please!) `reverse()`.

### 🚂 Quick Train Stop: Our Singly Linked List Station

For those who hopped on mid-journey, a whistle-stop tour:

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```
Each node (a carriage 🚃 in a train) in our list holds some data and a pointer to the next node, or null if it's the last one in line.

### 🔀 Making Sense of `reverse()`

Let's decipher mechanism:

```java
public void reverse() {
    Node prev = null;
    Node current = head;
    Node next = null;

    while (current != null) {
        next = current.next;
        current.next = prev;
        prev = current;
        current = next;
    }
    
    head = prev;
}
```

Imagine: you're re-arranging carriages of a train. You unhook, then move to a new position and continue until your entire train is arranged in the opposite order.

### 🤔 Why `reverse()`? 

Sometimes, to move forward, we need to look back ⏮ (I know I now it is `cliché`). If it's for algorithmic needs reversing a list can give fresh insight.

Keep exploring, flip things around once in a while, and always remain curious! 🌍
Yarn vs. NPM: Unleashing the Power of Package Managers for Efficient JavaScript Development
Published: 2023-08-27 12:22:37

In the world of JavaScript development, having a reliable and efficient package manager is crucial to streamline your workflow and manage dependencies effortlessly. While both Yarn and NPM serve this purpose, developers often find themselves debating which one to choose. In this comprehensive guide, we'll delve into the differences between Yarn and NPM, explore their features, and provide insights into when and why you might prefer one over the other. Let's embark on a journey to understand how to optimize your package management process and boost your productivity. [Read full post here >>](https://festack.blogspot.com/2023/08/yarn-vs-npm-unleashing-power-of-package.html)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y97m81v3lg0kryo0a8ix.png)
Java - 🚫 `removeAt(index)`: cleaning with one Index at a Time 🗑️
Tags: java, dsa, computerscience, singlylinkedlist
Published: 2023-08-27 12:11:00

Hello Dev.to enthusiasts! 🌟

In the realm of data structures, sometimes we need to let go. Maybe it's that piece of redundant data or just an old value taking up precious space. Introducing `removeAt(index)`!!!

### 🏢 Brief Elevator Pitch: The Singly Linked List

Just in case someone's late to the party:

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```
Each node in our list holds some data and a pointer to the next node, or null if it's the last one in line.

### 🧹 Breaking Down `removeAt(index)`

Here's our clean-up strategy:

```java
public void removeAt(int index) {
    // If the building's empty, LEAVE!
    if (head == null) return;
    
    // IF first floor you might be walking!
    if (index == 0) {
        head = head.next;
        return;
    }
    
    Node current = head;
    int count = 0;
    
    // Go floor by floor until your floor is found.
    while (current != null && count < index - 1) {
        current = current.next;
        count++;
    }

    // If we're at the right floor and there's an apartment to find out
    if (current != null && current.next != null) {
        current.next = current.next.next;
    }
}
```

### 🎈 Why `removeAt(index)`? 

The `removeAt(index)` method helps us strike the right balance in our data structures.

### 🌄 In Conclusion

With `removeAt(index)` in your coding arsenal, you’re equipped to manage your data structures. ✨

In [`the next article`](https://dev.to/hunorvadaszperhat/java-reverse-turning-your-singly-linked-list-world-upside-down-5g9l) we will look at `reverse()` method


Cheers and happy coding! 🚀
🌟 Exciting News: Nexus OS Release! 🌟
Tags: operating, systems, yash12007, softwaredevelopment
Published: 2023-08-27 12:07:37

🌟 Exciting News: Nexus OS Release! 🌟


Dear Community,

We're thrilled to announce the official release of Nexus OS version 1.0! As of August 16, 2023, Nexus OS is now available to the public under our unique Custom Modification-Only License.

Nexus OS is the result of countless hours of dedicated development, collaboration, and passion from our committed team. With this milestone release, we're taking a significant step forward in providing an operating system that empowers users with customization and innovation.

Key Highlights of Nexus OS 1.0:
- Custom Modification-Only License: Nexus OS is released under a license that encourages users to freely modify and customize the OS for personal use or educational purposes.
- User-Centric Interface: Our user interface ensures a seamless and intuitive experience for users of all skill levels.
- Optimized Performance: Nexus OS is optimized for speed and efficiency, offering smooth multitasking and responsive performance.
- Community-Driven Development: Our vibrant community's feedback and contributions have significantly influenced the evolution of the OS.

How You Can Get Involved:
- Explore and Download: Visit our website to download Nexus OS 1.0 and explore its powerful features.
- Become a Contributor: Whether you're a developer, designer, or tech enthusiast, join our growing community on GitHub and contribute to the OS's growth.
- Share Your Insights: Your feedback is invaluable. Share your thoughts, ideas, and suggestions on our forum to shape the future of Nexus OS.

Thank you for being a part of the Nexus OS journey. Together, we're shaping the landscape of customizable operating systems. Join us, personalize your experience, and let's harness technology for your benefit!
Link to Download Nexus OS: https://yash12007.github.io/Nexus


Warm regards,
The Nexus OS Team
Released on: August 16, 2023
How to handle global exception in .NET Core
Tags: dotnetcore, beginners
Published: 2023-08-27 12:04:05

In ASP.NET Core, you can handle global exceptions using middleware. Middleware is a component that sits in the request pipeline and can perform tasks before or after the request reaches your controller actions. Handling global exceptions through middleware allows you to centralize error handling and provide consistent behavior for your application.

Here's how you can create middleware to handle global exceptions in .NET Core:

1. **Create a Middleware Class:**

Create a new class for your middleware. This class should have a constructor that takes in RequestDelegate, which represents the next delegate in the pipeline. Inside the class, you can catch and handle exceptions.

```
public sealed class GlobalErrorHandlingMiddleware
{
    private readonly ILogger<GlobalErrorHandlingMiddleware> _logger;
    private readonly RequestDelegate _next;

    public GlobalErrorHandlingMiddleware(ILogger<GlobalErrorHandlingMiddleware> logger, RequestDelegate next)
    {
        _logger = logger;
        _next = next;
    }

    public async Task InvokeAsync(HttpContext context)
    {
        try
        {

            await _next(context);
        }
        catch(Exception ex)
        {
            _logger.LogError(ex, ex.Message);
            context.Response.ContentType = "application/json";
            context.Response.StatusCode = StatusCodes.Status500InternalServerError;
            await context.Response.WriteAsync("An error occurred.");
        }
    }
}
```

2. **Register Middleware:**
In your program.cs class, add the middleware, GlobalExceptionMiddleware before registering MVC or routing middleware. This ensures that the exception handling middleware is executed for all requests.

```
app.UseMiddleware<GlobalErrorHandlingMiddleware>();
```

By placing the UseMiddleware<GlobalErrorHandlingMiddleware>() call in the appropriate position, you ensure that any unhandled exceptions thrown within the pipeline will be caught by your custom middleware and handled according to your logic.

Thanks for reading.
Java - 🎯 `insertAt(index, data)` in Your Singly Linked List 📍
Tags: java, dsa, computerscience, singlylinkedlist
Published: 2023-08-27 12:02:21

Hello Dev.to enthusiasts! 🌟

In our coding lives, there are times when we desire precision. When inserting data 🩺 in a data structure, we want control. Enter the realm of `insertAt(index, data)` for the singly linked list. 

### 🏰 Quick Castle Tour: The Singly Linked List

A tiny refresher for our wandering minds (like mine!):

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```

### 🧐 Decoding `insertAt(index, data)`

Here's our blueprint:

```java
public void insertAt(int index, int data) {
    Node newNode = new Node(data);
    
    // If the list is empty or you're adding right at the front
    if (head == null || index == 0) {
        newNode.next = head;
        head = newNode;
        return;
    }
    
    Node current = head;
    int count = 0;
    
    // Loop through the list until you find the perfect node or reach the end
    while (current != null && count < index - 1) {
        current = current.next;
        count++;
    }

    // Found the spot? Great!
    if (current != null) {
        newNode.next = current.next;
        current.next = newNode;
    }
}
```

### 🤔 Why Embrace `insertAt(index, data)`?

Flexibility 🤸‍♂️. Rather than always adding rooms to the end or the beginning, this method gives us the freedom to choose our exact position.

### 💡 Wrapping Up

The `insertAt(index, data)` method is like having a precision tool 🔍 in your coding toolkit.

In [`the next article`](https://dev.to/hunorvadaszperhat/java-removeatindex-cleaning-with-one-index-at-a-time-mk) we will look at `removeAt(index)` method


Cheers and happy coding! 🚀
Java - Spring Cleaning with the `clear()` 🧼🧹
Tags: java, dsa, singlylinkedlist, computerscience
Published: 2023-08-27 11:54:22

Hello Dev.to enthusiasts! 🌟

Ever felt your data structures getting ... messy? 🤔 Just like our rooms need a sprucing up now and then, sometimes our linked lists yearn for a reset. Introducing the `clear()` method, the ultimate decluttering tool for our singly linked list. 

### 🏛 A Quick Architectural Peek: Our Singly Linked List

For the coding novices and the forgetful alike, here's a recap:

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```

Picture each node as a book 📚 on a vast bookshelf. Over time, these books accumulate, sometimes needing a rearrangement or cleanup.

### 🧙‍♂️ The Magic of `clear()`

```java
public void clear() {
    // It's like magically making every book disappear for a fresh start.
    head = null;
}
```

### 🤷‍♀️ Why `clear()`? 

One word: Efficiency ⚙️. Instead of tediously removing each node (or book), `clear()` offers a fresh slate in one quick step. It's the reboot button 🔄 we sometimes need for our code.

In [`the next article`](https://dev.to/hunorvadaszperhat/java-insertatindex-data-in-your-singly-linked-list-2nn1) we will look at `insertAt(index, data)` method



Cheers and happy coding! 🚀
Java - Finding Your Node's Place with `get(index)`! 💁‍♂️
Tags: java, dsa, singlylinkedlist, computerscience
Published: 2023-08-27 11:49:30

Hey Dev.to enthusiasts! 

Diving back into the maze of singly linked lists, have you ever felt like wanting a GPS to zoom straight to a node? Well, `get(index)` might just be the navigator you need.

### Quick Lay of the Land: Singly Linked List

For those just catching up:

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

class SinglyLinkedList {
    Node head;
    SinglyLinkedList() {
        this.head = null;
    }
}
```

### Deciphering `get(index)`

Here's a breakdown:

```java
public Node get(int index) {
    // If list is empty exit!
    if (head == null) return null;
    
    // We start at the starting line.
    Node current = head;
    int count = 0;
    
    // Race through the checkpoints.
    while (current != null) {
        if (count == index) {
            return current; // If found early return!
        }
        count++;
        current = current.next;
    }
    
    // If our index is out of bounds, return null.
    return null;
}
```

### Why Rely on `get(index)`? 🧭

Navigating data structures requires precision. With singly linked lists, `get(index)` ensures you can find your data based on position.

### To Conclude

With `get(index)` in your toolkit, you're equipped to move through your linked list with direction and purpose. 

In [`the next article`](https://dev.to/hunorvadaszperhat/java-spring-cleaning-with-the-clear-7o9) we will look at `clear()` method

Cheers and happy coding! 🚀