teleren/devto huggingface dataset:
HackerRank: Diagonal Difference Solution using PHP (Algorithm)
Tags: hackathon, hackerrank, algorithms, programming
Published: 2023-04-14 23:35:26

## Diagonal Difference Solution
Given a square matrix, calculate the absolute difference between the sums of its diagonals.
For example, the square matrix is shown below:

> 1 2 3
> 4 5 6
> 9 8 9

The left-to-right diagonal =1 + 5 + 9 = 15. The right to left diagonal = 3 + 5+ 9 = 17. Their absolute difference is **|15–17| = 2.**

**Function description**
Complete the diagonalDifference function in the editor below. It must return an integer representing the absolute diagonal difference.

**Difference takes the following parameter:**

arr: an array of integers.

**Input Format**
The first line contains a single integer, n , the number of rows and columns in the matrix arr.

Each of the next n lines describes a row, arr[i], and consists of n space-separated integers arr[i][j].

**Constraints**
. — 100 ≤ arr[i][j] ≤ 100

**Output Format**
Print the absolute difference between the sums of the matrix’s two diagonals as a single integer.

**Sample Input**

> 11 2 4
> 4 5 6
> 10 8 -12

**Sample Output**

> 15

**Explanation**
The primary diagonal is:

11
  5
   -12

Sum across the primary diagonal: 11 + 5–12 = 4

The secondary diagonal is:

   4
  5
10

Sum across the secondary diagonal: 4 + 5 + 10 = 19

> Difference: |4 –19| = 15

**Note:** |x| is the absolute value of x

## Solution (Base on how i solved it)

```
$first = 0;
$second = 0;
$n = sizeof($arr);
for ($i = 0; $i < $n; $i++){
for ($j = 0; $j < $n; $j++){
    if ($i === $j){
        $first += $arr[$i][$j];
    }
        if ($i + $j === $n - 1){
            $second += $arr[$i][$j];
        }
    }
}
return abs($first - $second);
}
```
Summary: React UI Library for Appwrite Functions
Published: 2023-04-14 23:30:59

## This project briefly explains how the implementation of Appwrite functions was integrated as a UI library. 

It replaces the code for sign up, sign in, reset password, logout, etc. with UI components that users can easily implement in their projects by simply installing the package. However, the project is not yet live on npm.

This UI library is built for React and is developed using React and Vanilla JavaScript with some CSS, and it is compiled by Babel. The project was challenging, and I learned about installing Docker and how the Appwrite package works.

Usage
`
-   Create your react app 
-   `Config file setup`
-   Inside your src folder make appwriteConfig.js file 

By default appwriteConfig.js contain this info
import { Client, Account } from "appwrite";

    const client = new Client();

    const account = new Account(client);

    client
        .setEndpoint('http://localhost:106/v1') // Your API Endpoint
        .setProject('6425d19c7a8619e5cb51') // Your project ID
    ;
-   Inside your client folder(or root folder name can vary) install react-appwrite-auth-library using
-   npm i react-appwrite-auth-library
-   In your .js/.jsx folder
-   import component for use

import Authsignup from "react-appwrite-auth-library/Authsignup";

    <Authsignup/> here takes email, password, and name as props. It can also have an inline styling Authstyle as inline prop styling.
    const Authstyle = {
        color: "red"
    }
    <Authsignup email={email} password={password} name={name} Authstyle={Authstyle} />`


1. Authdelete - Button to delete a user.
2. AuthGuestLogin - Button for a user to login as guest
3. AuthInitiateResetPassword - Button to initiate a password reset link.
4. AuthJWT - Button to create a JsonWebToken
5. AuthLogin - Button to create a user session
6. AuthLoginWithPhone - Login with phone number component
7. AuthLogout - Button to dismiss a user session
8. AuthMagicUrl - Component to create a magic url session
9. AuthResetPassword - Button to reset password
10. Authsignup - Component to sign up a user
11. AuthVerifyMagicUrl - Component to verify magic URL session
12. AuthVerifyPhone - Button to verify phone number
13. OAuth - Sign in with providers like google

