teleren/devto huggingface dataset:
API versioning
Tags: csharp, webap, restapi, apigateway
Published: 2023-10-25 16:53:43

**API versioning** is the practice of managing multiple versions of a web API to ensure backward compatibility while introducing new features and changes. As applications evolve, it's essential to provide a way for existing clients to continue working with the API, even if breaking changes are introduced in newer versions. API versioning helps achieve this by allowing clients to specify the version of the API they want to use.

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

**Why API Versioning is Required:**
Backward Compatibility: Different clients might be using different versions of your API. Versioning allows you to introduce changes without breaking existing clients.

Smooth Transition: Versioning enables a smooth transition for clients from an older version to a newer version by providing clear communication about changes and deprecations.

Flexibility: It allows developers to adopt new features and improvements at their own pace without forcing immediate upgrades.

**How to Implement API Versioning in .NET Core:**
In .NET Core, API versioning can be implemented in various ways. One common approach is using the Microsoft.AspNetCore.Mvc.Versioning NuGet package. Here's how you can do it:

1. Install Microsoft.AspNetCore.Mvc.Versioning:
First, you need to install the Microsoft.AspNetCore.Mvc.Versioning package using NuGet Package Manager or .NET CLI.

dotnet add package Microsoft.AspNetCore.Mvc.Versioning

2. Configure API Versioning in Startup.cs:
In your Startup.cs file, configure API versioning in the ConfigureServices method:


using Microsoft.AspNetCore.Mvc;

public void ConfigureServices(IServiceCollection services)
{
    services.AddApiVersioning(options =>
    {
        options.DefaultApiVersion = new ApiVersion(1, 0);
        options.AssumeDefaultVersionWhenUnspecified = true;
        options.ReportApiVersions = true;
    });    
}
In this example, DefaultApiVersion sets the default API version to 1.0, AssumeDefaultVersionWhenUnspecified allows requests without version information to default to the specified version, and ReportApiVersions includes API version information in the response headers.

3. Versioning Controller Endpoints:
To version your controllers, you can use API versioning attributes on your controllers and actions:

[ApiController]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
public class UsersController : ControllerBase
{
    // Controller actions...
}
In this example, the controller is versioned with ApiVersion("1.0"), and the route includes the version number ([controller] is replaced with the controller name).

With these steps, your .NET Core Web API is versioned, allowing clients to specify the version they want to use in their requests. Clients can include the version number in the URL, query parameters, or request headers, depending on your configuration.

Versioning ensures that changes and improvements can be made to your API while providing a stable and predictable experience for existing clients.
Contributions during Hacktoberfest 2023
Tags: hack23contributor
Published: 2023-10-25 16:49:16

### Intro

I mainly contribute to a rhythm game called [osu!](https://github.com/ppy/osu). This is my third time participating in Hacktoberfest. The lack of physical swag is a bit unfortunate, but other communities I saw are doing it this month and the digital swag given is tempting to collect, to say the least.

### Growth

Before, I was limiting myself to one community/organization most of the time. But this Hacktoberfest, I really wanted to explore and learn new languages or places to contribute. [ILLA Cloud](https://cloud.illacloud.com) was an interesting one. I also managed to fix a bug with their app editor UI (not merged yet though).
Authentication and Security
Published: 2023-10-25 16:44:29

Some of the methods we employ to address security issues are:
-`before_action`: We place this in the controller and name a function that we will write below in the private section that will be run before executing the specified routes. So for instance, `before_action :is_authorized_user, only: [:destroy, :create]` will run the function `is_authorized_user` before the create and destroy routes. We place them in the private section to follow the OOP principle of encapsulation and to increase security. This function outlines the logic determining if the current user is authorized to perform the create or destroy methods. 
-`skip_before_action`
-`redirect_to`
-`redirect_back` will send the user to the route from which they came, and we can add `fallback_location` to specify where we want them to be sent in the case that your application can't tell what the previous page was. You can also add a notice. 
-`current_user` 
-`if`/`else` conditional statements
-`only:` and `except:` to limit the routes that are generated in `resources` (e.g. there's no point in having a delete route for something you don't want to be deletable).
JS Code Challenges : 1
Published: 2023-10-25 16:41:56

#JS Code Challenge 1 

###Problem:
 Create an algorithm using a for  loop that can add the sum of all  natural numbers up to 100.

###The Breakdown:
  
 - Natural numbers are positive whole integers 

ex: 1, 2, 3    


- Find sum of natural numbers   
     
 ex: Find the sum of natural numbers of 5          

  1 + 2 + 3 + 4 + 5 = 15    

- Goal is to find the sum natural number up to 100

**Hint:**  Use a for loop.  

###Solution:



**Step 1** 

We need to have a constant variable that will not change.   

That should be the value of 100.

 

```
const val = 100; 
```
   

**Step 2** 

We need a variable to hold our sum. We also know our sum is NOT constant and will be changing as we are on our way to the sum natural numbers up to 100.  

 

```
let sum = 0;
```

**Step 3** 

Now that we have these variables we should be able to initialized a loop. We will use a for loop that will decrement. 

 

```
for (let i = val; i >= 1; i-- ){ 
    
     //code to execute  

 }  
```

- Start by letting **i** equal our **val** (100) 

- Next, we want the loop to continue until **i** is **greater than or equal to** 1 (only natural numbers remember)  

- Then, for each loop we want to **decrement**

**Step 4**

Okay so, now we need to figure out what logic to implement every time the loop is executed. 
Inside our  code block ...

```
for (let i = val; i >= 1; i-- ){
 
   sum = sum + i  
  
 }   

//can also be written as sum += i

```

 - To keep up with the changing **sum**, we want to update **sum** by making it equal to  whatever the previous **sum** value is plus **i**    

###Test: 

To test if we are going in the right direction, since we already know the sum of natural numbers of 5 is equal to 15 (from our Breakdown example).

Let's plug 5 into our loop, then console log the result.     ***Don't forget to change it back to val after you're done the test. 
  

```
for (let i = 5 ; i >= 1; i-- ){ 

 sum = sum + i

}

console.log('answer', sum); //returns 15     

```
 **This means our loop is working correctly...Congrats!**

**Step 5**
 Alright, let's console log the current value of sum to get our answer.   

```
for (let i = val; i >= 1; i-- ){ 
  
 sum = sum + i  

 }     

 console.log('answer', sum ); //returns 5050 


```

 Now, it’s your turn! 

###Practice

 

- 
Try writing this out from scratch

- Choose a different number to find   the sum of its natural numbers 

- Use something other than a for loop to solve


###Follow me for more!
How to Say Happy Birthday in Binary Code
Tags: html, webdev, beginners, programming
Published: 2023-10-25 16:36:50

Wishing someone a **happy birthday in binary code** is an innovative and tech-savvy way to celebrate their special day.

This article will guide you through the fascinating world of binary code and teach you how to say "Happy Birthday" using this intriguing language of computers.

## What is Binary Code?

Binary code is the fundamental language that computers use to communicate and process information. It consists of only `two characters: 0 and 1`. 

Each of these binary digits, or "bits," represents a basic unit of information. In this system, 0 usually signifies "off" or "no," while 1 represents "on" or "yes." 

By arranging these bits in sequences, we can represent complex data, characters, and numbers.

## Why Say Happy Birthday in Binary Code?

Wishing someone a **happy birthday in binary code** is a novel and intriguing way to show you care. 

It's perfect for tech-savvy individuals or those who appreciate a unique and thoughtful gesture. Moreover, it adds an element of surprise, making the birthday message even more special.

How to Say "Happy Birthday" in Binary Code

### Understand the ASCII Code:
To translate "Happy Birthday" into binary, you'll need to understand the **ASCII** (American Standard Code for Information Interchange) code. 

ASCII assigns numerical values to characters, symbols, and control codes. To convert letters into binary, you'll need to know the decimal ASCII values for each character.

### Break Down the Message:
"Happy Birthday" is a simple phrase, but it's crucial to break it down into individual characters to convert it to binary code. Here's a breakdown:

H: ASCII value 72
a: ASCII value 97
p: ASCII value 112
p: ASCII value 112
y: ASCII value 121
[Space]: ASCII value 32
B: ASCII value 66
i: ASCII value 105
r: ASCII value 114
t: ASCII value 116
h: ASCII value 104
d: ASCII value 100
a: ASCII value 97
y: ASCII value 121

### Convert to Binary:
Once you have the **ASCII values** for each character, you can convert them into binary. For example, the decimal value 72 becomes the binary value `1001000`.

### Arrange the Binary Values:
After converting each character, arrange the binary values together to form the complete message. Make sure to include spaces between the words.

So, "Happy Birthday" in binary code looks like this:

```
1001000 1100001 1110000 1110000 1111001 00100000 1000010 1101001 1110010 1110100 1101000 1100100 1100001 1111001
```

It demonstrates the power of technology and the effort you put into **making their birthday memorable**.

So, the next time you want to make a birthday extra special, consider saying [Happy Birthday in code](https://foolishdeveloper.com/happy-birthday-in-code/) of computers.
Is Qualcomm's New Chip The Ultimate AI Game-Changer?
Tags: webdev, ai, mobile, discuss
Published: 2023-10-25 16:27:40

Qualcomm, the semiconductor giant, has unveiled a groundbreaking PC laptop chip, the Snapdragon Elite X CPU, designed to outperform Apple's Mac chips. This chip, equipped with AI capabilities, aims to excel in tasks like email summarization and graphics generation. Major players, Google and Meta, have expressed interest in incorporating these AI features into their smartphones. 

Notably, this news comes after Microsoft pushed chipmakers, including Qualcomm, to develop AI-capable hardware for Windows, recognizing the importance of AI in maintaining Windows' relevance. Microsoft's CEO, Satya Nadella, anticipates a new era of "AI PCs" for both businesses and consumers, emphasizing the transformative potential of this collaboration. This development holds significant promise for the future of computing and AI integration.

Click on this [link ](https://www.techdogs.com/tech-news/td-newsdesk/is-qualcomms-new-chip-the-ultimate-ai-game-changer)to read the benefits of **The New Qualcomm Chips. **

Enjoyed reading this content piece? There's a lot more where this came from! Head to [TechDogs](https://www.techdogs.com/) homepage and check out the myriad of [Articles](https://www.techdogs.com/resource/td-articles), White Papers, Case Studies, Reports, Videos, [News](https://www.techdogs.com/resource/tech-news) and [Events & Webinars](https://www.techdogs.com/resource/events) to Know Your World of Technology.
Optimising loading custom fonts to reduce layout shifts
Published: 2023-10-25 16:16:39

One of the most common causes of layout shifts is late-loading web fonts. To avoid layout shifts caused by web fonts, you can use the following techniques:

- **Preload critical fonts**: Preloading critical fonts can help ensure that they are loaded before they are needed, thus avoiding layout shifts.
- **Subset fonts and serve as woff2**: Subsetting fonts and serving them as `woff2` can help reduce the size of the font files, which can speed up their loading time.
- **Use variable fonts or a limited set of weight variations**: Using variable fonts or a limited set of weight variations can help reduce the number of font files that need to be loaded, which can speed up their loading time.
- **Host your own fonts on your main domain or subdomain**: Hosting your own fonts on your main domain or subdomain can help ensure that they are loaded quickly and reliably.

To further optimise web font loading, you can also use the `font-display` property to control how web fonts are displayed while they are being loaded. For example, you can use `font-display: swap` to display fallback text while the web font is being loaded, and then swap in the web font when it is available.

[Fixing layout shifting brought on by custom fonts](https://www.sitelint.com/blog/fixing-layout-shifting-brought-on-by-custom-fonts/) can also be done using `font-display: optional`. This will avoid swapping and render fonts immediately when they are already available.
WIZARD WEB RECOVERY SPECIALIZE IN RECOVERING LOST OR STOLEN CRYPTO
Published: 2023-10-25 16:11:53

it didn't take long for doubts to creep in. As I started to interact with the platform, I noticed strange and inconsistent behavior. Transactions didn't go as smoothly as promised, and customer support was elusive. Red flags were waving, and my gut told me that something was amiss. That's when I realized I had fallen victim to a sophisticated scam. The platform's behavior raised more eyebrows than a detective at a magic show. Withdrawal requests were delayed or denied outright, and the promised returns seemed too good to be true. It was like playing a game of hide-and-seek with my money, and the platform was constantly seeking new hiding spots. These inconsistencies were clear indicators that something fishy was going on so I searched for restoration and I discovered Wizard web recovery. Wizard Web Recovery is a hacking group that helps swindled people to reclaim their lost Bitcoin and they did exactly the same in my case. Write Wizard Web recovery using the  email  address at: wziardwebrecovery@ programmer . net  if you require assistance in reclaiming your stolen Cryptocurrencies.
Update/add field to modal when use createOptionForm in Laravel Filament 3
Tags: filament, laravel, php
Published: 2023-10-25 16:10:47

When you use modal window to create a model relations without leaving the main model creation page, it is convenient. However, sometimes you need to add or update the fields that the user fills in the modal window. This is not described in the documentation but it is quite easy to do. For example, let's add a slug for a category. 

To do this, we need to call _createOptionAction_ to which we pass a callback in which we will process _$action_. In this action, you need to call the _mutateFormDataUsing_ method in which we can process the _$data_ in another callback. Not such a callback hell as in js, but it is already starting to be alarming 😅

```
use Filament\Forms\Components\Actions\Action;
use Filament\Forms;
use Filament\Forms\Form;
use Illuminate\Support\Str;

public static function form(Form $form): Form
{

    return $form
        ->schema([
            Forms\Components\Select::make('categories')
                ->relationship('categories', 'title')
                ->multiple()
                ->searchable()
                ->preload()
                ->createOptionForm([
                    Forms\Components\TextInput::make('title')
                        ->required()
                        ->maxLength(255),
                ])->createOptionAction(function (Action $action) {
                    $action->mutateFormDataUsing(function (array $data) {
                        $data['slug'] = Str::slug($data['title']);

                        return $data;
                    });
                })
        ]);
}
```

In general, this action is almost no different from the create action that is already described in the [documentation](https://filamentphp.com/docs/3.x/actions/prebuilt-actions/create#customizing-data-before-saving)
Improving the execution time of CI pipelines
Tags: ci, jenkins, maven, springboot
Published: 2023-10-25 16:05:28

Executing a large number of tests, especially integration tests, takes a lot of time. For instance, the pipeline of one of our projects for each Pull Request previously took nearly 30 minutes, including over 1 thousand test cases. This article guides you through several good techniques that we have discovered and applied to improve the time-consuming process.

## Parallel stages

Analyze the current phases in your pipeline and categorize them in parallel. For example, we can separate the build and verify code of Node.js and Maven modules simultaneously in our Jenkins pipelines. Please mind using the setting `failFast` whether you want to abort the pipeline immediately.

Read more: [Parallel stages with Declarative Pipeline 1.2 (jenkins.io)](https://www.jenkins.io/blog/2017/09/25/declarative-1/)

## Parallel test execution

If you use Maven, the plugin `maven-failsafe-plugin` is used to execute integration tests during phases `integration-test` and `verify` the build lifecycle. It allows us to execute tests in parallel. There are many settings related to parallel test execution, so make sure to configure them correctly for your environment. For example, we can execute tests in parallel using the `classes` mode and set `threadCount=7` for the Jenkins Agent with 8 CPU cores.

Read more: [Maven Failsafe Plugin – Fork Options and Parallel Test Execution (apache.org)](https://maven.apache.org/surefire/maven-failsafe-plugin/examples/fork-options-and-parallel-execution.html)

## Application profiles

There are certain integration tests that don't require the use of a database. These tests focus on scenarios like error handling, authentication filters, or loading configuration. For example, initializing the database with Testcontainers is time-consuming.  If you use Spring Boot, you can utilize a different profile and use the H2 in-memory database for these tests. The test class will be annotated with the `@ActiveProfiles` annotation to run with the specified profile.
ExpressVPN lanza un nuevo servidor en Nápoles para celebrar el 'Scudetto'
Published: 2023-10-25 15:51:56

La [reciente ](https://businessmanweek.com/)victoria del Nápoles en el campeonato de la Serie A le ha valido al muy querido equipo italiano su primer scudetto desde la década de los 90. Esta nueva ubicación de VPN es un [homenaje](https://confidentialpostal.com/), en conmemoración a la impresionante victoria del Società Sportiva Calcio Napoli y a la briosa ciudad a la que [representan](https://confidentialverse.com/). Han tenido que pasar 33 largos años... Pero el scudetto ha [vuelto ](https://connectionnewyork.com/)a Nápoles.
eDriving ayuda a las flotas a reducir el impacto medioambiental con EcoDrive impulsado por Greater Than
Published: 2023-10-25 15:50:43

[eDrivingSM](https://connectionnewyork.com/), una empresa de Solera y proveedor líder mundial de soluciones digitales de gestión de riesgos de los [conductores](https://confidentialpostal.com/), ha anunciado la disponibilidad mundial de su función EcoDrive impulsada por Greater Than (GREAT:ST), un [proveedor ](https://confidentialverse.com/)mundial de tecnología que convierte los datos de GPS en análisis y evaluación de gran impacto para los conductores. La integración de EcoDrive en la galardonada aplicación digital de seguridad del conductor MentorSM de eDriving permitirá a [eDriving ](https://businessmanweek.com/)apoyar aún más a sus clientes globales en la consecución de sus objetivos de seguridad y sostenibilidad.
Hactoberfest_2023 Contributor
Tags: hacktohactobeberfest23, hacktoberfest, hacktoberfest23
Published: 2023-10-25 15:34:23

### Intro
Hey there, fellow developers! I'm Aditi Kumar, and I'm thrilled to be part of this vibrant Hacktoberfest community. It is my first Hactoberfest and I'm very excited to collaborate, learn, and grow together. You can check out my [GitHub profile](https://github.com/Aditi020) to see what I've been up to lately.

### Highs and Lows
This Hacktoberfest has been like a wild rollercoaster full of ups and downs. I gotta say, one of the coolest moments was when I cracked a super tricky problem in an open-source project. It felt awesome! But, you know, there were times when I ran into problems that seemed impossible to tackle. But hey, they say, "When things get tough, the tough get going." So, I just reached out to the community, asked for help, and did some serious digging in the docs. With lots of persistence and teamwork, I managed to conquer those challenges.

Pull Request1: [PR1](https://github.com/rudra016/WebDev-OpenSource/pull/44)
Pull Request2: [PR2](https://github.com/rudra016/WebDev-OpenSource/pull/47)
Pull Request3: [PR3](https://github.com/rudra016/WebDev-OpenSource/pull/100)
Pull Request4: [PR4](https://github.com/usmanbvp/DSAProblemsHub/pull/19)

### Growth

Hacktoberfest 2023 transformed my skills. I leveled up in coding, explored new languages, and grasped web development workflows. I'm now more determined to make a meaningful impact with code. This event opened my eyes to open source, and I'm excited for the journey ahead. 🚀✨
JavaScript - Use Modules for Better Code Organization
Tags: javascript, programming, tutorial, beginners
Published: 2023-10-25 15:30:00

JavaScript modules provide a way to encapsulate and organize code into separate files or modules, helping you manage complex applications and maintainability. Modules allow you to split your code into smaller, reusable parts with well-defined interfaces. This promotes cleaner code, reduces potential naming conflicts, and enhances code reusability. There are several module formats available, but we'll focus on ES6 modules, which have become a standard in modern JavaScript:

- **Creating a Module:**

   In an ES6 module, each JavaScript file is treated as a module. You can export functions, variables, or classes using the `export` keyword:

   ```javascript
   // math.js (module file)
   export function add(a, b) {
     return a + b;
   }

   // main.js
   import { add } from './math.js';

   const result = add(2, 3);
   console.log(result); // 5
   ```

- **Default Exports:**

   You can also export a single "default" value from a module, which is useful for exporting a single function or class as the module's primary export:

   ```javascript
   // calculator.js (module file)
   export default function add(a, b) {
     return a + b;
   }

   // main.js
   import add from './calculator.js';

   const result = add(2, 3);
   console.log(result); // 5
   ```

- **Importing Modules:**

   You can import exported values from other modules using the `import` statement. This allows you to use functionality from other files within your application:

   ```javascript
   // main.js
   import { add } from './math.js';

   const result = add(2, 3);
   console.log(result); // 5
   ```

- **Module Benefits:**

   - **Encapsulation:** Modules help you encapsulate functionality, reducing the risk of global variable conflicts and promoting a more organized code structure.

   - **Reusability:** You can easily reuse modules across different application parts or in other projects.

   - **Maintenance:** Modules make it easier to manage and update individual pieces of code without affecting the entire application.

   - **Dependency Management:** You can clearly define dependencies between modules, making it easier to understand the relationships between different parts of your application.

Using JavaScript modules is a best practice for structuring and organizing your code in modern JavaScript applications. It promotes modularity, maintainability, and reusability, all of which are essential for building scalable and maintainable software.