teleren/devto huggingface dataset:
Deep copy in JavaScript, what is that?
Tags: javascript, programmers, web, learning
Published: 2024-01-27 03:53:23

JavaScript doesn’t need presentations; it is an awesome language. If you have been working with it, you probably have noticed some …weird behaviors. Once of them is Deep Copy, let’s take a look at this interesting concept

When we do a variable copy JavaScript create a new memory slot and there, is saving the value copied, then the new variable point to this new memory slot. For example:

```jsx
x = 5;
y = x;
```

**_y_** is pointing to a new memory slot, which have the same value of **_x_**, it means, 5. Visually it would be something like this:


![x point to A2 address and y point to A3 address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obixshbk9izu8ejwrevg.png)

What we see before applies only to primitives values, for objects is different. Imagine we have the follow two objects

```jsx
let a = {
	name: 'Rick',
	lastName: 'Sanchez',
};

let b = a;
```

In before code **_b_** doesn’t have its own memory slot as we could expect, instead of that, **_b_** is pointing to memory slot where **_a_** is saved


![variables a and b point to same A8 address](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/56pxulqm7n54ltaf5247.png)

What problems could this behaviour cause? Basically, if you change any field of  **_a_** or **_b_**, both variables will changed. Copy the follow code and verify by yourself

```jsx
let a = {
	name: 'Rick',
	lastName: 'Sanchez',
};

let b = a;

b.name = 'Morty';

console.log('a: ', a); // a:  { name: 'Morty', lastName: 'Sanchez' }
console.log('b: ', b); // b:  { name: 'Morty', lastName: 'Sanchez' }
```

The solution for this? We need to do a deep copy to save the value of **_a_** in a new independent memory slot where **_b_** will be pointing

```jsx
const b = JSON.parse(JSON.stringify(a));
```

In this way, we are forcing JavaScript to create a new memory slot by changing the format from Object to JSON, this is done using the **_stringify_** method, then the JSON with its own slot becomes into Object again with **_parse_** method, so both variables remain totally independent.
AWS Cloud Practitioner
Tags: aws, awscertified, awscloud, cloudcertification
Published: 2024-01-27 03:46:08

Today I passed the AWS Cloud Practitioner exam. I decided to take this foundational exam while learning about AWS due to the following reasons:

:cloud: It is part of a larger project I am working on
:cloud: It allows me to confirm my knowledge
:cloud: Gives me a survey of the AWS exam environment/experience
:cloud: Provides a discount on future certifications

I am planning on doing a lot of awesome things with cloud/security this year. Keep an eye on this space!


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/crpwtbtvutfn40zcqh0z.png)
Day 9: Safeguarding the Azure Network - Exploring Network Security Groups
Tags: 100daysofcloud, azure, adcstreak, cloud
Published: 2024-01-27 03:37:49

Yesterday's expedition in the #100DaysOfCloud delved deep into the realm of network security within Azure, as we explored the pivotal role of Network Security Groups (NSGs) in fortifying our cloud infrastructure. Let's dive into the world of Azure network defense and discover the power of NSGs!

### Understanding Network Security Groups: 
Network Security Groups serve as the first line of defense in Azure networking, acting as virtual firewalls to control inbound and outbound traffic to Azure resources. By defining security rules, NSGs enable granular control over network traffic, ensuring only authorized communication flows within the Azure environment.

### Granular Traffic Control: 
NSGs empower organizations to define specific rules based on source and destination IP addresses, ports, and protocols. This granular control allows administrators to tailor network security policies to meet the unique requirements of their applications and services, minimizing exposure to potential threats.

### Enhancing Security Posture: 
By implementing NSGs, organizations bolster their security posture within Azure, mitigating risks associated with unauthorized access, malicious activities, and data exfiltration. NSGs provide a crucial layer of defense against cyber threats, reinforcing the resilience of cloud-based infrastructures.

### Dynamic Rule Management: 
The flexibility of NSGs enables dynamic rule management, allowing administrators to adapt security policies in response to evolving threats and changing business requirements. Whether it's updating rules to accommodate new application deployments or tightening security controls in response to emerging threats, NSGs offer agility and responsiveness.

