teleren/devto huggingface dataset:
Kadane's Algorithm
Tags: python, programming
Published: 2022-01-01 14:32:41

## Maximum Subarray Sum: Kadane's Algorithm
If you are competitive programming or preparing for campus placements or technical interviews, you might have probably come across something like this:
**Given an array arr[] of N integers. Find the contiguous sub-array which has the maximum sum and return its sum. **
If not, so does the "Kadane's Algorithm" rings any bell?
_Kadane's algorithm is an iterative dynamic programming approach in which we search for a maximum sum contiguous subarray within a one-dimensional numeric array._

**Working of Kadane's Algorithm**
Some may think okay it's just the sum of all elements in an array. But an array may have negative integer elements, which decreases the total array's sum.
Thus we can say that the sum of all array elements isn't always the case.
A simple idea of Kadane's algorithm is to look for all positive contiguous segments of array and keep track of the maximum sum contiguous subarray among all positive segments.
An array is a contiguous memory block. So, a subarray is a slice of contiguous array that maintains the order of the elements.
Let us consider an array:
**arr={1,2,3,4}**
For this array, the sub-arrays are:
**For elements at 0th index**   {1},{1,2},{1,2,3},{1,2,3,4}
**For elements at 1st index**   {2},{2,3},{2,3,4}
**For elements at 2nd index**   {3},{3,4}
**For elements at 3rd index**   {4}
Now we know sub-arrays for an array.
_Brute Force Approach_
The brute force solution calculates the sum of each sub-array and then compares the results to determine the maximum sum of all sub-arrays sums. This method is straight forward, but it is not used commonly.
**This is because it has a time complexity of O(N^3) and O(N) space complexity.**
As we know, while writing any program, Time and Space Complexity plays a vital role in choosing the algorithm. Therefore, Kadane's algorithm is used because of its advantage considering time and space complexity.
_Kadane's Algorithm_
1. First, we will consider two elements, one which stores the maximum end of the subarray and another which stores the maximum sum far.
2. Let the two elements be named variables as max_end and max_far, respectively.
3. We will initialise both as 0.
4. Each time we get a positive sum, we compare it with max_end and update max_far if it is greater than it.
The Time and Space complexity are as:
**Time Complexity: O(N)**
**Space Complexity: O(1)**
Comparing the "Time and Space Complexity" of 'Brute Force Approach' and of 'Kadan's Algorithm', the latter is better when it comes to solving the same problem.
Hence, Kadane's algorithm is preferred method when it comes to finding the maximum contiguous sub-array sum.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nk5ukpr0rvpnae3h7aoa.png)
**Special Case**
For all the negative numbers in an array, all the elements in array are less than 0. So, we compare the sum of the consecutive elements with the current element from the array.
I need someone to clarify js code to me !!
Published: 2022-01-01 14:31:14

Hi everybody,
I'm new in JS and want to achieve a certain task. the task about changing pic when a drop menu value change.
I found the code online but I got 50% of it  !! 
Can any one take it bit by it and clear it to me ? your efforts is highly appreciated.
HTML:
<img src="http://www.flowsim.se/picts/selec01.jpg" width="70" height="70" name="myImage" />
<form method="" action="" name="myForm">
    <select size="1" name="switch" onchange="switchImage();">
        <option value="1">Image 1</option>
        <option value="2">Image 2</option>
        <option value="3">Image 3</option>
        <option value="4">Image 4</option>
        
    </select>
</form> 

JavaScript : 
let imageList = Array();
    for (let i = 1; i <= 4; i++) {
        imageList[i] = new Image(70, 70);
        imageList[i].src = "http://www.flowsim.se/picts/selec0" + i + ".jpg";
    }
    
    function switchImage() {
        let selectedImage = document.myForm.switch.options[document.myForm.switch.selectedIndex].value;
        document.myImage.src = imageList[selectedImage].src;
    }
JavaScript current year with getFullYear()
Tags: vue, nuxt, javascript, newyears
Published: 2022-01-01 14:27:58

Did you hard code the year in your footer? New year, new problems. 

With this one-liner, you can dynamically set the year with JavaScript:

```js
let year = new Date().getFullYear();
```

