teleren/devto huggingface dataset:
Iterators in JAVA
Published: 2024-02-14 16:25:00

## Intro
When I was going through and learning Java. I wished there was a collection of docs that was written that explains Java topics simply.

### Iterating through arrays


<li>For Loop:</li>
This is the standard for-loop. This is in a lot of different languages as well
``` 
int[] myArray = {1, 2, 3, 4, 5};
for (int i = 0; i < myArray.length; i++) {
    System.out.println(myArray[i]); // logic to log element
} 
```

<li>Enhanced For Loop (for-each):</li>
A more concise way to iterate through an array, especially beneficial when you don't need the index.
```
int[] myArray = {1, 2, 3, 4, 5};
for (int element : myArray) {
    System.out.println(element);
}
```
<li>Arrays.stream: </li>
The Streams API introduced in Java 8 offers a functional approach to array iteration.
```
int[] myArray = {1, 2, 3, 4, 5};
Arrays.stream(myArray).forEach(System.out::println);
```
<li>ListIterator: </li>
Ideal for iterating backward through a List, providing more control over traversal.
```
List<Integer> myList = Arrays.asList(1, 2, 3, 4, 5);
ListIterator<Integer> iterator = myList.listIterator(myList.size());
while (iterator.hasPrevious()) {
    System.out.println(iterator.previous());
}
```

### Iterating through objects

<li>Using Map.Entry:</li>
For iterating through key-value pairs in a Map, Map.Entry allows access to both the key and the value.
```
Map<String, Integer> myMap = new HashMap<>();
myMap.put("a", 1);
myMap.put("b", 2);
myMap.put("c", 3);

for (Map.Entry<String, Integer> entry : myMap.entrySet()) {
    System.out.println(entry.getKey() + ": " + entry.getValue());
}
```
<li>Using Java Streams API:</li>
Leveraging the powerful Streams API for concise and functional iteration through Map entries.
```
Map<String, Integer> myMap = new HashMap<>();
myMap.put("a", 1);
myMap.put("b", 2);
myMap.put("c", 3);

myMap.entrySet().stream().forEach(entry -> {
    System.out.println(entry.getKey() + ": " + entry.getValue());
});
```
![let us begin now giphy](https://media.giphy.com/media/v1.Y2lkPTc5MGI3NjExcGJoY2o2dmo1Z2drODVrNHJqYnhmOXZ3M3l6Z2lzZ3VhbXA1NjF3MSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/l0IycQmt79g9XzOWQ/giphy.gif)


### Things to look out for

<li> Immutable vs Mutable List </li>
Understanding the distinction between immutable and mutable lists is crucial. An immutable list cannot be modified after creation, while a mutable list allows changes. Consider your use case and requirements when choosing between them. 

</br>
Thank you for reading! I hope this information proves helpful.
Job Market for Web Developers
Tags: webdev, javascript, beginners, discuss
Published: 2024-02-14 16:17:12

📍Job Market for Web Developers 

I recently connected with @tapasadhikary to get insights on 
- Web Dev
- Tech writing 
- Opensource 
- Opportunities 
- Content Creation 

The video aims to get insights into the Job Market for Web Devs. 

Watch Complete Video Here👀
Support my Youtube Channel🙌
{% youtube https://youtu.be/BwmgazYmmec?si=F1pZ7kx31ix4AQbs %}
Testing Doing Harm
Tags: testing, discuss
Published: 2019-06-11 04:32:12

I have started wonder what are some general indicators that a testing effort should be reevaluated as it is likely the testing is doing harm. Flacky tests would be an easy goto but I thought there had to be more to what I've seen. This is written with automation in mind but may be applicable to manual testing. 

As I tried explaining some testing challenges to a coworker I realized the key indicator of harmful tests. At a high enough view a test consists of an input and an expectation. This gets complicated when the environment is part of the input, or when multiple expectations exist for an input. 

If you're unable to determine what the test is expecting as input or expectations it would likely be a good to improve, maybe it is causing some flakiness. 

The primary concern is when you're input or expected results are continuously in flux. It does not really matter if this is changing the environment or a json file in the test framework. I need to be clear I'm talking about the designated inputs and results here by giving some examples. 

Sometimes you will have failures because your validation relies on some form of content, text of a button or link. This can be fine for a lot of tests, but if the text is changing from one release to another then it is time to stop those changes or apply a different validation. (content may need testing but there needs to be clarity of ownership and what is tested) 

I often mock out and test with APIs. Sometimes these change, say from xml to json. I use the native API format to drive my test. This would mean my input would be changing from xml to json. However I don't concern myself with it because this isn't a constant change. I can mostly rely on the testing to report back without my intervention. If however the structure really is in constant flux it is important to optimize for this change assuming the initial development exploration is finished. 

Why is constant changing input and expectation so bad? The tests you write are intended to identify failure to meet expectations across changes. If your expected result or input needs modified every release you need to evaluate if your test needs updated or if there is a regression. I see this leading to an optimized work flow for "fixing" the test by modifying it to result in passing.

Now in those cases the system is changing and so the tests can be looked at as providing insight into those changes. But I would wonder, is that extra insight? Should there not already be documented changes about this? Would it not be better time spent getting real insight into how the system functions, risk identification and setup tests that cover a different part of the system.
✨ Consistency and Efficiency with .nvmrc
Tags: nvmrc, webdev, nvm, programming
Published: 2024-02-14 16:11:51

In the software development universe, ensuring consistency and compatibility across development environments is crucial for project success. One of the most common challenges faced by development teams is managing Node.js versions, especially in projects with multiple dependencies and different version requirements. And this is my current scenario, I work with several projects with different versions of Node.


## What is the .nvmrc file? 📁
The `.nvmrc` file is a configuration file used in Node.js projects. It allows specifying which version of Node.js to use in a given project, ensuring consistency across development and production environments. `.nvmrc` is a native tool of the Node Version Manager (NVM), a popular tool for managing and switching between different versions of Node.js on a system.

## How does .nvmrc work? ⚙️
The `.nvmrc` operates simply and straightforwardly. In the root directory of a Node.js project, you can create a file called `.nvmrc`. Inside this file, you specify the desired version of Node.js, for example, `14.17.0`. When a developer runs the `nvm use` command in the terminal within the project directory, NVM automatically checks the `.nvmrc` file and activates the specified version of Node.js for that project.

## Why is .nvmrc important? 💡
The use of `.nvmrc` brings several significant benefits to development teams:

- **Consistency**: Ensures that all team members are working with the same version of Node.js, reducing conflicts and inconsistencies.
- **Compatibility**: Ensures that the code developed is compatible with the specific version of Node.js defined for the project, avoiding compatibility issues in production environments.
- **Ease of configuration**: Simplifies the process of setting up new development and continuous integration environments, allowing new team members to get up to speed quickly.
- **Error reduction**: Minimizes the risks of errors related to Node.js version management, making development more reliable and predictable.

## How to implement .nvmrc in your projects? 🛠️
Implementing `.nvmrc` in your projects is simple and requires only a few steps:

1. Create a file called `.nvmrc` in the root directory of your project.
2. Inside the `.nvmrc` file, specify the desired version of Node.js (e.g., `14.17.0`).
3. Add and version the `.nvmrc` file along with your source code to ensure that all team members have access to the correct version of Node.js.

## Conclusion:
The `.nvmrc` file is a valuable tool for ensuring consistency and compatibility across development environments in Node.js projects. By implementing `.nvmrc` in your projects, you can reduce conflicts, improve development efficiency, and ensure the quality of the code produced. Be sure to consider using `.nvmrc` in your projects and take advantage of the benefits this practice can offer to your development team. 🌟
Strategies for Optimizing Content Marketing
Tags: marketing, devops, ai, learning
Published: 2024-02-14 16:01:06

Hey there! Have you ever wondered how to turn your content marketing efforts into a lead-generating powerhouse? You're in the right place!**_ Content marketing _**isn't just about creating compelling blogs, videos, or social media posts; it's about strategically crafting content that captivates your audience and guides them down the path to becoming potential customers. In today's digital landscape, mastering the art of optimizing content for lead generation can be a game-changer for businesses aiming to expand their customer base and boost conversions.[https://techbinate.com/strategies-for-optimizing-content-marketing/]
React Mini Projects For Beginners
Tags: react, webdev, beginners, learning
Published: 2024-02-14 15:57:21

**Also, read this on [Medium](https://medium.com/@sanjayxr/react-mini-projects-for-beginners-bd3a036ca1db) , [codenewbie](https://community.codenewbie.org/sanx/react-mini-projects-for-beginners-2ffk)**

In this post, we've delved into four beginner-friendly React projects, each with its complete source code available on my [GitHub Repository](https://github.com/sanjayr-12/React-Mini).

**1.Form Validation**

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

While libraries like React Hook Form, React Final Form, or Formik are available to handle validation, this project utilizes useState to manage validation, providing a stronger foundation for its usage.

**2.CountDown Timer**

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

In this project, we delve into using useEffect to handle side effects, and gain a better understanding of new Date() in React. The countdown timer steadily decreases until it reaches the specified target date.

**3.Todo List**

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

In this project, we implement CRUD operations, allowing users to manage tasks efficiently. Additionally, tasks are stored locally, ensuring they persist even after page reloads or browser closures. 

**4.News Website**

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

In this project, we utilize the API provided by [News API](https://newsapi.org/) and leverage Axios to fetch data from the API. To install Axios, run 

> npm install axios

For detailed information on how to use Axios with React, refer to this guide on [Axios](https://www.freecodecamp.org/news/how-to-use-axios-with-react/). The website allows users to search for news articles according to their preferences.

To integrate the API key:

- Visit the News API website and log in to your account.

- Navigate to the account section where you can find your API key.

- Replace 'YOUR KEY' in the source code with your API key. 

The complete source code is available in the [Repository](https://github.com/sanjayr-12/React-Mini).


Well, this is it! Explore these beginner-friendly React projects to enhance your understanding of key concepts and kickstart your journey in web development.
Long live the lean web
Tags: webdev, html, performance, css
Published: 2022-11-23 22:37:44

The following text is a [Twitter thread](https://twitter.com/thomasfuchs/status/934407069331001344) from Thomas Fuchs. Every web developer should have read this. He posted it in November 2017 and it becomes more valuable every year. Chris Ferdinandy even wrote [a whole book](https://leanweb.dev/ebook/) about it. Thomas ended the thread with the title of this post: 'Long live the lean web'.

*It’s a weird dichotomy: the more capable underlying web tech gets (CSS features, HTML canvas, etc.) the more larger and more complex frameworks on top of it become. If you actually use the underlying improvements directly you’ll notice that you need less and less JavaScript. I noticed that in our new app. We get so much more done with a lot less scripting especially because of newer CSS features like flexbox, calc, vw/vh units, compositing modes, etc. Most of the scripting has to do with progressive enhancement, rather than making basic stuff work. This has so many positive effects:*

- *Much improved load times, especially on mobile*
- *no lock-in to a client-side framework*
- *simpler HTML structure*
- *Less code = easier to debug*
- *Get more done faster with a smaller team*
- *Almost no cross-browser issues anymore*

*I’m hoping for a second renaissance for the Web, like the one we had after we collectively decided that we don’t want Flash no more. That will happen when people realize that ginormous lock-in client-side “browser-in-a-browser” frameworks aren’t necessary to make great apps.*

*KISS.*
*Less is more.*
*Brevity is the soul of wit.*
*&lt;/rant&gt;*

&nbsp;

## A huge fan

I have been advocating this lean web for quite a while now. I was interviewed recently about [artisanal web development](/blog/artisanal-web-development/) by David Large from CloudCannon, where I advocated passionately for less code (and writing this code yourself). Additionally, I posted an article on [how to get a 100% Google Lighthouse score](/blog/how-to-get-a-100-google-lighthouse-score/), which has generated quite a bit of attention. My trick to get to these perfect scores is to stop using frameworks. This is in line with the lean web. I also [wrote a post](/blog/jamstack-means-performance-right/) about the [Jamstack report from 2021](https://almanac.httparchive.org/en/2021/jamstack), where we can see that Jamstack websites (on average) [became terribly slow](/blog/jamstack-means-performance-right/) as a result of using insane amounts of Javascript. The lean web has clear advantages.

You can never give too much credits, hence this post. I aim to be a part of the second renaissance Thomas dreams of. Let's make it happen! Long live the lean web!

*This post was originally posted on [www.usecue.com](https://www.usecue.com/blog/long-live-the-lean-web/).*
How to earn money online
Tags: webdev, career, html, learning
Published: 2024-02-14 15:37:48

[Earning $1000 per week online can be achieved through various methods, but it's important to note that success in any online venture often requires time, effort, and consistency. Here are some legitimate ways to potentially earn money online:

Freelancing:

Platforms like Upwork, Freelancer, and Fiverr connect freelancers with clients seeking services such as writing, graphic design, programming, marketing, and more. Create a profile showcasing your skills and bid on relevant projects.
Online Surveys and Reviews:

Participate in paid online surveys or write reviews for products and services. Websites like Swagbucks, Survey Junkie, and Vindale Research offer compensation for your opinions.
Remote Work:

Search for remote job opportunities on websites like Remote OK, We Work Remotely, and FlexJobs. Many companies hire remote workers for various roles.
Content Creation:

Start a blog, YouTube channel, or podcast and monetize through advertising, sponsorships, or affiliate marketing. Consistent and quality content can attract a loyal audience over time.
Affiliate Marketing:

Promote products or services through affiliate marketing. Earn a commission for each sale made through your unique affiliate link. Amazon Associates is a popular program, but there are many others.
Online Courses and Ebooks:

If you have expertise in a particular field, create and sell online courses or ebooks. Platforms like Udemy, Teachable, and Gumroad can help you distribute and sell your content.
Stock Photography:

If you're good at photography, you can sell your photos on stock photo websites like Shutterstock, Adobe Stock, or iStock.
Virtual Assistance:

Offer virtual assistance services to businesses or entrepreneurs. Tasks may include email management, scheduling, customer support, and more.](https://www.profitablegatecpm.com/ygzv6yms0?key=ee1c8df856a540223793d9b1d0713007)
Bind properties in a NextJS server action form and useFormState
Published: 2024-02-14 15:31:52

NextJS suggests you [how to bind properties](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#passing-additional-arguments) in server actions when working with forms. As well they suggest how to listen to the status of your form [once you submit with useFormState](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations#server-side-validation-and-error-handling). However, how can you bind data AND useFormState together?

The order matters; in this case, you have to bind first, and then wrap it with `useFormState`.
```ts
import { updateServerAction } from './server-actions';

export function UpdateForm({id}: {id: number}) {
  const updateWithId = updateServerAction.bind(null, id)
  const [state, formAction] = useFormState(updateWithId, {
    message: '',
  });
 
  return (
    <form action={formAction}>
     ... my code
    </form>
  )
}
```

Now when invoking the server action, it can go in the following order:
```ts
"use server"

export async function updateServerAction(id: number, prevState: {message: string}, form: FormData) {
  // code
}
```

This is quite useful for forms where you need to pass data but you don't want to expose it as hidden fields in the form itself. With this technique now it is possible to listen to the status of the `useFormState` and pass data to the server without exposing it in the form.
Cosmoprof North America presenta su nueva edición
Published: 2024-02-14 15:20:47

[Cosmoprof](http://dailyquicknews.com) North America, la principal feria de belleza B2B, anuncia el comienzo de su edición en Miami, que constituye un nuevo [capítulo](http://capitaldigitalnews.com) en la [industria](http://dailycitylive.com) de la belleza. Tras el rotundo éxito de su 20ª edición en Las Vegas, Cosmoprof North [America](http://renovationsanfrancisco.com) trae su característica mezcla de innovación, colaboración y redes globales a la dinámica ciudad de Miami.
Renueva su confianza en el sistema de trazabilidad
Published: 2024-02-14 15:13:27

El Fondo [Monetario Internacional](http://dailyquicknews.com) (FMI) y el Banco Mundial han destacado los beneficios del sistema SITRAF, operado por SICPA, utilizado en Chile para aumentar los ingresos fiscales y [fortalecer](http://capitaldigitalnews.com) la administración tributaria. En particular, el FMI enfatizó que “reducir la gran brecha fiscal y el comercio ilícito requiere medidas de [administración](http://dailycitylive.com) tributaria fortalecidas, como la implementación del sistema de seguimiento y localización [SITRAF](http://renovationsanfrancisco.com)”.
Loops in Go (for and while)
Published: 2024-02-14 15:10:03

# Loops in Go (for and while)

Loops play a crucial role in programming as they allow us to repeat a block of code multiple times. In Go, we have two main types of loops: `for` and `while`. This guide will explore how to use both types effectively in your Go programs.

## The 'for' Loop

The `for` loop is the most commonly used loop type in Go. It allows you to iterate over a sequence of elements or repeat a set of statements until a specific condition is met.

Here's the basic syntax for the `for` loop:

```go
for initialization; condition; post {
    // Statements to be executed within the loop
}
```

The initialization step initializes any variables or expressions required for the loop. The condition evaluates whether to continue iterating or break out of the loop. The posted statement updates any state needed after each iteration.

### Example:

Let's say we want to print numbers from 1 to 5 using a `for` loop:

```go
package main

import "fmt"

func main() {
    for i := 1; i <= 5; i++ {
        fmt.Println(i)
    }
}
```

Output:
```
1
2
3
4
5
```

In this example, we initialize `i` with 1, set our condition as long as `i <= 5`, and increment `i` by one after each iteration.

## The 'while' Loop

Unlike some other programming languages, Go does not provide an explicit 'while' construct. However, we can achieve similar functionality using only the `for` loop itself.

Go's equivalent of a 'while' loop looks like this:

```go
condition := true   // Initialize condition outside the loop

for condition {
    // Statements to be executed within the while-like block
    
    if terminationCondition {
        condition = false   // Set the condition to exit the 'while' loop
    }
}
```

Here's an example demonstrating how we can use a 'while' loop in Go:

```go
package main

import "fmt"

func main() {
    counter := 0

    for counter < 5 {
        fmt.Println(counter)
        counter++
    }
}
```

Output:
```
0
1
2
3
4
```

In this example, we initialize `counter` as 0 and set our termination condition as long as `counter < 5`. Inside the loop, we increment the value of `counter` by one after each iteration.

## Conclusion

Loops are essential tools for iterating or repeating blocks of code. In Go, we have two primary types of loops: `for` and equivalent constructs for a 'while' loop. Understanding how to use these loops effectively will enable you to write more efficient code and improve your programming skills in Go.
Balonlatino busca revolucionar la cobertura del fútbol
Published: 2024-02-14 15:09:32

[Balonlatino](http://dailyquicknews.com) no se limita a seguir solo las noticias: hoy en día, todo el equipo de periodistas del sitio se sumerge en las [historias](http://capitaldigitalnews.com) humanas y trayectorias inspiradoras que moldean el fútbol moderno. Con reportajes [detallados](http://dailycitylive.com), análisis tácticos y entrevistas exclusivas, Balonlatino aporta una nueva dimensión a la [cobertura](http://renovationsanfrancisco.com) deportiva del fútbol.