teleren/devto huggingface dataset:
How to restore a postgreSQL database using command line
Tags: sql, database, tutorial
Published: 2022-05-25 12:52:21

In this article, I will be talking about One of the quickest ways to restore a database backup file on postgresql. When working with a new database file, it is more convenient to use the command line to restore the database, especially if the file is large so as to reduce query execution time.

**1. Locating the database file**
The first step is determine the location of the ".sql" file on your computer and change the directory in command line to the folder containing the database. In the example below we'll be using the "store.sql" database which is located in downloads. To change the directory you type "cd" followed by the file path then press Enter to switch to the new directory.


![Changing command line directory to the location of the database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8uflvgs5umhrn2ydusw.PNG)

---

**2. Running the postgresql application in command line**
After switching to the directory containing the database file, the next step is to run the postgersql executable file "psql.exe" in command line so that the database will be inserted through postgresql. to do this you have to copy the file path that contains the "psql.exe" file and the paste it in the command line wrapped up in quotes, this is to let the command line know that it should be run together.


![Running the psql executable file in command line](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cmvm4kqi1yknsgcjoc5u.PNG)

---

**3. Creating the database in PostgreSQL**
The next step is to create a database, this is the database that will house the backup file and this can be done using pgadmin. For this example we will create a database and name it "Store".


![creating a database on pdadmin](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5du1sso6sn0hu89iye7b.PNG)

---

**4. Upload the backup database file into the created database**
The last step is to upload the ".sql" file into the database that was created with pgadmin. to do this, following the line of code in step 2, you have to indicate the user "-U username" and the database "-d database_name". In this example the user is "postgres" which is the same as the "owner" from the picture in step 3, and the database_name is "Store", created in the previous step. once the user and the database have been indicated, you type "<" followed by the file name "store.sql" then press Enter to upload the database. you will the be prompted to input your user password and after the password has been correctly inputted, the backup file will be uploaded into the database.


![Uploading the backup file to the created database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nb209629jqk5t0bc0aro.PNG)


##
Changing is possible
Tags: lifestyle
Published: 2022-05-25 12:45:26

Many people complain about the fact that they don’t love their job instead they hate it.

I think that doing what you love is fundamental to having a happy life because we spend most of our time working. Surely, a job has ups and downs but what definitely matters is the way how you do things. If you leave space for improvement and provide the necessary rest when needed, you should have a more enjoyable experience at work.

So, instead of complaining, let’s begin to actively change, remembering that every goal is reached by the smallest steps, with a combination of “should’s” and “could’s”. Changing is a long process, awareness and engagement are key values to reach it. But don’t forget to rest!
Python Variables
Tags: python, programming, productivity, 100daysofcode
Published: 2022-05-25 12:39:48

Today let's discuss about variables in Python, what they are and how to use them.

## What are variables 
Variables are a kind of containers for storing data values. If you are familier with mathematics, then you have used variables there also. Similarly we also use variables in programming. But unlike mathematics you can change the value of a variable. 

Python is not statically typed. We do not need to declare variables before using them or declare their type. A variable is created the moment we first assign a value to it. A variable is a name given to a memory location. It is the basic unit of storage in a program.

- The value stored in a variable can be changed during program execution.
- A variable is only a name given to a memory location, all the operations done on the variable effects that memory location.

## Rules for creating variables in Python:

- A variable name must start with a letter or the underscore character.
- A variable name cannot start with a number.
- A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ).
- Variable names are case-sensitive (name, Name and NAME are three different variables).
- The reserved words(keywords) cannot be used naming the variable.

The code
```python
age = 45
salary = 1456.8
name = "John"
  
print(age)
print(salary)
print(name)
```
output:

```
45
1456.8
John
```

## Declare & re-declare variables
We can declare the variable by simply following the main rules of variable declaration. The re-declaration variables means we can change or update the value of the previously declared variable. We won't be able to work with the previous value of the variable after re-declaration

Let's see how to declare and re-declare variable and print them
```python
# declaring the var
Number = 100

# display
print("Before declare: ", Number)

# re-declare the var
Number = 120.3
	
print("After re-declare:", Number)
```

Output:

```
Before declare:  100
After re-declare: 120.3
```

---
If you like the content and want to get updates on more post like that please follow me @rhythmsaha

here are my social profiles
- github:[@rhythmsaha](https://github.com/rhythmsaha)
- linkedin: [@rhythmsaha](https://www.linkedin.com/in/rhythmsaha/)
- twitter: [@_rhythmsaha](https://twitter.com/_rhythmsaha)
HOW I UPLOADED A BACKED UP DATABASE TO A VALENTINA STUDIO USING COMMAND LINE
Tags: beginners, database, sql
Published: 2022-05-25 12:25:10

Thank you for checking out this post. I hope you find the content worth your time.

<u>**Valentina Studio is the ultimate data management tool for database administrators. Valentina Studio includes a wealth of database administration tools. It allows for easy integration and serves as a multi data management tool**
</u>

STEP 1:
Download and Install PostgreSQL on your device. https://www.postgresql.org/download/

STEP 2:
Download and Install Valentina on your device.
* Use a single password for both postgreSQL and valentina for easy remembrance and flexibility.

STEP 3:
Identify the directory where your database is located.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m296osbcbumdnb55vfr0.png) 

STEP 4: 
Open the folders to check for complete files.

STEP 5:
Open the search panel in your device and key in "cmd". Ignore the quote...

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

STEP 6:
Change the directory to where the database is located.
C:\Users\GodwinChiezugo><u>cd documents</u>
* In this case, my database is located at the documents folder.
* cd means change directory to what's written after it(documents, then to databases, and to employee where the data lives).

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

STEP 7:
Open your PgAdmin4 and input the password used during the installation process. Then open your Valentina and connect to the POSTGRES4, following the numbers as highlighted in the image below.

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

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

STEP 8:
Create a database in your Valentina as shown in the image below.

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

STEP 9:
Locate your file path in the program files, then copy and paste the location  
E.g C:\Program Files\PostgreSQL\14\bin
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x2pa0w22j5t9axk2i4oh.png)
**"C:\Program Files\PostgreSQL\14\bin\psql.exe"**
take note to add the file path name 'psql' and the execution function 'exe'.

STEP 10:
Include the specific user and name of the database created plus the direction the SQL file is going into _'<'_.
*  -U means user, -d means name of database created.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ldkfor1mfco2s6kmql0.png)
NOTE: always check for correct spelling of file names.

STEP 11:
Enter password and your data would load. Click on the Database created on valentina and reload to view the data inside.

THANK YOU!
Event Registration Landing Page
Tags: webdev, ux, programming, design
Published: 2022-05-25 11:56:36

Event Registration Landing Page

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

This Event Registration Landing Page Template is a great starting point for you to quickly create high quality, professional and modern looking landing page. The design of this landing page can be adapted in order to promote any business offers or products.

More effective event Landing Page Design to get go to UIHUT and purchase 17000+ design resources there.

Get 1 Year subscription only for $9/m (60% Discount) Use moy10 coupon code to get extra 10% discount.
A Beginners guide to Python. 🚀🔥
Tags: python, beginners, guide, programming
Published: 2022-05-25 11:55:12

## **What is Python**
Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.

It is used for:
1) web development (server-side),
2) software development,
3) mathematics,
4) system scripting.

## **What is Python used for?**
1. AI and machine learning
2. Data analytics
3. Data visualisation
4. Programming applications
5. Web development
6. Game development
7. Automation

## **Why Python?**
1) Python is Portable (works on Windows, Mac, Linux, Raspberry Pi, etc).
2) Python has a simple syntax similar to the English language.
3) Python has syntax that allows developers to write programs with fewer lines as compared to other programming languages.
4) Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
5) It supports all programming paradigms.

## **Let's Download Python**
Go on [Python's official site](https://www.python.org/) and download it.

## **Installing an IDE**
You can download any preferred IDE. I would be using PyCharm. You can download PyCharm from their [official site](https://www.jetbrains.com/pycharm/) and start coding.

For now write the below line of code and run it.
```py
print("Hello World!")
```

If you don't know, print() is a function that outputs the argument passed in the terminal.

## **Where to go now?**
You can check out these FREE courses-
1) [Programming with Mosh](https://www.youtube.com/watch?v=_uQrJ0TkZlc&vl=en)
2) [Edureka!](https://www.youtube.com/watch?v=WGJJIrtnfpk)
3) [freeCodeCamp](https://youtu.be/rfscVS0vtbw)
Why and When you need Feature Flags — with examples
Tags: programming, featureflags, examples, feature
Published: 2022-05-25 11:39:06


What is a Feature Flag?

Feature Flag is a coding practice where while working on a new feature, everything related to that feature will be developed in a such a way that the feature can be enabled/disabled from a boolean flag.

That means we don’t need to keep track of multiple branches in case of hot-fix. The app can easily be shipped with feature flag OFF and it will behave exactly like it was before the feature was introduced.

Feature flag are even more handy when there are multiple team members contributing to a repository. In that case, sometimes the team will have multiple features in progress and Feature Flag will be the ultimate solution.

Alright, enough with the intro, let’s move on to how you can start using them now!

You can more read on [blog.canopas.com](https://blog.canopas.com/why-and-when-do-you-need-feature-flags-with-examples-dd7c609e5413)
SQL Schema in Django Models
Tags: django, database, python, sql
Published: 2022-05-25 11:27:42

A schema in a SQL database is a list of logical data structures. It's commonly used for security-related management and permissions. 

The feature is supported by `PostgreSQL` and very well by Django. 
Let's see how to configure schema in Django for a `PostgreSQL` database. 

## Creating the database

First, ensure that the database is created.

```SQL
CREATE DATABASE coredb;

CREATE USER core WITH PASSWORD '12345678';

GRANT ALL PRIVILEGES ON DATABASE coredb TO core;
```

And let's create a schema. 

```SQL
CREATE SCHEMA AUTHORIZATION core;

CREATE SCHEMA IF NOT EXISTS coreschema AUTHORIZATION core;
```

We've created `coreschema` in the `coredb` database. And only the `core` user can access the schema for the moment. 

Let's see how to use it with Django.

## Django models configuration

Naturally, make sure that the Django project is configured with Django. It'll look like this.

```python
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'coredb',
        'USER': 'core',
        'PASSWORD': '12345678',
        'HOST': 'localhost',
        'PORT': 5432
    }
}
```

And when working with a model, use the `Meta` class to tell Django the name of the database table to use for the model.

```python
class Fruit(AbstractModel):

    name = models.CharField(max_length=100)

    class Meta:
        db_table = '"coreschema". "fruit"'
```

And run the migrations commands. And the table will be created under `coreschema`. 

Want to add something or have some comments? Let's discuss this in the comments section.

*Article posted using [bloggu.io](https://bloggu.io). Try it for free.*
Code Assignment That Was Given To Me During My Web Developer Interview - Episode 1
Tags: webdev, html, javascript, beginners
Published: 2022-05-25 11:26:20

{% embed https://youtu.be/TiKWM88Zwx4 %}

I thought it will be a great idea to share the information regarding the **code assignments** that were given to me during my **Web Development** related interviews 💯

So, I decided to create a **Youtube playlist** with multiple videos where in each video of that playlist, I will share details regarding a single coding assignment that was given to me from a company that I was interviewing for 👨‍💻

I have already created my first video for that playlist which you can find **[here](https://youtu.be/TiKWM88Zwx4)** or the one posted above. I will create more such videos in the future for this playlist and each video will include different coding assignment that was given to me from a different company with whom I was interviewing 🦄

I have also shared my solution ( what I was able to build based on the assignment ) in the video along with the result of the assignment ( if I was able to get shortlisted for the next round or not ) 😍

You should subscribe to my **[Youtube Channel](https://www.youtube.com/channel/UCIb8_J9lqtiWGMIOdQ5DVsg)** so you can stay updated with the entire series and also all my upcoming useful content that I will post there which will help you in your journey 🙌

**[This video](https://youtu.be/TiKWM88Zwx4)** is full of value so please make sure to watch the whole video, Drop a Like on that video and share your suggestions/feedback in the comment section of that video. Hope this helps 😇

---

Please do me a favour by **Reacting** to this post with 
❤️ + 🦄 and also bookmark 🔖 it for your future reference ✅

---

**Connect/Follow** me on Social platforms like Twitter, Linkedin where I regularly post Tips💡+ Guides📜 + Resources 🌟 related to Web Development and Programming 👨‍💻


![RammCodes Social Follow Request Banner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8a5vzbe9atsgmoll0oih.png)

### 🐦 **[My Twitter](https://twitter.com/rammcodes)**
### 👨‍💼 **[My Linkedin](https://www.linkedin.com/in/rammcodes/)**
### 🌐 **[My Website](https://rammaheshwari.com)**

---

Press the **Follow** button to stay updated with my content 🚀

Thanks for your **Support** ❤️
Entendendo let, const e escopo em javascript
Tags: javascript, beginners, braziliandevs
Published: 2022-05-25 11:25:03

## O que são variáveis?
Variáveis são espaços para guardar valores e utiliza-los em um futuro processamento.
No javascript utiliza-se palavras chaves(keywords) para declarar variáveis:

### Declarando uma variável com let
Para declarar uma variável utiliza a keyword let seguindo do nome da variável:
```js
let x; 
console.log(x); //undefined
```
Uma variável let declarada sem nenhum valor atribuido pelo programador, retorna com valor de undefined.

### Declarando uma variável com const

Variáveis utilizando const DEVEM ser declaradas com um valor inicial.
Apenas declarar, sem atribuir o valor gera o erro:
```js
const y;   // SyntaxError: Missing initializer in const declaration
```

# Entendendo o escopo de let e const
## O que é escopo?  
É o local onde a variável pode ser acessada ou está disponível.

### Escopo com let

```js
let a = "oi";

{
  let a = "hi!";
  
}
```
Aqui temos uma **variável a** declarada dentro de um bloco(escopo do bloco) e outra **variável a** fora do bloco (escopo global)
Temos dois escopos(áreas) diferentes.

Se eu tentar redeclarar a variável no mesmo escopo, gera um erro:

```js
let a = "Oi";
let a = "Hi!"; // SyntaxError: Identifier 'a' has already been declared
console.log(a);
```

Mas se eu declarar com o mesmo nome e em escopos diferentes:
```js
let a = "Oi";
{
  let a = "Hi!";
  console.log(`Valor dentro do bloco: ${a} `); // Valor dentro do bloco: Hi!
}

console.log(`Valor fora do bloco: ${a}`); // Valor fora do bloco: Oi
```     

Atualizando o valor de let:
```js
let a = "Oi";
a = "hahaha!";
{
  let a = "Hi!";
  console.log(`Valor dentro do bloco: ${a} `); // Valor dentro do bloco: Hi!
}

console.log(`Valor fora do bloco: ${a}`); // Valor fora do bloco: hahaha!
```
Mesmo atualizando o **valor de a** no escopo global, não interferiu na outra **variavel a** que foi declarada dentro do bloco.

Atualizando o valor de let no escopo de bloco:
```js
let a = "Oi";

{
  a = "hahaha!";
  console.log(`Valor dentro do bloco: ${a} `); // Valor dentro do bloco: hahaha!
}

console.log(`Valor fora do bloco: ${a}`); // Valor fora do bloco: Oi
```

## Escopo com const
const tem a mesma regra de redeclaração, porem seu valor não pode ser atualizado
```js
const a = "Oi"
{
  const a = "HI"
  console.log(`Valor dentro do bloco: ${a} `) 
}

function exibir() {
  const a = "Estou dentro da função!"
  console.log(a)
}

exibir()
console.log(`Valor fora do bloco: ${a}`) 
// Valor dentro do bloco: HI 
// Estou dentro da função!
// Valor fora do bloco: Oi
```
```js
const a = "Oi"
{
  a = "HI"
  console.log(`Valor dentro do bloco: ${a} `) 
}
console.log(`Valor fora do bloco: ${a}`) 
// TypeError: Assignment to constant variable.
```
```js
const a = "Oi"
function exibir() {
  a = "Estou dentro da função!"
  console.log(a)
}

exibir()
console.log(`Valor fora do bloco: ${a}`) 
// TypeError: Assignment to constant variable.
```

<br>**Resumindo**<br>
let:
NÃO PODE ser redeclarada no MESMO escopo
PODE ter seu valor atualizado 

const:
NÃO PODE ser redeclarada no MESMO escopo
NÃO PODE ter seu valor atualizado
Important JavaScript Shorthands to know 🚀🔥
Tags: javascript, webdev, expert, programming
Published: 2022-05-25 11:21:58

## **1) The Ternary Operator**

## Longhand-

```js
const x = 20;
let answer;
if (x > 10) {
    answer = "greater than 10";
} else {
    answer =  "less than 10";
}
```

## Shorthand
```js
const answer = x > 10 ? "greater than 10" : "less than 10";
```

## **2) Declaring Variables Shorthand**

## Longhand-
```js
let x;
let y;
let z = 3;
```

## Shorthand
```js
let x, y, z=3;
```

## **3) If True Presence Shorthand**

## Longhand-
```js
if (likeJavaScript === true)
```

## Shorthand
```js
if (likeJavaScript)
```

## **4) If Not True Presence Shorthand**

## Longhand-
```js
if (!likeJavaScript === true)
```

## Shorthand
```js
if (!likeJavaScript)
```

## **5) Arrow Function Shorthand**

## Longhand-
```js
function doAnything(){}
```

## Shorthand
```js
let doAnything = () => {}
```
How to redirect the domain to the port number using Nginx and set up SSL?
Tags: aws, nginx, ssl, https
Published: 2022-05-25 11:06:33


# Nginx Configuration Setup

## [ Install Nginx ](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04)
```bash
sudo apt update
sudo apt install nginx
```

## Link port with domain
Open this file in nano or vim `/etc/nginx/nginx.conf`
```bash
http{
  server{
    listen 80;
    server_name DOAMIN.com www.DOMAIN.com;
    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header Host $http_host;
      proxy_pass http://<IP_ADDRESS>;
    }
  }
}
```
After updating nginx.conf apply this commands 
Test nginx.conf `sudo nginx -t`
Restart nginx service `sudo systemctl restart nginx` or `sudo service nginx restart`
Check nginx status `sudo systemctl status nginx` or `sudo service nginx status`

## Issue ssl certificate from certbot
Ref: https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/

### Install certbot
```bash
sudo apt-get update
sudo apt-get install certbot
sudo apt-get install python-certbot-nginx
```

### Obtain the SSL/TLS Certificate
`sudo certbot --nginx -d example.com -d www.example.com`

It'll handle the required modification for https in nginx.conf

### [Automatically Renew Let’s Encrypt Certificates](https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/#auto-renewal)

`crontab -e`
`0 12 * * * /usr/bin/certbot renew --quiet`


# Manually setup SSL and https configuration on nginx
```bash
http{
  server{
    listen 80;
    server_name spotcodes.in www.spotcodes.in;
    return 301 https://$server_name$request_uri;
  }

  server {
    listen 443 ssl;
    server_name spotcodes.in www.spotcodes.in;

    ssl_certificate /etc/letsencrypt/live/spotcodes.in/cert.pem;
    ssl_certificate_key /etc/letsencrypt/live/spotcodes.in/privkey.pem;

    location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Host $http_host;
    proxy_pass http://3.83.202.107:2001;
    }
  }
}
```
<hr />

### Test SSL certificate installation
https://www.experte.com/ssl-check

#### Usefull links and credits
- https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/#auto-renewal
- https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04
- https://levelup.gitconnected.com/how-to-install-ssl-certificate-for-nginx-server-in-amazon-linux-2986f51371fb
- https://www.youtube.com/watch?v=X3Pr5VATOyA