If you are using [VueJS](https://vuejs.org) or [NuxtJS](https://nuxtjs.org), you can add the current year code directly into your template section

```vue
<template>
	<footer>
		Copyright © {{ new Date().getFullYear() }}
	</footer>
</template>
```

You can find more useful dev articles on my site, [frostbutter.com/articles](https://frostbutter.com/articles)
Most useful Programming Language of 2021
Published: 2022-01-01 14:13:37

If you work with computers, then the one thing you definitely need to know how to do is program. But which programming language should you learn? Many people start with Java because it is used in almost every internet-connected device and has a reputation for being easy to learn. However, after a few months of learning Java and playing around with it, I found that it was difficult for me to keep up as I wanted more flexibility in my coding skills. For example, I didn't like the way that if you accidentally put a ';' in your code it would automatically execute the following line, which wasn't something that I wanted to happen.
In addition, if you didn't know what coding was all about, then it would be quite difficult to know why your code was not working properly. For example, in one tutorial on Java programming I spent about a week trying to make a program for counting down from 20 seconds.
Webpage: https://tinyurl.com/56yehmth/
How to get DOM element text value in cypress
Tags: javascript, testing, programming
Published: 2022-01-01 14:11:06

## Hi Folk 🙋🏼


Now days develoepr has to write test cases for their component code and for test their own functionality.

there are many tools in market like 
`Chai` `Moka` `Jasmine` `Karma` `Jest`

but Cypress is single tool which is running on top of these above tools. becuase internally cypress use these mentioned tools including Jquery.

Cypress allow you to test your application e2e in browser with very smooth flow.

but sometime while working with cypress we need to get a element and match it's value with another element dynamically so how we can achive that

here I am going to show you how we can take innerText of any DOM element in cypress

```
cy.get(['YOUR_DOM_ELEMENT']).then(elm => {
  cy.get(['YOUR_DOM_ELEMENT']).should('has.text', elm[0].innerText)
});
```
Explaining WHY to other team members
Published: 2022-01-01 14:07:21

After a discussion with my other co-founder (approx: 2021-11-30)

We agreed that it would be good to have clear goals in the following format:

1. What is the system currently doing?
2. What we are trying to do?
3. Why?
4. The possible how's and what’s for each department (This is the only part that each department can add to, however, it should be succinct and pertain to the "why" as made in point number 3.)

This way we should be able to maintain the importance of a task from the top levels all the way to the people who are more “hands-on” with the task. I believe this sentence will create many thoughts at this point, but let's continue...

As mentioned, this also doubles up as an explanation to why protobuf doesn't have a native GUID/UUID support.

Something I came across that is a bad example of this is the integration of GUID/UUID into the protobuf lib:

- https://github.com/protocolbuffers/protobuf/issues/2224

You can see that the community is presenting many ideas and solutions, a lot of them very complex and not suitable as a solution, however, the amount of attention and the number of other threads with the same request for this feature is certainly a reason for concern. However, the main response to this is coming directly from a contributor of the project, was this single sentence statement:

> quote perezd - "We have no plans at this time to integrate this."
> https://github.com/protocolbuffers/protobuf/issues/2224#issuecomment-889268897

I'm still left wondering why not. I can accept that we’ll never know why and it is anyone’s prerogative to make the decision to not explain why for anything, but I can't help to think that others would be feeling the same as me.

A possible alternative is to try “bytes” as suggested in this older article from 2016:
https://developers.google.com/protocol-buffers/docs/reference/csharp/interface/google/protobuf/i-custom-diagnostic-message?hl=en

Anyway, let’s move on with life, and with development, for now, all references to GUID/UUID have been made as “strings” with the variable name suffixed with "_guid" so that we know it's a GUID/UUID that we are dealing with.
NFT in Metaverse? 
Published: 2022-01-01 13:42:30

You're one of the first settlers in a harsh new world, and to survive you'll have to take matters into your own hands. Explore, build, and eventually create a civilization from scratch. But watch out—there are other pioneers out there too. Competition is fierce and resources scarce in this wild frontier! Will you get along with your neighbors or declare war?
Though this may sound like a typical video game plotline, it's actually the basis for a new pioneering token called NFTs (non-fungible tokens).

The Power of NFTs

So what's so special about this idea? Fairly new to the world of cryptocurrencies and digital [assets](https://www.jbbatteryspain.com/), NFTs represent a standard of digital ownership that provides a lower barrier to entry for those with less experience in the cryptocurrency space. At the same time, unlike username systems, NFTs can be used as easily as any other cryptocurrency token. This means they could serve as an entry point for new users who may be unfamiliar with blockchain technology.
Docker - Run/Refactor PHP code from a web interface
Tags: docker, php, tooling, refactorit
Published: 2022-01-01 11:11:31

As a loyal reader of several forums for years, I frequently find unreadable PHP code posted by beginners asking for help. Before we can try to help them, it is sometimes useful to reformat the code and rewrite it partially. This can take times...

To execute the code to see where the problem is before fixing it, I have been using the [Run-PHP-Code](https://github.com/websiteduck/Run-PHP-Code) tool for a few years but it does not meet the need for reformatting ([php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) / [php code-beautifier](https://github.com/squizlabs/PHP_CodeSniffer/)) or refactoring ([rector](https://github.com/rectorphp/rector)). Second disadvantage here (since I don't trust the PHP code), *Run-PHP-Code* is running on my localhost i.e. on my machine and that can represent a risk (creation/deletion of files, ...). The ideal is to execute the code in a sandbox.

It had been a while since I wanted to do it: I took some hours to take the code of *Run-PHP-Code* to make his own Docker image, based on PHP 7.4.26 (version 1.0) or 8.1 (version 1.1) and thus to allow to run it in a secure environment.

I also took the time to add a "refactor" button which then calls php-cs-fixer, phpcbf and Rector.

The result is this ready-to-use Docker image: [https://hub.docker.com/r/cavo789/runcode](https://hub.docker.com/r/cavo789/runcode).

In only two CLI commands, you will have a web interface with an editor where, on the left side, you can copy/paste or type a PHP code and on the right side visualize the result of its execution (button `Run`) or its refactoring (button `Refactor`); the whole running in a Docker container and thus isolated from your machine. 

Pretty easy and helpful when trying to give support on forums.

![Run and refactor php from an isolated environment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/25uvrxisg07nwr7sygsz.png)
for ... in ... with object
Published: 2022-01-01 12:44:57

```js
const person = {
    firstName: 'John',
    lastName: 'Doe',
    age: 21,
};

let text = "";
for (let x in person) {
    text += person[x] + " ";
    console.log(text);
}

console.log(text);
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/llkqaxy8grln0u8goe8z.png)

{% codepen https://codepen.io/moonlxght10/pen/VwMXWjM %}
08 Advantages Of Using Illustrations In UI Design
Tags: design, uiweekly, tutorial
Published: 2022-01-01 12:24:56

Let’s [talk about](https://vector.cx/08-advantages-of-using-illustrations-in-ui-design/) how illustrations can help designers increase the usability of their visual designs and encourage users to keep on reading or interacting with your interfaces.
https://vector.cx/08-advantages-of-using-illustrations-in-ui-design/
Hello DEV Community!
Tags: aws, cloud
Published: 2022-01-01 12:21:34

I signed up for a DEV account only to join the exclusive DEV Organisation created for AWS Community Builders to use and publish quality content. 

I always wanted to write blogs/articles to share knowledge however, never got enough time to give it a chance and until now, I was only using this platform to check out the great articles written by my co-Community Builders.

After a lot of procrastination, finally, I have decided to start my journey of writing articles/blogs and I would like to give this credit to AWS Community Builder program which pushed and motivate me to give it a shot. 

It is an absolute honour to be part of this program where you get the opportunity to learn and grow together by sharing knowledge, networking with great and talented people from all over the world, and helping each other in every possible way. 

To give back to the community, I would like to start off by writing a post on the [Significance of Migration & Governance](https://dev.to/aws-builders/significance-of-management-governance-on-aws-53e0) on AWS.

PS: I chose this topic because I got selected to be part of this category in AWS Community Builder program so decided to go with it first :)
object is mutable! 
Published: 2022-01-01 12:19:40

```js
const person = {
    age: 30,
    firstName: 'John',
    lastName: 'Doe',
};

const x = person;

x.age = 65;
x.firstName = 'Adam';
x.lastName = 'Karpov';

console.log(x.age);
console.log(x.firstName);
console.log(x.lastName);
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfodjb70fz1301a7uhui.png)
Significance of Management & Governance on AWS
Tags: aws, beginners, cloud, cloudskills
Published: 2022-01-01 12:11:18

**What is Management & Governance on AWS?**
AWS Management and Governance services help customers to have innovation as well as control over cost, compliance, and security in their Organisation. 

With M&G services, AWS provides the following things: 

- Helps to manage highly dynamic cloud resources at massive scale
- Reduces complexity by offering a single control plane for customers to manage and govern their resources on AWS and on-premises. 
- Offers the broadest partner ecosystem for customers to extend and augment their management and governance system.

Further, using AWS M&G services, customers can assess their resource utilization and identify ways to reduce overall cost of their resources.

**Significance of AWS M&G Services**

AWS uses M&G services to help customers in enabling, provisioning, and operating their environment for both business agility and governance control.

Below is the list of AWS M&G services that

Enables you for speed with built-in governance control 
- AWS Control Tower
- AWS Organisations
- AWS Well-Architected Tool
- AWS Budgets
- AWS License Manager

Provision resources and applications that meet your policies
- AWS CloudFormation
- AWS Service Catalog
- AWS OpsWorks
- AWS Marketplace

Operate your environment with speed and governance.
- Amazon CloudWatch
- Amazon Managed Grafana
- Amazon Managed Service for Prometheus
- AWS CloudTrail
- AWS Config
- AWS System Manager
- AWS Cost and Usage Report
- AWS Cost Explorer
- AWS Managed Services
- AWS X-Ray
- AWS Distro for OpenTelemetry
- AWS Proton

Hope this information is helpful. Thank you.
blog about back-end
Published: 2022-01-01 12:08:13

Blog About Back-end —

CRUD OPERATION :
CRUD stands for Create, Read, Update, and Delete. 
In computer programming, create, read, update, and delete (CRUD) are the four basic operations of persistent storage. CRUD is also sometimes used to describe user interface conventions that facilitate viewing, searching, and changing information using computer-based forms and reports. The term was likely first popularized by James Martin in his 1983 book Managing the Data-base environment.[collected from Wikipedia].
In HTTP, the GET (read), PUT (create and update), and DELETE (delete) methods are CRUD operations as they have storage management semantics, meaning that they let user agents directly manipulate the states of target resources. The POST method on the other hand is a process operation that has target-resource-specific semantics excluding the semantics of CRUD operations.

Relational database (MySql)
What is a relational database?
A relational database is a collection of data items with pre-defined relationships between them. These items are organized as a set of tables with columns and rows. Tables are used to hold information about the objects to be represented in the database.
What is MySQL?
MySQL is an open-source relational database management system (RDBMS).Its name is a combination of "My", the name of co-founder Michael Widenius's daughter] and "SQL", the abbreviation for Structured Query Language. A relational database organizes data into one or more data tables in which data types may be related to each other; these relations help structure the data. SQL is a language programmers use to create, modify and extract data from the relational database, as well as control user access to the database. In addition to relational databases and SQL, an RDBMS like MySQL works with an operating system to implement a relational database in a computer's storage system, manages users, allows for network access and facilitates testing database integrity and creation of backups. 

What is called aggregation?
Aggregation is a special case of association. A directional association between objects. When an object 'has-a' another object, then you have got an aggregation between them. ... Aggregation is also called a “Has-a” relationship.
Mutation Testing in NodeJS
Tags: javascript, testing, programming, typescript
Published: 2022-01-01 12:05:02

## What is mutation testing?

> If you are reading this, we assume you are using TDD or that your coverage is nearly of 100%. If you are not complying to this requirement, start by building a strong Unit/Integration Test harness. Without a good coverage you won't get a lot of value out of this practice.


Mutation testing is a way to check if your current tests (unit, integration, etc...) are precise enougth to catch random changes in your code base. The tool navigates through the code and creates mutants by modifying mostly conditions and values (such as constants or conditionals).

For instance:

```javascript
return {code: this.value};
```

will generate several mutants:

```javascript
return null;
```

```javascript
return {};
```

```javascript
return undefined;
```

For each mutated version of your code, the tests base will be run.

If the test is still `green` the mutant will tagged this mutant state as `Survived`, otherwise it will be tagged as `Killed`.

The objective is to have as much `Killed` mutants as possible, meaning the tests is covering most cases and that a change in the code will be catched by a unit test.

We will be using Stryker as an automation tool:

* Website: [https://stryker-mutator.io/](https://stryker-mutator.io/)

Now! Let's go kill some mutants!

## Install Stryker dependencies

```bash
npm i -g stryker-cli
npm i -D stryker-html-reporter stryker-jest-runner stryker-typescript @stryker-mutator/core
```

## Configure

```bash
stryker init
```

Change the `stryker.conf.js` file to avoid analysing `.spec.ts` files and add the plugins manually to avoid dependencies errors:

```javascript
module.exports = function (config) {
  config.set({
    mutator: "typescript",
    packageManager: "npm",
    reporters: ['progress','html'],
    testRunner: "jest",
    transpilers: [],
    coverageAnalysis: "off",
    tsconfigFile: "tsconfig.json",
    mutate: ["src/**/*.ts", '!src/**/*.spec.ts'],
    htmlReporter: {
      baseDir: 'mutation'
    },
    plugins: ['stryker-html-reporter', 'stryker-jest-runner', 'stryker-typescript']
  });
};
```

## Start the test \(put your computer in a freezer!\)

```bash
stryker run
```

As always if you need help ask a friend 😊
Minitutorial python: pipenv
Tags: python, espanol, spanish, pipenv
Published: 2022-01-01 11:46:56

**Bienvenidos a un nuevo tutorial.**

Mi nombre es Rodrigo Garcia Trejo y hoy les traigo un tutorial de python en especial del gestor de entornos virtuales **pipenv**

-------
##Pipenv
**Pipenv** es una herramienta que nos ayuda a controlar nuestro entorno virtual (enviroment, venv, ) y al mismo tiempo tener un empaquetador de nuestras librerías y aplicaciones (Algo así como npm, yarn, etc)

-------

##Vamos al código
En nuestra terminal escribimos

``` 
pip install pipenv
```

![1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s2sg32ixzw0ev6pc3q5a.png)

Después de instalarlo ingresaremos el comando pipenv shell el cual nos generará un shell con el entorno virtual activado y tambien nos generará el archivo **Pipfile** que es donde se guardaran nuestras libreras y aplicaciones

```
pipenv shell
```

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

Una vez que tenemos el entorno virtual activado ya podremos instalar lo que queramos por ejemplo Django para ello utilizaremos el siguiente comando

```
pipenv install django
```


![3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z4i1mbktgbfer5pma5tq.png)

Eso es todo por el día de hoy con esto hemos aprendido a instalar y a utilizar **pipenv** espero que les haya servido este minitutorial
Is Angular still relevant in 2022?
Tags: angular, webdev, vue, javascript
Published: 2022-01-01 11:16:09

Angular is still developed. Last years performance improvements (Ivy engine) causes build time to be fast and comparable to React. Also interactiveness is comparable to React.

Angular enters 2022 year as a strong framework that proves its value for people who like to focus on design and user experience rather than handling technical issues introduced by complicated sets of libraries that form frameworks around React.

While React development is also ongoing and enables developers to hotwire amazing projects, Angular holds to the mission of being stable, predictable framework that you can learn once and transfer the knowledge to every project.

Year 2022 is for Angular deciding. Vue - a in between tries to buy programmers keyboards. Svelte is another library around. But the real competitor for Angular is Ember. The only framework that provides similar level of coding comfort.

Eventually 2022 will be a year of serious decisions. Will Angular be removed to replace or with intensively marketed React? Will developers working earlier with jQuery or React, Vue, Svelte put their horses on well thought through framework that helps to focus on user experience?

Will developers support Angular by adjusting libraries accordingly? Aside from technical discussions, and decisions, 2022 fate depends more on trends, just like fashion is dependant.

One is sure, Angular is here to stay supporting developers and users in in proving and having state of art experience.