teleren/devto huggingface dataset:
React's Secret Weapon: Synthetic Events
Tags: webdev, javascript, programming, react
Published: 2023-06-29 09:46:30

Have you ever wondered how React communicates consistently with so many different browsers? The secret lies in a powerful feature called Synthetic Events. Let's dive into this concept and understand how it enhances your React applications.

## The Universal Translator

Imagine being at a multi-language conference. Synthetic Events act like a translator, ensuring you understand the message no matter the language of the speaker (or browser). This is the magic of Synthetic Events in the world of React.

## What are Synthetic Events?

SyntheticEvent is a cross-browser wrapper around the browser's native event. It has the same interface as the native event, including methods like `stopPropagation()` and `preventDefault()`. However, it works identically across all browsers. This means that you can write your event handling code once, and it will work in every browser that React supports.

## Why Does React Use Synthetic Events?

React implements Synthetic Events to improve the consistency and performance of event handling. It's like having a universal translator, ensuring clear communication no matter the browser. This allows you to focus on building amazing user experiences without worrying about browser-specific quirks in event handling.

## Event Pooling for Efficiency

React also uses a technique called event pooling for efficiency. The SyntheticEvent object is reused for each event, and all properties are nullified after the event callback has been invoked. This is all about performance! It reduces the memory overhead of event handling, making your React applications faster and more responsive.

## The Power of Synthetic Events

So next time you're handling events in your React app, remember the power of Synthetic Events. They're your secret weapon for consistent, efficient event handling across all browsers. With Synthetic Events, you can focus on what really matters: building amazing user experiences.


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


The diagram above illustrates the flow of React Synthetic events with a `setCount` function:

* A button click event triggers a React Synthetic Event.
    
* The React Synthetic Event dispatches to the `onClick` handler.
    
* The `onClick` handler calls the `setCount` function.
    
* The `setCount` function updates the `count` state.
    
* The updated `count` state triggers a render of the React Component.
    
* The React Component generates a DOM update, which can trigger another button click event, continuing the cycle.
    

This is the power of Synthetic Events in action. It's all taken care of under the hood by React's Synthetic Events, allowing you to focus on building amazing user experiences.

---

