teleren/devto huggingface dataset:
SDC Day 10
Published: 2021-03-26 10:57:48

Today I deployed my PostgreSQL database to an EC2 instance and seeded the data. The main difficulties were setting up my SSH(Secure Shell) and expanding the storage as needed. I learned that I can edit the SSH config file so that I can start up my instances more easily. Once I connected to the instance, I then used PGAdmin to access my instance and manually add the tables I needed. Seeding was an easy process that only required me to import the csv files into the tables! However, while importing my last table I realized that my 8GB of storage was not enough for the final csv to import. I then upgraded it to 12GB on AWS and then expanded the partition in SSH to reflect the new storage changes. This however was still not enough and I was then blocked from changing the storage for another 6 hours. In order to keep the progress moving, I decided to make an image of my instance and launch a new 30GB instance using that image. This created an exact copy of my instance with all the previously seeded data present. I was then able to finish importing and seeding my database!
SDC Day 9
Published: 2021-03-26 10:49:30

I finally finished my last endpoint with a single query! I was really close to giving up and using a naive solution but I was able to figure out the query just in time. I ended up changing up the structure of my query to aggregate within my LEFT JOIN LATERAL clauses. Normally using regular LEFT JOINs would give me duplicated data that seemed to multiply off each other. LATERAL allows the sub-SELECT to refer to columns of FROM items that appear before it in the FROM list. What an interesting query! I'm not sure if anyone else did it like I did, but I'm very proud of my solution.
How to show Array of errors in Vue.js ? Backend Validation with Laravel Help plz ?
Published: 2021-03-26 10:15:56

Hi, I have some complex data and I want to show the validation error array data in vue file but I can not because I have got some data that has index please share your opinion 

vue file

```
<template>
  <div>
    <form enctype="multipart/form-data" @submit.prevent="handleSubmit">
      <div v-for="(contact, index) in contacts" :key="index" class="row">
        <div class="col col-md-3">
          <div class="form-group mb-4">
            <label for="personName">Contact Person Name</label>
            <input
              id="personName"
              v-model="contact.name"
              type="text"
              class="form-control"
            />
            <small> Want to show here the error ? </small
            >
          </div>
        </div>

        <!-- Add or Remove button -->

        <div class="col col-md-12 text-right">
          <div class="row ml-4">
            <div v-show="index == contacts.length - 1">
              <button
                class="btn btn-warning mb-2 mr-2 btn-rounded"
                @click.prevent="add"
              >
                Add More
              </button>
            </div>
            <div v-show="index || (!index && contacts.length > 1)">
              <button
                class="btn btn-danger mb-2 mr-2 btn-rounded"
                @click.prevent="remove"
              >
                Remove
              </button>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      contacts: [
        {
          name: "",
        },
      ],

      errors: [],
    };
  },
  methods: {
    handleSubmit() {
      let data = new FormData();
      data.append("contacts", JSON.stringify(this.contacts));

      Request.POST_REQ(data, "/add-institute")
        .then(() => {
          alert("success");
        })
        .catch((err) => {
          this.errors = err.response.data.errors;
        });
    },
    add() {
      this.contacts.push({
        name: "",
        email: "",
        phone: "",
        alternate_phone: "",
      });
    },
    remove(index) {
      this.contacts.splice(index, 1);
    },
  },
};
</script>

```

controller file

```

public function add_institute(Request $request) {
  $request['contacts'] = json_decode($request['contacts'], true);
  $request->validate([
      'contacts.*.name'=> 'unique:institute_contact_people|distinct',
  ]);

  ...rest of code of insert 

  return response()->json("Success...");
}

```

Getting Response data

```
errors: {
  contacts.0.name: ["The contacts.0.name has already been taken.", "The contacts.0.name field has a duplicate value."]
  0: "The contacts.0.name has already been taken."
  contacts.1.name: ["The contacts.1.name has already been taken.", "The contacts.1.name field has a duplicate value."]
  0: "The contacts.1.name has already been taken."
}
```
Using React in JSFiddle, Coderpad, or just an HTML page
Tags: react, coderpad, interview, webdev
Published: 2021-03-26 10:13:02

