teleren/devto huggingface dataset:
OpenTelemetry
Published: 2024-06-20 19:06:40

## What is OpenTelemetry?
OpenTelemetry is an open-source project that provides a set of APIs, libraries, agents, and instrumentation to enable observability in software applications. Tracing is one of the core features of OpenTelemetry, which helps in tracking the execution of operations within and across services. 

## What is OpenTelemetry Tracing?
OpenTelemetry tracing is a way to capture and visualise the flow of requests as they traverse through different components of a distributed system. It allows developers to understand how different parts of an application interact and identify performance bottlenecks, errors, and latency issues.

### Key Concepts

* #### Trace
    A trace represents the entire journey of a request as it moves through a system. It consists of a series of spans that are linked together.

* #### Span
    A span represents a single operation within a trace. It contains information such as the operation name, start and end timestamps, attributes (metadata), and references to other spans (parent/child relationships).

* #### Context Propagation
    Context propagation allows trace context to be passed along with requests as they move through different services and components. This ensures that spans are correctly linked together to form a complete trace.

* #### Sampling
    Sampling determines which traces are collected and reported. It helps control the volume of trace data, balancing the need for observability with resource constraints.


### How OpenTelemetry Tracing Works

* #### Instrumentation
    OpenTelemetry provides instrumentation libraries for various programming languages and frameworks. These libraries automatically capture trace data for common operations like HTTP requests, database queries, and more.

* #### Context Injection
    When a request enters a service, OpenTelemetry injects trace context into the request headers. This context is propagated through downstream services, ensuring that all operations related to the initial request are included in the same trace.

* #### Span Creation
    Each operation within a service creates a new span. Developers can create custom spans to capture additional operations or specific code blocks.

* #### Trace Exporting
    Collected trace data is exported to a backend for analysis. OpenTelemetry supports various backends, including Jaeger, Zipkin, Prometheus, and more. The exported data can be visualised to understand request flows and identify issues.

---

### Benefits of OpenTelemetry Tracing

* #### End-to-End Visibility
    Provides a comprehensive view of how requests are processed across different services, helping to identify bottlenecks and improve performance.

* #### Error Detection
    Helps in identifying and diagnosing errors by showing where they occur in the request flow.

* #### Performance Optimisation
    By measuring the latency of different operations, developers can pinpoint and optimise slow parts of the system.

* #### Improved Debugging
    Detailed trace data makes it easier to debug complex issues that involve multiple services.
1552. Magnetic Force Between Two Balls
Tags: php, leetcode, algorithms, programming
Published: 2024-06-20 19:04:13

1552\. Magnetic Force Between Two Balls

Medium

In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has `n` empty baskets, the <code>i<sup>th</sup></code> basket is at `position[i]`, Morty has `m` balls and needs to distribute the balls into the baskets such that the **minimum magnetic force** between any two balls is **maximum**.

Rick stated that magnetic force between two different balls at positions `x` and `y` is `|x - y|`.

Given the integer array `position` and the integer `m`. Return _the required force_.

**Example 1:**

