teleren/devto huggingface dataset:
1470. Shuffle the Array(easy)
Tags: dsa, java, leetcode, beginners
Published: 2024-02-23 15:35:44

## Introduction

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

Here we have given an and all we have to do is shuffle the array. So the procedure is we have to separate the array in two parts from the middle and n is the middle point and the array is always have event number of index. Now we have to take element from the each array put it in serial. Like we have nums = [2,5,1,3,4,7], n = 3. Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7]. 

##Examples

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


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

##Steps
1. take a new array arr having same length of nums
2. Run for loop, from 0 to n;
3. Now in even position put, arr[2*i] = nums[i];
4. In odd position, arr[2*i+i] = nums[n + i];

##Java Code1:

```
class Solution {
    public int[] shuffle(int[] nums, int n) {
        int [] arr = new int[n*2];
        for(int i = 0; i < n; i++){
            arr[2*i] = nums[i];
            arr[2*i + 1] = nums[n + i];
        }
        return arr;
    }
}
```

## Java Code2:

```
class Solution {
    public int[] shuffle(int[] nums, int n) {
        int[] ans = new int[2*n];
        int start = 1, end = n, i = 1;
        ans[0] = nums[0];
        while( i < 2*n){
            if( i % 2 != 0) {
                ans[i] = nums[end];
                end++;
            }
            else{
                ans[i] = nums[start];
                start++;
            }
            i++;
        }
        return ans;
    }
}
```

##Output

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ygglg53m8564s9i9kv0y.png)
How to cache requests in Angular
Tags: angular, webdev, typescript, beginners
Published: 2024-02-23 15:33:43

#Table contents

- [Purpose](#purpose)
- [What?](#what)
- [How?](#how)
- [Seeing the change](#seeing-the-change)
- [Conclusion](#conclusion)

#Purpose

In our application, users often revisit the same path/page multiple times. Each time a user returns to the page, the application makes another API call. However, why do we call the same API path every time the user returns to the page instead of saving the request and reusing it?

Pros:

- Saving API resources (fewer calls, lower cost)
- Eliminating repetitive loaders every time the user enters the page

#What?

To achieve this, we utilize the `shareReplay` method in RxJS. According to the [documentation](https://www.learnrxjs.io/learn-rxjs/operators/multicasting/sharereplay), `shareReplay` replays the result of an Observable as many times as needed.

#How?

Implementing it is straightforward. All you need to do is add the `shareReplay` pipe to the Observable, as shown in the code below:

```ts
  public getFacts() {
      return this.httpClient.get<Fact[]>('https://cat-fact.herokuapp.com/facts')
      .pipe(shareReplay());
  }
```

Now you're all set. Simply use the method, and the pipe will handle everything for you.

#Seeing the change

Let's compare the difference between using `shareReplay` and not using it.

**Without using it:**

![Image of code making 2 http calls](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2bjge5spll3wel6z0lk.png)

Notice that every time I click "Call subscriber" my code makes an HTTP call and returns the cat facts.

However, since my API changes daily rather than constantly, let's add shareReplay and observe the result:

![Image of code making no http calls after using shareReplay method](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ze6v5crq958x7079wcwx.png)



See? When I clicked "Call subscriber", it returned the same result without making any additional HTTP calls!

#Conclusion

RxJS is a powerful tool, and with just a simple line of code, your performance could be significantly improved.

**Cheers!!!**
Angular 17 with clean architecture - Error: Dependency Injection
Tags: angular, typescript, cleancode, frontend
Published: 2024-02-23 15:32:26

I'm learning how to build corners in a neat architecture. But I encountered a small problem while implementing it. When you click to log in to the website, the above error appears and this error appears in line 22 of AuthLoginUseCase. Can someone help me solve this problem? Thank you!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hu6rffjzl1194y955ice.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ga901nayfo0xzam9ytv3.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lwhft4vg9ldbk9je76n5.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aa6dxi62wp6c5ur20lyo.jpg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hk498ntqqh41cyip9sud.jpg)
The Law Office of Pablo G Pinasco
Published: 2024-02-23 15:12:58

 If you have been injured in California due to the negligence of someone else, you need a personal injury attorney who will fight tirelessly to get you the compensation you deserve. We are the the personal injury law firm to call. With years of experience representing clients in personal injury cases, we have proven success in getting our clients in California the maximum compensation they deserve for their injuries. An injury from an accident is a very important moment in a person’s life, so it is equally important to not settle for anything less than the best when it comes to your case. Contact us today and you will see why we are the best choice for a personal injury law firm in California.
Address:      5632 Van Nuys Blvd Unit 3131, Sherman Oaks, CA 91401, United States
Phone: +1 2136994878
Business email : contact@lawpgp.com
Website:  https://lawpgp.com/santa-ana/
Configuring Wildcard Subdomains: A Comparison of Nginx and Caddy
Tags: nginx, devops, webdev, caddy
Published: 2024-02-23 15:25:39

### Introduction

Wildcard subdomains allow you to dynamically handle multiple subdomains under a parent domain without explicitly defining the configuration for each subdomain. 

![An illustration of a multitenant application with subdomains](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/voy3xj8mp4rs7f1o6pqi.png)

A common use case for wildcard subdomains is in multitenant applications where each customer accesses the application from their unique domain. Manually configuring each subdomain is impractical in this scenario.

In this article, we will look at configuring wildcard subdomains on Nginx and Caddy and compare both options.


### Requirements
- The article assumes you have Nginx and Caddy installed


### Nginx Configuration
To get started, we'll create a new config file. You need root access to update the configuration so we will prefix the command with `sudo`

```bash
sudo nano /etc/nginx/sites-available/app.com
```

Add the following configuration to the file

```text
server {

    server_name *.app.com;

    location / {
        proxy_pass http://127.0.0.1:8090;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

```

This configuration proxies all requests to a service running on port 8090. The key bit is `server_name *.app.com;`, this tells nginx to handle all requests made to `*.app.com` (customer1.app.com, customer2.app.com ...).

### Caddy Configuration
Just like Nginx, we'll begin by editing the main configuration file and prefixing the call with `sudo` since it requires root access:

```bash
sudo nano /etc/caddy/Caddyfile
```

And the contents: 

```text
*.app.com {
    request_body {
        max_size 10MB
    }
    reverse_proxy 127.0.0.1:8090 {
        transport http {
            read_timeout 360s
        }
    }
}
```

### Comparison and Conclusion

Both Nginx and Caddy have similar configuration patterns they both have distinct approaches so the syntax differs greatly. They however both provide nearly the same levels of flexibility and functionality with Caddy being more akin to JSON and supporting it natively.
Mastering the :not() CSS Pseudo-Class
Tags: css, pseudo, class, not
Published: 2024-02-23 15:03:40

**Introduction:**
In CSS, the :not() pseudo-class serves as a powerful tool for selecting elements that do not match a given set of selectors. By negating specific selectors, :not() offers flexibility in styling and targeting elements in a document. However, its usage comes with nuances and unexpected outcomes that developers need to understand to leverage it effectively.

**Syntax:**
The syntax of the :not() pseudo-class is straightforward:
```css
:not(<complex-selector-list>) {
  /* CSS rules */
}
```
Here, `<complex-selector-list>` represents a comma-separated list of one or more selectors that the element should not match.

**Key Points:**
1. **Useless Selectors:** :not() can lead to writing selectors that are ineffective. For instance, :not(*) matches any element that is not an element itself, rendering the accompanying rule useless.
2. **Specificity Increase:** It's essential to note that :not() can increase the specificity of a rule. This means that selectors like #foo:not(#bar) will have higher specificity due to the presence of multiple ID selectors.
3. **Replacement of Specificity:** The specificity of :not() is determined by the most specific selector within its argument list, similar to :is(). It essentially adopts the specificity of the selectors it negates.
4. **Surprising Matching:** :not() selects everything that is "not an X." This can lead to unexpected results, especially when used with descendant combinators, as there may be multiple paths to select a target element.
5. **Negating Multiple Selectors:** Multiple selectors can be negated simultaneously using :not(). For example, :not(.foo, .bar) is equivalent to :not(.foo):not(.bar).
6. **Handling Invalid Selectors:** If any selector within :not() is invalid or unsupported, the entire rule will be invalidated. To overcome this, the :is() pseudo-class can be used, as it accepts a forgiving selector list.

### Advance instance

{% codepen https://codepen.io/r4nd3l/pen/dyrBOgQ  %}

**Conclusion:**
The :not() pseudo-class is a valuable asset in the CSS arsenal, offering a means to target elements that do not match specific selectors. However, its usage requires careful consideration of its behavior and potential quirks to avoid unintended consequences. By understanding its syntax, intricacies, and best practices, developers can wield the :not() pseudo-class effectively to enhance the styling and structure of their web projects.
Unveiling the Timeless Charm of Buddha Statues: A Journey into Fibre Art
Tags: buddha, statue, fibre
Published: 2024-02-23 14:59:08


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/443i81x6rgudzad1gtpw.PNG)
Welcome to The Stone Studio's blog, where we delve into the captivating world of Buddha statues, with a special focus on the exquisite craftsmanship of [**fibre Buddha statue**](https://www.thestonestudio.in/handicraft/fibre-buddha-statues/). Join us on a journey to discover the profound symbolism, cultural significance, and unparalleled beauty encapsulated within these timeless works of art.

**Exploring the Serene Beauty of Buddha Statues:** Buddha statues have long been revered as symbols of enlightenment, inner peace, and spiritual awakening. Crafted with meticulous attention to detail, these statues serve as powerful reminders of the teachings and wisdom of the Buddha.

**The Rise of Fibre Buddha Statues: **In recent years, fibre Buddha statues have gained popularity for their durability, versatility, and stunning resemblance to traditional stone sculptures. Made from high-quality materials, such as fiberglass resin, these statues offer a lightweight yet resilient alternative to their stone counterparts.

**Craftsmanship and Artistry**: At The Stone Studio, we take pride in our commitment to craftsmanship and artistry. Each fibre Buddha statue is meticulously handcrafted by skilled artisans, who imbue every piece with a sense of reverence and devotion.

**Capturing the Essence of Serenity**: One of the most remarkable qualities of fibre Buddha statues is their ability to capture the essence of serenity and tranquility. Whether placed in a meditation space, garden, or home altar, these statues radiate a sense of calm and peace to all who behold them.

**Symbolism and Spiritual Significance**: From the serene smile of the Buddha to the graceful posture of meditation, every aspect of a fibre Buddha statue is infused with profound symbolism and spiritual significance. Each gesture and expression serves as a reminder of the path to enlightenment and inner harmony.

**Enhancing Your Living Space**: Whether you're a devout Buddhist practitioner or simply appreciate the beauty of spiritual art, a fibre Buddha statue can serve as a striking centerpiece for any living space. With various sizes, styles, and finishes available, you can easily find the perfect statue to complement your home décor.

As we conclude our exploration into the world of [**Buddha statues**](https://www.thestonestudio.in/handicraft/buddha-statues/), we invite you to discover the timeless charm and spiritual resonance of fibre Buddha statues at The Stone Studio. Embrace the beauty of these exquisite works of art and invite a sense of peace and tranquility into your life today.
SWS Console: Creating Private RDS instances and Bastion EC2 resources.
Published: 2024-02-23 14:45:20

After creating the [AWS EC2 DMS service](https://docs.stevewebservice.com/aws/feature-guide/ec2-dms/) on the SteveWebService Console, we pondered another issue. Typically, to launch a service, one needs to configure client web, API servers, and a database.

Considering this flow, we naturally thought that configuring RDS instances is necessary in AWS Cloud.

So, we decided to create the service following the flow depicted in the image below, and named it DB & Bastion EC2 Turn Key.


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

First, when creating an RDS with DB & Bastion EC2 Turn Key, the creation begins with setting up the Bastion EC2. If a Bastion EC2 already exists within the VPC (SWS Project), it won't be created separately.

Additionally, the RDS instance is created privately. The reason for creating it privately is that when you create a VPC using the Sws Console's VPC Turn Key (SWS Project), the Security Group of the RDS is configured so that it can only be accessed via the Bastion EC2.

[Visit the Steve Web Service homepage](https://www.stevewebservice.com/)

[Visit Steve Web Service AWS VPC Turn Key feature](https://docs.stevewebservice.com/aws/feature-guide/sws-project/)

Now, in the creation process outlined above, we've minimized the elements users need to input to the extent possible, so that with just project selection, database name, and engine type (mysql, mariadb, etc.), the RDS instance can be created in just 10 minutes, as depicted in the image below.


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

Isn't it incredibly easy? Users can configure RDS with just simple inputs and clicks, even without any prior learning about AWS Cloud.

But we didn't stop there; we've structured the interface to provide detailed screens on how users can access RDS instances via the Bastion EC2.


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

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

Through the console, users can download a PEM key and access guidance on how to connect to the Bastion EC2, enabling them to access and utilize the RDS from there. With the SteveWebService tool, users can configure an architecture to access Bastion EC2 and RDS instances privately on AWS Cloud without learning about EC2 or RDS. Isn't it remarkably easy?

Continuing in this vein, we aim to develop tools that assist users in building cloud architectures without the need for learning AWS Cloud, allowing developers to focus more on business. Furthermore, we strive to provide value by enabling even small teams of developers to make the most of AWS resources.

Our next article will delve into the history of solving different problems. End.


[Visit the Steve Web Service homepage](https://www.stevewebservice.com/)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2a3aylo7al680lkkfr1k.png)
Vibe check, coming back to a new place, free project idea.
Published: 2024-02-23 14:43:40

Well it looks and feels familiar. However, I'm curious what I left to come back to. How is it here now? 

It feels so weird to be a daily part of something for a long time and then to get away from it and come back to it. 

Much like when we have project you pour your heart and soul into it... just to one day put it in a folder for no one to see and spiderwebs to collect.

It's still your love but it feels like a stranger now. So this is me testing the waters and seeing who responds. Sure it's not tech related but sometimes we need to put the coding cap down and just be human for a little while.

So if you are reading this, I have a free idea for you. Well two things.

First, open up that old project, reach out to an old friend, dust off those notes you held so dear before and reconnect! 

Second, one of you please make a website that gives a place to show off your partially completed projects. It'll be like a old school "Under Construction" signs you used to see on the modified cars back in the day... it's ok to be a work in progress.. show us. 

The name for it can be called "Partial Passions" 

Much Love.

--DeChamp
Majestic Lake View Suite with Balcony in Udaipur
Published: 2024-02-23 14:33:22

Drenched in a calming blue, this room will make you feel like royalty. Walk into this richly decorated and luxuriously spacious room that boasts a kind size bed, living room, a writing corner with an additional bay-window style large nook to lounge in. Only one such suite in the hotel, this room is a unique fusion of old world charm with modern amenities. The four poster bed, chequered flooring, distressed style hard wood furniture will take you back in time while offering you modern comforts of a mini bar, TV, tea/coffee maker and wifi.
[https://swaroopvilas.com/majestic-lake-view-suite-with-balcony.html](https://swaroopvilas.com/majestic-lake-view-suite-with-balcony.html)
Good coding habits 🕊️ and the not-so-good ones 💩
Tags: programming, productivity, devops, learning
Published: 2024-02-23 14:27:05

Our talented developers and engineering managers created a FREE guide that explores promoting good habits in software development (and eliminating bad ones 💩). It’s called:


“The Good, the Bad, and the Ugly: Exploring 26 Behavioral Practices in Software Development.”

Here’s a sample of a few topics we covered:
- Learning to Say ‘No!’ 
- Onboarding Too Much and Too Fast 
- Mentorship 
- Reckless Deployment 
- Rubber Stamping PRs 
- AND SO MUCH MORE!

Check it out and feel free to share. 

https://howareyou.work/exploring-26-behavioral-practices-in-software-development/
I had created a new Graphics Programming Language "Tortoys" 🐢
Tags: programming, python, tutorial, discuss
Published: 2024-02-23 14:24:35

Github : https://github.com/rudransh61/Tortoys

Yes ,u heard that right , I had created a new programming language and i have a very solid reason also.
So , if you are a beginner or just started programming you may wonder
what the heck how this graphics is alchualy workin ? how is dat 'pro'grammed???

and after some time you find out that its 'Turtle'
and you try it on python

but for creating just a small app you have to write tons of diff objects or watever ... like turtle.screen.title("wth how big is this?")

so i had created a seperate programming language in python (whichis itself written in another proglang C)
so its called 
Tortoys
syntax is insanely simple
```
TITLE "Thats what i need"
MOVE 10
SPEED 1
$ this is a comment
```
you can tell some ideas to add to it , so try this and make something beautiful with it or very basic (as loops are not implemented yet)
Github : https://github.com/rudransh61/Tortoys
Non-sequential IDs matter in Django
Tags: django
Published: 2024-03-09 09:12:16

---
title: Non-sequential IDs matter in Django
published: true
date: 2024-02-23 14:00:58 UTC
tags: Django
canonical_url: https://www.paleblueapps.com/rockandnull/sequential-ids-vs-uuids/
---

 ![Non-sequential IDs matter in Django](https://images.unsplash.com/photo-1555529902-5261145633bf?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTc3M3wwfDF8c2VhcmNofDF8fGxvY2t8ZW58MHx8fHwxNzA4Njk2Njk3fDA&ixlib=rb-4.0.3&q=80&w=2000)

In the world of software development, unique identifiers (IDs) play a crucial role in managing and accessing data. While Django models typically use auto-incrementing integer IDs by default, this approach can pose security and privacy concerns. Here's where [Universally Unique Identifiers (UUIDs)](https://en.wikipedia.org/wiki/Universally_unique_identifier?ref=paleblueapps.com) come to the rescue, offering a more robust and secure alternative.

## The Problem

Sequential IDs, like 1, 2, 3, are easily guessable. Publicly exposing sequential IDs in URLs can be problematic. This allows malicious actors to potentially manipulate URLs and potentially access unauthorized resources. If you expose "/resource/1" and "/resource/2," users might guess "/resource/3". This can lead to unexpected behavior and potential security vulnerabilities if, for instance, the resource access check is for some reason omitted.

## A mitigation solution

UUIDs are 128-bit random numbers represented as strings like "34f212e4-212f-47b6-b6b6-34f212e4212e." They offer several key advantages:

- **Uniqueness:** The sheer randomness of UUIDs makes them incredibly unlikely to collide, even across multiple servers or databases. This eliminates predictability and guessability, significantly enhancing security.
- **Anonymity:** UUIDs don't reveal any inherent order or information about the data they identify. This protects sensitive information and enhances user privacy.
- **Scalability:** UUIDs are efficient and scalable, even for large datasets. They don't suffer from performance issues associated with auto-incrementing integers, especially in distributed systems.

Django provides the `UUIDField` to seamlessly integrate UUIDs into your models. Here's how:

```
from django.db import models
import uuid

class MyModel(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4)
    # ... other fields

```

Moving from sequential IDs to UUIDs in Django is a straightforward yet impactful security and privacy upgrade. By leveraging the inherent randomness and anonymity of UUIDs, you can significantly strengthen your application's defenses while improving scalability and flexibility with one simple small change.

Happy coding!