teleren/devto huggingface dataset:
Custom Middle Ware In Asp.net Core Web API
Tags: aspdotnet, cloudnativeapplications, azure, cloud
Published: 2023-06-08 16:53:50

In ASP.NET Core Web API, middleware is a component that sits in the request pipeline and processes HTTP requests and responses. It allows you to add custom logic to handle various aspects of the request/response flow, such as authentication, logging, error handling, and more.

To create custom middleware in ASP.NET Core Web API, follow these steps:

1. Create a new class that will serve as your middleware component. The class should have a constructor that takes a `RequestDelegate` parameter. The `RequestDelegate` represents the next middleware component in the pipeline.

```csharp
public class CustomMiddleware
{
    private readonly RequestDelegate _next;

    public CustomMiddleware(RequestDelegate next)
    {
        _next = next;
    }

    public async Task InvokeAsync(HttpContext context)
    {
        // Custom logic to be executed before the next middleware
        // ...

        await _next(context);

        // Custom logic to be executed after the next middleware
        // ...
    }
}
```

2. Implement the `InvokeAsync` method in your middleware class. This method contains the actual logic that will be executed for each HTTP request. You can perform any custom operations here, such as modifying the request/response, logging, or checking authentication.

3. Open the `Startup.cs` file in your ASP.NET Core Web API project. In the `Configure` method, add your middleware component to the request pipeline using the `UseMiddleware` extension method.

```csharp
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    // Other middleware components...

    app.UseMiddleware<CustomMiddleware>();

    // Other middleware components...
}
```

Make sure to add your middleware component in the desired order within the pipeline. The order of middleware components matters as they are executed sequentially.

That's it! Your custom middleware is now part of the request pipeline in your ASP.NET Core Web API. You can add additional custom middleware components following the same pattern.

Inside your `InvokeAsync` method, you have access to the `HttpContext` object, which provides information about the current request and response. You can use this object to inspect and modify various aspects of the request and response.

Note that middleware components can be used for cross-cutting concerns and can be reused across multiple controllers or actions. They provide a modular way to add custom functionality to your ASP.NET Core Web API.
takeUntilDestroyed() - How I got disappointed
Tags: angular, rxjs
Published: 2023-06-08 16:44:45

Hi Friends, George here.

It was a big surprise for me - takeUntilDestroyed - finally something natively supported by Angular coming to version 16.

When it arrived I was disapponted. Why?
Well let's say I was hoping for something more seamless to use.

Let's have a look at how this new pipe is implemented:
```
export function takeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {
  if (!destroyRef) {
    assertInInjectionContext(takeUntilDestroyed);
    destroyRef = inject(DestroyRef);
  }

  const destroyed$ = new Observable<void>(observer => {
    const unregisterFn = destroyRef!.onDestroy(observer.next.bind(observer));
    return unregisterFn;
  });

  return <T>(source: Observable<T>) => {
    return source.pipe(takeUntil(destroyed$));
  };
}
```

What is that weird destroyRef parameter?

`DestroyRef` is an injectable token which can take a callback `onDestroy` and this callback will be executed right before it's scope is destroyed. Angular needs this reference object to know when the to clean up your sbscription.

And that's the little annoying thing about this pipe. It's not magic! It doesn't work by itself! It always needs to have this destroyRef object.

How does it get it? There are two ways you can see in the code:
```
 if (!destroyRef) {
    assertInInjectionContext(takeUntilDestroyed);
    destroyRef = inject(DestroyRef);
  }
```

1. You can provide `destroyRef` manually as a pipe parameter

2. You can let Angular to inject it by itself

This second option seems easy, right? No, because you need to be _in_ the injection context.

Wait a sec, don't we have injection context everywhere?

**No.**

Here's where injection context works:
```
inject() must be called from an injection context 
such as a constructor, a factory function, a field initializer, 
or a function used with `runInInjectionContext`. 
```

Get it?
You want to subscribe to an observable in `ngOnInit` and use `takeUntilDestroyed` to handle unsubscribe? Tough luck! You're not in the injection context.

How do we do it then?

We do it by injecting `destroyRef` in the injection context and passing it as a parameter to the pipe.
Example:
```
class MyComponent {
  destroyRef = inject(DestroyRef);
  ngOnInit() {
    timer(0, 1000).pipe(takeUntilDestroyed(this.destroyRef)).subscribe(n => console.log('timer', n));
  }
}
```

And here we are. The amount of code to do it is now quite similar to well known method of declaring an unsubscribe subject by yourself.

As we see this is not magic solution to all world's problems. In fact we should still keep in mind to try not to subscribe manually. 

I was really looking forward to a future to discard our typescript mixin that handles unsubscribe logic inside a base class that you have to extend if needed. I might share it with you in another post so stay tuned.

Enjoy coding


To learn more about DestroyRef provider I highly recommend this video from Dmytro on [Decoded Fronted Youtube channel](https://www.youtube.com/watch?v=ga-MU1sb-Oo)
BatFetch
Tags: battery, bash, linux, cli
Published: 2023-06-08 16:39:16


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

*BatFetch* is a command-line tool that displays detailed information about the battery of your device in a clean and organized way. The tool is *inspired by pfetch*, a popular command-line system information tool.

It provides information about the *battery model, current charge level, power state, and health status*. The tool also displays an *ASCII art* title that adds a touch of fun to the output.

### Installation:
AUR:
```
yay -S batfetch
```
#### For manual instalation:
```
git clone https://github.com/ashish-kus/batfetch 
cd batfetch && chmod +x batfetch
sudo cp ./batfetch /usr/bin/ 
exec $shell && batfetch
```
3.15 - Prisma with Alex Ruheni
Tags: podcast, webdev, javascript, beginners
Published: 2023-06-08 16:28:08

Original: https://codingcat.dev/podcast/Prisma-with-Alex-Ruheni
          {% youtube https://youtu.be/-Wc2SPzK7tw %}
          {% spotify spotify:episode:2PGQxdJN6111UwkfTQA5yf %}
Angular Project Mongodb database Connect | Angular Website Project | Angular App
Tags: webdev, javascript, angular, programming
Published: 2023-06-08 16:10:06

{% embed https://www.youtube.com/live/3BRMc-bHZwU?feature=share %}
{% embed https://youtube.com/playlist?list=PLmwJLue37PZfQTgu-AXNee3EDj7oIlqeh %}

{% embed https://softwaretechit.medium.com/ %}
{% embed https://softwaretechit.com/ %}
{% embed https://blog.softwaretechit.com/ %}
{% embed https://shop.softwaretechit.com/ %}
JSON
Tags: javascript, webdev, programming, html
Published: 2023-06-08 07:12:17

JavaScript Object Notation or "JSON" for short - is a data format that utilizes a syntax that closely resembles that of JavaScript objects. The data is in a "human-readable" text format and usually consists of strings written in the form of JavaScript _objects_, containing "keys" and "values". Then, we can further group these objects into _arrays_, another JS data type that is familiar to new and experienced developers. Let's not forget to mention, like in the basic JavaScript object, JSON also allows the use of JS data types such as numbers, booleans and _object_ **methods**.


![JS Object](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/794l0wcophjdndlgmpw2.png) `(Basic JS object - only the object values *consisting of the string data type require double quotations/quotation)`




![JSON Object](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yx2gisuww4s7nhq30irb.png) `(Basic JSON string - resembling a JS object but all text must be wrapped in double quotations)
`


Although appearing as JavaScript, many different programs are able to parse as well as generate JSON. It is used to to send data from a server to the client, as well as send client data to a server.

JSON data can be saved in its own file, consisting of a text document/file using the ".json" tag name. Along with an ".html" file, and a ".js" file - we can manipulate, request and receive data displayed on a webpage.





JSON is another stepping stone in the current learnings I am undergoing in my software development journey. This is another part to the bigger picture I touched base on in my previous blog post about - Manipulating the DOM. 

In my next few blog posts I will go over more on this topic and break down how using JSON, we can send and receive data using postman, "fetch" and the different types of HTTP requests they entail, working with the JSON server.
DoDo - New Frontend Framework
Tags: javascript, dodo, framework, development
Published: 2023-06-08 15:39:15

Blazing fast, easy to learn, Javascript, frontend framework for reactive web pages & apps

- extremly fast in development, compilation and execution
- no typescript
- no overly frequent updates
- compiling powered by Vite
- application with optimised file sizes
- use import & export ES Modules to build complex apps with clear and readable code
- Model-View-Controller (MVC), intuitive app structure
- simple API but rich with great features
- easy to learn and easy to use
- intended for reactive web pages and apps
- developers can be productive like never before


[http://dodo.mikosoft.info/](http://dodo.mikosoft.info/)
Deep dissection of const declarations
Tags: javascript, webdev, beginners, programming
Published: 2023-06-08 15:38:10

In this post, I will be describing why we should be vigilant while using const to declare variables. 

**const variables are mutable.**

```javascript

const countries = ["India","USA","UK"];
countries[1] = "Japan";
console.log(countries); 

```

What do you anticipate from above code? Will it throw error?

Well no, the output is :
`[ 'India', 'Japan', 'UK' ]`

We can clearly see that `countries` variable is altered without causing any exception. This shows that `const` can't make variables immutable.

In the same sequence, try to guess the output of the following code:

```javascript

const myName = "rudra";
myName[0] = "R";
console.log(myName)

```

Did you guess the output to be `Rudra`? 
If yes, then unfortunately your Javascript basics are not strong.
The output will be `rudra`. 


Here is the reason: 

> _In Javascript, all the primitives ( Numbers, Strings, Boolean, BigInt, Symbol, Undefined and Null) are immutable, ie once they are initialised, their value can't be changed, but can only be reassigned. All primitives are stored in call stack._

<br>

> _Whereas, all the reference variables ( Objects, Arrays, Maps, Sets ) are mutable, ie there value can be changed directly from the memory location where they are stored. All references are stored in heap area._

**const variables can't be reassigned.**

This is the sole purpose of using `const`. Once a variable declared using `const`, can't be reassigned with other value.

```javascript

const countries = ["India","USA","UK"];
countries = ["India","USA","UK"];
console.log(countries);

```

Output: 
`TypeError: Assignment to constant variable.`
DAY 5(II) - Rotate Image
Tags: coding, programming, learning, beginners
Published: 2023-06-08 15:14:41

Hello to anyone reading this. I am still relatively new to coding and this platform as well, so please feel free to drop any corrections/advice for me.
I am trying to do the 100 Day-Challenge of consistent coding and this is Day-5.Looking forward to a positive interaction with all of you.

## DAY 5 Problem 2: Rotate Image
_You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise)._
_You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation._


![Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n5rh4m9nsoj4w17flv8q.png)
**Example:**

> Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]

> Output: [[7,4,1],[8,5,2],[9,6,3]]

## Intuition:
We can closely observe the original matrix and the final matrix to deduce this out.
Starting the row from top, row of the matrix is in the ending column in resultant matrix.
To use this approach , we will have to take another matrix of n*n but that will exceed the required space complexity. But still let's take a look at it.

```
vector<vector<int>> rotate(vector<vector<int>>& matrix) {
        vector<vector<int>> matrixAns;
        int size = matrix.size();

        for(int i = 0; i < size; i++)
        {
            for(int j = 0; j < size; j++)
            {
                matrixAns[j][size-i-1] = matrix[i][j];
            }
        }
    return matrixAns;
        
    }
```
**Complexity Analysis**
> Time Complexity: O(N^2)
> Space Complexity: O(N)

Although this is an approach, in a space constrained environment. It will most likely fail.
So we are going to have to come up with a better approach.

**Optimal Solution**

- To solve this, We will have to know what a transpose of a matrix is.
- To put it simply a transpose of a matrix swaps the element of a matrix in diagonally opposite position
- That is , swapping of rows and columns
- After simply transposing, we will reverse elements in each row and get the desired answer.


![Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jk76xfjj7sol201umsl0.jpeg)



```
void transposeMatrix(vector<vector<int>>& matrix)
    {
        int n = matrix.size();
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < i; j++)
            {
                swap(matrix[i][j],matrix[j][i]);
            }
        }
    }
    void rotate(vector<vector<int>>& matrix) {
        transposeMatrix(matrix);
        for(int i = 0; i < matrix.size(); i++)
        {
            reverse(matrix[i].begin(),matrix[i].end());
        }
        
        
    }

```

**Complexity Analysis**
> Time Complexity: O(N^2)
> Space Complexity: O(1)
Aprendendo Git Branching - Comandos
Tags: git
Published: 2023-06-08 15:12:39

---
title: Aprendendo Git Branching - Comandos
published: true
description: Série de posts sobre o site/aplicativo Aprendendo Git Branching. Aqui vou postar os comandos que aprendi e o que entendi de cada um.
tags: git
series: Learning Git Branching
---
Comandos utilizados e aprendidos na série **Aprendendo Git Branching**.

## Comandos
### `commit`
```bash
# cria um snapshot do trabalho atual
git commit
```

### `branch`
```bash
# cria uma nova branch chamada newImage
git branch newImage
```

### `checkout`
```bash
# cria a nova branch bugFix e altera para a mesma
git checkout -b bugFix

# C1: hash do commit
# faz checkout e aponta o head para o commit C1
git checkout C1

# sendo que a branch bugFix está em C4:
# 1-fazer checkout para a branch bugFix
# 2-fazer checkout para o commit C3
git checkout bugFix^

# sendo que HEAD e a branch main está em C4:
# 1-fazer checkout para a branch main
# 2-fazer checkout para o commit C0
git checkout HEAD~4

# sendo que HEAD e a branch main está em C7:
# 1-fazer checkout para o segundo pai do commit C7
# 2-fazer checkout para dois commits atrás do segundo pai
git checkout HEAD~^2~2
```

### `cherry-pick`
```bash
# dados os commits C1, C2, C3, C4, C5, C6 e C7
# escolher apenas os commits C7, C3 e C5 nessa ordem
# para serem adicionados na branch main
git cherry-pick C7 C3 C5
```

### `reset`
```bash
# move a referêcia para o commit anterior repo LOCAL
git reset HEAD~1
```


### `revert`
```bash
# move a referêcia para o commit anterior repo REMOTO
git revert HEAD
```

### `rebase`
```bash
# tendo feito o checkout para branch bugFix
# move o trabalho dessa branch para a main
git rebase main

# tendo a branch main como HEAD
# selecionar opções dentro dos útimos 3 commits
git rebase -i HEAD~3
```

### `merge`
```bash

```

### `tag`
```bash
# cria uma tag para o commit C1 com o nome v1.0
git tag v1.0 C1
```

### `fetch`
```bash

```

### `pull`
```bash
# faz o pull e rebase ao mesmo tempo
git pull --rebase

```

### `push`
```bash

```
Introducing... the Team Pando flow editor
Published: 2023-06-08 15:04:08

# You can now easily edit your Team Pando product flows

[Last week](https://blog.teampando.com/blog/20230530-end-to-end-product-lifecycle-in-team-pando?utm_source=devto&utm_medium=web&utm_campaign=flow-editor) we gave you a sneak peak into how we use Team Pando to build features _for_ Team Pando.

That feature has now been live and used by amazing members of Team Pando for a few days so we thought it was time to officially share a demo with you all.

First, a reminder about what we built.

Team Pando's Requirements Understanding Engine is the world's first and best engine for extracting the structure from the normal product requirements we all write every day. We turn requirements into [product flows](https://blog.teampando.com/blog/20230607-product-building-blocks?utm_source=devto&utm_medium=web&utm_campaign=flow-editor) that faithfully represent the product that you're defining.

When the flows that we generate are slightly different from what you expected, your first choice should be to update the requirements to clarify your intention. We recommend that as the first choice not because it will help our Requirements Understanding Engine but because it will help the rest of your team understand exactly what you have in mind.

Sometimes, though, you just want to make a quick change. In those cases, Team Pando now let's you easily make changes to the flow we created for each requirement.

Check out flow editing in action, below.

Or open up [Team Pando](https://app.teampando.com/?utm_source=medium&utm_medium=web&utm_campaign=20230608-introducing-flow-editor) and try it out for yourself!

{% embed https://www.youtube.com/embed/xaI87dLfss4 %}
Video SDK for Android Native - Java & Kotlin
Published: 2023-06-08 14:57:57

Reference you can check here: https://github.com/v-empower/MeetHour-Web-MobileSDKs/tree/master/Mobile/Native/android

# MeetHour SDK Implementation - Steps

1. SDK Example Link - https://github.com/v-empower/MeetHour-Web-MobileSDKs
2. API Documentation Link - https://docs.v-empower.com/docs/MeetHour-API/

# Steps to Integrate:

1. Signup for Meet Hour (https://meethour.io) and signup for Developer or Higher plan. Currently we offer 28 days free trial.
2. Once you signup for developer plan, and go to our Dashboard - (https://portal.meethour.io) and tap on "Developers" menu.
3. Now copy and Client ID & Client Secret and keep it handy with you.
4. Go to our API documentation and hit Login API to get oAuth Access Token - (https://bit.ly/3E2hKU7)
5. Once you get an access token, you can access any our API. Now you first thing you have to do is create a contact in our system as soon as user signup in your platform using this API (https://bit.ly/3LRehug). This will give you unique contact_id of that user. You require this id when you schedule a meeting below.
6. Later go to Schedule Meeting API -> Pass all the parameters needed to generate a new meetings - (https://bit.ly/3riFLkx)
7. Once the meeting is genereate, in order to join a meeting you require to Generate JWT Token using this API (https://bit.ly/3ur5pFR) and pass it to the conference URL via MT Parameter - https://meethour.io?mt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImFjY2Vzc190b2tlbiI6ImV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSlNVekkxTmlKOS5leUpoZFdRaU9pSTVNemxrWmpVeE5pMDJNekEzTFRRNVkyUXRPVGMxTXkwek1XRTNNemRrT1RGaE1HWWlMQ0pxZEdraU9pSmtNMlUyT

---
id: dev-guide-android-sdk
title: Meet Hour Android SDK
---

## Latest Verion - 4.2.4

The Meet Hour Android SDK provides the same user experience as the Meet Hour app,
in a customizable way which you can embed in your apps.

## Build your own, or use a pre-build SDK artifacts/binaries

MeetHour conveniently provides a pre-build SDK artifacts/binaries in its Maven repository. When you do not require any
modification to the SDK itself or any of its dependencies, it's suggested to use the pre-build SDK. This avoids the
complexity of building and installing your own SDK artifacts/binaries.

### Use pre-build SDK artifacts/binaries

In your project, add the Maven repository
`https://repo.meethour.io/maven/releases` and the
dependency `go.meethour.io.react:meet-hour-sdk:4.0.1` into your `build.gradle` files.

The repository typically goes into the `build.gradle` file in the root of your project:

```gradle
allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://repo.meethour.io/maven/releases"
        }
    }
}
```

Dependency definitions belong in the individual module `build.gradle` files:

```gradle
dependencies {
    // (other dependencies)
    implementation ('go.meethour.io.react:meet-hour-sdk:4.2.4') { transitive = true }
}
```
Make your Ansible Playbooks even more reliable and secure
Tags: ansible, ansibleplaybooks, automation
Published: 2023-06-08 14:30:00

We have just released Steampunk Spotter 2.0! We have been working really hard on our Ansible Playbook scanning tool and are happy to share that Spotter now offers many new features and checks that will make your automation even more reliable and secure:

⚙️ **Custom rules and policies:** You can now add your own rules and policies, whether this is compliance with organizational and industry regulations, setting playbook standards, or defining naming conventions. Spotter includes an Open Policy Agent (OPA)-compliant policy definition engine, making it easy to create and include OPA-based policies written in Rego.

⚙️ **Assisted playbook writing:** In VSC, you can now write the desired action, and Spotter will provide suitable tasks or playbooks.

⚙️ **Security checks:** In addition to best practice, validation and upgrades checks, we have added security check that will help you follow security best practices and identify potential vulnerabilities and policy violations.

⚙️ **Up-to-date knowledge base:** You can already check if your playbooks are compatible with the freshly released Ansible 2.15.

⚙️ **Scan profiles:** You can now tell Spotter to run all checks or just specific ones to avoid seeing results that are irrelevant to you at that time.

⚙️ **Reporting:** Gain valuable insights into your scan activity and data, spot trends and monitor progress.

If you'd like to know more about Spotter 2.0, check out [this blog post](https://steampunk.si/blog/steampunk-spotter-what-is-new-in-2-0/), or [try it out](https://steampunk.si/spotter/).
JSTL extension for snippets suggestions
Tags: java, jst, vscode, extensions
Published: 2023-06-08 14:27:34

Vscode is the favourite text editor for most developers. It's extensions make it life easier for developers. But a thing i experienced while working with jsp, servlets, springmvc ,etc , that developers don't prefer working with vscode. The main reason being there was no extension for jstl snippets which can work flawlessly when language mode is HTML, so that one can use emmet features and jstl snippets at the same time. The extensions available will generate some limited snippets that too when language mode is JSP, so now you don't have access to the emmet features.

So to overcome these problems I have created a vscode extension which will provide all above features at the same time. You can check the extension following the below link: https://marketplace.visualstudio.com/items?itemName=DebrajBhal.jstl-snippets-by-deb