Sometimes we may need to use React in Coderpad when we interview candidates or get interviewed.

There is actually a way to do that easily in Coderpad:

1. Just change the language to `HTML`
2. Choose the Packages next to that, and choose `React`

Then we can write code such as

```js
<script
  src="https://unpkg.com/react@17/umd/react.development.js"
  crossorigin
></script>
<script
  src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
  crossorigin
></script>

<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

<div id="root"></div>

<script type="text/babel">
  function App() {
    const [count, setCount] = React.useState(0);

    function handleClick() {
      setCount((c) => c + 1);
    }

    return (
      <div>
        count: {count} <button onClick={handleClick}>Click</button>
      </div>
    );
  }

  ReactDOM.render(<App />, document.getElementById("root"));
</script>
```

Demo in Coderpad (if it can allow public access): https://app.coderpad.io/G7E9DQQT

Demo in JSFiddle: https://jsfiddle.net/d9m68rft/

Or demo in Codesandbox: https://codesandbox.io/s/brave-leaf-6dmbu?file=/index.html

One issue is that as of right now, Coderpad or JSFiddle cannot auto format our code with the JSX, and sometimes the code is a bit messy due to indentation.  Codesandbox can reformat everything on File -> Save, but some companies disallow moving the code to else where and pasting in back to Coderpad, to discourage cheating, probably.

Coderpad current uses React 16.13.1 and it is good enough for React Hooks.  To be able to use React Hooks, we must use React 16.8 or above. 
 The scripts in the above code is suggested by the React documentation itself: https://reactjs.org/docs/add-react-to-a-website.html

We can also see the different versions of React files that can be included, in: https://cdnjs.com/libraries/react

JSFiddle has a React choice, but it requires a little bit of configuartion. The best website to use React is https://codesandbox.io I found.

Codersandbox is a bit tricky to share with another person. One time I had to constantly save the file, and ask the other person to constantly refresh her page.  I often had to ask, "do you see the updates?"

It can in fact be quite easy:

1. On the left side of the window, click on the bottom icon, which is "Share"

![Codesandbox to share](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b9lxt8uxj66cc6qf2wff.png)

2. And then, copy that "live" link and share with the other person:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0yd9necouw2d0l7jeba8.png)

It is somewhat a pity that some companies do not allow using Codesandbox because they have more control using Coderpad with replaying the interview.  But I suppose one way is to be so good in it, that the interviewer is totally impressed and can vow that you said and typed everything yourself, and vow to say that you are one of the best candidates he has met so far and recommend a strong hire.
Zuri Training
Published: 2021-03-26 10:10:11

So...here we are. I saw a post on twitter one day about a training that would take place with **Zuri** in partnership with **Ingessive4Good** and **HNG** all over it and decided, 'why not try this? you never know'. Getting that welcome email was the most exciting part for me because I never thought I would be accepted. I am all in it to learn and gain the most because who knows when such an opportunity will come by again.

We are still working on our first task of creating a CV and uploading some links but am super excited and looking forward to the whole process. Each task has a period of 2 weeks to complete it so as to accommodate those who are not always online. The tasks so far are also very friendly.

We have started our classes with links being uploaded on YouTube and on zuriboard. We also have awesome **resources** coming our way. The best part is the **mentors**. Ever had of patient people, because these ones are super patient and always ready to assist.

I will keep in touch about the whole process but for now, that's all from me. Chao!!
How to create a Variable in python 
Published: 2021-03-26 09:55:21

What is a variable?
A variable is a very important function in python. In fact, variables arent just important in python, it is important in all programming languages like javascript Lua, etc. 


How do I create a variable?
The code below is shown to how to create a variable.

```python
a = "Hello this is an example"
print (a)

``` 
Why is this important?
Variables in very important because variables can be in many programming languages. Like javascript, C, PHP, etc. 


Conclusion
At the end of the day, Programming variables can be very important.
Documenting My Web Dev Journey 
Tags: webdev, javascript, react, algorithms
Published: 2021-03-26 09:46:14

Hello World!

My name is Adan I am excited and eager to document my goals and accomplishment as I embark on this journey to take my coding skills to the next level. They say you can't climb a mountain if it's smooth, you gotta go up the rough edges to make it to the top.

My goal is write about all the materials that I want to absolutely master. It will also help me stay focus on one particular topic at a time. 

please be patient with me as I will make tons of mistakes, run in to dead ends and might get stuck on a problem longer than I will enjoy. 

Thank you for listening and being part of my experience!
Método indexOf - JavaScript
Tags: javascript, tutorial, webdev, beginners
Published: 2021-03-26 09:44:07

O método **indexOf()** retorna o valor do primeiro índice em que o elemento for encontrado no array. Caso contrário será retornado -1, indicando que o elemento não existe no array.

## **Parâmetros**

**searchElement -** Elemento a ser pesquisado no array.

**fromIndex -** O índice para iniciar a procura e tem o valor padrão 0. Caso o valor passado seja maior ou igual ao tamanho do array, é retornado -1 e significa que o item não será procurado. Caso o valor seja negativo, a procura do array será de trás pra frente. (Opcional)

### Sintaxe

```jsx
const elementIndex = numbers.indexOf(searchElement, fromIndex);
```

## **Retorno**

O método **indexOf()** retorna o valor do índice em que o elemento for encontrado no array. Caso contrário será retornado -1, indicando que o elemento não existe no array.

## Exemplos

Retorna o índice do elemento que contém o valor 10

```jsx
const numbers = [10, 6, 8, 19, 18, 20];

const elementIndex = numbers.indexOf(10);
// elementIndex -> 0
```

Retorna o índice do elemento que contém o valor 19, procurando a partir do índice 3

```jsx
const numbers = [10, 6, 8, 19, 18, 20];

const elementIndex = numbers.indexOf(19, 3);
// elementIndex -> 3
```

<a href="https://www.notion.so/elianbecali/indexOf-5ab39a1ca4be467da35fe6d5ac251492" target="_blank">Método indexOf | Notion
</a>
<a href="https://www.youtube.com/watch?v=M5wZE8ptqEc" target="_blank">Método indexOf | Youtube
</a>
Speedup your javaScript code using this for loops , analysis using "benchmarkjs" tool. 
Tags: javascript, es6
Published: 2021-03-26 09:42:49

Hello, programmers and enthusiastic learner, hope you all having great day. So in last post I had analyze execution time of various loops in javaScript using **console object**. Today I am going to analyze it using **benchmarkjs tool** , thanks for **Conner Peet**  for his valuable suggestion.
    So let's start...

```javascript

const cars = ["Tesla", "Tata", "Ford", "Land Rover", "Audi"];

let myCars;

//For-let loop
bench("for-let i++", () => {
  for (let i = 0; i < cars.length; i++) {
    myCars = cars[i];
  }
});

//For-let (i--) loop
bench("for-let i--", () => {
  for (let i = cars.length - 1; i >= 0; i--) {
    myCars = cars[i];
  }
});

//forEach Loop
bench("forEach", () => {
  cars.forEach((car) => {
    myCars = car;
  });
});

//For of loop
bench("for of", () => {
  for (const car of cars) {
    myCars = car;
  }
});

//For in loop
bench("for in", () => {
  for (const car in cars) {
    myCars = car;
  }
});

//map
bench("map", () =>
  cars.map((car) => {
    myCars = car;
  })
);

//Output

D:\JavaScript\Loops> matcha loops.js

         12,200,000 ops/sec > for-let i++ (24.4x)
         10,300,000 ops/sec > for-let i-- (20.6x)
         11,200,000 ops/sec > forEach (22.4x)
          7,080,000 ops/sec > for of (14.1x)
            502,000 ops/sec > for in (1x)
          5,760,000 ops/sec > map (11.5x)

  Benches: 6
  Fastest: for-let i++
  Elapsed: 35.5s


```
I used this [tool](https://github.com/connor4312/matcha), by **Conner Peet**.
Hope this article add some value to your skill , Your precious suggestions and advice are always welcome!
deploy flask app to iis on windows server
Published: 2021-03-26 09:41:16

hi,
i need help to deploy flask web app thati have already created in visual studio 2019 and i need to know how to deploy it to iis web server ,i really got frustrated from the lack of helpful resources in this stuff,all over the web, people talk about configuring a web.config file of the flask app which i can't really found in the rooy folder of the application, any help is highly appreciated?
Nuxt: Ignore SSL issues for axios proxy (Development only)
Tags: vue, javascript
Published: 2021-03-26 09:29:59

I just recently came across an issue, where me and my colleague were live sharing backend (in .net) and I was consuming it in Nuxt application but I was getting `UNABLE_TO_VERIFY_LEAF_SIGNATURE` and `DEPTH_ZERO_SELF_SIGNED_CERT`, SSL issues with nodejs and axios proxy.

All the ajax requests in (my) nuxt app goes through axios proxy plugin. 

Usually this SSL issue happens because you are running or consuming a HTTPS server, but your machine cannot validate the SSL certificate.

After some research, I found an easy way to disable SSL checks (only for local development environment, please).
Here is what I am doing in my `nuxt.config.js` file.

(Here I am also assuming that you already have `ENV` environment variable setup)

```javascript
{
// nuxt.config.js
...
    proxy: {
        '/api/': {
            target: process.env.MAIN_API_URL, // a url for your api
            secure: !process.env.ENV === 'development'
        }
    }
}
```

Again, `secure: false` should be only setup when you are testing locally. Hope this saves you some hours of frustration :)
Implementing Min Heap in Java
Tags: heap, datastructure, priorityqueue, java
Published: 2021-03-26 09:18:30

A **Min-Heap** is a complete binary tree in which the value in each internal node is smaller than or equal to the values in the children of that node.  
Mapping the elements of a heap into an array is trivial: if a node is stored an index **n**, then its left child is stored at index **2n+1** and its right child at index **2n+2**.
### Example
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h2m0p24w67wxie4h8pf3.png)

#### Min Heap Representation
A Min heap is typically represented as an array.
Consider an array `Arr[]` with root at `Arr[0]`. For any **i<sup>th</sup>** node, i.e., **Arr[i]**:  
* `Arr[(i -1) / 2]` returns its parent node.
* `Arr[(2 * i) + 1]` returns its left child node.
* `Arr[(2 * i) + 2]` returns its right child node.

#### Operations on Min Heap
1. **getMin()**: It returns the root element of Min Heap. Time Complexity of this operation is **O(1)**.
2. **extractMin()**: Removes the minimum element from MinHeap. Time Complexity of this Operation is **O(Log n)** as this operation needs to maintain the heap property (by calling heapify()) after removing root.
3. **insert()**: Inserting a new key takes **O(Log n)** time. We add a new key at the end of the tree. If new key is larger than its parent, then we don’t need to do anything. Otherwise, we need to traverse up to fix the violated heap property.

#### Implementation of Min Heap in Java using Priority Queues
Here’s how you can implement a min heap using `PriorityQueue` class in Java. By default Min Heap is implemented by this class.

```
import java.util.*;
public class MinHeap {
	static PriorityQueue<Integer> minHeap = new PriorityQueue<Integer>();
	public static void main(String args[]) {
		
		// Adding elements using add()
		minHeap.add(8);
		minHeap.add(5);
		minHeap.add(13);
		minHeap.add(2);
		minHeap.add(23);
		minHeap.add(16);
		
		// Displaying minHeap elements
		print();
		
		// Find number of elements using size()
		System.out.println("Size of heap = "+minHeap.size());
		
		// View head using peek()
		System.out.println("Head = "+minHeap.peek());
		
		// Remove head and modify Heap using poll()
		minHeap.poll();
		System.out.println("Heap after removing head");
		print();
		
		// Remove specific element using remove()
		minHeap.remove(8);
		System.out.println("Heap after removing 8");
		print();
		
		// Check if an element is present using contains()
		boolean flag=minHeap.contains(15);
		System.out.println("Does heap contain element 15? " +flag);
		
		System.out.println("Size of heap = "+minHeap.size());
	}
	public static void print() {
		System.out.print("Min Heap : ");
		for(Integer i:minHeap)
			System.out.print(i+" ");
		System.out.println("\n");
	}
}
```

**Output**
```
Min Heap : 2 5 13 8 23 16 

Size of heap = 6
Head = 2
Heap after removing head
Min Heap : 5 8 13 16 23 

Heap after removing 8
Min Heap : 5 16 13 23 
```
Public #dataviz from Bigquery in the browser
Tags: datascience, bigdata, security, showdev
Published: 2021-03-26 09:12:23

Over the last few months I have been solving a series of technical challenges that allows making BigQuery derived data visualisations public, completely within the browser, using free tools. The important thing is that your BigQuery credentials remain protected, yet you still do not need to run a server, or pay any money!

A powerful browser based literate coding and dataviz environment is provided by [Observable](https://observablehq.com).

My tutorial covers

- Creating a Service Account
- Password protecting it with with SubtleCrypto
- Instantiating a BQ client in the browser using GAPI
- Logging into Firebase Storage using a service account
- Setting up Firebase Security Rules.
- Reading and Writing to Firebase storage

Checkout the [full tutorial here](https://observablehq.com/@endpointservices/cache-bigquery
). It's written in a notebook so the tutorial is executable and you can fork it to make your own BQ integration.
Wordpress Dockerfile
Published: 2021-06-17 08:25:17

---
title: Wordpress Dockerfile
published: true
date: 2021-03-26 09:09:09 UTC
tags: 
canonical_url: https://boobo94.github.io//devops/wordpress-docker/
---

```
version: '3'

services:
  # Database
  db:
    image: mysql:5.7
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    ports:
      - "3306:3306"
    environment:
      MYSQL_ROOT_PASSWORD: wordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress
    networks:
      - wpsite
  # phpmyadmin
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - '8080:80'
    environment:
      PMA_HOST: db
      MYSQL_ROOT_PASSWORD: wordpress 
    
    networks:
      - wpsite
  # Wordpress
  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - "8000:80"
    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: wordpress
      WORDPRESS_DB_NAME: wordpress
    networks:
      - wpsite

networks:
  wpsite:
volumes:
  db_data:

```

Official [documentation](https://docs.docker.com/compose/wordpress/)
How to make money with a blog - I earn up to 50 $ per day with a blog
Tags: beginners, blog
Published: 2021-03-26 08:45:22

Hello, friends my name is **Rahul** and in this article of today we will talk (***<a href="https://blog.stackfindover.com/how-to-make-money-with-a-blog/">How to make money with a blog</a>***) about how we can earn a good amount of money by using a blog, so let’s start this awesome article today.

###My blogging journey###
Today I tell you a bit about my **blogging journey**. When I completed college, I could not understand what I should do next. After 3 months of completing college, I joined an IT company and I learned a lot there and after 6 months, my friend and I made a plan that we create a website like <a href="https://stackoverflow.com/">StackOverflow</a>.

#### #1 Domain Name is Most Important####

The biggest problem was that we have to think of a good domain name. the first night we thought a lot and finally, we got a domain <a href="https://stackfindover.com">Stackfindover</a> The best thing about this domain was that it was similar to Stackoverflow.

We worked very hard on this domain and we had created a website like **StackOverflow**, but that site was not popular, and later we had to close it.

#### #2 Write up to 20 articles####
I still remember that I thought that this domain will pay good money someday. and it happened, after 1 month I made a <a href="https://en.wikipedia.org/wiki/Subdomain">subdomain</a> and started putting articles in it, I had published about **20 articles**.

#### #3 Applying for publishing Ads####
I applied for **Google AdSense Ads** and Google rejected my site many times but I **never gave up** and finally, the day had come, for the day I had waited for a **long time**.

###How to make money with a blog###
There are many methods to **earn money from a blog**. Today we will learn about some methods which are very popular.

1. **Google AdSense Ads**
2. **Other Ads Network**
3. **Affiliate marketing**
4. **eBook writing and selling**
5. **Publishing Sponsored Post**


###<a href="https://blog.stackfindover.com/how-to-make-money-with-a-blog/">Read Full Article</a>###