I hope this blog post provides a comprehensive understanding of Synthetic Events. If you have any questions or comments, feel free to leave them below!  
You can block my tweets at [**RITAV DAS (@dasritav) / Twitter**](https://twitter.com/dasritav)
Scissor Documentation
Published: 2023-06-29 09:45:04

**SCISSOR**
A simple, seamless url-shortener and qr-code generator.

**FUNCTIONALITIES**

- URL Shortening: Scissor allows users to shorten URLs by pasting a long URL into the Scissor platform and a shorter URL gets generated when the 'Get Link' button.

- Custom URLs: Scissor also allows users to customize their shortened URLs. Users can choose their own custom domain name and customize the URL to reflect their brand or content.

- QR Code Generation: Scissor allows users to also generate QR codes for the shortened URLs.

- Link History: Scissor allows users to see the history of links they’ve created so they can easily find and reuse links they have previously created

- Analytics: Scissor provides basic analytics that allow users to track their shortened URL's performance. Users can see how many clicks their shortened URL has received and the IP addresses from where the clicks are coming from. This is available in the 'History' tab.

**API ROUTES**
_GET /history_
Retrieves all urls that have been shortened, including, ipaddresses and number of clicks. It is the postlude to the GET /:url route

_GET /:url_
Responsible for redirecting from the shortened url to proper locations. It saves all necessary information available in the /history
_
POST /basicUrl_
Creates random shortened url versions

_POST /customUrl_
Creates custom shortened url versions

_POST /qrcode_
Creates qrcode for urls using the 'qrcode' module

**INSTRUCTIONS**
Please carefully read the instructions
*Paste your url into the textbox labelled "Paste Url Here".

Click on the associated button to retrieve a shortened version of your url.

*For custom url, input a custom name for your url in the textbox labelled "Enter your custom url".

Click on the associated button to retrieve a shortened version of your url.

*For the qrcode generator, Paste your url into the textbox labelled "Paste Url Here".

Click on the "Get Qr Code" button.
What is meant by branching in DevOps ?
Tags: devops
Published: 2023-06-29 09:43:45

In DevOps, branching refers to the practice of creating separate code branches or streams within a version control system to facilitate parallel development, collaboration, and code management. Branching allows multiple developers or teams to work on different features, bug fixes, or experiments simultaneously without interfering with each other's work.

**Here are some key aspects and benefits of branching in DevOps:**

**1. Parallel Development:** Branching enables developers to work on different features or enhancements independently, in parallel. Each branch represents a separate line of development where team members can make changes, test their code, and iterate without impacting the main codebase.

**2. Code Isolation and Safety:** By creating separate branches, the changes made by developers are isolated from the main codebase until they are thoroughly tested and ready for integration. This isolation provides a safety net, preventing unverified or unstable code from affecting the stability of the main branch.

**3. Collaboration and Code Review:** Branching promotes collaboration and code review practices. Developers can work on their individual branches and collaborate on specific features or bug fixes. Code reviews can be conducted on the branches to ensure code quality, adherence to standards, and knowledge sharing within the team.

**4. Feature Experimentation:** Branching allows teams to create experimental branches to explore new features, technologies, or approaches. These branches can be used to prototype, test hypotheses, or gather feedback from stakeholders before merging the changes into the main codebase.

**5. Release Management:** Branching supports release management by providing the ability to create separate branches for different release cycles. This allows for bug fixes, hotfixes, or emergency patches to be made on a specific release branch without affecting ongoing development or previously released versions.

Version control systems such as Git provide branching capabilities and features like merging and rebasing to manage the lifecycle of branches. Best practices include creating short-lived branches, merging changes regularly, and keeping the main branch stable and deployable at all times. By obtaining [DevOps Engineer Course](https://www.edureka.co/masters-program/devops-engineer-training), you can advance your career in DevOps. With this course, you can demonstrate your expertise in uppet, Nagios, Chef, Docker, and Git Jenkins. It includes training on Linux, Python, Docker, AWS DevOps, many more fundamental concepts, and many more critical concepts among others.

Branching strategies can vary based on team size, project complexity, and development workflows. Common strategies include feature branches, release branches, and long-lived branches. It is important for teams to establish clear guidelines, communication channels, and branching policies to ensure smooth collaboration and code management within the DevOps environment.
Enterprise Application Development Company - Seasia Infotech
Tags: mobile, mobileapp, appdevelopment, webdev
Published: 2023-06-29 09:29:55

The goal of [enterprise application development](https://www.seasiainfotech.com/application-services?utm_source=devto&utm_medium=devto_profile&utm_campaign=profile) is to provide a cohesive, automated and streamlined approach to an organization's operations. By centralizing multiple business processes and integrating them into a single system, enterprise applications provide organizations with better data management, improved decision-making capabilities, increased efficiency, and enhanced productivity.
How to check how much space node_modules folders take up on your hard-disk
Tags: webdev, javascript, shell
Published: 2023-06-29 09:15:00


You have probably seen the meme about *node_modules* being the heaviest objects in the universe. While that is an exaggeration in the service of a joke, your project's node dependencies can gobble a considerable chunk of your hard-drive. How can you find out how much space your *node_modules* folders take up?

![node_modules meme comparing node_modules to sun, neutron star, and black hole as the heaviest objects in the universe. node_modules is number 1](https://www.roboleary.net/assets/img/blog/2023-06-28-space-node-modules/node-modules-meme.webp)

## Command to check the size of the node modules on your system

You can find out how much space is being used on your system by running the following command on your home directory:

```shell
find . -type d -iname node_modules -prune  | sed 's/^/"/g' | sed 's/$/"/g' | tr '\n' ' ' | xargs du -chs
```

This command requires the common unix utility programs: `find`, `sed`, `tr`, `xargs`, and `du` that are installed by default on most unix-like systems (linux and co). This command accommodates for filepaths with spaces, I noticed that the command used in other articles will choke on these filepaths!

This is the abbreviated output from the command on my system:

```
59M	  ./programming/study/css/css-grid/css-grid-master/node_modules
21M	  ./programming/workspace/articles/scroll-direction/node_modules
29M	  ./programming/workspace/articles/trignometry/node_modules
22M	  ./programming/workspace/articles/stranger-things/node_modules
...   ...
9.0G  total
```

**It is 9 gigabytes for me!**

## How do I free this space up?

How you liberate the disk space is up to you!

Some people like to nuke every *node_modules* folder on their system. Then when they need to work on a project, they have to reinstall the dependencies. You can do a recursive find and delete using the `rm` command with `find`, but be careful! You can read the article, [How to Delete ALL node_modules folders on your machine](https://trilon.io/blog/how-to-delete-all-nodemodules-recursively), if you want to do that.

If you are on Windows, keep in mind that it can be particularly slow! You may encounter [the error below](https://stackoverflow.com/questions/28175200/how-to-delete-node-modules-deep-nested-folder-in-windows):

> The source file name(s) are larger than is supported by the file system. Try moving to a location which has a shorter path name, or try renaming to shorter name(s) before attempting this operation

You can read this article to find the quickest option: [Quick way to delete node_modules folder on Windows](https://cloudhadoop.com/nodejs-quick-way-delete-node-modules/).

I prefer to do this as part of general tidy up of my projects. Over time, I have migrated some of my projects to use `pnpm` instead of `npm`, and that has reduced the footprint of my projects significantly. I am trying to improve my habits with deleting projects that I downloaded temporarily. It is a bit of a battle to curb the tide in JavaScript-land!
Creating a Build Script for Go
Published: 2023-06-29 09:14:04

A bash script to generate build for all OS in Go.

## The Script

Copy the following script and save it as `build.sh`. You may want to set the script executable after save it - `chmod +x build.sh`.

```bash
#!/bin/bash

# Set the package name and version
if [ ! "$PACKAGE_NAME" ]; then
    echo -ne "\nMissing Package Name.\n"
    exit 1
fi

if [ ! "$PACKAGE_VERSION" ]; then
    echo -ne "\nMissing Package Version.\n"
    exit 1
fi

# Define the target operating systems and architectures with file extensions
TARGETS=(
  "linux/amd64:tar.gz"
  "linux/arm64:tar.gz"
  "darwin/amd64:tar.gz"
  "windows/amd64:zip"
)

# Set the output directory
OUTPUT_DIR="installers"

# Create the output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

# Build for each target
for target in "${TARGETS[@]}"; do
  # Split the target into GOOS and GOARCH with file extension
  goos_arch="${target%:*}"
  file_extension="${target#*:}"
  IFS='/' read -r goos goarch <<< "$goos_arch"

  # Set the environment variables
  export GOOS="$goos"
  export GOARCH="$goarch"

  # Build the package
  echo "Building for $GOOS/$GOARCH..."
  file_name="${PACKAGE_NAME}-${PACKAGE_VERSION}-${GOOS}-${GOARCH}"
  output_file="$OUTPUT_DIR/$file_name"

  if [ $GOOS = "windows" ]; then
        output_zip="${output_file}"
        output_file+='.exe'
        GOOS=$GOOS GOARCH=$GOARCH go build -o "${output_file}"
        zip -m "${output_zip}.zip" "${output_file}"
    else
        GOOS=$GOOS GOARCH=$GOARCH go build -o "${output_file}"
        tar -czvf "${output_file}.tar.gz" "${output_file}"
    fi

    rm "${output_file}"
done

```

## Usage

```bash
export PACKAGE_VERSION=1.0.0 && export PACKAGE_NAME=shipper && . ./build.sh
```

You should see all archives in `installers/` directory.
Selection Sort
Tags: beginners, cpp, algorithms, selectionsort
Published: 2023-06-29 09:09:15

## Selection Sort:

Selection sort is a simple comparison-based sorting algorithm. It works by dividing the input array into two parts: the sorted portion at the beginning and the unsorted portion at the end. The algorithm repeatedly selects the smallest element from the unsorted portion and swaps it with the element at the beginning of the unsorted portion, expanding the sorted portion by one element. This process is repeated until the entire array is sorted.

Here's the step-by-step procedure for selection sort:

1. Start with the unsorted portion consisting of the entire array.
2. Find the smallest element in the unsorted portion.
3. Swap the smallest element with the first element of the unsorted portion.
4. Expand the sorted portion by one element and reduce the unsorted portion by one element.
5. Repeat steps 2-4 until the unsorted portion becomes empty.


## C++ Code(Iterative):

```
#include<iostream>
using namespace std;
void selection_sort(int arr[],int n){
    for (int i = 0; i < n-1; i++)
    {
        int min_index=i;
        for (int j = i; j <= n-1; j++)
        {
            if (arr[j]<arr[min_index])
            {
                min_index=j;
            }            
        }  
        swap(arr[i],arr[min_index]);      
    }   
}
int main()
{
    int n;
    cin>>n;
    int arr[1000];
    for (int i = 0; i < n; i++)
    {
        cin>>arr[i];
    }
    
    selection_sort(arr,n);
    for (int i = 0; i < n; i++)
    {
        cout<<arr[i]<<" ,";
    }
    return 0;
}
```
Kickstart Your Journey With Rego
Tags: general, devops, rego
Published: 2023-11-21 14:32:24

---
title: Kickstart Your Journey With Rego
published: true
date: 2023-06-29 08:43:43 UTC
tags: General,devops,rego
canonical_url: https://blog.shellnetsecurity.com/2023/06/623/general/kickstart-your-journey-with-rego/
---

Rego, the language powering the Open Policy Agent (OPA), has become an indispensable tool for developers and security professionals alike. In order to kickstart your journey with Rego, it makes sense to first understand some of the basics. I put the cart before the horse by first posting how to use Rego in Rego Based ... [Read more](https://blog.shellnetsecurity.com/2023/06/623/general/kickstart-your-journey-with-rego/ "Kickstart Your Journey With Rego")

The post [Kickstart Your Journey With Rego](https://blog.shellnetsecurity.com/2023/06/623/general/kickstart-your-journey-with-rego/) appeared first on [My Battles With Technology](https://blog.shellnetsecurity.com).
#LearnedToday: CSS appearance
Tags: learnedtoday, css, webdev
Published: 2023-06-29 08:19:24

👓 CSS **`appearance`** property can be used to apply platform-specific styling to an element that doesn’t have it by default or to **remove platform-specific styling from an element that does have it by default**.

## Use case
remove user agent's styles from an input of type search.

In webkit browsers, especially in **Safari**, there are **limitations on overriding some styles**, such as `padding` or `font-family`. Sometimes is litterally impossible to do it!

With the rule `appearance: none;` you can easily override them in a standard way.

```css
input[type=search] {
  appearance: none;
  padding: 50px;
}
```

CSS Tricks: https://css-tricks.com/almanac/properties/a/appearance

🗄 Docs: https://developer.mozilla.org/en-US/docs/Web/CSS/appearance

ℹ Browser support: https://caniuse.com/?search=appearance
Mac with Apple Silicon & Minikube
Published: 2023-06-29 07:55:08

# Install Docker

https://docs.docker.com/desktop/install/mac-install/


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

# Install Minikube

https://minikube.sigs.k8s.io/docs/start/

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

```
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-darwin-arm64
sudo install minikube-darwin-arm64 /usr/local/bin/minikube
```

# Install kubectl

https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/

```
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"
```

move and update execution

```
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
sudo chown root: /usr/local/bin/kubectl
```

# Install helm

```
https://helm.sh/docs/intro/install/
```

install

```
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
```
Mantine simple responsive component attribute
Tags: frontend, ui, mantine, react
Published: 2023-06-29 07:47:40

Hello there, i want to share how to write an attribute with simple responsive using mantine. 

**simple responsive attribute component** support breakpoint property (**xs, sm, md, lg, xl**), using **simple responsive attribute component** is by creating an object.

here's the example: 
```
<Text fz={{ base: 32, lg: 48 }} weight={600}> Lorem ipsum dolor </Text>
```

Following the above there is an attribute called fz that represent font size, each of the breakpoint property active when the width of the viewport is met, property **base** is use when another property breakpoints (**xs, sm, md, lg, xl**) are not met.

Now, you can easily set responsive component in mantine.
What is Cost Management in Project Management?
Tags: management
Published: 2023-06-29 07:41:03

Cost Management is an essential knowledge area in project management, as defined by the Project Management Institute (PMI) in the Project Management Professional (PMP) certification. Cost management focuses on planning, estimating, budgeting, monitoring, and controlling project costs throughout the project lifecycle.

**In PMP, cost management encompasses the following key processes:**

**1. Cost Estimating:** This process involves developing an approximation of the project's costs based on available information, historical data, and expert judgment. Cost estimating aims to determine the overall project budget and provide a basis for resource allocation and decision-making.

**2. Cost Budgeting:** Cost budgeting involves allocating the estimated costs to individual project activities or work packages. It establishes the cost baseline, which serves as a reference for comparing and controlling actual project costs during execution.

**3. Cost Control:** Cost control focuses on monitoring project costs and ensuring that they align with the approved budget. It involves tracking actual expenditures, comparing them against the planned costs, identifying variances, and implementing corrective actions when necessary. Cost control helps project managers maintain financial discipline and prevent cost overruns.

**Cost management in PMP also includes several important tools and techniques:**

**- Earned Value Management (EVM):** EVM integrates scope, schedule, and cost performance metrics to assess project performance and forecast future outcomes. It helps in measuring the value of work completed and evaluating cost and schedule variances.

**- Variance Analysis:** Variance analysis involves comparing actual project costs against the planned costs to identify deviations and variances. Cost variances (CV) and schedule variances (SV) are calculated to assess the magnitude and impact of the deviations.

**- Forecasting:** Cost management techniques involve forecasting future project costs based on historical performance, trends, and changes in project scope or requirements. Forecasting helps in assessing the financial health of the project and making informed decisions.

Effective cost management is crucial for project success as it ensures that the project is delivered within the approved budget and financial constraints. It requires continuous monitoring, analysis, and control of costs throughout the project lifecycle to optimize resource utilization, mitigate risks, and deliver value to stakeholders. By obtaining  [Project Management Certification](https://www.edureka.co/masters-program/project-management-course), you can advance your career as PMP. With this course, you can demonstrate your expertise in extensive knowledge of Project Management concepts highlighted in the PMBOK Guide - 7th Edition which is aligned with the latest PMP Exam Content Outline, and many more critical concepts among others.