![q3v1](https://assets.leetcode.com/uploads/2020/08/11/q3v1.jpg)

- **Input:** position = [1,2,3,4,7], m = 3
- **Output:** 3
- **Explanation:** Distributing the 3 balls into baskets 1, 4 and 7 will make the magnetic force between ball pairs [3, 3, 6]. The minimum magnetic force is 3. We cannot achieve a larger minimum magnetic force than 3.

**Example 2:**

- **Input:** position = [5,4,3,2,1,1000000000], m = 2
- **Output:** 999999999
- **Explanation:** We can use baskets 1 and 1000000000.

**Constraints:**


- `n == position.length`
- `2 <= n <= 105`
- <code>1 <= position[i] <= 10<sup>9</sup></code>
- All integers in `position` are **distinct**.
- `2 <= m <= position.length`



**Solution:**

```
class Solution {

    /**
     * @param Integer[] $position
     * @param Integer $m
     * @return Integer
     */
    function maxDistance($position, $m) {
        sort($position);
        $left = 1;
        $right = $position[count($position) - 1];
        while ($left < $right) {
            $mid = ($left + $right + 1) >> 1;
            if ($this->check($position, $mid, $m)) {
                $left = $mid;
            } else {
                $right = $mid - 1;
            }
        }
        return $left;
    }

    public function check($position, $f, $m) {
        $prev = $position[0];
        $cnt = 1;
        for ($i = 1; $i < count($position); ++$i) {
            $curr = $position[$i];
            if ($curr - $prev >= $f) {
                $prev = $curr;
                ++$cnt;
            }
        }
        return $cnt >= $m;
    }
}
```



**Contact Links**

- **[LinkedIn](https://www.linkedin.com/in/arifulhaque/)**
- **[GitHub](https://github.com/mah-shamim)**
Clash Of Clans Mod APK
Tags: gamedev
Published: 2024-06-20 19:02:38


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlp6xe3vin46hacxhmfh.jpg)
<a href=https://clashofclans.fun/>Clash of Clans Mod APK offers an exciting twist to the original game</a>, providing players with enhanced features and unlimited resources. This modified version allows gamers to access unlimited gems, gold, elixir, and dark elixir from the start, speeding up game progression and enabling them to build and upgrade their villages swiftly. With these resources readily available, players can experiment with various strategies, construct powerful defenses, and train armies quickly without the usual resource constraints.

Moreover, the mod APK often includes additional features such as custom heroes, troops, and buildings not found in the standard version, offering a unique gameplay experience. Players can engage in more challenging battles, participate in clan wars with strengthened armies, and explore new levels of creativity in base design.

However, it's essential to download Clash of Clans Mod APK from trusted sources to avoid potential security risks or issues with gameplay stability. Due to its modified nature, it may not always receive updates or support from the official game developers, affecting compatibility and functionality over time.

In conclusion, Clash of Clans Mod APK provides an exhilarating alternative for players seeking a faster-paced and resource-abundant gameplay experience, albeit with considerations for security and long-term support.
Should we or shouldn't we? Create a project management mobile app
Tags: productivity, feedback, discuss, opensource
Published: 2024-06-20 19:01:49

If you're new to OpenProject-we're a leading open source project management tool that helps teams make progress in a busy world.

The OpenProject team is close with the community and regularly asks questions, takes requests, and sends new updates.

This summer the team is asking: Do you want an OpenProject mobile app?

👉 [Take our quick survey](https://openproject.limequery.com/116122?lang=en)

🔒 Your responses are completely anonymous!

🗓️ The survey will be open until July 15, 2024.

In the comments, tell us if you already use a project management mobile app? What features do you love about it? What do you miss?
Extending String for Validation in Dart 3
Tags: dart, extensions, string
Published: 2024-06-20 19:00:27

In Dart 3, one of the powerful features you can leverage is extensions. Extensions allow you to add new functionality to existing libraries. In this article, we will demonstrate how to extend the `String` class to include common validation checks such as email validation, numeric check, and phone number validation.

## Creating the String Extension

Let's start by creating an extension on the `String` class. We will define three validation methods:

1. `isValidEmail` - Checks if the string is a valid email format.
2. `isNumeric` - Checks if the string consists only of numeric characters.
3. `isPhoneNumber` - Checks if the string is a valid phone number.

Here's the code for the `StringValidation` extension:

```dart
extension StringValidation on String {
  bool get isValidEmail {
    final regex = RegExp(r'^[^@]+@[^@]+\.[^@]+');
    return regex.hasMatch(this);
  }

  bool get isNumeric {
    final regex = RegExp(r'^-?[0-9]+$');
    return regex.hasMatch(this);
  }

  bool get isPhoneNumber {
    final regex = RegExp(r'^\+?[0-9]{10,13}$');
    return regex.hasMatch(this);
  }
}
```

### Explanation

- **isValidEmail**: This method uses a regular expression to check if the string follows a basic email pattern (e.g., `example@test.com`).
- **isNumeric**: This method checks if the string contains only numeric characters, including an optional leading minus sign for negative numbers.
- **isPhoneNumber**: This method validates if the string is a phone number. It allows an optional leading plus sign and checks for a length between 10 to 13 digits.

## Usage

Using these extensions is straightforward. You simply call the new methods on any string instance. Below is an example demonstrating how to use these validation methods:

```dart
void main() {
  var email = "example@test.com";
  var phone = "+1234567890";
  var number = "12345";

  print(email.isValidEmail);    // Output: true
  print(phone.isPhoneNumber);   // Output: true
  print(number.isNumeric);      // Output: true
}
```

### Explanation

- **email.isValidEmail**: Checks if the `email` string is a valid email. The output will be `true` if the string matches the email pattern.
- **phone.isPhoneNumber**: Validates if the `phone` string is a valid phone number. The output will be `true` if the string matches the phone number pattern.
- **number.isNumeric**: Checks if the `number` string consists of numeric characters. The output will be `true` if the string matches the numeric pattern.

## Conclusion

By using Dart's extension methods, you can add reusable validation logic to the `String` class. This approach makes your code cleaner and more modular. You can extend this pattern to include more validations as needed, enhancing the robustness of your applications.

Try integrating these extensions into your Dart projects and see how they can simplify your validation logic. Happy coding!
Enhancing List Functionality in Dart with Custom Extensions
Tags: dart, extensions, list
Published: 2024-06-20 18:57:58

Dart, a language known for its flexibility and robust features, allows developers to extend the functionality of existing classes without modifying them. One powerful way to achieve this is through extensions. In this article, we'll explore how to create a custom extension for the `List` class in Dart to add some useful utility methods.

## Introduction to Dart Extensions

Extensions in Dart enable you to add new functionalities to existing libraries. By creating an extension, you can introduce new methods and properties to a class without altering its source code. This is particularly useful when you want to augment the capabilities of widely used classes like `List`.

## Creating the `ListUtils` Extension

Let's dive into the code for our custom extension `ListUtils` which adds three handy methods to the `List` class:

1. `firstOrNull`: Returns the first element of the list, or `null` if the list is empty.
2. `lastOrNull`: Returns the last element of the list, or `null` if the list is empty.
3. `takeLast`: Returns the last `n` elements of the list.

Here's the code for our extension:

```dart
extension ListUtils<T> on List<T> {
  T? firstOrNull() {
    return isEmpty ? null : this[0];
  }

  T? lastOrNull() {
    return isEmpty ? null : this[length - 1];
  }

  List<T> takeLast(int n) {
    return skip(length - n).toList();
  }
}
```

### Method Breakdown

#### `firstOrNull`

This method returns the first element of the list if it exists; otherwise, it returns `null`.

```dart
T? firstOrNull() {
  return isEmpty ? null : this[0];
}
```

#### `lastOrNull`

Similar to `firstOrNull`, this method returns the last element of the list or `null` if the list is empty.

```dart
T? lastOrNull() {
  return isEmpty ? null : this[length - 1];
}
```

#### `takeLast`

This method returns the last `n` elements of the list. It uses the `skip` method to skip the first `length - n` elements and then converts the remaining elements to a list.

```dart
List<T> takeLast(int n) {
  return skip(length - n).toList();
}
```

## Using the Extension

To see our extension in action, we can use the following example in the `main` function:

```dart
void main() {
  var list = [1, 2, 3];
  print(list.firstOrNull()); // Output: 1
  print(list.lastOrNull());  // Output: 3
  print(list.takeLast(2));   // Output: [2, 3]
}
```

### Explanation

- `list.firstOrNull()`: Since the list is not empty, this will return the first element, `1`.
- `list.lastOrNull()`: This will return the last element, `3`.
- `list.takeLast(2)`: This will return the last two elements of the list, `[2, 3]`.

## Conclusion

Extensions in Dart provide a powerful mechanism to enhance the functionality of existing classes in a clean and maintainable way. By creating the `ListUtils` extension, we have added methods to the `List` class that can simplify common operations. This approach keeps our codebase clean and reusable.

By understanding and utilizing Dart extensions, you can significantly improve your productivity and code quality. Happy coding!
Enjoy react key takeaways from a new developer.
Tags: webdev, react, beginners, programming
Published: 2024-06-20 18:56:56

Welcome back to my second blog on DEV. I have completed phase 2 of FlatIron school and this phase covered react. Phase 1 was JavaScript, phase 2 was React with phase 3 being Python and SQL. React was difficult for me due to a lot of different concepts and learning it a lot faster than javascript. 

**Key Topics Covered in This Blog:**

The Impact React had on me as a developer
The useState Hook
Lastly Props

Starting with React's had on my understanding of web development, it's hard to write how it changed my preception. Now, when I scroll through Facebook or click a link, I know that it triggers an onClick event, followed by a GET request. Understanding this process has been extremely impactful on my day-to-day, and I enjoyed working with React.

**Understanding and Using useState:**
Initially, useState was nothing short of a challenge. Its syntax and the concept of hooks were completely new to us as students. However, useState was very helpful and was the backbone in our project and for React projects in general. It allows us to update the page without refreshing it. To explain the syntax, the useState is defined as const [state, setState] = useState(). When setState(Anything) is called, it triggers a re-render and updates the page. The state variable holds the value of Anything, which could be data from a fetch request, a boolean for a loading feature, and so on.

**Props:**
Props are similar to arguments in JavaScript but are different. They allow you to pass functions, state or setState, variables, and data. Props allow you to pass what you will need to other files. You need to send props and accept them. Props can be deconstructed and go hand and hand with state.
Sail:onLagoon!
Tags: laravel, sail
Published: 2024-06-20 18:53:40

Laravel users, we’re so excited to announce the launch of Sail:onLagoon! 

If you’re familiar with Sail, you know it’s a quick and easy way to spin up a Laravel site. And now it’s fully integrated with Lagoon, allowing you to spin up a Laravel site configured for Lagoon quickly and easily.  

Check out our demo video to see how quick and seamless Sail:onLagoon is:

{% youtube O2FcUz4Rt9E %}

And read more in the documentation here: https://github.com/uselagoon/sailonlagoon

This is also just the beginning of Lagoon’s relationship with Laravel! Historically we have given a lot of focus to Drupal, and now we are working to grow our support and expertise in the Laravel space. We’re reaching out to you because we want to become a part of the Laravel ecosystem. We want Laravel users to help us drive our efforts, so we’d appreciate it if you could take a few minutes to fill out our Laravel user survey: https://forms.gle/96cQHNQL6gKF3gZ78

You can also check out our Laravel example: https://github.com/lagoon-examples/laravel-example-simple

Questions? Want to learn more? Join us on the Lagoon Discord: https://discord.gg/te5hHe95JE
5. Where to Go Now: Putting Unit Testing into Action
Tags: react, vitest, unittest, javascri
Published: 2024-06-20 18:50:38

Now that you've grasped the fundamentals of unit testing, it's time to apply this valuable skillset to real-world projects. Here's how you can take the next steps:

**1\. Dive into Hands-on Practice:**

- **Build Mini-Apps with TDD:** Experiment with Test-Driven Development (TDD) by creating small, focused applications like:

    - **Todo List:** Manage tasks effectively with features like adding, marking, and filtering todos.

    - **Expense Tracker:** Track your finances by recording expenses, categorizing them, and visualizing spending patterns.

    - **Calculator:** Build a basic calculator to test various arithmetic operations.

    - **Weather App:** Fetch weather data (using a free API) and display it in a user-friendly format.

    - **Simple E-commerce Shop:** Simulate adding items to a cart, calculating totals, and handling basic checkout logic.

- **Start Small, Scale Up:** Begin with a straightforward app and gradually add complexity to refine your unit testing skills.

- **Embrace TDD:** Practice the TDD cycle (red, green, refactor) to ensure your code is well-tested and maintainable.

**2\. Deepen Your Knowledge with Advanced Topics:**

- **Vitest's Hidden Gems:** While you've covered core principles, consider exploring Vitest's advanced capabilities:

    - **Mocking Libraries:** Learn to mock external dependencies (like APIs or databases) to isolate your components and focus on their internal behavior. Popular libraries include `jest.mock` or `vitest.mock`.

    - **Snapshot Testing:** Utilize snapshot testing to ensure UI components render consistently as expected. Tools like `jest-serializer-vue` or `@testing-library/jest-dom` can simplify this process.

    - **Parallel Testing:** Leverage Vitest's built-in parallel test execution to speed up your test suite, especially in large projects. This can significantly reduce test runtime.

- **Error Handling in Unit Tests:** Craft tests to handle various error scenarios gracefully, ensuring your app behaves predictably even under unexpected conditions. This includes testing proper error messages, logging, or fallback mechanisms.

**3\. Integrate Unit Testing into Your Workflow:**

- **Continuous Integration (CI):** Set up a CI pipeline (like CircleCI, Jenkins, or GitHub Actions) to automatically run your unit tests whenever you push code changes. This provides continuous feedback on code quality and catches regressions early.

- **Code Coverage Reports:** Utilize tools like `jest-coverage` or `vitest --coverage` to generate code coverage reports. Aim for high code coverage (generally 80% or more) to ensure most of your application's logic is tested.

**Beyond Vitest:**

While Vitest is a fantastic testing framework, feel free to explore other options that might suit your project or preferences, such as Jest (also popular with React) or Mocha. The core concepts of unit testing remain largely consistent across frameworks.
Digital Nomadism in 2024
Tags: webdev, beginners, programming, ai
Published: 2024-06-20 18:43:30

Hi everyone!
in last month i've been search (on web and offline) a way to talk with a digital nomad in 2024. 

Many programmers and many designer but... BUT... what is the really way to begin a "Digital Nomad"? 

What is the best way to work in Nomad Mode?
What is (if anyone don't have a full remote work) the best way to survive (economic)?

**What do you think about that?**
Episode 24/24: Vertical Architectures, WebAssembly, Angular v9's Secret, NgRx
Tags: webdev, javascript, angular, programming
Published: 2024-06-20 18:38:35

Brandon Roberts unveiled why Angular 9 has the highest download rates. Manfred Steyer gave a talk about vertical architectures. Evgeniy Tuboltsev published a guide on how to integrate WebAssembly into Angular, and NgRx 18 was released.

{% embed https://youtu.be/mEAcIGUgluo %}

## Vertical Architectures

At the Angular Community Meetup,  Manfred Steyer presented an upgraded version of his talk about DDD in Angular.

He mentioned the team topologies model, where we have four different types of teams responsible for different tasks:

1. Platform services team
2. Specialization team
3. Supportive teams
4. Value stream team

{% embed https://www.youtube.com/watch?v=AEMMyvFkx4c %}

## NgRx 18

NgRx, the most popular state management library in Angular, was released in v18 making it compatible to Angular 18.

Be careful, if you want to use the Signal Store. It **will** become stable later and it is not released yet.

To use it in Angular 18, run `npm i @ngrx/signals@next` or use the schematic (also with the `next` tag).

{% embed https://dev.to/ngrx/announcing-ngrx-18-ngrx-signals-is-almost-stable-eslint-v9-support-new-logo-and-redesign-workshops-and-more-17n2 %}

## The secret behind Angular 9

At the moment, Angular is downloaded around 3.5 million times per week, making it the third most downloaded framework after React and Vue.

Around 450,000 downloads come from Angular 9. Given that the current version is 18, that's a little bit strange.

Brandon Roberts discovered that Angular 9 is a dependency of codelzyer. Codelzyer is a library we used before typescript ESLint came out.

It is very likely that Codelyzer is part of many applications, although it is not actively used, and developers should remove it.

According to the statistics, Codelzyer has a current download number of 600,000.

Without Codelzyer, Angular's download numbers would/will drop by 17%.

{% embed https://www.youtube.com/watch?v=fQGDZzrIPRg %}

## WebAssembly & Angular

WebAssembly allows to run application in browser, which have been written in other languages than Javascript. In addition, the execution speed is almost like native code.

Evgeniy Tuboltsev wrote an article where he showed, how to port an application written in Rust to WebAssembly and consume it in Angular. As for the comparison, his example runs three faster than its JavaScript counterpart.

{% embed https://medium.com/@eugeniyoz/powering-angular-with-rust-wasm-0eed1668a51c %}