Skip to content

Instantly share code, notes, and snippets.

View okellogabrielinnocent's full-sized avatar
🖥️
Work with Ethics

Gabriel Okello okellogabrielinnocent

🖥️
Work with Ethics
View GitHub Profile

There are three ways to host multiple websites on a single server:

Name-based Virtual Hosting. IP-based Virtual Hosting. Port-based Virtual Hosting. In this tutorial, we will explain the process for hosting two websites on a single server in three different ways.

Prerequisites A fresh Ubuntu 18.04 VPS on the Atlantic.Net Cloud Platform. Two valid domain names or subdomain names pointed to your VPS IP address. In this tutorial, we will use site1.example.com and site2.example.com as subdomains.

PSQL

Run in the bash:

psql -U postgres

If this fails and throws psql: error: could not connect to server: FATAL: database "l" does not exist then run

psql -d template1

PSQL

Magic words:

psql -U postgres

If this fails and throws psql: error: could not connect to server: FATAL: database "l" does not exist then run

psql -d template1

PSQL

Magic words:

bash
psql -U postgres

If this fails and throws psql: error: could not connect to server: FATAL: database "l" does not exist then run

psql -d template1

PSQL

Magic words:

psql -U postgres

If this fails and throws psql: error: could not connect to server: FATAL: database "l" does not exist then run

To check if postgress was intalled and template1 is a database created by postgres itself, and is present on all installations.

{
$today_date = date('Y-m-d');
$today = $this->saleRepository->model::whereDate('create_at', $today_date)->get()->count();
$yesterday = $this->saleRepository->model::whereDate('created_at', date('Y-m-d', strtotime('-1 day')))->get()->count();
$month_date = date('m');
$month = $this->saleRepository->model::whereMonth('created_at', $month_date)->get()->count();
$previous_month = $this->saleRepository->model::whereMonth('created_at', date('m', strtotime('-1 month')))->get()->count();

Commands

Access monitor: mysql -u [username] -p; (will prompt for password)

Show all databases: show databases;

Access database: mysql -u [username] -p [database](will prompt for password)

Create new database: create database [database];

Select database: use [database];

# Transform the frequencies inside content_ratings to proportions and percentages while creating separate dictionaries for each.
# Assign the dictionary storing proportions to a variable named c_ratings_proportions.
# Assign the dictionary storing percentages to a variable named c_ratings_percentages.
# Optional challenge: try to solve this exercise using a single for loop (solution to this challenge provided).
content_ratings= {'4+': 4433, '12+': 1155, '9+': 987, '17+': 622}
total_number_of_apps = 7197
c_ratings_proportions = {}
c_ratings_percentages = {}
# Loop over the content_ratings dictionary and transform the frequencies to percentages. For every iteration of the loop:
# Transform the dictionary value (the frequency) to a proportion by dividing it by the total number of apps.
# Transform the updated dictionary value (the proportion) to a percentage by multiplying it by 100.
# Find out the percentage of apps that have a content rating of '17+'. Assign your answer to a variable named percentage_17_plus.
# Find out the percentage of apps that can be downloaded by a 15-year-old. Assign your answer to a variable named percentage_15_allowed.
content_ratings = {'4+': 4433, '12+': 1155, '9+': 987, '17+': 622}
total_number_of_apps = 7197
opened_file = open('AppleStore.csv')
from csv import reader
read_file = reader(opened_file)
apps_data = list(read_file)
genre_counting ={}
for row in apps_data[1:]:
genre= row[11]
if genre in genre_counting:
genre_counting[genre] += 1