### Use Cases: Securing Azure Workloads: 
NSGs find application across various Azure workloads, from virtual machines and virtual networks to Azure Kubernetes Service (AKS) clusters and Azure App Services. Whether it's enforcing access controls for web applications or restricting inbound RDP access to VMs, NSGs play a pivotal role in safeguarding Azure resources.

### Monitoring and Compliance: 
Beyond enforcement, NSGs provide visibility into network traffic patterns, facilitating monitoring, and compliance efforts. By analyzing NSG flow logs and leveraging Azure Monitor, organizations gain insights into network activity, identify potential security incidents, and ensure compliance with regulatory requirements.

### Empowering Secure Azure Networking: 
As organizations embrace the cloud, the importance of robust network security cannot be overstated. Network Security Groups emerge as a cornerstone of Azure network defense, empowering organizations to build resilient, secure, and compliant cloud infrastructures.

Thanks, @azdevindia and @beingwizard for the session and resources.


### Resources:
- https://michaeldurkan.com/2021/11/16/100daysofcloud-day9-azurenetworksecuritygroupsnsg/
Question: Implement a Binary Search Algorithm
Tags: beginners, programming, java, datastructures
Published: 2024-01-27 03:16:11

# Question: Implement a Binary Search Algorithm 

**Problem Description:**
Write a Java function to perform a binary search on a sorted array and return the index of a given target element. If the target is not present, return -1.

**Solution:**

```java
public class BinarySearch {
    // Function to perform binary search on a sorted array
    static int binarySearch(int[] arr, int target) {
        int left = 0;
        int right = arr.length - 1;

        while (left <= right) {
            int mid = left + (right - left) / 2;

            if (arr[mid] == target) {
                return mid; // Target found, return the index
            } else if (arr[mid] < target) {
                left = mid + 1; // Target is in the right half
            } else {
                right = mid - 1; // Target is in the left half
            }
        }

        return -1; // Target not found
    }

    public static void main(String[] args) {
        int[] sortedArray = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        int target1 = 5;
        int target2 = 11;

        System.out.println("Sorted Array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]");
        System.out.println("Searching for target " + target1 + ": Index " + binarySearch(sortedArray, target1));
        System.out.println("Searching for target " + target2 + ": Index " + binarySearch(sortedArray, target2));
    }
}
```

**Explanation:**
The `binarySearch` function performs a binary search on the sorted array. It maintains two pointers, `left` and `right`, and calculates the middle index (`mid`). It compares the element at the middle index with the target and narrows down the search space accordingly. This process continues until the target is found or the search space is empty.

This question assesses the candidate's understanding of binary search, a fundamental algorithm used for efficiently searching sorted data sets.
Question: Validate Parentheses in a String
Tags: beginners, programming, java, datastructures
Published: 2024-01-27 03:14:32

# Question: Validate Parentheses in a String

**Problem Description:**
Write a Java function to determine whether the parentheses in a given string are balanced. The string can contain parentheses ('(', ')'), curly braces ('{', '}'), and square brackets ('[', ']').

**Solution:**

```java
import java.util.Stack;

public class BalancedParentheses {
    // Function to check if parentheses are balanced
    static boolean areParenthesesBalanced(String expression) {
        Stack<Character> stack = new Stack<>();

        for (char ch : expression.toCharArray()) {
            if (ch == '(' || ch == '{' || ch == '[') {
                stack.push(ch);
            } else if (ch == ')' || ch == '}' || ch == ']') {
                if (stack.isEmpty() || !isMatchingPair(stack.pop(), ch)) {
                    return false;
                }
            }
        }

        // Stack should be empty if parentheses are balanced
        return stack.isEmpty();
    }

    // Helper function to check if two parentheses form a matching pair
    static boolean isMatchingPair(char opening, char closing) {
        return (opening == '(' && closing == ')') ||
               (opening == '{' && closing == '}') ||
               (opening == '[' && closing == ']');
    }

    public static void main(String[] args) {
        String expression1 = "{[()]}";
        String expression2 = "([)]";

        System.out.println("Expression 1: " + expression1);
        System.out.println("Are parentheses balanced? " + areParenthesesBalanced(expression1));

        System.out.println("\nExpression 2: " + expression2);
        System.out.println("Are parentheses balanced? " + areParenthesesBalanced(expression2));
    }
}
```