[Github](https://github.com/appwrite-octernship/create-add-on-package-ui-helper-libraries-Kizito007.git)
Looking for devs to join a genuine cypherpunk spirit project
Tags: blockchain, opensource, coin, cypherpunk
Published: 2023-04-14 23:07:24

Be part of an innovative peer-to-peer payment network, completely decentralized without any central authority, that enables instant payments at virtually no cost to anyone in the world: **Cyberyen**.

Cyberyen is anarchy - without rulers, but not without rules. Rules are defined and enforced by network members. Cyberyen's underlying "bottom-up" governance model, where each node operator governs itself by making sure no one else on the network breaks the rules they agree to.

Cyberyen Core is an open source software that allows anyone to manage a node on the Cyberyen blockchain network and uses the Scrypt hashing method adopted for this cryptocurrency to confirm work.

Cyberyen is a hybrid grown from Litecoin with the addition of new block parameters. Bundled with The Mimblewimble Protocol, Cyberyen provides users with the ability to send confidential transactions where the amount being sent is known only between the sender and recipient, as well as the benefit of having a personal address balance and increased transaction throughput.

We are seeking passionate and dedicated developers who share our vision and want to be part of our adventure.

https://www.cyberyen.org
What you should know about Data Science to get started.
Tags: datascience, beginners, python, programming
Published: 2023-04-14 23:06:50

  Data science is a very trendy topic/profession nowadays.A lot of people are interested in this field but really not sure what Data science actually means. This article is all about what is Data science and why it is important for a company to have one. 
  So, let's start with the really first question you ask yourself when you hear about this field. What is Data Science?
The definition you can see on Google would be something like  Data science combining domain expertise, programming skills, and knowledge of mathematics and statistics to extend manful insight from data. Which is a good definition but what does exactly that mean?     
  When it comes to Data Science there are 5 main stages.

1. Capture
  This is the process of extracting information from any type of documents and converting it into a format readable by a computer.

2. Maintain
  That is when we are cleaning, correcting, ingesting, storing, organizing and maintaining the data created and collected by an organization.

3.Process 
  Systematic approach to solving a data problem. Choosing a strategy we will use to solve the problem.

4.Analyze 
  Process when applying statistics and logic to describe and illustrate, condense and recap, and evaluate data.

5. Comunicate 
  When we do data visualization, making decisions, and reporting our findings to clients or business people in order to help them make strategic and business decisions.

The second very important question you should ask is what problems can data science solve?
There is 4 main problems that data science can solve:

1. Regression
  Regression is answering the question: how much or how many? It used to predict a continuous value. For example, what would be the sale price of a house?

2. Classification
  Classification is answering the question: which category? It used to predict which category something will fall into.If you're trying to figure out whether a client is likely to default on a loan or which of your products a customer is likely to prefer, you're dealing with a classification problem.

3. Anomaly detection
  Anomaly detection is answering the question: if this is weird? It  identifies fraud and is used to find unusual patterns that do not conform to expected behavior.

4.Recommender systems
  Recommender systems answer the question: which item would a user prefer? It used to predict user preferences towards a product/service. For example when we watch Netflix we can notice a section like "recommended for you because you watched ..." This is exactly what recommender systems are.

The work data scientists do is very interesting and helpful. It helps to improve businesses and first of all quality of lives. In my opinion data science will always be relevant, in the future it will be even more necessary for every company since we live in the technical world and there are no limits in development. I hope my blog was interesting, informative, and inspiring.
Are you happy with the time for your code to be reviewed?
Tags: github, javascript, programming
Published: 2023-04-14 23:03:51

This is actually more of a discussion rather than a blog. As a developer I always feel like the review process is slow. Often time it takes days or even weeks to get it reviewed and approved.

Other than a review reminder is there any other way to improve it? 

I'm interested to know what you guys do to speed up the review process.
Explain ChatGPT to a Five Year Old
Tags: explainlikeimfive, ai, chatgpt, programming
Published: 2023-04-14 22:53:29

## Have you ever heard of ChatGPT? 💬🧑‍💻

💡 It's a pretty cool thing that can help you with all sorts of questions and problems you might have. 

But what is it exactly? ❓🤔🧐

🔍 Let's find out!
JavaScript array methods
Tags: javascript, programming, tutorial, webdev
Published: 2023-04-14 22:43:05

In this article, I will like to talk about javascript array methods but first of all, I will like us to know what an array is.

An array is in an ordered list of values. Each value is called an element specified by an index: A javascript array has the following characteristics: First, an array can hold values of mixed types. For example, you can have an array that stores elements with the types number, string, boolean and null.

Javascript methods: are actions that can be performed on objects. A javascript method is a property containing a function definition

Now Back to the main deal of today, I will like to highlight some important javascript methods just a few, it is not like the others are not important you can check on them if you want to know more in detail. You can see that below.

```
[4, 5, 6, 7].at(1)         // 5
[4, 5, 6, 7].push(8)       // [4, 5, 6, 7, 8]
[4, 5, 6, 7].pop()         //[4, 5, 6, ]
[4, 5, 6, 7].fil(1)        //[1, 1, 1, 1]
[4, 5, 6, 7].join(' ')     //'4 5 6 7 '(string)
[4, 5, 6, 7].shift()       //[ 5, 6, 7]
[4, 5, 6, 7].reverse()     //[7, 6, 5, 4]
[4, 5, 6, 7].unshift(3)    // [3, 4, 5, 6, 7]
[4, 5, 6, 7].includes(6)   //true
[4, 5, 6, 7].map(item => 2*item) // [8, 10, 12, 14]
[4, 5, 6, 7].filter(item => item > 5)  //[6,7]
[4, 5, 6, 7].find(item => item > 5)    //6 (first match)
[4, 5, 6, 7].every(item => item > 0)   // true
[4, 5, 6, 7].findIndex(item => item === 5)  // 1
[4, 5, 6, 7].reduce((prev, curr) => prev+curr, 0)   //22
```
How Kyte's Head of Product & Engineering Survived SVB's Collapse & Outsmarted Uber
Tags: startup, podcast, devops, management
Published: 2023-04-14 22:21:00

It hasn't been smooth sailing for startups this year. As this week's guest Nick Cobb puts it "You can add bank runs to the list of things founders have to deal with." Of course, it hasn't been easy going for engineering leaders either.

That's why Nick, the VP of Engineering & Head of Product at Kyte, sat down with us to discuss how to build an engineering culture with a bias toward action, why he deleted his team's staging environment, and what it takes to outmaneuver his former employer, Uber.

An angel investor, Nick also touches on the aftershocks of the SVB crash and its lasting effects on the startup community.

Recorded live at LeadDev New York, this episode is a must-listen for engineering leaders who want to place product innovation in the driver's seat of their engineering org.

{% spotify spotify:episode:2YzYHNSKHLrxHozCyqJNoh %}

## Episode Highlights:
* (2:21) Impact of SVB on startup ecosystem
* (7:59) Is now the perfect time to invest in an early stage startup?
* (13:02) Metrics to pay attention to
* (19:33) Uber's lack of innovation
* (24:44) Dogfooding culture
* (27:30) What's happening in self-driving?
* (30:23) Leading engineering teams at Kyte
* (41:09) Postmortem culture

***While you’re here, check out this video from our [YouTube channel](https://www.youtube.com/c/DevInterrupted?sub_confirmation=1), and be sure to like and [subscribe](https://www.youtube.com/c/DevInterrupted?sub_confirmation=1) when you do!*** 

{% youtube jmXSUG66q40 %}

### Want to cut code-review time by up to 40%? Add estimated review time to pull requests automatically!
*gitStream is the free dev tool from LinearB that eliminates the No. 1 bottleneck in your team’s workflow: pull requests and code reviews. After reviewing the work of 2,000 dev teams, LinearB’s engineers and data scientists found that pickup times and code review were lasting 4 to 5 days longer than they should be.* 

*The good news is that they found these delays could be eliminated largely by adding estimated review time to pull requests!*

### Learn more about how gitStream is making coding better [HERE](https://linearb.io/blog/why-estimated-review-time-improves-pull-requests-and-reduces-cycle-time/?utm_source=Substack%2FMedium%2FDev.to&utm_medium=referral&utm_campaign=gitStream%20-%20Referral%20-%20Distribution%20Footers).

![Start using gitstream today!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xg1l6hxt134px501bf7d.png)
Conditional Rendering in React
Published: 2023-04-14 21:25:43

**Conditional Rendering in React**

In React, you can create distinct components that encapsulate behavior you need. Then, you can render only some of them, depending on the state of your application.

Conditional rendering in React works the same way conditions work in JavaScript. Use JavaScript operators like if or the conditional operator to create elements representing the current state, and let React update the UI to match them.

Here’s an example of conditional rendering in React:

import React from 'react';

function Example(props) {
  const isLoggedIn = props.isLoggedIn;
  if (isLoggedIn) {
    return <UserGreeting />;
  }
  return <GuestGreeting />;
}

function UserGreeting(props) {
  return <h1>Welcome back!</h1>;
}

function GuestGreeting(props) {
  return <h1>Please sign up.</h1>;
}
In this example, the Example component checks the value of isLoggedIn prop and conditionally renders either the UserGreeting or GuestGreeting component.
Angular standalone components
Tags: angular, javascript, frontend, braziliandevs
Published: 2023-04-14 21:15:57

Vídeo desenvolvendo na prática:
[![Vídeo sobre Angular standalone components](https://user-images.githubusercontent.com/7671459/232959832-cbc9b865-056f-4972-928d-64c5d78880cc.png)](http://www.youtube.com/watch?v=CB88oX_eI-g "Video Title")


A estrutura do Angular é baseada em componentes.
Os Componentes são partes de interface. Blocos compostos por um template, um estilo e uma classe.

Antes do Angular 14 era necessário um módulo, que é um mecanismo para agrupar components, directives, pipes e services relacionados.

Mas agora com as APIs do standalone components, pode ser totalmente independente, deixando NgModule opcional, o que torna a criação de aplicativos Angular mais simplificada.

Os módulos não foram descontinuados e ainda podem ser usados. Inclusive é possível usar componentes com módulos e sem na mesma aplicação.
Eu tenho criados novos componentes das aplicações com essa API, mas ainda não migrei as anteriores.

**Etapas executas no vídeo:**

Criamos o projeto
```bash
ng new angular-standalone
```

Criamos o componente verses passando a flag --standalone
```bash
ng generate component verses --standalone
```

Ao usar a flag, foi criado nosso componente sem o arquivo de módulos e com o sinalizador standalone: true e imports dentro do arquivo de componente.

```js
@Component({
  selector: 'app-verses',
  standalone: true,
  imports: [CommonModule],
  providers: [],
  templateUrl: './verses.component.html',
  styleUrls: ['./verses.component.css']
})
```

Também criamos o serviço chamado verses na mesma pasta para consumo da API
```bash
ng generate service verses/verses
```

```javascript
@Injectable({
  providedIn: 'root'
})
export class VersesService {

  constructor(private httpClient: HttpClient) { }

  getVerse(): Observable<Verse> {
    return this.httpClient.get<Verse>('https://www.abibliadigital.com.br/api/verses/nvi/sl/23').pipe(take(1));
  }
}
```

Vamos adicionar o serviço e modulo HttpClientModule no nosso componente

```javascript
@Component({
  selector: 'app-verses',
  standalone: true,
  imports: [CommonModule, HttpClientModule],
  providers: [VersesService],
  templateUrl: './verses.component.html',
  styleUrls: ['./verses.component.css']
})
```

Para carregar a rota desse componente em lazy loading, o que faz carregar apenas ao acessar a rota, usamos o loadComponent;

```javascript
{
    path: '',
    title: 'Verses',
    loadComponent: () => import('./verses/verses.component')
    .then(c => c.VersesComponent)
  }
```

Se você está em uma versão do Angular anterior a 13, recomendo o upgrade devido a ganhos de performance que essa versão traz.
Na versão 14 foi introduzido principalmente o standalone components, e se tornou estável na versão 15.

[GitHub Projeto](https://github.com/raphaelramos/angular-standalone-components)
Day 736 : Hot Mess
Tags: hiphop, code, coding, lifelongdev
Published: 2023-04-14 21:15:00

_liner notes_:
- Professional : Pretty chill day. Just worked on some projects and started to get things ready for my trip next week. Also got an email about speaking at a conference in November. Pretty dope! I've never been to that part of the world yet. We'll see how it goes.

- Personal : I got the details to gallery transition to work! While doing that, I somehow changed the details to details transition, but I like how it looks now better than before. hahaha It's funny, at the beginning of the week everything was a hot mess and now it's working how I want. Still a hot mess, though. I'll clean it up this weekend and integrate it into my side project. I also put up some cargo nets to be used as storage space on the inside roof of my van. Going to see what I can move up there so I can clear out space in other areas.

![A river in Abkhazia flowing over a rocky riverbed and riverbanks through a dense forest](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rakcx6zsr684yqmhqgr7.jpg)

Going to finish putting together tracks for the radio show. Then continue working on my side projects. Maybe I'll watch another episode of "Swarm".

Have a great night and weekend!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube bm1xR6-fCXk %}
What makes you stay disciplined?
Tags: discuss
Published: 2023-04-14 21:10:13

Yes, what makes you stay disciplined when feeling like you don't want to do your daily stuff?

Once I heard that you don't necessarily need to have motivation every time, and sometimes your motivation needs to be don't have a motivation at all.

That makes sense to me, because we may always want to find something to inspire us, but if that something never comes out, then you end up in a frustrating situation.

It has been like two months since I can't stay focused on my work, 4 of 7 days a week I'm just playing video games and at this time I don't even enjoy that time spent. I want to go outside, but when the time comes I feel so comfortable in my house. I want to learn things and try new hobbies but it's too hard to get up off my chair and take action.

But no more, I will start to make things better starting today, this is my first attempt to change, writing my very first post here was always a thing I wanted to do. And wanted to kick off by starting a discussion regarding this topic, because I'm sure a lot of us as devs once faced a situation like this.

So tell me, how do you deal with these problems? What moves you when the motivation is gone? I read you 👀
How not to create another bug while fixing one
Tags: webdev, beginners, programming
Published: 2023-04-14 20:57:26

Many developers make mistakes of making more bugs while trying to fix a bug. People will trust you more if you don't produce these unnecessary outcomes. 

Here are 5 tips that I've learned over time 

1. Understand the root cause of the bug: Before you start fixing the bug, make sure you understand the root cause of the problem. This will help you to identify potential side effects of the fix. Any reports, logs, or system dashboard can be useful information. 

3. Write test cases: Before fixing the bug, write test cases that cover the problem. These test cases should be able to reproduce the bug and should also cover any related scenarios. After you have fixed the bug, run these test cases to verify that the bug has been fixed and that there are no new issues. 

4. Isolate changes: When fixing a bug, try to isolate the changes to the smallest possible area of code. This will help you to identify any potential issues that may arise from the changes you make. And if you are not sure what side effects your changes can make, try to communicate with other members first..! 

5. Review your code: Have someone else review your code before you merge it into the main codebase. A fresh set of eyes may identify issues that you missed. Even if you already covered the automated tests, running a quick manual test will never hurt.

6. Monitor: After you have fixed the bug, monitor the application for any regressions. This involves checking that the fix did not introduce new issues. Again, any reports, logs, or system dashboard can be useful. 

I was able to produce less bugs after I started applying these tactics to the daily workflow. So try these and become more reliable dev in your team! 

If you like this content, please follow https://bitethecode.substack.com and https://github.com/bitethecode. I will try to share what I've learned with y'all!
What is a function in coding? explained by a semi-layman
Tags: javascript, beginners, webdev, tutorial
Published: 2023-04-14 20:31:59

What is a function? 

**Functions are tools.**

🔨 I need to hammer a nail. The hammer is a tool. The hammer is a function. I expect the nail to be hammered with this tool / function.

🥣 I need to eat cereal. The spoon is a tool. The spoon is a function. I expect to eat my cereal with this tool / function. 

🏠 I need to calculate my mortgage. The mortgage calculator is a tool. The mortgage calculator is a function. I expect to calculate my monthly mortgage payments with this tool / function.

**Functions are tools.**

We decided to become programmers to solve problems, no matter the size. Every problem can be broken down to smaller problems. And for every problem, we can create our own tools to solve them. That is the power of programming -- creating our own tools to tackle the problems we want to fix. Amazing stuff!
Error eks 1.26
Published: 2023-04-14 20:21:39

Hi! I have a question: Has anyone updated their EKS/AWS cluster to version 1.26? In the team I work with, we had version 1.22 and started doing version updates step by step after reading the AWS documentation. Recently, the latest version of EKS, 1.26, was released and we decided to update. We started by updating the control plane without problems, but when updating the node group, we encountered an error:
Error: failed to join the kubernetes cluster
The problem is that we can't update the node group or create a new one now because we're getting the same error. During the update, we followed the documentation steps and analyzed all the dependencies that we might have. Could this be an AWS issue? We can't find a solution; it seems like a networking problem, as if the instance created couldn't access the cluster :cara_pensativa: