teleren/devto huggingface dataset:
Magento {\"error\":{\"root_cause\"[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index\":
Published: 2021-05-14 16:14:48

To fix this error you need to reindex bin/magento indexer:reindex

{"0":"{\"error\":{\"root_cause\":[{\"type\":\"index_not_found_exception\",\"reason\":\"no such index\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_2\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_2\"}],\"type\":\"index_not_found_exception\",\"reason\":\"no such index\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"magento2_product_2\",\"index_uuid\":\"_na_\",\"index\":\"magento2_product_2\"},\"status\":404}","1":"#1 Elasticsearch\\Connections\\Connection->Elasticsearch\\Connections\\{closure}() called at [vendor\/react\/promise\/src\/FulfilledPromise.php:28]\n#2 React\\Promise\\FulfilledPromise->then() called at [vendor\/ezimuel\/ringphp\/src\/Future\/CompletedFutureValue.php:55]\n#3 GuzzleHttp\\Ring\\Future\\CompletedFutureValue->then() called at [vendor\/ezimuel\/ringphp\/src\/Core.php:341]\n#4 GuzzleHttp\\Ring\\Core::proxy() called at [vendor\/elasticsearch\/elasticsearch\/src\/Elasticsearch\/Connections\/Connection.php:329]\n#5 Elasticsearch\\Connections\\Connection->Elasticsearch\\Connections\\{closure}() called at [vendor\/elasticsearch\/elasticsearch\/src\/Elasticsearch\/Connections\/Connection.php:227]\n#6 Elasticsearch\\Connections\\Connection->performRequest() called at [vendor\/elasticsearch\/elasticsearch\/src\/Elasticsearch\/Transport.php:105]\n#7 Elasticsearch\\Transport->performRequest() called at [vendor\/elasticsearch\/elasticsearch\/src\/Elasticsearch\/Client.php:1559]\n#8 Elasticsearch\\Client->performRequest() called at [vendor\/elasticsearch\/elasticsearch\/src\/Elasticsearch\/Client.php:1192]\n#9 Elasticsearch\\Client->search() called at [vendor\/magento\/module-elasticsearch-7\/Model\/Client\/Elasticsearch.php:367]\n#10 Magento\\Elasticsearch7\\Model\\Client\\Elasticsearch->query() called at [vendor\/magento\/module-elasticsearch\/SearchAdapter\/Dynamic\/DataProvider.php:221]\n#11 Magento\\Elasticsearch\\SearchAdapter\\Dynamic\\DataProvider->getAggregation() called at [vendor\/magento\/framework\/Search\/Dynamic\/Algorithm\/Manual.php:48]\n#12 Magento\\Framework\\Search\\Dynamic\\Algorithm\\Manual->getItems() called at [vendor\/magento\/module-elasticsearch\/SearchAdapter\/Aggregation\/Builder\/Dynamic.php:48]\n#13 Magento\\Elasticsearch\\SearchAdapter\\Aggregation\\Builder\\Dynamic->build()
Angular forms - NEVER rely on a disabled "submit" button!
Tags: angular, html, security
Published: 2021-05-14 15:56:37

Let's say you're just writing some Angular code.

A form.

That form has some required fields, like email and password.

Your "submit" button is disabled until the form is valid, by using `<button type="submit" [disabled]="myForm.invalid">`, which you can find in many stackoverflow answers.

You're safe - the feature is working, a user isn't able to submit an invalid form.


Actually, you're not.

Now, try opening the dev console in your browser and manually removing the `disabled` attribute from the "submit" button.
The button is enabled again and you're able to submit the form, even though the form is invalid.

Remember to add an additional check for the form's validity in the submission function!

Example:
```
<form (ngSubmit)="submitMyForm()" [formGroup]="myForm">
  <input type="email" formControlName="email" />
  <input type="password" formControlName="password" />
  <button type="submit" [disabled]="myForm.invalid">Submit</button>
</form>
```

Your `submitMyForm` method should have something to prevent an invalid form from being submitted. Like:
```
submitMyForm() {
  if (this.myForm.invalid) {
   // here potentially add some visual feedback for a user
    return;
  }

  // form submission logic here
}
```

Live demo: https://stackblitz.com/edit/angular-reactive-forms-zvzqvd

Just to clarify - any client-side security is not sufficient on its own, so always validate on the server too!
The truth about Open Source Developers. (WDS #2)
Tags: opensource, webdev, javascript
Published: 2021-05-14 15:49:52

Disclaimer this is 100% satire. For fun on a Friday (Web Dev Satire #2)

---

![Screen Shot 2021-05-14 at 11.07.55 AM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x1j1aw6e99t2b4g0xacx.png)

---
# Open Source developers make a lot
 As you can see from this chart, I didn't exaggerate that open-source developers make way more than FAANG Developers. This might be the single driving factor in deciding to make a project open-source.

It's the fastest and most secure way to grab the bag and start buying houses like it's Monopoly. Anyone who tells you Open-source developers don't make this much, well, those are paid actors. 

---

# OS developers love vague issues
One of the best ways to support OS is making vague issues that don't relate to the project. Got to keep those developers on their toes. Sometimes they get lonely. Remind them that you care, just not enough to duplicate the issue or provide any practical information. If you include a version number, you've gone too far. 

![Screen Shot 2021-05-14 at 11.19.24 AM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e4jc5yponpgxtenr3znr.png)
 
---

# Complain and add nothing on an open issue 
If you do find a valid issue on Github, complain. Dog-pile on it as much as you can. 

Here are some phrases the OS developers love:
- "This is stupid, why does it work this way?"
- "Same"
- "The docs are useless"
- "Can you fix this today?"
- "Help." (That's the entire comment)

--- 

# Rant about GitHub activity
Why are you making a billion dollars a year when you only commit a few times? Who cares about raising money so you can keep the project alive, I want my free project now! 

---

# Star the project and keep moving, even if you work at a Fortune 500 company

![EPXUU1RXUAEdbjj](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5dl0qsgq23bhfpkp2otz.jpeg)
*Source: [David K Piano](https://twitter.com/DavidKPiano) go give him a follow on Twitter. This picture is too good not to include.*

Bonus points if you can get your company to send a box of chocolates or a few stickers to that project the company depends on. The margins are so razor-thin for F500 companies that a box of chocolates might be a stretch. 

---
---

In case it isn't clear by now, this is satire! Web Dev has gotten so full of uninformed opinions, I thought I'd poke some fun. To all Open-source developers, you're great. The community wouldn't be the same without you! Happy Friday!

Some of my favorite OS Developers. Thank you!
[Henry at BabelJS](https://twitter.com/left_pad)
[Evan You of VueJS](https://twitter.com/youyuxi)
[Guillaume Chau of VueJS](https://twitter.com/Akryum)



![c7b8113247fecd83bd9b5ed5bd3f34d5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1m71xz5fzmhype617i0.png)
*Real of open source developers*
Infinite Scroll with Doodle
Tags: kotlin, webdev, javascript, showdev
Published: 2021-05-14 15:41:54

See how to display an ["infinite" stream](https://nacular.github.io/doodle-tutorials/#/photostream) of images from unsplash.com using Doodle's DynamicLists. Doodle [tutorials](https://nacular.github.io/doodle-tutorials) is a good place to see in-depth examples of how to build apps.

[Doodle](https://github.com/nacular/doodle) is a pure Kotlin UI framework for the Web, that lets you create rich applications without worrying about Javascript, HTML or CSS. Check out the [documentation](https://nacular.github.io/doodle) to learn more.

Feedback is always appreciated.

{% github nacular/doodle-tutorials no-readme %}
Building 'delta' on Alpine Linux
Tags: rust, alpinelinux
Published: 2021-05-14 23:03:28

---
title: Building 'delta' on Alpine Linux
published: true
date: 2021-05-14 15:24:07 UTC
tags: rust,alpinelinux
canonical_url: https://www.solarwinter.net/building-delta-on-alpine/
---

Short post for a change this time. :-)

I've just built [delta](https://github.com/dandavison/delta) on an Alpine Linux image. There were a couple of dependencies I had to install before it would build, and one of them puzzled me for a bit.

[Cargo](https://doc.rust-lang.org/cargo/) was building and failed on `crti.o`:

```
 = note: /usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
```

`apk search` didn't show anything useful. So, for myself in the future (or anyone else who happens to be searching for this) - the package that provides `crti.o` for Alpine is `musl-dev`.
Line filter program that removes digits
Tags: go, linux, unix
Published: 2021-05-14 15:13:53

 :pushpin: A filter is a program that gets data from standard input, performs some manipulation of the data, and then writes its results to standard output.
Auxiliary input may come from command line flags or configuration files, while auxiliary output may go to standard error.

 :pushpin: Most common functions:

 :arrow_forward: Convert data to a different format
 :arrow_forward: Add printer instructions to the beginning of each document
 :arrow_forward: Add, delete, or modify data in a document

  :pushpin: Unix has many filter programs, most common are: cat, cut, grep,

Go Playground: https://play.golang.org/p/s8FwQRkZXdr

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kaoyx8djfnvg4x8y7jov.png)
Multiple arrow operators in a single function
Tags: javascript, react, angular, node
Published: 2021-05-14 15:13:39

 
We may have come across arrow functions in javascript and are almost saturated learning about the difference between normal functions and arrow functions, the difference between ES5 and ES6 and everything that is connected to it. But everytime we come across multiple arrows in a single function, we keep struggling - or it could just be a "me" problem. Here goes, what multiple arrows in a function mean.

A simple ES6 function that demonstrates it:-
```
const add = x => y => x + y
```
This can be written in ES5 functional format like this:
```
function add(x){
 return function(y){
  return x + y
 }
}
```

The above code explains what is going on with multiple arrow operators. It returns a function which in turn accepts a parameter, the nested returned function maintains the state of x. This methodology is called [currying](https://blog.bitsrc.io/understanding-currying-in-javascript-ceb2188c339). 

To call the above function, we follow a slightly different syntax. React developers who have worked on Redux would have come across such function calls when using the [connect function](https://react-redux.js.org/api/connect). Here we go:-

```
add(2)(3)
// This would return 5
```

That's just another javascript basics that could help you crack your dream job interview. Thank me later! :wink:
The Problem With My Website
Tags: react, webdev, portfolio, javascript
Published: 2021-05-14 15:12:22

## 
## 
Here I'm talking about [my website](https://www.pradnyanandpohare.in). It's my portfolio website and one thing I was sure that I needed one. I have this one from past two years and time to time I'm trying to improve it.

# The Problem 

We need to improve or fix something when there is a problem. And the problem with my website was ***each time I used to switch to new route my component used to mount again and api call used to fire to fetch data.***

Issues with this 

* User have to wait until component render data
* API used to fire again an again to get data
* Website used feel slow 
* All the state data used to reset 

# Findings

When I look online it says whenever we change path, in react it mount that component again. But  I was thinking why the online website does not behave like mine one does. 
I asked my friend **Mohit** and **Anurag** as both were working with React JS from couple of years. 

The conclusion of the discussion was to use **redux** and have a state to check whether user visited that page or not  and according to that in ComponentDidMount trigger animation or fetch API . 

# Implementation 

After adding redux and all other checks in ComponentDidMount , the redux state used to reset whenever I used to change my route. I thought my be its because I'm using class component but its should not matter whether its class or functional because store should not reset because of it. 

So I went to basic, I looked online How one navigate to another page. Thats where I found my mistake.I was using Anchor Element to navigate to another page where everyone was using one of the following method 

## 1.Link
```js
 <Link to="/path" className="btn btn-primary">Navigate</Link>
```
 
## 2.Redirect (From react-router)
```js
<Redirect to='/myComponent' />
```
## 
## 
## 3.Using history prop
```js
props.history.push('/path')
```
## 
## 
I ended up using history prop to navigate between my pages. So the combination of redux state check and navigating using history prop I'm able solve my problem.
## 
## 
## Things Improved 
* No multiple calls to API for data
* User does not have to wait 


Maybe I'm right maybe I'm wrong but for now It's how I resolved it. Do let me know guys if you hsave any other solution by commenting below. 

If you want to read more Do visit [my website](https://www.pradnyanandpohare.in). Cheers.
## 
##
Angular : Getting through that pesky company proxy
Tags: angular, node, javascript, webdev
Published: 2021-05-14 14:48:55

If you are attempting to get an Angular site running on your Windows work computer at XYZ Company the chances are that you are having problems getting through the company proxy.

There are (at least) two package managers that need to get through the proxy:
1. NPM
2. Typings

For NPM you need to add the following lines to the `.npmrc` file:
```javascript
proxy=http://[DOMAIN]%5C[USER]:[PASS]@[PROXY]:[PROXYPORT]/
https-proxy=http://[DOMAIN]%5C[USER]:[PASS]@[PROXY]:[PROXYPORT]/
```

For Typings you need to add the following lines to the `.typingsrc` file:
```javascript
proxy=http://[DOMAIN]%5C[USER]:[PASS]@[PROXY]:[PROXYPORT]/
https-proxy=http://[DOMAIN]%5C[USER]:[PASS]@[PROXY]:[PROXYPORT]/
rejectUnauthorized=false
```

These files probably don't exist yet, so you can create them as blank text files. They can be added to the project root
(same place as `package.json` or you can put them in %HOMEPATH% and they will be available to all your projects.

<a href="https://www.buymeacoffee.com/rkycom" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>

With all that being said, I highly recommend you keep learning!

Thank you for reading this article. Please feel free to connect with me on [LinkedIn](https://www.linkedin.com/in/www-rajeshkumaryadav-com/) and [Twitter](https://twitter.com/rky_com).
Recursion using functions
Tags: c
Published: 2021-05-14 14:38:37

Different Ways of Writing Recursive Functions 
1)Function calling itself: (Direct way) 
Most of us aware atleast two different ways of writing recursive programs. Given below is towers of Hanoi code. It is an example of direct calling.



#include<stdio.h>
 
// Assuming n-th disk is bottom disk (count down)

void tower(int n, char sourcePole, char destinationPole, char auxiliaryPole)
{

   // Base case (termination condition)

   if(0 == n)

     return;
 

   // Move first n-1 disks from source pole

   // to auxiliary pole using destination as

   // temporary pole

   tower(n-1, sourcePole, auxiliaryPole,

      destinationPole);
 

    // Move the remaining disk from source

   // pole to destination pole

   printf("Move the disk %d from %c to %c\n", 

    n,sourcePole, destinationPole);
 

   // Move the n-1 disks from auxiliary (now source)

   // pole to destination pole using source pole as

   // temporary (auxiliary) pole

   tower(n-1, auxiliaryPole, destinationPole,

     sourcePole);
}
int main()
{

   tower(3, 'S', 'D', 'A');

    

   return 0;
}


2)Recursion using mutual function call: (Indirect way) 
Indirect calling. Though least pratical, a function [funA()] can call another function [funB()] which inturn calls [funA()] former function. In this case both the functions should have the base case.
Defensive Programming:
We can combine defensive coding techniques with recursion for graceful functionality of application. Usually recursive programming is not allowed in safety critical applications, such as flight controls, health monitoring, etc. However, one can use a static count technique to avoid uncontrolled calls (NOT in safety critical systems, may be used in soft real time systems).


void recursive(int data)
{

   static callDepth;

   if(callDepth > MAX_DEPTH)

      return;
 

   // Increase call depth

   callDepth++;
 

   // do other processing

   recursive(data);
 

   // do other processing

   // Decrease call depth

   callDepth--;
}

callDepth depth depends on function stack frame size and maximum stack size.
Recursion using function pointers: (Indirect way) 
Recursion can also implemented with function pointers. An example is signal handler in POSIX complaint systems. If the handler causes to trigger same event due to which the handler being called, the function will reenter.
Parameter Passing Techniques in C
Published: 2021-05-14 14:34:49

There are different ways in which parameter data can be passed into and out of methods and functions. Let us assume that a function B() is called from another function A(). In this case A is called the “caller function” and B is called the “called function or callee function”. Also, the arguments which A sends to B are called actual arguments and the parameters of B are called formal arguments.
Pass By Value : This method uses in-mode semantics. Changes made to formal parameter do not get transmitted back to the caller. Any modifications to the formal parameter variable inside the called function or method affect only the separate storage location and will not be reflected in the actual parameter in the calling environment. This method is also called as call by value.
// C program to illustrate
// call by value
#include <stdio.h>

void func(int a, int b)
{
	a += b;
	printf("In func, a = %d b = %d\n", a, b);
}
int main(void)
{
	int x = 5, y = 7;

	// Passing parameters
	func(x, y);
	printf("In main, x = %d y = %d\n", x, y);
	return 0;
}

Pass by reference(aliasing) : This technique uses in/out-mode semantics. Changes made to formal parameter do get transmitted back to the caller through parameter passing. Any changes to the formal parameter are reflected in the actual parameter in the calling environment as formal parameter receives a reference (or pointer) to the actual data. This method is also called as call by reference. This method is efficient in both time and space.
// C program to illustrate
// call by reference
#include <stdio.h>

void swapnum(int* i, int* j)
{
	int temp = *i;
	*i = *j;
	*j = temp;
}

int main(void)
{
	int a = 10, b = 20;

	// passing parameters
	swapnum(&a, &b);

	printf("a is %d and b is %d\n", a, b);
	return 0;
}
How Relative Frequency Is Important for Predictions (Pandas)
Tags: datascience, analytics
Published: 2021-05-14 14:19:09

#What is the relative frequency? How to find it? And what importance does it serve?
>When analyzing data, sometimes knowing the value count of some of the entries in a certain column isn't enough to form an insight into what the data means. So, we obtain the relative frequency, which is the ratio of the frequency of a particular occurrence divided by the total number of occurrences.

>For example, if you can form meaningful insights from data 9 times out of 12, this means that this happens 75% of the time.

##How to find it in Pandas?
>Instead of using this:
```python
df['Column'].value_counts()
```
>You should add normalize=True
```python
df['Column'].value_counts(normalize=True)
```

>>The default of normalization is False, which doesn't take into account the frequency of the occurrence.

##The importance of Relative Frequency
>When you obtain the relative frequency of something, you're better able to get an insight into the probability of its occurrence, which means that you can make better predictions.

_Note: You can represent the probability distribution using histograms. And when representing the relative frequency using histograms, the heights would indicate the probability._
Deleting all Firebase users
Tags: firebase
Published: 2021-04-17 08:08:40

There are 100's of zombie users in my Firebase account and I was looking for efficient way of deleting all Firebase users. 

There are three ways in which we can delete users in Firebase
1. Using Client SDK: in which we can only delete the current user account
 `firebase.auth().currentUser?.delete();`
2. Login to Firebase console and delete user one by one from the web page. There is no bulk delete option.
3. Delete all user at once using Admin SDK 

I used third option because it is fastest. Let's go through steps of writing script to delete users using Admin SDK.

We need to write simple `node.js` script in which we will initialise Admin SDK and interact with Firebase in privileged environment.

Before this we will need to generate private key which is used in initialising Admin SDK. Below steps are copied form Firebase docs to generate key

> **To generate a private key file for your service account:**
> 1. In the Firebase console, open Settings > Service Accounts.
> 3. Click Generate New Private Key, then confirm by clicking Generate Key.
> 3. Securely store the JSON file containing the key.

Now we have the private key, lets start writing node script

Create a new folder. Run the following in terminal
```
npm init
sudo npm install firebase-admin --save
```

Now create an `index.js` file in this folder and copy the below script. Replace `serviceAccount` file path and `databaseURL`.

```
const admin = require("firebase-admin");
const serviceAccount = require("./path/to/serviceAccountKey.json");
const databaseURL = "https://project-name.firebaseio.com"

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: databaseURL
});

const deleteAllUsers = (nextPageToken) => {
  let uids = []
  admin
    .auth()
    .listUsers(100, nextPageToken)
    .then((listUsersResult) => {
      uids = uids.concat(listUsersResult.users.map((userRecord) => userRecord.uid))
      console.log(uids)
      if (listUsersResult.pageToken) {
        deleteAllUsers(listUsersResult.pageToken);
      }
    })
    .catch((error) => {
      console.log('Error listing users:', error);
    }).finally(() => {
      admin.auth().deleteUsers(uids)
    })
};

deleteAllUsers();
```

Above scripts fetch users in batch and collects uid of users. Which then are passed to `deleteUsers` function.

Above script will delete all the users in Firebase.