**Explanation:**
The `areParenthesesBalanced` function uses a stack to keep track of opening parentheses, curly braces, and square brackets encountered in the string. When a closing parenthesis is encountered, it checks if it matches the last opening parenthesis on the stack using the `isMatchingPair` function. If there is a mismatch or the stack is not empty after processing the entire string, the parentheses are not balanced.

This question assesses the candidate's understanding of stacks and their ability to use them to solve real-world problems, such as validating expressions.
Kinh nghiệm cá cược Golf ảo từ các chuyên gia tại 188bet
Published: 2024-01-27 03:11:28


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ochbkzp9ofuhmh4rpy4m.png)
Trước khi tham gia vào golf ảo tại nhà cái 188Bet, người chơi cần hiểu rõ những điều cơ bản sau:

Cá cược Golf ảo: Đây là việc người chơi đặt cược vào các trận đấu giữa các người chơi ảo, thay vì các golf thủ thực tế.

Xác định kết quả: Kết quả cuối cùng của mỗi trận đấu dựa trên các số liệu được tạo ngẫu nhiên, với tỷ lệ cược được nhà cái liệt kê.

Tỷ lệ cược thay đổi: Tỷ lệ cược cho mỗi loại cược khác nhau và được cập nhật liên tục dựa trên ưu thế của từng người chơi và giai đoạn cụ thể trong trận đấu.

Các kèo cược đa dạng: Mỗi trận đấu golf ảo mang đến nhiều lựa chọn cược khác nhau để người chơi tham gia.

Trực tiếp và Video trận đấu: Video trận đấu được hiển thị dưới dạng "trực tiếp", cho phép người chơi theo dõi và đặt cược vào trận đấu golf ảo mà họ quan tâm tại thời điểm hiện tại.

Xem thêm tại: https://88betg.com/ca-cuoc-golf-ao-cho-tan-thu/
Xem thêm tại: https://88betg.blogspot.com/
#golfao #88betg #188BET #nha_cai_188BET #nha_cai #casino
Question: Find the Common Elements in Two Arrays
Tags: beginners, programming, java, dsa
Published: 2024-01-27 03:08:14


**Question: Find the Common Elements in Two Arrays**

**Problem Description:**
Given two arrays of integers, write a Java function to find and print the common elements present in both arrays.

**Solution:**

```java
import java.util.HashSet;

public class CommonElementsInArrays {
    // Function to find common elements in two arrays
    static void findCommonElements(int[] arr1, int[] arr2) {
        HashSet<Integer> set = new HashSet<>();
        for (int num : arr1) {
            set.add(num);
        }

        System.out.print("Common elements: ");
        for (int num : arr2) {
            if (set.contains(num)) {
                System.out.print(num + " ");
            }
        }
    }

    public static void main(String[] args) {
        int[] arr1 = {1, 2, 4, 5, 6};
        int[] arr2 = {2, 3, 5, 7};

        System.out.println("Array 1: [1, 2, 4, 5, 6]");
        System.out.println("Array 2: [2, 3, 5, 7]");

        findCommonElements(arr1, arr2);
    }
}
```

**Explanation:**
This solution uses a HashSet to store unique elements from the first array (`arr1`). Then, it iterates through the second array (`arr2`) and checks if each element is present in the HashSet. If it is, the element is a common element, and it is printed.

This question assesses the candidate's knowledge of data structures (HashSet in this case) and their ability to efficiently solve problems involving arrays and sets.
Question: Implement a Stack using Linked List
Tags: beginners, programming, java, dsa
Published: 2024-01-27 03:05:04


**Problem Description:**
Implement a stack data structure using a linked list. The stack should support the standard stack operations: push, pop, and isEmpty.

**Solution:**

```java
class Node {
    int data;
    Node next;

    Node(int data) {
        this.data = data;
        this.next = null;
    }
}

public class StackUsingLinkedList {
    private Node top; // top of the stack

    // Constructor to initialize an empty stack
    public StackUsingLinkedList() {
        this.top = null;
    }

    // Function to check if the stack is empty
    public boolean isEmpty() {
        return top == null;
    }

    // Function to push an element onto the stack
    public void push(int data) {
        Node newNode = new Node(data);
        newNode.next = top;
        top = newNode;
        System.out.println(data + " pushed to the stack");
    }

    // Function to pop an element from the stack
    public int pop() {
        if (isEmpty()) {
            System.out.println("Stack is empty");
            return -1;
        }
        int popped = top.data;
        top = top.next;
        return popped;
    }

    // Function to peek at the top element of the stack
    public int peek() {
        if (isEmpty()) {
            System.out.println("Stack is empty");
            return -1;
        }
        return top.data;
    }

    public static void main(String[] args) {
        StackUsingLinkedList stack = new StackUsingLinkedList();

        System.out.println("Is the stack empty? " + stack.isEmpty());

        stack.push(10);
        stack.push(20);
        stack.push(30);

        System.out.println("Top element is " + stack.peek());

        System.out.println(stack.pop() + " popped from the stack");

        System.out.println("Is the stack empty? " + stack.isEmpty());
    }
}
```

**Explanation:**
This code demonstrates the implementation of a stack using a linked list. The `Node` class is used to represent each element in the stack, and the `StackUsingLinkedList` class contains methods for `push`, `pop`, `isEmpty`, and `peek` operations. The main method demonstrates the usage of the stack.

This question assesses the candidate's understanding of data structures, particularly linked lists and how they can be used to implement common operations like stack operations.
Free AWS Exam Retake (Q1-Q2 2024)
Tags: aws, awscertification, cloudcomputing
Published: 2024-01-27 02:11:38


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xmqcpto8rc2zjli22wk.png)NOW is the time. Pearson VUE is offering a FREE EXAM RETAKE (if you need it). Here are a few steps listed on Pearson VUE's website to help you along the way https://lnkd.in/ge2UDfeN

🔸 1/ Login to your AWS Certification Account or create an account

🔸 2/ Schedule your AWS Certification exam with Pearson VUE before April 15, 2024. Retake must be taken before June 30, 2024 for the promo code to be valid.

🔸 3/ Register for your exam: Proceed to checkout and pay for your exam applying the promo code during checkout. Get your promo code below so you have the assurance of getting a free exam retake in case you need it!

🔸 4/ Prepare for your exam: From start to certified, gain confidence going into exam day with AWS Skill Builder's trusted exam prep resources, curated by the experts at AWS.

Use the link below to check Pearson VUE's website for full details, including retake terms and conditions. Good luck on your exam! 

**Happy Learning & Happy Got Certified!!!**

[Free AWS Exam Retake](https://home.pearsonvue.com/aws/freeretake)
Is the USA going to collapse?
Tags: beginners, tutorial, discuss, news
Published: 2024-01-27 02:42:49

I was walking through one of Saddam’s former palaces in Baghdad when an Enlisted Soldier commented to me, “"I bet Saddam never thought American Soldiers would one day be walking these halls when he built this”. I responded, “"Some day there will be foreign Soldiers walking through our White House and Congress. Hopefully not in our lifetime or our children's’ but it always happens inevitably”.

He just stared at me; taken out of his moment[.Read more](urlhttps://www.toprevenuegate.com/ncyayd2kw?key=b46e3b1f6518ee5d4a918d5d77bb6e2b)
𝐍𝐞𝐰 𝐜𝐨𝐮𝐫𝐬𝐞𝐬 𝐚𝐧𝐝 𝐚𝐧𝐝 𝐜𝐞𝐫𝐭𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐨𝐟𝐟𝐞𝐫𝐢𝐧𝐠𝐬 𝐟𝐫𝐨𝐦 𝐀𝐖𝐒 𝐓𝐫𝐚𝐢𝐧𝐢𝐧𝐠 𝐚𝐧𝐝 𝐂𝐞𝐫𝐭𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧 𝐢𝐧 𝐉𝐚𝐧𝐮𝐚𝐫𝐲 𝟐𝟎𝟐𝟒
Tags: cloudcomputing, cloudsecurity, awstraining, aws
Published: 2024-01-27 02:04:36

In January, we launched 24 new digital training products on AWS Skill Builder, including three new learning plans for Artificial Intelligence (AI) and Machine Learning (ML), and a Solutions Architect-focused version of AWS Card Clash. On Coursera, we launched courses 5-9 to round out the AWS Cloud Technology Consultant Professional Certificate. To learn DevOps-style best practices for building, training, and deploying ML models, check out the updated three-day AWS Classroom course, MLOps Engineering on AWS.

𝗛𝗮𝗽𝗽𝘆 𝗹𝗲𝗮𝗿𝗻𝗶𝗻𝗴! 🚀 

[AWS Training and Certification Blog](https://aws.amazon.com/blogs/training-and-certification/jan-2024-new-offerings/)
Exploring Dockerfile Frontends: A Guide with Sample App and Examples
Published: 2024-01-27 01:59:22

Dockerfile Frontends are a powerful feature introduced by Buildx, providing developers with flexibility and extensibility in the Docker image-building process. In this blog post, we'll delve into the concept of Dockerfile Frontends, understand how they work, and explore real-world examples with a sample application.

## Understanding Dockerfile Frontends

Dockerfile Frontends act as interpreters that convert high-level representations of the build process, often written in a Dockerfile, into a set of build steps that can be executed by Buildx. Different frontends offer varying levels of abstraction and integration with specific workflows. They allow developers to experiment with new features, choose alternative syntaxes, or even integrate third-party tools seamlessly.

## The Sample Application

To demonstrate Dockerfile Frontends in action, let's consider a simple Node.js application. The application consists of an Express.js server serving a "Hello, Dockerfile Frontends!" message.

```
// app.js
const express = require('express');
const app = express();
const port = 3000;

app.get('/', (req, res) => {
  res.send('Hello, Dockerfile Frontends!');
});

app.listen(port, () => {
  console.log(`App listening at http://localhost:${port}`);
});
```

## Example: Using the Default Dockerfile Frontend

Let's start with the default Dockerfile frontend. Create a Dockerfile with the following content:

```
# syntax=docker/dockerfile:1
FROM node:14

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

CMD ["node", "app.js"]
```

This Dockerfile uses the default syntax (1) and sets up a Node.js environment to run the sample application.

## Example: Using an Experimental Dockerfile Frontend

Now, let's experiment with an experimental Dockerfile frontend. Create a Dockerfile with the following content:

```
# syntax=docker/dockerfile:1-labs
FROM node:14

WORKDIR /app

COPY package*.json ./
RUN npm install

COPY . .

CMD ["node", "app.js"]
```

In this example, the Dockerfile uses an experimental syntax (1-labs). The use of experimental syntax might introduce features or changes that are not yet considered stable, so use it with caution.

## Building the Images

Build the Docker images for both examples:

```
docker buildx create --use
docker buildx build -t myapp-default --file Dockerfile.default .
docker buildx build -t myapp-experimental --file Dockerfile.experimental .
```

## Conclusion

Dockerfile Frontends open up new possibilities for customizing the build process and experimenting with alternative syntaxes. Whether you choose the default syntax or an experimental one, understanding Dockerfile Frontends empowers you to tailor your image-building workflow to your specific needs.

Experiment with different frontends, explore their features, and stay updated with the latest releases and documentation. Docker's extensibility allows you to adapt your Dockerfile to different use cases and integrate seamlessly with evolving technologies in the containerization space.
What is the ideal tech stack for building websites in 2024? 👨‍💻
Tags: webdev, programming, learning, database
Published: 2024-01-27 01:16:30

The ideal tech stack for building websites in 2024 depends on specific project requirements, but popular choices include React or Vue.js for frontend, Node.js or Django for backend, and databases like MongoDB or PostgreSQL. Serverless architecture and JAMstack are also gaining traction. Stay updated on emerging technologies for the most current options.[Read more](urlhttps://www.toprevenuegate.com/ncyayd2kw?key=b46e3b1f6518ee5d4a918d5d77bb6e2b)