teleren/devto huggingface dataset:
Leetcode 217. Contains Duplicate. DSA - #4
Published: 2022-09-16 05:28:19


## [Question Link](https://leetcode.com/problems/contains-duplicate/)

[Python](https://github.com/Uchiha-Itachi0/Mai_kisi_ko_DSA_nahi_padhta/blob/master/Python/217.%20Contains%20Duplicate.py) || [C++](https://github.com/Uchiha-Itachi0/Mai_kisi_ko_DSA_nahi_padhta/blob/master/C%2B%2B/217._Contains_Duplicate.cpp) || [TypeScript](https://github.com/Uchiha-Itachi0/Mai_kisi_ko_DSA_nahi_padhta/blob/master/TypeScript/217.%20Contains%20Duplicate.ts)

## Brute Force Approach

This approach is very simple, so I am not going to waste much time in this approach

- We take one element and compare it with all the other elements.
- We do this for all the elements.

### Code

```python
def containsDuplicateMethod1(nums: list[int]) -> bool:
    length = len(nums)
    for i in range(length):
        for j in range(i + 1, length):
            if nums[i] == nums[j]:
                return True
    return False
```

Time Complexity: O(n^2)
Space Complexity: O(1)

## Better Approach using Sorting

Since we have to find the duplicate elements, so we can sort the array and then find the duplicate elements.
Duplicate elements will be adjacent to each other.

For example: `nums = [1, 2, 3, 1]`

After sorting: `nums = [1, 1, 2, 3]`

Now we can find the duplicate elements by comparing the adjacent elements.

### Code

```python
def containsDuplicateMethod2(nums: list[int]) -> bool:
    nums.sort()
    length = len(nums)
    for i in range(length - 1):
        if nums[i] == nums[i + 1]:
            return True
    return False
```

Time Complexity: O(nlogn)
Space Complexity: O(1)

## Best Approach using Hashing

This method is also very easy to understand.

- We create a Set.
- We traverse the array and check if the element is present in the Set or not.
- If the element is present in the Set then we return True.
- If the element is not present in the Set then we add the element in the Set.
- If we traverse the whole array, and we don't find any duplicate element then we return False.

### Code

```python
def containsDuplicateMethod3(nums: list[int]) -> bool:
    storage = set()
    for value in nums:
        if value in storage:
            return True
        storage.add(value)

    return False
```

Time Complexity: O(n)
Space Complexity: O(n)

## Bonus
## Best Approach using Hashing (one liner)

```python
def containsDuplicateMethod4(nums: list[int]) -> bool:
    return len(nums) != len(set(nums))
```
Open Source NebulaGraph Database Raises Tens of Millions of Dollars in Series A Funding
Tags: opensource, database, funding, nosql
Published: 2022-09-16 05:24:47

[NebulaGraph](https://nebula-graph.io), a leading open source graph database, announced it raised tens of millions of US dollars in Series A funding. Investors in the round are led by Jeneration Capital, with participation from the previous investors - Matrix Partner China, Redpoint China Ventures, and Source Code Capital. China Renaissance served as the exclusive financial advisor in this financing round.


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

NebulaGraph plans to continue building its established business strategy by accelerating the pace of its expansion to the global market, while also strengthening R&D to enhance product performance and differentiation with cutting-edge graph technology.

Earlier this year, NebulaGraph joined Linked Data Benchmark Council (LDBC) as an organizational member to participate in developing graph industry standards and specifications, especially the creation and popularization of Graph Query Language (GQL), which is a forthcoming International Standard Language for property graph querying.

Designed for scalability and fast recovery, NebulaGraph boasts a distributed, high-availability architecture, making it an ideally reliable graph database in production environments. Its capability in handling ultra-large datasets with trillions of edges, coupled with instant event data stream processing, has allowed Nebula Graph database to excel at transactional integrity and operational availability.

Hundreds of well-established enterprises, including Tencent, Meituan, JD Digits, and Kuaishou, are leveraging NebulaGraph Database to boost their graph data processing capabilities.

Sherman Ye, the founder and CEO of NebulaGraph, said, “Thanks to the in-depth understanding of industrial scenarios, the transformative value of our products, and the surging demand in graph technology, NebulaGraph is well-positioned to capture future growth opportunities.”

About NebulaGraph

NebulaGraph is an open-source [graph database](https://nebula-graph.io) developed by vesoft Inc. It can store and process billions of vertices and trillions of edges with milliseconds of latency. With a distributed and scalable architecture, its shared-nothing deployment eliminates any single failure point and allows fast recoveries to secure business continuity.

For more information, please visit https://nebula-graph.io or follow NebulaGraph on Twitter.
Laravel 8 Group By Query Example
Tags: laravel, laravel8, mysql, groupby
Published: 2022-09-16 04:56:17

In this article, we will see laravel 8 group by query example. how to use group by in laravel 8. As you might expect, the groupBy and having methods may be used to group the query results. 

learn how to create a collection of data using the laravel groupBy method. It can allow us to group the data by type, id, date, etc.

Also, we will give you an example of the laravel 8 group by with where clause and query of the group by in MySQL. 

The GROUP BY statement is often used with aggregate functions COUNT(), MAX(), MIN(), SUM(), AVG() to group the result set by one or more columns.

So, let's see how to use group by in laravel 6, laravel 7, and laravel 8 or laravel 8 group by with where clause.
AWS CodeDeploy Cheat Sheet
Tags: 30daysofaws, day08, certifieddeveloperassociate
Published: 2022-09-16 04:20:51

![](https://seeklogo.com/images/A/aws-codedeploy-logo-2A6E3A318A-seeklogo.com.png?v=637830372770000000)

## About

CodeDeploy is a fully managed deployment service that automates software deploy­ments to a variety of compute services such as EC2, Fargate, Lambda, & on-pre­mises servers

- [Documentation](https://aws.amazon.com/codedeploy/)
- [User Guide](https://docs.aws.amazon.com/codedeploy/?id=docs_gateway)

CodeDeploy can also deploy a serverless Lambda function.

CodeDeploy can be connected to CodePipeline and use artifacts from there.

### Platforms

Need to choose the compute platform:

- EC2/On-premises.
- AWS Lambda.
- Amazon ECS.

### AppSpec File

The application specification file (AppSpec file) is a YAML-formatted, or JSON-formatted file used by CodeDeploy to manage a deployment.

The AppSpec file defines the deployment actions you want AWS CodeDeploy to execute.

#### Deployment types

- **In-place deployment (EC2 only)**
- **Blue/green deployments:**
  
  - AWS Lambda: Traffic is shifted from one version of a Lambda function to a new version of the same Lambda function.

  - Amazon ECS: Traffic is shifted from a task set in your Amazon ECS service to an updated, replacement task set in the same Amazon ECS service.
  
  - EC2/On-Premises: Traffic is shifted from one set of instances in the original environment to a replacement set of instances.

## Price

[Current price](https://aws.amazon.com/codedeploy/pricing/)

## Use Cases

Type: Developer Tools

## Practice

- [Continuous Integration and Deployment with AWS Code Services](https://cloudacademy.com/lab/continuous-integration-deployment-aws-code-services/)

## Questions

### Q1

**What will happen if you delete an unused custom deployment configuration in AWS CodeDeploy?**

1. You will no longer be able to associate the deleted deployment configuration with new deployments and new deployment groups.
2. Nothing will happen, as the custom deployment configuration was unused.
3. All deployment groups associated with the custom deployment configuration will also be deleted.
4. All deployments associated with the custom deployment configuration will be terminated.

### Q2

**What happens when you delete a deployment group with the AWS CLI in AWS CodeDeploy?**

1. All details associated with that deployment group will be moved from AWS CodeDeploy to AWS OpsWorks.
2. The instances used in the deployment group will change.
3. All details associated with that deployment group will also be deleted from AWS CodeDeploy.
4. The instances that were participating in the deployment group will run once again.

> - [Practice notes](https://romankurnovskii.com/en/docs/aws-certified-developer-associate/codedeploy/)
> - [Questions](https://dev.to/romankurnovskii/aws-ec2-top-
questions-certified-developer-exam-27oo)
Persona para produtoras de conteúdo
Tags: braziliandevs, trans
Published: 2022-09-16 04:09:23

# O quê é Persona?

Persona é basicamente uma forma de escolher seu público alvo, se baseando nas atividades, características, e personalidade da pessoa.

Vamos criar um exemplo. Eu, Lissa, crio o **Cantina da Lissa**, um restaurante focado em culinária exótica, como Brownie de colágeno, Pão duro como uma rocha, e Crepioca de mel.

Durante a formulação do restaurante, eu preciso definir o meu público alvo, e para isso eu crio uma pessoa que iria consumir o meu restaurante. Nisso eu escrevo algumas características dessa pessoa:

- De 20 à 28 anos
- Turista que não conhece a culinária local
- Busca novas experiências
- Tem um paladar bem variado, gostando de um alimento azedo até algo bem ardido

Com isso eu escrevi uma **persona**. Eu criei uma pessoa que consumiria meu produto.

## Função da Persona

A função de uma persona é definir o público alvo de um produto, com isso poderemos encaixar o produto melhor ao nosso público alvo, e também o marketing do nosso conteúdo. Pois, públicos alvos diferentes, exigem uma linguagem diferente também.

Por exemplo, a Netflix é uma marca que se posiciona como se fosse uma adolescente. Não digo isso criticando, mas sim apenas citando, porque o público alvo dela em boa parte são adolescentes e jovens adultos, então se comunicar como elus faz sentido para atingir melhor esse público.

## Como aplicar persona no seu conteúdo?

Podemos aplicar persona em nossos conteúdos, fazendo algumas perguntas:

- Pra quem eu produzo meu conteúdo?
- Porque eu produzo meu conteúdo?
- Meu conteúdo é sobre o que?

E com essas 3 perguntas, você terá uma boa ideia de pra quem você produz, e com isso, uma melhor ideia de como você deve se comportar para atingir esse público.

Eu por exemplo, a persona dos meus conteúdos é:

> Pessoas. Especialmente de grupos sub-representados, que estão procurando conteúdo sobre algum tema que envolve tecnologia, buscando algo didático, que consiga ensinar, profundo, que consiga explicar, e poético, que consiga inspirar.

Com essa persona, posso guiar o meu conteúdo e a minha forma de comunicar esse conteúdo para esse público.

## Como eu posso saber como me comunicar com meu público?

Conhecendo ele.

Eu faço parte do meu público alvo, então eu instintivamente sei como comunicar para este. E na real eu acho que assim que é bom. Quando você consegue se ver no seu próprio conteúdo, como se o que você produzisse fosse um espelho da sua alma, porque aquilo faz parte de você.

## Finalização

Nesse artigo você aprendeu o básico sobre persona, e como usar esse conceito como pessoa criadora de conteúdo

Muito obrigada por ler ❤️🏳️‍⚧️ e me segue nas redes, é tudo [@lissatransborda](https://twitter.com/lissatransborda) 👀
Majority Element
Tags: javascript, leetcode
Published: 2022-09-16 04:08:35

```js
/**
 * @param {number[]} nums
 * @return {number}
 */
var majorityElement = function(nums) {
    let map = {};
    
    for(let i=0; i<nums.length; i++){
        if(map[nums[i]]){
            map[nums[i]] = map[nums[i]] +1;
        }else {
             map[nums[i]] = 1;
        }
    };
   
    let max =0;
    let maxKey = 0;
    for(const key in map){
        let value = map[key];
        if(max < value){
            max = value;
            maxKey = key;
        } 
    }
return maxKey;
};

```
1770. Leetcode solution in Java
Tags: java, programming
Published: 2022-09-16 02:29:53

```
class Solution {
  public int maximumScore(int[] nums, int[] multipliers) {
    // dp[s][i] := max score of nums[s..e] and multipliers[i],
    dp = new Integer[multipliers.length][multipliers.length];
    return maximumScore(nums, 0, multipliers, 0);
  }

  private Integer[][] dp;

  int maximumScore(int[] nums, int s, int[] multipliers, int i) {
    if (i == multipliers.length)
      return 0;
    if (dp[s][i] != null)
      return dp[s][i];

    // # of nums picked on the start side = s,
    // # of nums picked on the end side = i - s,
    // so e = n - (i - s) - 1
    final int e = nums.length - (i - s) - 1;
    final int pickStart = nums[s] * multipliers[i] + maximumScore(nums, s + 1, multipliers, i + 1);
    final int pickEnd = nums[e] * multipliers[i] + maximumScore(nums, s, multipliers, i + 1);
    return dp[s][i] = Math.max(pickStart, pickEnd);
  }
}

```
#leetcode
#challenge
here is the link for the problem: 
https://leetcode.com/problems/maximum-score-from-performing-multiplication-operations/
MQTT Series: Setup broker on Raspberry PI
Published: 2022-09-16 02:23:33

## Setup broker

Before installing the MQTT broker to our Raspberry Pi, we need to update the operating system.
All we need to do to update the system is to run the following two commands.

```
sudo apt update
sudo apt upgrade
```

Once the system has finished updating, we can now install the Mosquitto software.

```
sudo apt install mosquitto mosquitto-clients
```

At this point, you will now have the Mosquitto MQTT broker up and running on your device.
You can verify that it is installed and running by using the command below.

```
sudo systemctl status mosquitto
```

## Testing the installation

Our first task is to start up a subscriber. The subscriber is what will listen to our MQTT broker running on the Raspberry Pi.

```
mosquitto_sub -h localhost -t "mqtt/mytopic"
```
Using the “-h” argument, you can specify the hostname you want to connect to. In our case, we are using the local MQTT broker that we installed on our Raspberry Pi.

Next, we use the “-t” argument to tell the Mosquitto subscriber what topic we should listen to from the MQTT broker.

For our example, we are listening to a topic called “mqtt/mytopic“.

Now we need to use the MQTT publisher client that we installed on our Raspberry Pi earlier to publish a message to the topic.

```
mosquitto_pub -h localhost -t "mqtt/mytopic" -m "Hello world"
```
NLW - eSports 2022
Tags: rocketseat, nlwesports, css, htm
Published: 2022-09-16 01:35:46

# NLW-eSports 🚀

<p align="center">
  <img src="https://global-uploads.webflow.com/61d83a2ebb0ae01ab96e841a/630ced17a99fbd99b6169b52_Logo-NLW-eSports.svg"/>
</p>

![preview](https://cdn.discordapp.com/attachments/868299459543592962/1019955894676619314/explorer-projeto.png)

> Trilha Explorer

## Projeto 💻
Projeto desenvolvido na semana NLW eSports, o qual é voltado para comunidade game. A aplicação é uma interface animada e interativa a qual é possível compartilhar seus principais jogos e influenciadores da área dos games.

Acesse o projeto [aqui](https://gangorra.github.io/NLW-eSports/)

## Tecnologias 🛠️

- HTML <br>
- CSS

------------------------------
Este projeto foi desenvolvido durante a [Next Level Week](https://lp.rocketseat.com.br/nlw), realizada pela [Rocketseat](https://www.rocketseat.com.br) 🚀
DevStream 0.9.0 Release
Tags: devstream, devops, tooling, opensource
Published: 2022-09-16 01:09:23

## Official Releases for Different Platforms

- [dtm-darwin-arm64](https://devstream.gateway.scarf.sh/releases/v0.9.0/dtm-darwin-arm64)
- [dtm-darwin-amd64](https://devstream.gateway.scarf.sh/releases/v0.9.0/dtm-darwin-amd64)
- [dtm-linux-amd64](https://devstream.gateway.scarf.sh/releases/v0.9.0/dtm-linux-amd64)

## Major Changes since Last Release

This version focuses on two things:

- refactoring
- making the Jenkins/GitLab/Harbor/Java combination prod-ready

Here we highlighted a few changes in this release:

### Core

* helm-type plugins now support local charts
* there is a new "force" flag to `dtm destroy` command, thanks to @csonezp
* k8s backend is supported for storing state

### Plugins

* GitHub Actions for Python is enhanced
* Jenkins/GitLab/Harbor plugins are greatly enhanced, including documentation, features, default values, etc.
* ArgoCD plugin now treat namespace in an "upsert" manner
* new plugin: harbor
* added many default options for each plugin

### Docs

* Install dtm with asdf in quickstart, thanks to @zhenyuanlau
* GitLab + Jenkins + Harbor On Premise Toolchain best practice (in Mandarin)
* There is a new document (in both English and Chinese) detailing how to setup a local development Environment for Golang/K8s related projects (not specific to DevStream)

## More

See the [full changelog here](https://github.com/devstream-io/devstream/compare/v0.8.0...v0.9.0).
Neural Network Algorithm
Published: 2022-09-16 00:54:03

Artificial neural networks (ANNs) are comprised of a node layers, containing an input layer, one or more hidden layers, and an output layer. Each node, or artificial neuron, connects to another and has an associated weight and threshold. If the output of any individual node is above the specified threshold value, that node is activated, sending data to the next layer of the network. Otherwise, no data is passed along to the next layer of the network.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qw25s5fepw5a4sds7f75.jpg)
Are you doing CI/CD?
Tags: continuousintegratio, cicd, gitflow, hotfix
Published: 2022-09-19 07:19:35

---
title: Are you doing CI/CD?
published: true
date: 2022-09-16 00:00:00 UTC
tags: continuousintegratio,cicd,gitflow,hotfix
canonical_url: https://jhall.io/archive/2022/09/16/are-you-doing-ci/cd/
cover_image: https://jhall.io/images/bn-flowing-river.jpg
---

Yesterday I attended the [Agile Tour Vienna 2022](https://agiletourvienna.at/) conference, and met some great people, heard some great talks… and gave a talk.

I estimate 40 or so people attended my presentation, and as I often do, I started with an exercise:

“Raise your hand if your current team is doing CI/CD.”

About 2/3 of the hands went up.

Then I said “Put your hand down if you did NOT do a release to production last week.”

A few hands went down.

I continued: “Put your hand down if you did NOT do a release to production yesterday.”

About half went down.

“Put your hand down if you have a permanent branch called `develop`.” More down.

“Put your hand down if you have a special release process for ‘hotfixes’.” A few more went down.

“Keep your hand up only if every developer on your team merged to `master` yesterday.”

By now only 3 hands remained.

“Put your hand down if you have any open pull requests more than 24 hours old.”

Only one hand was still up.

Only one.

“Congratulations! ONE person in this room is actually doing CD!”

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Vault Enable AppRole Auth Method
Published: 2022-09-15 22:10:45

NOTE: This post assumes that you have all ready set up a vault server: https://dev.to/frederickollinger/production-hashicorp-vault-minimal-configuration-485a

## What is an Auth Method?

An auth method is a method to valid requests from clients. It provides authentication, that is it checks to see that you are who you say you are. It does not handle authorization which tells you what resources you may or may not do or access.

## Where Would You Use AppRole Auth Method?

AppRole is most often used for machine to machine authentication.

## What is a Policy?

A policy allows one to control what a particular Role can do with vault, what secrets to change, access, etc.

## Enabling AppRole

AppRole is not turned on my default so as a one time operation, one must enable it:

```sh
vault auth enable approle
```

## Create a Vault Policy

Vault policies are in HCL files.

Save this in a file named policy.hcl.

```hcl
path "secret/data" {
  capabilities = [ "read" ]
}
```

Tell Vault to read the Policy:

```sh
cat policy.hcl | vault policy write data-policy -
```

List the policies:

```
vault policy list
```

## Define a Role 

A Role is needed to access a particular resource. Each role has an attached policy.

In this example, we are going to call our role: 'dataapp'.

```
vault write auth/approle/role/dataapp policies=data-policy
```

List the roles

```
vault list auth/approle/role
```

## Generate the Authentication Credentials

In order to login, one needs both the RoleID and the SecretID.

The RoleId is analogous to a username while the SecretID is like a password.

RoleID:

```sh
vault read auth/approle/role/dataapp/role-id
```

SecretID:

```sh
vault write -f auth/approle/role/dataapp/secret-id
```

## Use Credentials To Login Using AppRole

Replace $ROLE_ID and $SECRET_ID with those generated above.

```sh
vault write auth/approle/login \
role_id=$ROLE_ID \
secret_id=$SECRET_ID
```
Binary Numbers
Tags: computerscience
Published: 2022-09-15 22:24:15

The binary number system is what allows computing systems to store information. It is a base-2 number system. This means each digit consists of powers of 2. The digits are represented by only 1s and 0s. A bit is the smallest unit of data used in computing. A binary digit equals one bit. From right to left, starting with 2^0, the powers progressively increase:


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

Every digit is multiplied by either 1 or 0, depending on which ones are needed. 

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

To convert binary numbers into decimal numbers we need to take the greatest power of 2 in our number. As an example, for the number 20 that is 16. Subtract the highest power and repeat this until the sum of all these powers is the number we want. 20 represented in binary is 10100, which is 2^4 x 1 + 2^3 x 0 + 2^2 x 1 + 2^1 x 0 + 2^0 x 0 = 16 + 4

197 would be 11000101 = 2^7 + 2^6 + 2^2 + 2^0 = 128 + 64 + 4 + 1

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

Decimal numbers belong to a base-10 system. That is why they're made up of the digits 0-9.

Binary addition is largely the same as decimal addition. However, only 1 and 0 can be used. 5 + 4 would look like this:

   110
+
   100

0 + 0 = 0 and 1 + 0 = 1. 1 + 1 is more than 1 so we'd write down 0 and carry the 1 to the next column. So 18 - 17 = 10010 - 10001 = 00001 = 1. It is not possible to borrow from 0. If we are borrowing from a 1 that is a few 0s to the left, the 0s are replaced with 2s. 4 - 1 = 100 - 001 = 101 = 3

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

When we subtract 1 from 0 we must borrow from a 1 to the left.  6 - 4 = 110 - 100 = 10 = 2

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

Binary multiplication is similar to decimal multiplication: 1 x 0 = 0, 1 x 1 = 1, 0 x 0 = 0 

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

When dividing binary numbers 0 : 1 = 0, 1 : 1 = 1. For example, 38 : 19 = 100110 : 10011 = 10 = 2. If the divisor is greater than the dividend the quotient will be 0. We then bring down the next number and repeat. 

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