Month 5

Download as pdf or txt
Download as pdf or txt
You are on page 1of 201

0x06. Regular expression


RegexDevOps

● By: Sylvain Kalache

● Weight: 1

● Project over - took place from May 3, 2023 6:00 AM to May 4, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…

● Auto QA review: 22.95/24 mandatory & 5.85/9 optional


● Altogether: 157.79%
○ Mandatory: 95.63%
○ Optional: 65.0%
○ Calculation: 95.63% + (95.63% * 65.0%) == 157.79%

Concepts
For this project, we expect you to look at this concept:

● Regular Expression

Background Context
For this project, you have to build your regular expression using Oniguruma, a regular
expression library that which is used by Ruby by default. Note that other regular expression
libraries sometimes have different properties.

Because the focus of this exercise is to play with regular expressions (regex), here is the
Ruby code that you should use, just replace the regexp part, meaning the code in between
the //:

sylvain@ubuntu$ cat example.rb


#!/usr/bin/env ruby
puts ARGV[0].scan(/127.0.0.[0-9]/).join
sylvain@ubuntu$
sylvain@ubuntu$ ./example.rb 127.0.0.2
127.0.0.2
sylvain@ubuntu$ ./example.rb 127.0.0.1
127.0.0.1
sylvain@ubuntu$ ./example.rb 127.0.0.a

Resources
Read or watch:

● Regular expressions - basics


● Regular expressions - advanced
● Rubular is your best friend
● Use a regular expression against a problem: now you have 2 problems
● Learn Regular Expressions with simple, interactive exercises

Requirements
General

● Allowed editors: vi, vim, emacs


● All your files will be interpreted on Ubuntu 20.04 LTS
● All your files should end with a new line
● A README.md file, at the root of the folder of the project, is mandatory
● All your Bash script files must be executable
● The first line of all your Bash scripts should be exactly #!/usr/bin/env ruby
● All your regex must be built for the Oniguruma library

Quiz questions

Great! You've completed the quiz successfully! Keep going! (Show quiz)

Tasks
0. Simply matching School

mandatory

Score: 100.0% (Checks completed: 100.0%)

Requirements:
● The regular expression must match School
● Using the project instructions, create a Ruby script that accepts one argument and
pass it to a regular expression matching method

Example:

sylvain@ubuntu$ ./0-simply_match_school.rb School | cat -e


School$
sylvain@ubuntu$ ./0-simply_match_school.rb "Best School" | cat -e
School$
sylvain@ubuntu$ ./0-simply_match_school.rb "School Best School" | cat -e
SchoolSchool$
sylvain@ubuntu$ ./0-simply_match_school.rb "Grace Hopper" | cat -e
$

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 0-simply_match_school.rb

Done! Help Check your code Get a sandbox QA Review

1. Repetition Token #0

mandatory

Score: 100.0% (Checks completed: 100.0%)


Requirements:

● Find the regular expression that will match the above cases
● Using the project instructions, create a Ruby script that accepts one argument and
pass it to a regular expression matching method

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 1-repetition_token_0.rb

Done! Help Check your code Get a sandbox QA Review

2. Repetition Token #1

mandatory

Score: 100.0% (Checks completed: 100.0%)


Requirements:

● Find the regular expression that will match the above cases
● Using the project instructions, create a Ruby script that accepts one argument and
pass it to a regular expression matching method

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 2-repetition_token_1.rb

Done! Help Check your code Get a sandbox QA Review

3. Repetition Token #2

mandatory

Score: 100.0% (Checks completed: 100.0%)


Requirements:

● Find the regular expression that will match the above cases
● Using the project instructions, create a Ruby script that accepts one argument and
pass it to a regular expression matching method

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 3-repetition_token_2.rb

Done! Help Check your code Get a sandbox QA Review

4. Repetition Token #3

mandatory

Score: 76.67% (Checks completed: 100.0%)


Requirements:

● Find the regular expression that will match the above cases
● Using the project instructions, create a Ruby script that accepts one argument and
pass it to a regular expression matching method
● Your regex should not contain square brackets

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 4-repetition_token_3.rb

Done! Help Check your code Get a sandbox QA Review

5. Not quite HBTN yet

mandatory

Score: 100.0% (Checks completed: 100.0%)


Requirements:

● The regular expression must be exactly matching a string that starts with h ends with
n and can have any single character in between
● Using the project instructions, create a Ruby script that accepts one argument and
pass it to a regular expression matching method

Example:

sylvain@ubuntu$ ./5-beginning_and_end.rb 'hn' | cat -e


$
sylvain@ubuntu$ ./5-beginning_and_end.rb 'hbn' | cat -e
hbn$
sylvain@ubuntu$ ./5-beginning_and_end.rb 'hbtn' | cat -e
$
sylvain@ubuntu$ ./5-beginning_and_end.rb 'h8n' | cat -e
h8n$
sylvain@ubuntu$
$

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 5-beginning_and_end.rb

Done! Help Check your code Get a sandbox QA Review

6. Call me maybe
mandatory

Score: 82.5% (Checks completed: 100.0%)

This task is brought to you by a professional advisor Neha Jain, Senior Software Engineer at
LinkedIn.

Requirement:

● The regular expression must match a 10 digit phone number

Example:

sylvain@ubuntu$ ./6-phone_number.rb 4155049898 | cat -e


4155049898$
sylvain@ubuntu$ ./6-phone_number.rb " 4155049898" | cat -e
$
sylvain@ubuntu$ ./6-phone_number.rb "415 504 9898" | cat -e
$
sylvain@ubuntu$ ./6-phone_number.rb "415-504-9898" | cat -e
$
sylvain@ubuntu$

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 6-phone_number.rb

Done! Help Check your code Get a sandbox QA Review

7. OMG WHY ARE YOU SHOUTING?

mandatory

Score: 100.0% (Checks completed: 100.0%)


Requirement:

● The regular expression must be only matching: capital letters

Example:

sylvain@ubuntu$ ./7-OMG_WHY_ARE_YOU_SHOUTING.rb "I realLy hOpe VancouvEr


posseSs Yummy Soft vAnilla Dupper Mint Ice Nutella cream" | cat -e
ILOVESYSADMIN$
sylvain@ubuntu$ ./7-OMG_WHY_ARE_YOU_SHOUTING.rb "WHAT do you SAY?" | cat -e
WHATSAY$
sylvain@ubuntu$ ./7-OMG_WHY_ARE_YOU_SHOUTING.rb "cannot read you" | cat -e
$
sylvain@ubuntu$

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 7-OMG_WHY_ARE_YOU_SHOUTING.rb

Done! Help Check your code Get a sandbox QA Review

8. Textme

#advanced
Score: 65.0% (Checks completed: 100.0%)

This exercise was prepared for you by Guillaume Plessis, VP of Infrastructure at TextMe. It is
something he uses daily. You can thank Guillaume for his project on Twitter.

For this task, you’ll be taking over Guillaume’s responsibilities: one afternoon, a TextMe VoIP
Engineer comes to you and explains she wants to run some statistics on the TextMe app text
messages transactions.

Requirements:

● Your script should output: [SENDER],[RECEIVER],[FLAGS]


○ The sender phone number or name (including country code if present)
○ The receiver phone number or name (including country code if present)
○ The flags that were used

You can find a [log file here].

Example:

$ ./100-textme.rb 'Feb 1 11:00:00 ip-10-0-0-11 mdr: 2016-02-01 11:00:00 Receive


SMS [SMSC:SYBASE1] [SVC:] [ACT:] [BINF:] [FID:] [from:Google] [to:+16474951758]
[flags:-1:0:-1:0:-1] [msg:127:This planet has - or rather had - a problem,
which was this: most of the people on it were unhappy for pretty much of the
time.] [udh:0:]'
Google,+16474951758,-1:0:-1:0:-1
$
$
$ ./100-textme.rb 'Feb 1 11:00:00 ip-10-0-64-10 mdr: 2016-02-01 11:00:00
Receive SMS [SMSC:SYBASE2] [SVC:] [ACT:] [BINF:] [FID:] [from:+17272713208]
[to:+19172319348] [flags:-1:0:-1:0:-1] [msg:136:Orbiting this at a distance of
roughly ninety-two million miles is an utterly insignificant little blue green
planet whose ape-descended] [udh:0:]'
+17272713208,+19172319348,-1:0:-1:0:-1
$
$ ./100-textme.rb 'Feb 1 11:00:00 ip-10-0-64-11 mdr: 2016-02-01 11:00:00 Sent
SMS [SMSC:SYBASE1] [SVC:backendtextme] [ACT:] [BINF:] [FID:] [from:18572406905]
[to:14022180266] [flags:-1:0:-1:-1:-1] [msg:136:Far out in the uncharted
backwaters of the unfashionable end of the western spiral arm of the Galaxy
lies a small unregarded yellow sun.] [udh:0:]'
18572406905,14022180266,-1:0:-1:-1:-1
$
$
$ ./100-textme.rb 'Feb 1 11:00:00 ip-10-0-64-11 mdr: 2016-02-01 11:00:00 Sent
SMS [SMSC:SYBASE1] [SVC:backendtextme] [ACT:] [BINF:] [FID:] [from:12392190384]
[to:19148265919] [flags:-1:0:-1:-1:-1] [msg:99:life forms are so amazingly
primitive that they still think digital watches are a pretty neat idea.]
[udh:0:]'
12392190384,19148265919,-1:0:-1:-1:-1
$

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x06-regular_expressions
● File: 100-textme.rb

Done! Help Check your code Get a sandbox QA Review

Copyright © 2023 ALX, All rights reserved.

0x07. Networking basics #0


DevOpsNetwork

● By: Sylvain Kalache

● Weight: 1

● Project over - took place from May 3, 2023 6:00 AM to May 5, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…

● Auto QA review: 6.5/13 mandatory


● Altogether: 50.0%
○ Mandatory: 50.0%
○ Optional: no optional tasks

Resources
Read or watch:

● OSI model
● Different types of network
● LAN network
● WAN network
● Internet
● MAC address
● What is an IP address
● Private and public address
● IPv4 and IPv6
● Localhost
● TCP and UDP
● TCP/UDP ports List
● What is ping /ICMP
● Positional parameters

man or help:

● netstat
● ping
Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of Google:

OSI Model

● What it is
● How many layers it has
● How it is organized

What is a LAN

● Typical usage
● Typical geographical size

What is a WAN

● Typical usage
● Typical geographical size

What is the Internet

● What is an IP address
● What are the 2 types of IP address
● What is localhost
● What is a subnet
● Why IPv6 was created

TCP/UDP

● What are the 2 mainly used data transfer protocols for IP (transfer level on the OSI schema)
● What is the main difference between TCP and UDP
● What is a port
● Memorize SSH, HTTP and HTTPS port numbers
● What tool/protocol is often used to check if a device is connected to a network
Copyright - Plagiarism

● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and pasting
someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.

Requirements

General

● Allowed editors: vi, vim, emacs


● All your Bash script files will be interpreted on Ubuntu 20.04 LTS
● All your files should end with a new line
● A README.md file, at the root of the folder of the project, is mandatory
● All your Bash script files must be executable
● Your Bash script must pass shellcheck without any error
● The first line of all your Bash scripts should be exactly #!/usr/bin/env bash
● The second line of all your Bash scripts should be a comment explaining what is the script doing

More Info
The second line of all your Bash scripts should be a comment explaining what is the script doing

For multiple choice question type tasks, just type the number of the correct answer in your answer file,
add a new line for every new answer, example:

What is the most important position in a software company?

1. Project manager
2. Backend developer
3. System administrator

sylvain@ubuntu$ cat foo_answer_file


3
sylvain@ubuntu$

Source for question 1 here

Tasks
0. OSI model

mandatory

Score: 50.0% (Checks completed: 100.0%)

OSI (Open Systems Interconnection) is an abstract model to describe layered communication and
computer network design. The idea is to segregate the different parts of what make communication
possible.

It is organized from the lowest level to the highest level:

● The lowest level: layer 1 which is for transmission on physical layers with electrical impulse, light
or radio signal
● The highest level: layer 7 which is for application specific communication like SNMP for emails,
HTTP for your web browser, etc

Keep in mind that the OSI model is a concept, it’s not even tangible. The OSI model doesn’t perform any
functions in the networking process. It is a conceptual framework so we can better understand complex
interactions that are happening. Most of the functionality in the OSI model exists in all communications
systems.
In this project we will mainly focus on:

● The Transport layer and especially TCP/UDP


● On the Network layer with IP and ICMP

The image bellow describes more concretely how you can relate to every level.
Questions:

What is the OSI model?

1. Set of specifications that network hardware manufacturers must respect


2. The OSI model is a conceptual model that characterizes the communication functions of a
telecommunication system without regard to their underlying internal structure and technology
3. The OSI model is a model that characterizes the communication functions of a telecommunication
system with a strong regard for their underlying internal structure and technology

How is the OSI model organized?

1. Alphabetically
2. From the lowest to the highest level
3. Randomly

Repo:
● GitHub repository: alx-system_engineering-devops
● Directory: 0x07-networking_basics
● File: 0-OSI_model

Done! Help Check your code Get a sandbox QA Review

1. Types of network

mandatory

Score: 50.0% (Checks completed: 100.0%)


LAN connect local devices together, WAN connects LANs together, and WANs are operating over the
Internet.

Questions:

What type of network a computer in local is connected to?

1. Internet
2. WAN
3. LAN

What type of network could connect an office in one building to another office in a building a few streets
away?

1. Internet
2. WAN
3. LAN

What network do you use when you browse www.google.com from your smartphone (not connected to
the Wifi)?

1. Internet
2. WAN
3. LAN

Repo:
● GitHub repository: alx-system_engineering-devops
● Directory: 0x07-networking_basics
● File: 1-types_of_network

Done! Help Check your code Get a sandbox QA Review

2. MAC and IP address

mandatory

Score: 50.0% (Checks completed: 100.0%)

Questions:
What is a MAC address?

1. The name of a network interface


2. The unique identifier of a network interface
3. A network interface

What is an IP address?

1. Is to devices connected to a network what postal address is to houses


2. The unique identifier of a network interface
3. Is a number that network devices use to connect to networks

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x07-networking_basics
● File: 2-MAC_and_IP_address

Done! Help Check your code Get a sandbox QA Review

3. UDP and TCP

mandatory

Score: 50.0% (Checks completed: 100.0%)


Let’s fill the empty parts in the drawing above.

Questions:

● Which statement is correct for the TCP box:


1. It is a protocol that is transferring data in a slow way but surely
2. It is a protocol that is transferring data in a fast way and might loss
data along in the process
● Which statement is correct for the UDP box:
1. It is a protocol that is transferring data in a slow way but surely
2. It is a protocol that is transferring data in a fast way and might loss
data along in the process
● Which statement is correct for the TCP worker:
1. Have you received boxes x, y, z?
2. May I increase the rate at which I am sending you boxes?

Repo:
● GitHub repository: alx-system_engineering-devops
● Directory: 0x07-networking_basics
● File: 3-UDP_and_TCP

Done! Help Check your code Get a sandbox QA Review

4. TCP and UDP ports

mandatory

Score: 50.0% (Checks completed: 100.0%)

Once packets have been sent to the right network device using IP using either UDP or TCP as a mode of
transportation, it needs to actually enter the network device.

If we continue the comparison of a network device to your house, where IP address is like your postal
address, UDP and TCP ports are like the windows and doors of your place. A TCP/UDP network device
has 65535 ports. Some of them are officially reserved for a specific usage, some of them are known to be
used for a specific usage (but nothing is officially declared) and the rest are free of use.

While the full list of ports should not be memorized, it is important to know the most used ports, let’s start
by remembering 3 of them:

● 22 for SSH
● 80 for HTTP
● 443 for HTTPS
Note that a specific IP + port = socket.

Write a Bash script that displays listening ports:

● That only shows listening sockets


● That shows the PID and name of the program to which each socket belongs

Example:

sylvain@ubuntu$ sudo ./4-TCP_and_UDP_ports


Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 *:sunrpc *:* LISTEN
518/rpcbind
tcp 0 0 *:ssh *:* LISTEN
1240/sshd
tcp 0 0 *:32938 *:* LISTEN
547/rpc.statd
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
518/rpcbind
tcp6 0 0 [::]:ssh [::]:* LISTEN
1240/sshd
tcp6 0 0 [::]:33737 [::]:* LISTEN
547/rpc.statd
udp 0 0 *:sunrpc *:*
518/rpcbind
udp 0 0 *:691 *:*
518/rpcbind
udp 0 0 localhost:723 *:*
547/rpc.statd
udp 0 0 *:60129 *:*
547/rpc.statd
udp 0 0 *:3845 *:*
562/dhclient
udp 0 0 *:bootpc *:*
562/dhclient
udp6 0 0 [::]:47444 [::]:*
547/rpc.statd
udp6 0 0 [::]:sunrpc [::]:*
518/rpcbind
udp6 0 0 [::]:50038 [::]:*
562/dhclient
udp6 0 0 [::]:691 [::]:*
518/rpcbind
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name
Path
unix 2 [ ACC ] STREAM LISTENING 7724 518/rpcbind
/run/rpcbind.sock
unix 2 [ ACC ] STREAM LISTENING 6525 1/init
@/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 8559 835/dbus-daemon
/var/run/dbus/system_bus_socket
unix 2 [ ACC ] STREAM LISTENING 9190 1087/acpid
/var/run/acpid.socket
unix 2 [ ACC ] SEQPACKET LISTENING 7156 378/systemd-udevd
/run/udev/control
sylvain@ubuntu$

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x07-networking_basics
● File: 4-TCP_and_UDP_ports

Done! Help Check your code Get a sandbox QA Review

5. Is the host on the network

mandatory

Score: 50.0% (Checks completed: 100.0%)


The Internet Control Message Protocol (ICMP) is a protocol in the Internet protocol suite. It is used by
network devices, to check if other network devices are available on the network. The command ping
uses ICMP to make sure that a network device remains online or to troubleshoot issues on the network.

Write a Bash script that pings an IP address passed as an argument.

Requirements:

● Accepts a string as an argument


● Displays Usage: 5-is_the_host_on_the_network {IP_ADDRESS} if no argument passed
● Ping the IP 5 times

Example:

sylvain@ubuntu$ ./5-is_the_host_on_the_network 8.8.8.8


PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=63 time=12.9 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=63 time=13.6 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=63 time=7.83 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=63 time=11.3 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=63 time=7.57 ms

--- 8.8.8.8 ping statistics ---


5 packets transmitted, 5 received, 0% packet loss, time 4006ms
rtt min/avg/max/mdev = 7.570/10.682/13.679/2.546 ms
sylvain@ubuntu$
sylvain@ubuntu$ ./5-is_the_host_on_the_network
Usage: 5-is_the_host_on_the_network {IP_ADDRESS}
sylvain@ubuntu$

It is interesting to look at the time value, which is the time that it took for the ICMP request to go to the
8.8.8.8 IP and come back to my host. The IP 8.8.8.8 is owned by Google, and the quickest roundtrip
between my computer and Google was 7.57 ms which is pretty fast, which is a sign that the network path
between my computer and Google’s datacenter is in good shape. A slow ping would indicate a slow
network.

Next time you feel that your connection is slow, try the ping command to see what is going on!

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x07-networking_basics
● File: 5-is_the_host_on_the_network

Done! Help Check your code Get a sandbox QA Review


0x08. Networking basics #1
DevOpsNetworkSysAdmin

● By: Sylvain Kalache

● Weight: 1

● Project over - took place from May 3, 2023 6:00 AM to May 5, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…

● Auto QA review: 1.5/3 mandatory & 0.5/1 optional


● Altogether: 75.0%
○ Mandatory: 50.0%
○ Optional: 50.0%
○ Calculation: 50.0% + (50.0% * 50.0%) == 75.0%

Resources
Read or watch:

● What is localhost
● What is 0.0.0.0
● What is the hosts file
● Netcat examples

man or help:

● ifconfig
● telnet
● nc
● cut

Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of
Google:

General

● What is localhost/127.0.0.1
● What is 0.0.0.0
● What is /etc/hosts
● How to display your machine’s active network interfaces

Copyright - Plagiarism

● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and
pasting someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.

Requirements
General

● Allowed editors: vi, vim, emacs


● All your files will be interpreted on Ubuntu 20.04 LTS
● All your files should end with a new line
● A README.md file, at the root of the folder of the project, is mandatory
● All your Bash script files must be executable
● Your Bash script must pass Shellcheck (version 0.7.0 via apt-get) without any errors
● The first line of all your Bash scripts should be exactly #!/usr/bin/env bash
● The second line of all your Bash scripts should be a comment explaining what is the script
doing

Quiz questions

Great! You've completed the quiz successfully! Keep going! (Show quiz)

Tasks
0. Change your home IP

mandatory

Score: 50.0% (Checks completed: 100.0%)

Write a Bash script that configures an Ubuntu server with the below requirements.

Requirements:

● localhost resolves to 127.0.0.2


● facebook.com resolves to 8.8.8.8.
● The checker is running on Docker, so make sure to read this

Example:

sylvain@ubuntu$ ping localhost


PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.012 ms
^C
--- localhost ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.012/0.012/0.012/0.000 ms
sylvain@ubuntu$
sylvain@ubuntu$ ping facebook.com
PING facebook.com (157.240.11.35) 56(84) bytes of data.
64 bytes from edge-star-mini-shv-02-lax3.facebook.com (157.240.11.35):
icmp_seq=1 ttl=63 time=15.4 ms
^C
--- facebook.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 15.432/15.432/15.432/0.000 ms
sylvain@ubuntu$
sylvain@ubuntu$ sudo ./0-change_your_home_IP
sylvain@ubuntu$
sylvain@ubuntu$ ping localhost
PING localhost (127.0.0.2) 56(84) bytes of data.
64 bytes from localhost (127.0.0.2): icmp_seq=1 ttl=64 time=0.012 ms
64 bytes from localhost (127.0.0.2): icmp_seq=2 ttl=64 time=0.036 ms
^C
--- localhost ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.012/0.024/0.036/0.012 ms
sylvain@ubuntu$
sylvain@ubuntu$ ping facebook.com
PING facebook.com (8.8.8.8) 56(84) bytes of data.
64 bytes from facebook.com (8.8.8.8): icmp_seq=1 ttl=63 time=8.06 ms
^C
--- facebook.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 8.065/8.065/8.065/0.000 ms
In this example we can see that:

● before running the script, localhost resolves to 127.0.0.1 and facebook.com resolves to
157.240.11.35
● after running the script, localhost resolves to 127.0.0.2 and facebook.com resolves to
8.8.8.8

If you’re running this script on a machine that you’ll continue to use, be sure to revert localhost to
127.0.0.1. Otherwise, a lot of things will stop working!

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x08-networking_basics_2
● File: 0-change_your_home_IP

Done! Help Check your code Get a sandbox QA Review

1. Show attached IPs

mandatory

Score: 50.0% (Checks completed: 100.0%)

Write a Bash script that displays all active IPv4 IPs on the machine it’s executed on.
Example:

sylvain@ubuntu$ ./1-show_attached_IPs | cat -e


10.0.2.15$
127.0.0.1$
sylvain@ubuntu$

Obviously, the IPs displayed may be different depending on which machine you are running the
script on.

Note that we can see our localhost IP :)

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x08-networking_basics_2
● File: 1-show_attached_IPs

Done! Help Check your code Get a sandbox QA Review

2. Port listening on localhost

#advanced

Score: 50.0% (Checks completed: 100.0%)


Write a Bash script that listens on port 98 on localhost.

Terminal 0

Starting my script.

sylvain@ubuntu$ sudo ./100-port_listening_on_localhost

Terminal 1

Connecting to localhost on port 98 using telnet and typing some text.

sylvain@ubuntu$ telnet localhost 98


Trying 127.0.0.2...
Connected to localhost.
Escape character is '^]'.
Hello world
test

Terminal 0

Receiving the text on the other side.

sylvain@ubuntu$ sudo ./100-port_listening_on_localhost


Hello world
test

For the sake of the exercise, this connection is made entirely within localhost. This isn’t really
exciting as is, but we can use this script across networks as well. Try running it between your local
PC and your remote server for fun!

As you can see, this can come in very handy in a multitude of situations. Maybe you’re debugging
socket connection issues, or you’re trying to connect to a software and you are unsure if the issue is
the software or the network, or you’re working on firewall rules… Another tool to add to your
debugging toolbox!

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x08-networking_basics_2
● File: 100-port_listening_on_localhost

Done! Help Check your code Get a sandbox

0x00. AirBnB clone - The console


Group projectPythonOOP

● By: Guillaume

● Weight: 5

● Project to be done in teams of 2 people (your team:)


● Project over - took place from May 8, 2023 6:00 AM to May 15, 2023 6:00 AM

● Manual QA review was done by Damilola Esan on May 19, 2023 11:41 PM

● An auto review will be launched at the deadline

In a nutshell…

● Contribution: 100.0%
● Manual QA review: 48.0/48 mandatory
● Auto QA review: 295.5/302 mandatory & 233.0/233 optional
● Altogether: 196.28%
○ Mandatory: 98.14%
○ Optional: 100.0%
○ Contribution: 100.0%
○ Calculation: 100.0% * (98.14% + (98.14% * 100.0%) ) == 196.28%

Concepts

For this project, we expect you to look at these concepts:

● Python packages
● AirBnB clone
Background Context

Welcome to the AirBnB clone project!

Before starting, please read the AirBnB concept page.

First step: Write a command interpreter to manage your AirBnB objects.

This is the first step towards building your first full web application: the AirBnB clone. This first step is
very important because you will use what you build during this project with all other following projects:
HTML/CSS templating, database storage, API, front-end integration…

Each task is linked and will help you to:

● put in place a parent class (called BaseModel) to take care of the initialization, serialization and
deserialization of your future instances
● create a simple flow of serialization/deserialization: Instance <-> Dictionary <-> JSON string <->
file
● create all classes used for AirBnB (User, State, City, Place…) that inherit from BaseModel
● create the first abstracted storage engine of the project: File storage.
● create all unittests to validate all our classes and storage engine

What’s a command interpreter?

Do you remember the Shell? It’s exactly the same but limited to a specific use-case. In our case, we want
to be able to manage the objects of our project:

● Create a new object (ex: a new User or a new Place)


● Retrieve an object from a file, a database etc…
● Do operations on objects (count, compute stats, etc…)
● Update attributes of an object
● Destroy an object

Resources
Read or watch:

● cmd module
● cmd module in depth
● packages concept page
● uuid module
● datetime
● unittest module
● args/kwargs
● Python test cheatsheet
● cmd module wiki page
● python unittest

Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of Google:

General

● How to create a Python package


● How to create a command interpreter in Python using the cmd module
● What is Unit testing and how to implement it in a large project
● How to serialize and deserialize a Class
● How to write and read a JSON file
● How to manage datetime
● What is an UUID
● What is *args and how to use it
● What is **kwargs and how to use it
● How to handle named arguments in a function

Copyright - Plagiarism

● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and pasting
someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.
Requirements

Python Scripts

● Allowed editors: vi, vim, emacs


● All your files will be interpreted/compiled on Ubuntu 20.04 LTS using python3 (version 3.8.5)
● All your files should end with a new line
● The first line of all your files should be exactly #!/usr/bin/python3
● A README.md file, at the root of the folder of the project, is mandatory
● Your code should use the pycodestyle (version 2.8.*)
● All your files must be executable
● The length of your files will be tested using wc
● All your modules should have a documentation (python3 -c
'print(__import__("my_module").__doc__)')
● All your classes should have a documentation (python3 -c
'print(__import__("my_module").MyClass.__doc__)')
● All your functions (inside and outside a class) should have a documentation (python3 -c
'print(__import__("my_module").my_function.__doc__)' and python3 -c
'print(__import__("my_module").MyClass.my_function.__doc__)')
● A documentation is not a simple word, it’s a real sentence explaining what’s the purpose of the
module, class or method (the length of it will be verified)

Python Unit Tests

● Allowed editors: vi, vim, emacs


● All your files should end with a new line
● All your test files should be inside a folder tests
● You have to use the unittest module
● All your test files should be python files (extension: .py)
● All your test files and folders should start by test_
● Your file organization in the tests folder should be the same as your project
● e.g., For models/base_model.py, unit tests must be in:
tests/test_models/test_base_model.py
● e.g., For models/user.py, unit tests must be in: tests/test_models/test_user.py
● All your tests should be executed by using this command: python3 -m unittest discover
tests
● You can also test file by file by using this command: python3 -m unittest
tests/test_models/test_base_model.py
● All your modules should have a documentation (python3 -c
'print(__import__("my_module").__doc__)')
● All your classes should have a documentation (python3 -c
'print(__import__("my_module").MyClass.__doc__)')
● All your functions (inside and outside a class) should have a documentation (python3 -c
'print(__import__("my_module").my_function.__doc__)' and python3 -c
'print(__import__("my_module").MyClass.my_function.__doc__)')
● We strongly encourage you to work together on test cases, so that you don’t miss any edge case

GitHub

There should be one project repository per group. If you clone/fork/whatever a project repository
with the same name before the second deadline, you risk a 0% score.

More Info

Execution

Your shell should work like this in interactive mode:

$ ./console.py
(hbnb) help

Documented commands (type help <topic>):


========================================
EOF help quit

(hbnb)
(hbnb)
(hbnb) quit
$

But also in non-interactive mode: (like the Shell project in C)

$ echo "help" | ./console.py


(hbnb)

Documented commands (type help <topic>):


========================================
EOF help quit
(hbnb)
$
$ cat test_help
help
$
$ cat test_help | ./console.py
(hbnb)

Documented commands (type help <topic>):


========================================
EOF help quit
(hbnb)
$

All tests should also pass in non-interactive mode: $ echo "python3 -m unittest discover tests"
| bash

Video library(8 total)

HBNB project overview

HBNB - the console


Python: Unique Identifier

Python: Unittests

Python: BaseModel and inheritance

Code consistency

Python: Modules and Packages

HBNB - storage abstraction

Tasks
0. README, AUTHORS

mandatory

Score: 100.0% (Checks completed: 100.0%)

● Write a README.md:
○ description of the project
○ description of the command interpreter:
■ how to start it
■ how to use it
■ examples
● You should have an AUTHORS file at the root of your repository, listing all individuals having
contributed content to the repository. For format, reference Docker’s AUTHORS page
● You should use branches and pull requests on GitHub - it will help you as team to organize your
work
Repo:

● GitHub repository: AirBnB_clone


● File: README.md, AUTHORS

Done! Help QA Review

1. Be pycodestyle compliant!

mandatory

Score: 100.0% (Checks completed: 100.0%)

Write beautiful code that passes the pycodestyle checks.

Repo:

● GitHub repository: AirBnB_clone

Done! Help Check your code Get a sandbox QA Review

2. Unittests
mandatory

Score: 82.69% (Checks completed: 100.0%)

All your files, classes, functions must be tested with unit tests

guillaume@ubuntu:~/AirBnB$ python3 -m unittest discover tests


...............................................................................
....
...............................................................................
....
.......................
----------------------------------------------------------------------
Ran 189 tests in 13.135s

OK
guillaume@ubuntu:~/AirBnB$

Note that this is just an example, the number of tests you create can be different from the above example.

Warning:

Unit tests must also pass in non-interactive mode:

guillaume@ubuntu:~/AirBnB$ echo "python3 -m unittest discover tests" | bash


...............................................................................
....
...............................................................................
....
.......................
----------------------------------------------------------------------
Ran 189 tests in 13.135s

OK
guillaume@ubuntu:~/AirBnB$

Repo:

● GitHub repository: AirBnB_clone


● File: tests/

Done! Help Check your code Get a sandbox QA Review

3. BaseModel

mandatory

Score: 96.15% (Checks completed: 100.0%)

Write a class BaseModel that defines all common attributes/methods for other classes:

● models/base_model.py
● Public instance attributes:
○ id: string - assign with an uuid when an instance is created:
■ you can use uuid.uuid4() to generate unique id but don’t forget to convert to a
string
■ the goal is to have unique id for each BaseModel
○ created_at: datetime - assign with the current datetime when an instance is created
○ updated_at: datetime - assign with the current datetime when an instance is created and
it will be updated every time you change your object
● __str__: should print: [<class name>] (<self.id>) <self.__dict__>
● Public instance methods:
○ save(self): updates the public instance attribute updated_at with the current datetime
○ to_dict(self): returns a dictionary containing all keys/values of __dict__ of the
instance:
■ by using self.__dict__, only instance attributes set will be returned
■ a key __class__ must be added to this dictionary with the class name of the
object
■ created_at and updated_at must be converted to string object in ISO format:
■ format: %Y-%m-%dT%H:%M:%S.%f (ex: 2017-06-14T22:31:03.285259)
■ you can use isoformat() of datetime object
■ This method will be the first piece of the serialization/deserialization process:
create a dictionary representation with “simple object type” of our BaseModel

guillaume@ubuntu:~/AirBnB$ cat test_base_model.py


#!/usr/bin/python3
from models.base_model import BaseModel

my_model = BaseModel()
my_model.name = "My First Model"
my_model.my_number = 89
print(my_model)
my_model.save()
print(my_model)
my_model_json = my_model.to_dict()
print(my_model_json)
print("JSON of my_model:")
for key in my_model_json.keys():
print("\t{}: ({}) - {}".format(key, type(my_model_json[key]),
my_model_json[key]))

guillaume@ubuntu:~/AirBnB$ ./test_base_model.py
[BaseModel] (b6a6e15c-c67d-4312-9a75-9d084935e579) {'my_number': 89, 'name':
'My First Model', 'updated_at': datetime.datetime(2017, 9, 28, 21, 5, 54,
119434), 'id': 'b6a6e15c-c67d-4312-9a75-9d084935e579', 'created_at':
datetime.datetime(2017, 9, 28, 21, 5, 54, 119427)}
[BaseModel] (b6a6e15c-c67d-4312-9a75-9d084935e579) {'my_number': 89, 'name':
'My First Model', 'updated_at': datetime.datetime(2017, 9, 28, 21, 5, 54,
119572), 'id': 'b6a6e15c-c67d-4312-9a75-9d084935e579', 'created_at':
datetime.datetime(2017, 9, 28, 21, 5, 54, 119427)}
{'my_number': 89, 'name': 'My First Model', '__class__': 'BaseModel',
'updated_at': '2017-09-28T21:05:54.119572', 'id':
'b6a6e15c-c67d-4312-9a75-9d084935e579', 'created_at':
'2017-09-28T21:05:54.119427'}
JSON of my_model:
my_number: (<class 'int'>) - 89
name: (<class 'str'>) - My First Model
__class__: (<class 'str'>) - BaseModel
updated_at: (<class 'str'>) - 2017-09-28T21:05:54.119572
id: (<class 'str'>) - b6a6e15c-c67d-4312-9a75-9d084935e579
created_at: (<class 'str'>) - 2017-09-28T21:05:54.119427

guillaume@ubuntu:~/AirBnB$

Repo:

● GitHub repository: AirBnB_clone


● File: models/base_model.py, models/__init__.py, tests/

Done! Help Check your code Get a sandbox QA Review

4. Create BaseModel from dictionary

mandatory

Score: 100.0% (Checks completed: 100.0%)

Previously we created a method to generate a dictionary representation of an instance (method


to_dict()).
Now it’s time to re-create an instance with this dictionary representation.

<class 'BaseModel'> -> to_dict() -> <class 'dict'> -> <class 'BaseModel'>

Update models/base_model.py:

● __init__(self, *args, **kwargs):


○ you will use *args, **kwargs arguments for the constructor of a BaseModel. (more
information inside the AirBnB clone concept page)
○ *args won’t be used
○ if kwargs is not empty:
■ each key of this dictionary is an attribute name (Note __class__ from kwargs is
the only one that should not be added as an attribute. See the example output,
below)
■ each value of this dictionary is the value of this attribute name
■ Warning: created_at and updated_at are strings in this dictionary, but inside
your BaseModel instance is working with datetime object. You have to convert
these strings into datetime object. Tip: you know the string format of these
datetime
○ otherwise:
■ create id and created_at as you did previously (new instance)

guillaume@ubuntu:~/AirBnB$ cat test_base_model_dict.py


#!/usr/bin/python3
from models.base_model import BaseModel

my_model = BaseModel()
my_model.name = "My_First_Model"
my_model.my_number = 89
print(my_model.id)
print(my_model)
print(type(my_model.created_at))
print("--")
my_model_json = my_model.to_dict()
print(my_model_json)
print("JSON of my_model:")
for key in my_model_json.keys():
print("\t{}: ({}) - {}".format(key, type(my_model_json[key]),
my_model_json[key]))

print("--")
my_new_model = BaseModel(**my_model_json)
print(my_new_model.id)
print(my_new_model)
print(type(my_new_model.created_at))

print("--")
print(my_model is my_new_model)

guillaume@ubuntu:~/AirBnB$ ./test_base_model_dict.py
56d43177-cc5f-4d6c-a0c1-e167f8c27337
[BaseModel] (56d43177-cc5f-4d6c-a0c1-e167f8c27337) {'id':
'56d43177-cc5f-4d6c-a0c1-e167f8c27337', 'created_at': datetime.datetime(2017,
9, 28, 21, 3, 54, 52298), 'my_number': 89, 'updated_at':
datetime.datetime(2017, 9, 28, 21, 3, 54, 52302), 'name': 'My_First_Model'}
<class 'datetime.datetime'>
--
{'id': '56d43177-cc5f-4d6c-a0c1-e167f8c27337', 'created_at':
'2017-09-28T21:03:54.052298', '__class__': 'BaseModel', 'my_number': 89,
'updated_at': '2017-09-28T21:03:54.052302', 'name': 'My_First_Model'}
JSON of my_model:
id: (<class 'str'>) - 56d43177-cc5f-4d6c-a0c1-e167f8c27337
created_at: (<class 'str'>) - 2017-09-28T21:03:54.052298
__class__: (<class 'str'>) - BaseModel
my_number: (<class 'int'>) - 89
updated_at: (<class 'str'>) - 2017-09-28T21:03:54.052302
name: (<class 'str'>) - My_First_Model
--
56d43177-cc5f-4d6c-a0c1-e167f8c27337
[BaseModel] (56d43177-cc5f-4d6c-a0c1-e167f8c27337) {'id':
'56d43177-cc5f-4d6c-a0c1-e167f8c27337', 'created_at': datetime.datetime(2017,
9, 28, 21, 3, 54, 52298), 'my_number': 89, 'updated_at':
datetime.datetime(2017, 9, 28, 21, 3, 54, 52302), 'name': 'My_First_Model'}
<class 'datetime.datetime'>
--
False
guillaume@ubuntu:~/AirBnB$

Repo:
● GitHub repository: AirBnB_clone
● File: models/base_model.py, tests/

Done! Help Check your code Get a sandbox QA Review

5. Store first object

mandatory

Score: 96.67% (Checks completed: 96.67%)

Now we can recreate a BaseModel from another one by using a dictionary representation:

<class 'BaseModel'> -> to_dict() -> <class 'dict'> -> <class 'BaseModel'>

It’s great but it’s still not persistent: every time you launch the program, you don’t restore all objects
created before… The first way you will see here is to save these objects to a file.

Writing the dictionary representation to a file won’t be relevant:

● Python doesn’t know how to convert a string to a dictionary (easily)


● It’s not human readable
● Using this file with another program in Python or other language will be hard.
So, you will convert the dictionary representation to a JSON string. JSON is a standard representation of
a data structure. With this format, humans can read and all programming languages have a JSON reader
and writer.

Now the flow of serialization-deserialization will be:

<class 'BaseModel'> -> to_dict() -> <class 'dict'> -> JSON dump -> <class
'str'> -> FILE -> <class 'str'> -> JSON load -> <class 'dict'> -> <class
'BaseModel'>

Magic right?

Terms:

● simple Python data structure: Dictionaries, arrays, number and string. ex: { '12': {
'numbers': [1, 2, 3], 'name': "John" } }
● JSON string representation: String representing a simple data structure in JSON format. ex: '{
"12": { "numbers": [1, 2, 3], "name": "John" } }'

Write a class FileStorage that serializes instances to a JSON file and deserializes JSON file to
instances:

● models/engine/file_storage.py
● Private class attributes:
○ __file_path: string - path to the JSON file (ex: file.json)
○ __objects: dictionary - empty but will store all objects by <class name>.id (ex: to store
a BaseModel object with id=12121212, the key will be BaseModel.12121212)
● Public instance methods:
○ all(self): returns the dictionary __objects
○ new(self, obj): sets in __objects the obj with key <obj class name>.id
○ save(self): serializes __objects to the JSON file (path: __file_path)
○ reload(self): deserializes the JSON file to __objects (only if the JSON file
(__file_path) exists ; otherwise, do nothing. If the file doesn’t exist, no exception should
be raised)

Update models/__init__.py: to create a unique FileStorage instance for your application

● import file_storage.py
● create the variable storage, an instance of FileStorage
● call reload() method on this variable

Update models/base_model.py: to link your BaseModel to FileStorage by using the variable storage

● import the variable storage


● in the method save(self):
○ call save(self) method of storage
● __init__(self, *args, **kwargs):
○ if it’s a new instance (not from a dictionary representation), add a call to the method
new(self) on storage

guillaume@ubuntu:~/AirBnB$ cat test_save_reload_base_model.py


#!/usr/bin/python3
from models import storage
from models.base_model import BaseModel

all_objs = storage.all()
print("-- Reloaded objects --")
for obj_id in all_objs.keys():
obj = all_objs[obj_id]
print(obj)

print("-- Create a new object --")


my_model = BaseModel()
my_model.name = "My_First_Model"
my_model.my_number = 89
my_model.save()
print(my_model)

guillaume@ubuntu:~/AirBnB$ cat file.json


cat: file.json: No such file or directory
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ ./test_save_reload_base_model.py
-- Reloaded objects --
-- Create a new object --
[BaseModel] (ee49c413-023a-4b49-bd28-f2936c95460d) {'my_number': 89,
'updated_at': datetime.datetime(2017, 9, 28, 21, 7, 25, 47381), 'created_at':
datetime.datetime(2017, 9, 28, 21, 7, 25, 47372), 'name': 'My_First_Model',
'id': 'ee49c413-023a-4b49-bd28-f2936c95460d'}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ cat file.json ; echo ""
{"BaseModel.ee49c413-023a-4b49-bd28-f2936c95460d": {"my_number": 89,
"__class__": "BaseModel", "updated_at": "2017-09-28T21:07:25.047381",
"created_at": "2017-09-28T21:07:25.047372", "name": "My_First_Model", "id":
"ee49c413-023a-4b49-bd28-f2936c95460d"}}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ ./test_save_reload_base_model.py
-- Reloaded objects --
[BaseModel] (ee49c413-023a-4b49-bd28-f2936c95460d) {'name': 'My_First_Model',
'id': 'ee49c413-023a-4b49-bd28-f2936c95460d', 'updated_at':
datetime.datetime(2017, 9, 28, 21, 7, 25, 47381), 'my_number': 89,
'created_at': datetime.datetime(2017, 9, 28, 21, 7, 25, 47372)}
-- Create a new object --
[BaseModel] (080cce84-c574-4230-b82a-9acb74ad5e8c) {'name': 'My_First_Model',
'id': '080cce84-c574-4230-b82a-9acb74ad5e8c', 'updated_at':
datetime.datetime(2017, 9, 28, 21, 7, 51, 973308), 'my_number': 89,
'created_at': datetime.datetime(2017, 9, 28, 21, 7, 51, 973301)}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ ./test_save_reload_base_model.py
-- Reloaded objects --
[BaseModel] (080cce84-c574-4230-b82a-9acb74ad5e8c) {'id':
'080cce84-c574-4230-b82a-9acb74ad5e8c', 'updated_at': datetime.datetime(2017,
9, 28, 21, 7, 51, 973308), 'created_at': datetime.datetime(2017, 9, 28, 21, 7,
51, 973301), 'name': 'My_First_Model', 'my_number': 89}
[BaseModel] (ee49c413-023a-4b49-bd28-f2936c95460d) {'id':
'ee49c413-023a-4b49-bd28-f2936c95460d', 'updated_at': datetime.datetime(2017,
9, 28, 21, 7, 25, 47381), 'created_at': datetime.datetime(2017, 9, 28, 21, 7,
25, 47372), 'name': 'My_First_Model', 'my_number': 89}
-- Create a new object --
[BaseModel] (e79e744a-55d4-45a3-b74a-ca5fae74e0e2) {'id':
'e79e744a-55d4-45a3-b74a-ca5fae74e0e2', 'updated_at': datetime.datetime(2017,
9, 28, 21, 8, 6, 151750), 'created_at': datetime.datetime(2017, 9, 28, 21, 8,
6, 151711), 'name': 'My_First_Model', 'my_number': 89}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ cat file.json ; echo ""
{"BaseModel.e79e744a-55d4-45a3-b74a-ca5fae74e0e2": {"__class__": "BaseModel",
"id": "e79e744a-55d4-45a3-b74a-ca5fae74e0e2", "updated_at":
"2017-09-28T21:08:06.151750", "created_at": "2017-09-28T21:08:06.151711",
"name": "My_First_Model", "my_number": 89},
"BaseModel.080cce84-c574-4230-b82a-9acb74ad5e8c": {"__class__": "BaseModel",
"id": "080cce84-c574-4230-b82a-9acb74ad5e8c", "updated_at":
"2017-09-28T21:07:51.973308", "created_at": "2017-09-28T21:07:51.973301",
"name": "My_First_Model", "my_number": 89},
"BaseModel.ee49c413-023a-4b49-bd28-f2936c95460d": {"__class__": "BaseModel",
"id": "ee49c413-023a-4b49-bd28-f2936c95460d", "updated_at":
"2017-09-28T21:07:25.047381", "created_at": "2017-09-28T21:07:25.047372",
"name": "My_First_Model", "my_number": 89}}
guillaume@ubuntu:~/AirBnB$

Repo:

● GitHub repository: AirBnB_clone


● File: models/engine/file_storage.py, models/engine/__init__.py,
models/__init__.py, models/base_model.py, tests/

Done? Help Check your code Ask for a new correction Get a sandbox QA Review

6. Console 0.0.1

mandatory

Score: 100.0% (Checks completed: 100.0%)

Write a program called console.py that contains the entry point of the command interpreter:
● You must use the module cmd
● Your class definition must be: class HBNBCommand(cmd.Cmd):
● Your command interpreter should implement:
○ quit and EOF to exit the program
○ help (this action is provided by default by cmd but you should keep it updated and
documented as you work through tasks)
○ a custom prompt: (hbnb)
○ an empty line + ENTER shouldn’t execute anything
● Your code should not be executed when imported

Warning:

You should end your file with:

if __name__ == '__main__':
HBNBCommand().cmdloop()

to make your program executable except when imported. Please don’t add anything around - the Checker
won’t like it otherwise

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) help

Documented commands (type help <topic>):


========================================
EOF help quit

(hbnb)
(hbnb) help quit
Quit command to exit the program

(hbnb)
(hbnb)
(hbnb) quit
guillaume@ubuntu:~/AirBnB$

No unittests needed

Repo:

● GitHub repository: AirBnB_clone


● File: console.py

Done! Help Check your code Get a sandbox QA Review

7. Console 0.1

mandatory

Score: 100.0% (Checks completed: 100.0%)

Update your command interpreter (console.py) to have these commands:

● create: Creates a new instance of BaseModel, saves it (to the JSON file) and prints the id. Ex: $
create BaseModel
○ If the class name is missing, print ** class name missing ** (ex: $ create)
○ If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ create
MyModel)
● show: Prints the string representation of an instance based on the class name and id. Ex: $ show
BaseModel 1234-1234-1234.
○ If the class name is missing, print ** class name missing ** (ex: $ show)
○ If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ show
MyModel)
○ If the id is missing, print ** instance id missing ** (ex: $ show BaseModel)
○ If the instance of the class name doesn’t exist for the id, print ** no instance found
** (ex: $ show BaseModel 121212)
● destroy: Deletes an instance based on the class name and id (save the change into the JSON
file). Ex: $ destroy BaseModel 1234-1234-1234.
○ If the class name is missing, print ** class name missing ** (ex: $ destroy)
○ If the class name doesn’t exist, print ** class doesn't exist ** (ex:$ destroy
MyModel)
○ If the id is missing, print ** instance id missing ** (ex: $ destroy BaseModel)
○ If the instance of the class name doesn’t exist for the id, print ** no instance found
** (ex: $ destroy BaseModel 121212)
● all: Prints all string representation of all instances based or not on the class name. Ex: $ all
BaseModel or $ all.
○ The printed result must be a list of strings (like the example below)
○ If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ all
MyModel)
● update: Updates an instance based on the class name and id by adding or updating attribute
(save the change into the JSON file). Ex: $ update BaseModel 1234-1234-1234 email
"aibnb@mail.com".
○ Usage: update <class name> <id> <attribute name> "<attribute value>"
○ Only one attribute can be updated at the time
○ You can assume the attribute name is valid (exists for this model)
○ The attribute value must be casted to the attribute type
○ If the class name is missing, print ** class name missing ** (ex: $ update)
○ If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ update
MyModel)
○ If the id is missing, print ** instance id missing ** (ex: $ update BaseModel)
○ If the instance of the class name doesn’t exist for the id, print ** no instance found
** (ex: $ update BaseModel 121212)
○ If the attribute name is missing, print ** attribute name missing ** (ex: $ update
BaseModel existing-id)
○ If the value for the attribute name doesn’t exist, print ** value missing ** (ex: $
update BaseModel existing-id first_name)
○ All other arguments should not be used (Ex: $ update BaseModel 1234-1234-1234
email "aibnb@mail.com" first_name "Betty" = $ update BaseModel
1234-1234-1234 email "aibnb@mail.com")
○ id, created_at and updated_at cant’ be updated. You can assume they won’t be
passed in the update command
○ Only “simple” arguments can be updated: string, integer and float. You can assume
nobody will try to update list of ids or datetime

Let’s add some rules:

● You can assume arguments are always in the right order


● Each arguments are separated by a space
● A string argument with a space must be between double quote
● The error management starts from the first argument to the last one

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) all MyModel
** class doesn't exist **
(hbnb) show BaseModel
** instance id missing **
(hbnb) show BaseModel My_First_Model
** no instance found **
(hbnb) create BaseModel
49faff9a-6318-451f-87b6-910505c55907
(hbnb) all BaseModel
["[BaseModel] (49faff9a-6318-451f-87b6-910505c55907) {'created_at':
datetime.datetime(2017, 10, 2, 3, 10, 25, 903293), 'id':
'49faff9a-6318-451f-87b6-910505c55907', 'updated_at': datetime.datetime(2017,
10, 2, 3, 10, 25, 903300)}"]
(hbnb) show BaseModel 49faff9a-6318-451f-87b6-910505c55907
[BaseModel] (49faff9a-6318-451f-87b6-910505c55907) {'created_at':
datetime.datetime(2017, 10, 2, 3, 10, 25, 903293), 'id':
'49faff9a-6318-451f-87b6-910505c55907', 'updated_at': datetime.datetime(2017,
10, 2, 3, 10, 25, 903300)}
(hbnb) destroy
** class name missing **
(hbnb) update BaseModel 49faff9a-6318-451f-87b6-910505c55907 first_name "Betty"
(hbnb) show BaseModel 49faff9a-6318-451f-87b6-910505c55907
[BaseModel] (49faff9a-6318-451f-87b6-910505c55907) {'first_name': 'Betty',
'id': '49faff9a-6318-451f-87b6-910505c55907', 'created_at':
datetime.datetime(2017, 10, 2, 3, 10, 25, 903293), 'updated_at':
datetime.datetime(2017, 10, 2, 3, 11, 3, 49401)}
(hbnb) create BaseModel
2dd6ef5c-467c-4f82-9521-a772ea7d84e9
(hbnb) all BaseModel
["[BaseModel] (2dd6ef5c-467c-4f82-9521-a772ea7d84e9) {'id':
'2dd6ef5c-467c-4f82-9521-a772ea7d84e9', 'created_at': datetime.datetime(2017,
10, 2, 3, 11, 23, 639717), 'updated_at': datetime.datetime(2017, 10, 2, 3, 11,
23, 639724)}", "[BaseModel] (49faff9a-6318-451f-87b6-910505c55907)
{'first_name': 'Betty', 'id': '49faff9a-6318-451f-87b6-910505c55907',
'created_at': datetime.datetime(2017, 10, 2, 3, 10, 25, 903293), 'updated_at':
datetime.datetime(2017, 10, 2, 3, 11, 3, 49401)}"]
(hbnb) destroy BaseModel 49faff9a-6318-451f-87b6-910505c55907
(hbnb) show BaseModel 49faff9a-6318-451f-87b6-910505c55907
** no instance found **
(hbnb)

No unittests needed

Repo:

● GitHub repository: AirBnB_clone


● File: console.py

Done! Help Check your code Get a sandbox QA Review

8. First User

mandatory

Score: 100.0% (Checks completed: 100.0%)

Write a class User that inherits from BaseModel:


● models/user.py
● Public class attributes:
○ email: string - empty string
○ password: string - empty string
○ first_name: string - empty string
○ last_name: string - empty string

Update FileStorage to manage correctly serialization and deserialization of User.

Update your command interpreter (console.py) to allow show, create, destroy, update and all used
with User.

guillaume@ubuntu:~/AirBnB$ cat test_save_reload_user.py


#!/usr/bin/python3
from models import storage
from models.base_model import BaseModel
from models.user import User

all_objs = storage.all()
print("-- Reloaded objects --")
for obj_id in all_objs.keys():
obj = all_objs[obj_id]
print(obj)

print("-- Create a new User --")


my_user = User()
my_user.first_name = "Betty"
my_user.last_name = "Bar"
my_user.email = "airbnb@mail.com"
my_user.password = "root"
my_user.save()
print(my_user)

print("-- Create a new User 2 --")


my_user2 = User()
my_user2.first_name = "John"
my_user2.email = "airbnb2@mail.com"
my_user2.password = "root"
my_user2.save()
print(my_user2)
guillaume@ubuntu:~/AirBnB$ cat file.json ; echo ""
{"BaseModel.2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4": {"__class__": "BaseModel",
"id": "2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4", "updated_at":
"2017-09-28T21:11:14.333862", "created_at": "2017-09-28T21:11:14.333852"},
"BaseModel.a42ee380-c959-450e-ad29-c840a898cfce": {"__class__": "BaseModel",
"id": "a42ee380-c959-450e-ad29-c840a898cfce", "updated_at":
"2017-09-28T21:11:15.504296", "created_at": "2017-09-28T21:11:15.504287"},
"BaseModel.af9b4cbd-2ce1-4e6e-8259-f578097dd15f": {"__class__": "BaseModel",
"id": "af9b4cbd-2ce1-4e6e-8259-f578097dd15f", "updated_at":
"2017-09-28T21:11:12.971544", "created_at": "2017-09-28T21:11:12.971521"},
"BaseModel.38a22b25-ae9c-4fa9-9f94-59b3eb51bfba": {"__class__": "BaseModel",
"id": "38a22b25-ae9c-4fa9-9f94-59b3eb51bfba", "updated_at":
"2017-09-28T21:11:13.753347", "created_at": "2017-09-28T21:11:13.753337"},
"BaseModel.9bf17966-b092-4996-bd33-26a5353cccb4": {"__class__": "BaseModel",
"id": "9bf17966-b092-4996-bd33-26a5353cccb4", "updated_at":
"2017-09-28T21:11:14.963058", "created_at": "2017-09-28T21:11:14.963049"}}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ ./test_save_reload_user.py
-- Reloaded objects --
[BaseModel] (38a22b25-ae9c-4fa9-9f94-59b3eb51bfba) {'id':
'38a22b25-ae9c-4fa9-9f94-59b3eb51bfba', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 13, 753337), 'updated_at': datetime.datetime(2017, 9, 28, 21,
11, 13, 753347)}
[BaseModel] (9bf17966-b092-4996-bd33-26a5353cccb4) {'id':
'9bf17966-b092-4996-bd33-26a5353cccb4', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 14, 963049), 'updated_at': datetime.datetime(2017, 9, 28, 21,
11, 14, 963058)}
[BaseModel] (2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4) {'id':
'2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 14, 333852), 'updated_at': datetime.datetime(2017, 9, 28, 21,
11, 14, 333862)}
[BaseModel] (a42ee380-c959-450e-ad29-c840a898cfce) {'id':
'a42ee380-c959-450e-ad29-c840a898cfce', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 15, 504287), 'updated_at': datetime.datetime(2017, 9, 28, 21,
11, 15, 504296)}
[BaseModel] (af9b4cbd-2ce1-4e6e-8259-f578097dd15f) {'id':
'af9b4cbd-2ce1-4e6e-8259-f578097dd15f', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 12, 971521), 'updated_at': datetime.datetime(2017, 9, 28, 21,
11, 12, 971544)}
-- Create a new User --
[User] (38f22813-2753-4d42-b37c-57a17f1e4f88) {'id':
'38f22813-2753-4d42-b37c-57a17f1e4f88', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 42, 848279), 'updated_at': datetime.datetime(2017, 9, 28, 21,
11, 42, 848291), 'email': 'airbnb@mail.com', 'first_name': 'Betty',
'last_name': 'Bar', 'password': 'root'}
-- Create a new User 2 --
[User] (d0ef8146-4664-4de5-8e89-096d667b728e) {'id':
'd0ef8146-4664-4de5-8e89-096d667b728e', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 42, 848280), 'updated_at': datetime.datetime(2017, 9, 28, 21,
11, 42, 848294), 'email': 'airbnb2@mail.com', 'first_name': 'John', 'password':
'root'}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ cat file.json ; echo ""
{"BaseModel.af9b4cbd-2ce1-4e6e-8259-f578097dd15f": {"id":
"af9b4cbd-2ce1-4e6e-8259-f578097dd15f", "updated_at":
"2017-09-28T21:11:12.971544", "created_at": "2017-09-28T21:11:12.971521",
"__class__": "BaseModel"}, "BaseModel.38a22b25-ae9c-4fa9-9f94-59b3eb51bfba":
{"id": "38a22b25-ae9c-4fa9-9f94-59b3eb51bfba", "updated_at":
"2017-09-28T21:11:13.753347", "created_at": "2017-09-28T21:11:13.753337",
"__class__": "BaseModel"}, "BaseModel.9bf17966-b092-4996-bd33-26a5353cccb4":
{"id": "9bf17966-b092-4996-bd33-26a5353cccb4", "updated_at":
"2017-09-28T21:11:14.963058", "created_at": "2017-09-28T21:11:14.963049",
"__class__": "BaseModel"}, "BaseModel.2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4":
{"id": "2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4", "updated_at":
"2017-09-28T21:11:14.333862", "created_at": "2017-09-28T21:11:14.333852",
"__class__": "BaseModel"}, "BaseModel.a42ee380-c959-450e-ad29-c840a898cfce":
{"id": "a42ee380-c959-450e-ad29-c840a898cfce", "updated_at":
"2017-09-28T21:11:15.504296", "created_at": "2017-09-28T21:11:15.504287",
"__class__": "BaseModel"}, "User.38f22813-2753-4d42-b37c-57a17f1e4f88": {"id":
"38f22813-2753-4d42-b37c-57a17f1e4f88", "created_at":
"2017-09-28T21:11:42.848279", "updated_at": "2017-09-28T21:11:42.848291",
"email": "airbnb@mail.com", "first_name": "Betty", "__class__": "User",
"last_name": "Bar", "password": "root"},
"User.d0ef8146-4664-4de5-8e89-096d667b728e": {"id":
"d0ef8146-4664-4de5-8e89-096d667b728e", "created_at":
"2017-09-28T21:11:42.848280", "updated_at": "2017-09-28T21:11:42.848294",
"email": "airbnb_2@mail.com", "first_name": "John", "__class__": "User",
"password": "root"}}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ ./test_save_reload_user.py
-- Reloaded objects --
[BaseModel] (af9b4cbd-2ce1-4e6e-8259-f578097dd15f) {'updated_at':
datetime.datetime(2017, 9, 28, 21, 11, 12, 971544), 'id':
'af9b4cbd-2ce1-4e6e-8259-f578097dd15f', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 12, 971521)}
[BaseModel] (2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4) {'updated_at':
datetime.datetime(2017, 9, 28, 21, 11, 14, 333862), 'id':
'2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 14, 333852)}
[BaseModel] (9bf17966-b092-4996-bd33-26a5353cccb4) {'updated_at':
datetime.datetime(2017, 9, 28, 21, 11, 14, 963058), 'id':
'9bf17966-b092-4996-bd33-26a5353cccb4', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 14, 963049)}
[BaseModel] (a42ee380-c959-450e-ad29-c840a898cfce) {'updated_at':
datetime.datetime(2017, 9, 28, 21, 11, 15, 504296), 'id':
'a42ee380-c959-450e-ad29-c840a898cfce', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 15, 504287)}
[BaseModel] (38a22b25-ae9c-4fa9-9f94-59b3eb51bfba) {'updated_at':
datetime.datetime(2017, 9, 28, 21, 11, 13, 753347), 'id':
'38a22b25-ae9c-4fa9-9f94-59b3eb51bfba', 'created_at': datetime.datetime(2017,
9, 28, 21, 11, 13, 753337)}
[User] (38f22813-2753-4d42-b37c-57a17f1e4f88) {'password':
'63a9f0ea7bb98050796b649e85481845', 'created_at': datetime.datetime(2017, 9,
28, 21, 11, 42, 848279), 'email': 'airbnb@mail.com', 'updated_at':
datetime.datetime(2017, 9, 28, 21, 11, 42, 848291), 'last_name': 'Bar', 'id':
'38f22813-2753-4d42-b37c-57a17f1e4f88', 'first_name': 'Betty'}
[User] (d0ef8146-4664-4de5-8e89-096d667b728e) {'password':
'63a9f0ea7bb98050796b649e85481845', 'created_at': datetime.datetime(2017, 9,
28, 21, 11, 42, 848280), 'email': 'airbnb_2@mail.com', 'updated_at':
datetime.datetime(2017, 9, 28, 21, 11, 42, 848294), 'id':
'd0ef8146-4664-4de5-8e89-096d667b728e', 'first_name': 'John'}
-- Create a new User --
[User] (246c227a-d5c1-403d-9bc7-6a47bb9f0f68) {'password': 'root',
'created_at': datetime.datetime(2017, 9, 28, 21, 12, 19, 611352), 'email':
'airbnb@mail.com', 'updated_at': datetime.datetime(2017, 9, 28, 21, 12, 19,
611363), 'last_name': 'Bar', 'id': '246c227a-d5c1-403d-9bc7-6a47bb9f0f68',
'first_name': 'Betty'}
-- Create a new User 2 --
[User] (fce12f8a-fdb6-439a-afe8-2881754de71c) {'password': 'root',
'created_at': datetime.datetime(2017, 9, 28, 21, 12, 19, 611354), 'email':
'airbnb_2@mail.com', 'updated_at': datetime.datetime(2017, 9, 28, 21, 12, 19,
611368), 'id': 'fce12f8a-fdb6-439a-afe8-2881754de71c', 'first_name': 'John'}
guillaume@ubuntu:~/AirBnB$
guillaume@ubuntu:~/AirBnB$ cat file.json ; echo ""
{"BaseModel.af9b4cbd-2ce1-4e6e-8259-f578097dd15f": {"updated_at":
"2017-09-28T21:11:12.971544", "__class__": "BaseModel", "id":
"af9b4cbd-2ce1-4e6e-8259-f578097dd15f", "created_at":
"2017-09-28T21:11:12.971521"}, "User.38f22813-2753-4d42-b37c-57a17f1e4f88":
{"password": "63a9f0ea7bb98050796b649e85481845", "created_at":
"2017-09-28T21:11:42.848279", "email": "airbnb@mail.com", "id":
"38f22813-2753-4d42-b37c-57a17f1e4f88", "last_name": "Bar", "updated_at":
"2017-09-28T21:11:42.848291", "first_name": "Betty", "__class__": "User"},
"User.d0ef8146-4664-4de5-8e89-096d667b728e": {"password":
"63a9f0ea7bb98050796b649e85481845", "created_at": "2017-09-28T21:11:42.848280",
"email": "airbnb_2@mail.com", "id": "d0ef8146-4664-4de5-8e89-096d667b728e",
"updated_at": "2017-09-28T21:11:42.848294", "first_name": "John", "__class__":
"User"}, "BaseModel.9bf17966-b092-4996-bd33-26a5353cccb4": {"updated_at":
"2017-09-28T21:11:14.963058", "__class__": "BaseModel", "id":
"9bf17966-b092-4996-bd33-26a5353cccb4", "created_at":
"2017-09-28T21:11:14.963049"},
"BaseModel.a42ee380-c959-450e-ad29-c840a898cfce": {"updated_at":
"2017-09-28T21:11:15.504296", "__class__": "BaseModel", "id":
"a42ee380-c959-450e-ad29-c840a898cfce", "created_at":
"2017-09-28T21:11:15.504287"},
"BaseModel.38a22b25-ae9c-4fa9-9f94-59b3eb51bfba": {"updated_at":
"2017-09-28T21:11:13.753347", "__class__": "BaseModel", "id":
"38a22b25-ae9c-4fa9-9f94-59b3eb51bfba", "created_at":
"2017-09-28T21:11:13.753337"},
"BaseModel.2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4": {"updated_at":
"2017-09-28T21:11:14.333862", "__class__": "BaseModel", "id":
"2bf3ebfd-a220-49ee-9ae6-b01c75f6f6a4", "created_at":
"2017-09-28T21:11:14.333852"}, "User.246c227a-d5c1-403d-9bc7-6a47bb9f0f68":
{"password": "root", "created_at": "2017-09-28T21:12:19.611352", "email":
"airbnb@mail.com", "id": "246c227a-d5c1-403d-9bc7-6a47bb9f0f68", "last_name":
"Bar", "updated_at": "2017-09-28T21:12:19.611363", "first_name": "Betty",
"__class__": "User"}, "User.fce12f8a-fdb6-439a-afe8-2881754de71c": {"password":
"root", "created_at": "2017-09-28T21:12:19.611354", "email":
"airbnb_2@mail.com", "id": "fce12f8a-fdb6-439a-afe8-2881754de71c",
"updated_at": "2017-09-28T21:12:19.611368", "first_name": "John", "__class__":
"User"}}
guillaume@ubuntu:~/AirBnB$

No unittests needed for the console

Repo:

● GitHub repository: AirBnB_clone


● File: models/user.py, models/engine/file_storage.py, console.py, tests/

Done! Help Check your code Get a sandbox QA Review

9. More classes!

mandatory

Score: 100.0% (Checks completed: 100.0%)


Write all those classes that inherit from BaseModel:

● State (models/state.py):
○ Public class attributes:
■ name: string - empty string
● City (models/city.py):
○ Public class attributes:
■ state_id: string - empty string: it will be the State.id
■ name: string - empty string
● Amenity (models/amenity.py):
○ Public class attributes:
■ name: string - empty string
● Place (models/place.py):
○ Public class attributes:
■ city_id: string - empty string: it will be the City.id
■ user_id: string - empty string: it will be the User.id
■ name: string - empty string
■ description: string - empty string
■ number_rooms: integer - 0
■ number_bathrooms: integer - 0
■ max_guest: integer - 0
■ price_by_night: integer - 0
■ latitude: float - 0.0
■ longitude: float - 0.0
■ amenity_ids: list of string - empty list: it will be the list of Amenity.id later
● Review (models/review.py):
○ Public class attributes:
■ place_id: string - empty string: it will be the Place.id
■ user_id: string - empty string: it will be the User.id
■ text: string - empty string

Repo:

● GitHub repository: AirBnB_clone


● File: models/state.py, models/city.py, models/amenity.py, models/place.py,
models/review.py, tests/
Done! Help Check your code Get a sandbox QA Review

10. Console 1.0

mandatory

Score: 100.0% (Checks completed: 100.0%)

Update FileStorage to manage correctly serialization and deserialization of all our new classes: Place,
State, City, Amenity and Review

Update your command interpreter (console.py) to allow those actions: show, create, destroy, update
and all with all classes created previously.

Enjoy your first console!

No unittests needed for the console

Repo:

● GitHub repository: AirBnB_clone


● File: console.py, models/engine/file_storage.py, tests/
Done! Help Check your code Get a sandbox QA Review

11. All instances by class name

#advanced

Score: 100.0% (Checks completed: 100.0%)

Update your command interpreter (console.py) to retrieve all instances of a class by using: <class
name>.all().

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) User.all()
[[User] (246c227a-d5c1-403d-9bc7-6a47bb9f0f68) {'first_name': 'Betty',
'last_name': 'Bar', 'created_at': datetime.datetime(2017, 9, 28, 21, 12, 19,
611352), 'updated_at': datetime.datetime(2017, 9, 28, 21, 12, 19, 611363),
'password': '63a9f0ea7bb98050796b649e85481845', 'email': 'airbnb@mail.com',
'id': '246c227a-d5c1-403d-9bc7-6a47bb9f0f68'}, [User]
(38f22813-2753-4d42-b37c-57a17f1e4f88) {'first_name': 'Betty', 'last_name':
'Bar', 'created_at': datetime.datetime(2017, 9, 28, 21, 11, 42, 848279),
'updated_at': datetime.datetime(2017, 9, 28, 21, 11, 42, 848291), 'password':
'b9be11166d72e9e3ae7fd407165e4bd2', 'email': 'airbnb@mail.com', 'id':
'38f22813-2753-4d42-b37c-57a17f1e4f88'}]
(hbnb)

No unittests needed

Repo:
● GitHub repository: AirBnB_clone
● File: console.py

Done! Help Check your code Get a sandbox QA Review

12. Count instances

#advanced

Score: 100.0% (Checks completed: 100.0%)

Update your command interpreter (console.py) to retrieve the number of instances of a class: <class
name>.count().

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) User.count()
2
(hbnb)

No unittests needed

Repo:

● GitHub repository: AirBnB_clone


● File: console.py
Done! Help Check your code Get a sandbox QA Review

13. Show

#advanced

Score: 100.0% (Checks completed: 100.0%)

Update your command interpreter (console.py) to retrieve an instance based on its ID: <class
name>.show(<id>).

Errors management must be the same as previously.

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) User.show("246c227a-d5c1-403d-9bc7-6a47bb9f0f68")
[User] (246c227a-d5c1-403d-9bc7-6a47bb9f0f68) {'first_name': 'Betty',
'last_name': 'Bar', 'created_at': datetime.datetime(2017, 9, 28, 21, 12, 19,
611352), 'updated_at': datetime.datetime(2017, 9, 28, 21, 12, 19, 611363),
'password': '63a9f0ea7bb98050796b649e85481845', 'email': 'airbnb@mail.com',
'id': '246c227a-d5c1-403d-9bc7-6a47bb9f0f68'}
(hbnb) User.show("Bar")
** no instance found **
(hbnb)

No unittests needed

Repo:
● GitHub repository: AirBnB_clone
● File: console.py

Done! Help Check your code Get a sandbox QA Review

14. Destroy

#advanced

Score: 100.0% (Checks completed: 100.0%)

Update your command interpreter (console.py) to destroy an instance based on his ID: <class
name>.destroy(<id>).

Errors management must be the same as previously.

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) User.count()
2
(hbnb) User.destroy("246c227a-d5c1-403d-9bc7-6a47bb9f0f68")
(hbnb) User.count()
1
(hbnb) User.destroy("Bar")
** no instance found **
(hbnb)

No unittests needed
Repo:

● GitHub repository: AirBnB_clone


● File: console.py

Done! Help Check your code Get a sandbox QA Review

15. Update

#advanced

Score: 100.0% (Checks completed: 100.0%)

Update your command interpreter (console.py) to update an instance based on his ID: <class
name>.update(<id>, <attribute name>, <attribute value>).

Errors management must be the same as previously.

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) User.show("38f22813-2753-4d42-b37c-57a17f1e4f88")
[User] (38f22813-2753-4d42-b37c-57a17f1e4f88) {'first_name': 'Betty',
'last_name': 'Bar', 'created_at': datetime.datetime(2017, 9, 28, 21, 11, 42,
848279), 'updated_at': datetime.datetime(2017, 9, 28, 21, 11, 42, 848291),
'password': 'b9be11166d72e9e3ae7fd407165e4bd2', 'email': 'airbnb@mail.com',
'id': '38f22813-2753-4d42-b37c-57a17f1e4f88'}
(hbnb)
(hbnb) User.update("38f22813-2753-4d42-b37c-57a17f1e4f88", "first_name",
"John")
(hbnb) User.update("38f22813-2753-4d42-b37c-57a17f1e4f88", "age", 89)
(hbnb)
(hbnb) User.show("38f22813-2753-4d42-b37c-57a17f1e4f88")
[User] (38f22813-2753-4d42-b37c-57a17f1e4f88) {'age': 89, 'first_name': 'John',
'last_name': 'Bar', 'created_at': datetime.datetime(2017, 9, 28, 21, 11, 42,
848279), 'updated_at': datetime.datetime(2017, 9, 28, 21, 15, 32, 299055),
'password': 'b9be11166d72e9e3ae7fd407165e4bd2', 'email': 'airbnb@mail.com',
'id': '38f22813-2753-4d42-b37c-57a17f1e4f88'}
(hbnb)

No unittests needed

Repo:

● GitHub repository: AirBnB_clone


● File: console.py

Done! Help Check your code Get a sandbox QA Review

16. Update from dictionary

#advanced

Score: 100.0% (Checks completed: 100.0%)

Update your command interpreter (console.py) to update an instance based on his ID with a dictionary:
<class name>.update(<id>, <dictionary representation>).
Errors management must be the same as previously.

guillaume@ubuntu:~/AirBnB$ ./console.py
(hbnb) User.show("38f22813-2753-4d42-b37c-57a17f1e4f88")
[User] (38f22813-2753-4d42-b37c-57a17f1e4f88) {'age': 23, 'first_name': 'Bob',
'last_name': 'Bar', 'created_at': datetime.datetime(2017, 9, 28, 21, 11, 42,
848279), 'updated_at': datetime.datetime(2017, 9, 28, 21, 15, 32, 299055),
'password': 'b9be11166d72e9e3ae7fd407165e4bd2', 'email': 'airbnb@mail.com',
'id': '38f22813-2753-4d42-b37c-57a17f1e4f88'}
(hbnb)
(hbnb) User.update("38f22813-2753-4d42-b37c-57a17f1e4f88", {'first_name':
"John", "age": 89})
(hbnb)
(hbnb) User.show("38f22813-2753-4d42-b37c-57a17f1e4f88")
[User] (38f22813-2753-4d42-b37c-57a17f1e4f88) {'age': 89, 'first_name': 'John',
'last_name': 'Bar', 'created_at': datetime.datetime(2017, 9, 28, 21, 11, 42,
848279), 'updated_at': datetime.datetime(2017, 9, 28, 21, 17, 10, 788143),
'password': 'b9be11166d72e9e3ae7fd407165e4bd2', 'email': 'airbnb@mail.com',
'id': '38f22813-2753-4d42-b37c-57a17f1e4f88'}
(hbnb)

No unittests needed

Repo:

● GitHub repository: AirBnB_clone


● File: console.py

Done? Help Check your code Get a sandbox QA Review

17. Unittests for the Console!


#advanced

Score: 100.0% (Checks completed: 100.0%)

Write all unittests for console.py, all features!

For testing the console, you should “intercept” STDOUT of it, we highly recommend you to use:

with patch('sys.stdout', new=StringIO()) as f:


HBNBCommand().onecmd("help show")

Otherwise, you will have to re-write the console by replacing precmd by default.

Repo:

● GitHub repository: AirBnB_clone


● File: tests/test_console.py

Done! Help Check your code Get a sandbox QA Review

Ready for a new manual review


0x00. Fix my code
Debugging

● By: Guillaume

● Weight: 1

● Project over - took place from May 15, 2023 6:00 AM to May 29, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…

● Auto QA review: 1.0/1 mandatory & 85.0/85 optional


● Altogether: 200.0%
○ Mandatory: 100.0%
○ Optional: 100.0%
○ Calculation: 100.0% + (100.0% * 100.0%) == 200.0%

Background Context
Fix my code is a new type of project, where we’ll jump into an existing code base and fix it!

Sometimes you will know the language, sometimes not.

Please download the repository 0x00-Fix_My_Code_Challenge and use it as initial files for all solutions.

You should not recode everything, just fix it!

This project is NOT mandatory at all. It is 100% optional. Doing any part of this project will add a project
grade of over 100% to your average. Your score won’t get hurt if you don’t do it, but if your current
average is greater than your score on this project, your average might go down. Have fun!
Requirements

General

● Allowed editors: vi, vim, emacs


● All your files will be compiled on Ubuntu 20.04 LTS
● All your files should end with a new line
● A README.md file, at the root of the folder of the project is mandatory

Tasks
0. FizzBuzz

#advanced

Score: 100.0% (Checks completed: 100.0%)

Please take a look at my implementation of FizzBuzz in Python: source code

Something is going wrong….

$ ./0-fizzbuzz.py 50
1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 Fizz 16 17 Fizz 19 Buzz Fizz
22 23 Fizz Buzz 26 Fizz 28 29 Fizz 31 32 Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41
Fizz 43 44 Fizz 46 47 Fizz 49 Buzz
$
15 should print FizzBuzz not Fizz

Repo:

● GitHub repository: Fix_My_Code_Challenge


● Directory: 0x00-challenge
● File: 0-fizzbuzz.py

Done! Help Check your code Get a sandbox QA Review

1. Print square

#advanced

Score: 100.0% (Checks completed: 100.0%)

Please take a look at my implementation of printing a square in Javascript: source code

Something is going wrong….

$ ./1-print_square.js 4
####
####
####
####
$ ./1-print_square.js 10
################
################
################
################
################
################
################
################
################
################
################
################
################
################
################
################
$

./1-print_square.js 10 should print a square of size 10…

Repo:

● GitHub repository: Fix_My_Code_Challenge


● Directory: 0x00-challenge
● File: 1-print_square.js

Done! Help Check your code Get a sandbox QA Review

2. Sort

#advanced
Score: 100.0% (Checks completed: 100.0%)

Please find here my implementation of sorting arguments in Ruby: source code

Something is going wrong….

$ ruby 2-sort.rb 12 41 2 C 9 -9 31 fun -1 32


31
32
12
41
2
9
-9
-1
$

Repo:

● GitHub repository: Fix_My_Code_Challenge


● Directory: 0x00-challenge
● File: 2-sort.rb

Done! Help Check your code Get a sandbox QA Review

3. User password
#advanced

Score: 100.0% (Checks completed: 100.0%)

Please find here my implementation of a User class in Python: source code

Something is going wrong….

$ ./3-user.py
Test User
is_valid_password should return True if it's the right password
$

My tests should not print any error…

Repo:

● GitHub repository: Fix_My_Code_Challenge


● Directory: 0x00-challenge
● File: 3-user.py

Done! Help Check your code Get a sandbox QA Review

4. Double linked list


#advanced

Score: 100.0% (Checks completed: 100.0%)

Please find here my implementation of a Double linked list in C: source code

Something is going wrong….

$ gcc -Wall -pedantic -Werror -Wextra -std=gnu89 main.c free_dlistint.c


print_dlistint.c add_dnodeint_end.c delete_dnodeint_at_index.c -o
delete_dnodeint
$ ./delete_dnodeint
0
1
2
3
4
98
402
1024
-----------------
0
1
2
3
4
0
402
1024
-----------------
1
2
3
4
0
402
1024
-----------------
2
3
4
0
402
1024
-----------------
3
4
0
402
1024
-----------------
4
0
402
1024
-----------------
0
402
1024
-----------------
402
1024
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
-----------------
$

It doesn’t look right…

Repo:
● GitHub repository: Fix_My_Code_Challenge
● Directory: 0x00-challenge
● File: 4-delete_dnodeint/

Done! Help Check your code QA Review

0x0D. SQL - Introduction


SQLMySQL

● By: Guillaume

● Weight: 1

● Project over - took place from May 16, 2023 6:00 AM to May 17, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…

● Auto QA review: 67.6/104 mandatory & 15.6/24 optional


● Altogether: 107.25%
○ Mandatory: 65.0%
○ Optional: 65.0%
○ Calculation: 65.0% + (65.0% * 65.0%) == 107.25%

Concepts

For this project, we expect you to look at these concepts:

● Databases
● Databases
Resources
Read or watch:

● What is Database & SQL?


● A Basic MySQL Tutorial
● Basic SQL statements: DDL and DML (no need to read the chapter “Privileges”)
● Basic queries: SQL and RA
● SQL technique: functions
● SQL technique: subqueries
● What makes the big difference between a backtick and an apostrophe?
● MySQL Cheat Sheet
● MySQL 8.0 SQL Statement Syntax
● installing MySQL in Ubuntu 20.04

Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of
Google:
General

● What’s a database
● What’s a relational database
● What does SQL stand for
● What’s MySQL
● How to create a database in MySQL
● What does DDL and DML stand for
● How to CREATE or ALTER a table
● How to SELECT data from a table
● How to INSERT, UPDATE or DELETE data
● What are subqueries
● How to use MySQL functions

Copyright - Plagiarism

● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and
pasting someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.

Requirements

General

● Allowed editors: vi, vim, emacs


● All your files will be executed on Ubuntu 20.04 LTS using MySQL 8.0 (version 8.0.25)
● All your files should end with a new line
● All your SQL queries should have a comment just before (i.e. syntax above)
● All your files should start by a comment describing the task
● All SQL keywords should be in uppercase (SELECT, WHERE…)
● A README.md file, at the root of the folder of the project, is mandatory
● The length of your files will be tested using wc

More Info
Comments for your SQL file:

$ cat my_script.sql
-- 3 first students in the Batch ID=3
-- because Batch 3 is the best!
SELECT id, name FROM students WHERE batch_id = 3 ORDER BY created_at DESC LIMIT
3;
$

Install MySQL 8.0 on Ubuntu 20.04 LTS

$ sudo apt update


$ sudo apt install mysql-server
...
$ mysql --version
mysql Ver 8.0.25-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
$

Connect to your MySQL server:

$ sudo mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.25-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> quit
Bye
$

Use “container-on-demand” to run MySQL


In the container, credentials are root/root

● Ask for container Ubuntu 20.04


● Connect via SSH
● OR connect via the Web terminal
● In the container, you should start MySQL before playing with it:

$ service mysql start


* Starting MySQL database server mysqld
$
$ cat 0-list_databases.sql | mysql -uroot -p
Database
information_schema
mysql
performance_schema
sys
$

In the container, credentials are root/root

Quiz questions

Great! You've completed the quiz successfully! Keep going! (Show quiz)

Tasks
0. List databases

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that lists all databases of your MySQL server.


guillaume@ubuntu:~/$ cat 0-list_databases.sql | mysql -hlocalhost -uroot -p
Enter password:
Database
hbtn_0c_0
information_schema
mysql
performance_schema
sys
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 0-list_databases.sql

Done! Help Check your code Get a sandbox QA Review

1. Create a database

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates the database hbtn_0c_0 in your MySQL server.

● If the database hbtn_0c_0 already exists, your script should not fail
● You are not allowed to use the SELECT or SHOW statements

guillaume@ubuntu:~/$ cat 1-create_database_if_missing.sql | mysql -hlocalhost


-uroot -p
Enter password:
guillaume@ubuntu:~/$ cat 0-list_databases.sql | mysql -hlocalhost -uroot -p
Enter password:
Database
information_schema
hbtn_0c_0
mysql
performance_schema
guillaume@ubuntu:~/$ cat 1-create_database_if_missing.sql | mysql -hlocalhost
-uroot -p
Enter password:
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 1-create_database_if_missing.sql

Done! Help Check your code Get a sandbox QA Review

2. Delete a database

mandatory

Score: 65.0% (Checks completed: 100.0%)


Write a script that deletes the database hbtn_0c_0 in your MySQL server.

● If the database hbtn_0c_0 doesn’t exist, your script should not fail
● You are not allowed to use the SELECT or SHOW statements

guillaume@ubuntu:~/$ cat 0-list_databases.sql | mysql -hlocalhost -uroot -p


Enter password:
Database
hbtn_0c_0
information_schema
mysql
performance_schema
sys
guillaume@ubuntu:~/$ cat 2-remove_database.sql | mysql -hlocalhost -uroot -p
Enter password:
guillaume@ubuntu:~/$ cat 0-list_databases.sql | mysql -hlocalhost -uroot -p
Enter password:
Database
information_schema
mysql
performance_schema
sys
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 2-remove_database.sql

Done! Help Check your code Get a sandbox QA Review

3. List tables
mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that lists all the tables of a database in your MySQL server.

● The database name will be passed as argument of mysql command (in the following
example: mysql is the name of the database)

guillaume@ubuntu:~/$ cat 3-list_tables.sql | mysql -hlocalhost -uroot -p mysql


Enter password:
Tables_in_mysql
columns_priv
component
db
default_roles
engine_cost
func
general_log
global_grants
gtid_executed
help_category
help_keyword
help_relation
help_topic
innodb_index_stats
innodb_table_stats
password_history
plugin
procs_priv
proxies_priv
replication_asynchronous_connection_failover
replication_asynchronous_connection_failover_managed
role_edges
server_cost
servers
slave_master_info
slave_relay_log_info
slave_worker_info
slow_log
tables_priv
time_zone
time_zone_leap_second
time_zone_name
time_zone_transition
time_zone_transition_type
user
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 3-list_tables.sql

Done! Help Check your code Get a sandbox QA Review

4. First table

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates a table called first_table in the current database in your MySQL
server.
● first_table description:
○ id INT
○ name VARCHAR(256)
● The database name will be passed as an argument of the mysql command
● If the table first_table already exists, your script should not fail
● You are not allowed to use the SELECT or SHOW statements

guillaume@ubuntu:~/$ cat 4-first_table.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$ cat 3-list_tables.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
Tables_in_hbtn_0c_0
first_table
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 4-first_table.sql

Done! Help Check your code Get a sandbox QA Review

5. Full description

mandatory

Score: 65.0% (Checks completed: 100.0%)


Write a script that prints the full description of the table first_table from the database hbtn_0c_0
in your MySQL server.

● The database name will be passed as an argument of the mysql command


● You are not allowed to use the DESCRIBE or EXPLAIN statements

guillaume@ubuntu:~/$ cat 5-full_table.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
Table Create Table
first_table CREATE TABLE `first_table` (\n `id` int DEFAULT NULL,\n
`name` varchar(256) DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
COLLATE=utf8mb4_0900_ai_ci
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 5-full_table.sql

Done! Help Check your code Get a sandbox QA Review

6. List all in table

mandatory

Score: 65.0% (Checks completed: 100.0%)


Write a script that lists all rows of the table first_table from the database hbtn_0c_0 in your
MySQL server.

● All fields should be printed


● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 6-list_values.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 6-list_values.sql

Done! Help Check your code Get a sandbox QA Review

7. First add

mandatory

Score: 65.0% (Checks completed: 100.0%)


Write a script that inserts a new row in the table first_table (database hbtn_0c_0) in your
MySQL server.

● New row:
○ id = 89
○ name = Best School
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 7-insert_value.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$ cat 6-list_values.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
id name
89 Best School
guillaume@ubuntu:~/$ cat 7-insert_value.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$ cat 7-insert_value.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$ cat 6-list_values.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
id name
89 Best School
89 Best School
89 Best School
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 7-insert_value.sql
Done! Help Check your code Get a sandbox QA Review

8. Count 89

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that displays the number of records with id = 89 in the table first_table of the
database hbtn_0c_0 in your MySQL server.

● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 8-count_89.sql | mysql -hlocalhost -uroot -p hbtn_0c_0


| tail -1
Enter password:
3
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 8-count_89.sql
Done! Help Check your code Get a sandbox QA Review

9. Full creation

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates a table second_table in the database hbtn_0c_0 in your MySQL server
and add multiples rows.

● second_table description:
○ id INT
○ name VARCHAR(256)
○ score INT
● The database name will be passed as an argument to the mysql command
● If the table second_table already exists, your script should not fail
● You are not allowed to use the SELECT and SHOW statements
● Your script should create these records:
○ id = 1, name = “John”, score = 10
○ id = 2, name = “Alex”, score = 3
○ id = 3, name = “Bob”, score = 14
○ id = 4, name = “George”, score = 8

guillaume@ubuntu:~/$ cat 9-full_creation.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$
Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 9-full_creation.sql

Done! Help Check your code Get a sandbox QA Review

10. List by best

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that lists all records of the table second_table of the database hbtn_0c_0 in your
MySQL server.

● Results should display both the score and the name (in this order)
● Records should be ordered by score (top first)
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 10-top_score.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
score name
14 Bob
10 John
8 George
3 Alex
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 10-top_score.sql

Done! Help Check your code Get a sandbox QA Review

11. Select the best

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that lists all records with a score >= 10 in the table second_table of the database
hbtn_0c_0 in your MySQL server.

● Results should display both the score and the name (in this order)
● Records should be ordered by score (top first)
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 11-best_score.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
score name
14 Bob
10 John
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 11-best_score.sql

Done! Help Check your code Get a sandbox QA Review

12. Cheating is bad

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that updates the score of Bob to 10 in the table second_table.

● You are not allowed to use Bob’s id value, only the name field
● The database name will be passed as an argument of the mysql command
guillaume@ubuntu:~/$ cat 12-no_cheating.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$ cat 10-top_score.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
score name
10 John
10 Bob
8 George
3 Alex
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 12-no_cheating.sql

Done! Help Check your code Get a sandbox QA Review

13. Score too low

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that removes all records with a score <= 5 in the table second_table of the
database hbtn_0c_0 in your MySQL server.
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 13-change_class.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
guillaume@ubuntu:~/$ cat 10-top_score.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
score name
10 John
10 Bob
8 George
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 13-change_class.sql

Done! Help Check your code Get a sandbox QA Review

14. Average

mandatory

Score: 65.0% (Checks completed: 100.0%)


Write a script that computes the score average of all records in the table second_table of the
database hbtn_0c_0 in your MySQL server.

● The result column name should be average


● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 14-average.sql | mysql -hlocalhost -uroot -p hbtn_0c_0


Enter password:
average
9.3333
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 14-average.sql

Done! Help Check your code Get a sandbox QA Review

15. Number by score

mandatory

Score: 65.0% (Checks completed: 100.0%)


Write a script that lists the number of records with the same score in the table second_table of the
database hbtn_0c_0 in your MySQL server.

● The result should display:


○ the score
○ the number of records for this score with the label number
● The list should be sorted by the number of records (descending)
● The database name will be passed as an argument to the mysql command

guillaume@ubuntu:~/$ cat 15-groups.sql | mysql -hlocalhost -uroot -p hbtn_0c_0


Enter password:
score number
10 2
8 1
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 15-groups.sql

Done! Help Check your code Get a sandbox QA Review

16. Say my name

mandatory
Score: 65.0% (Checks completed: 100.0%)

Write a script that lists all records of the table second_table of the database hbtn_0c_0 in your
MySQL server.

● Don’t list rows without a name value


● Results should display the score and the name (in this order)
● Records should be listed by descending score
● The database name will be passed as an argument to the mysql command

In this example, new data have been added to the table second_table.

guillaume@ubuntu:~/$ cat 16-no_link.sql | mysql -hlocalhost -uroot -p hbtn_0c_0


Enter password:
score name
18 Aria
12 Aria
10 John
10 Bob
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 16-no_link.sql

Done! Help Check your code Get a sandbox QA Review


17. Go to UTF8

#advanced

Score: 65.0% (Checks completed: 100.0%)

Write a script that converts hbtn_0c_0 database to UTF8 (utf8mb4, collate utf8mb4_unicode_ci)
in your MySQL server.

You need to convert all of the following to UTF8:

● Database hbtn_0c_0
● Table first_table
● Field name in first_table

guillaume@ubuntu:~/$ cat 100-move_to_utf8.sql | mysql -hlocalhost -uroot -p


Enter password:
guillaume@ubuntu:~/$ cat 5-full_table.sql | mysql -hlocalhost -uroot -p
hbtn_0c_0
Enter password:
Table Create Table
first_table CREATE TABLE `first_table` (\n `id` int(11) DEFAULT NULL,\n
`name` varchar(256) COLLATE utf8mb4_unicode_ci DEFAULT NULL\n) ENGINE=InnoDB
DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
guillaume@ubuntu:~/$

Repo:
● GitHub repository: alx-higher_level_programming
● Directory: 0x0D-SQL_introduction
● File: 100-move_to_utf8.sql

Done! Help Check your code Get a sandbox QA Review

18. Temperatures #0

#advanced

Score: 65.0% (Checks completed: 100.0%)

Import in hbtn_0c_0 database this table dump: download

Write a script that displays the average temperature (Fahrenheit) by city ordered by temperature
(descending).

guillaume@ubuntu:~/$ cat 101-avg_temperatures.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
city avg_temp
Chandler 72.8627
Gilbert 71.8088
Pismo beach 71.5147
San Francisco 71.4804
Sedona 70.7696
Phoenix 70.5882
Oakland 70.5637
Sunnyvale 70.5245
Chicago 70.4461
San Diego 70.1373
Glendale 70.1225
Sonoma 70.0392
Yuma 69.3873
San Jose 69.2990
Tucson 69.0245
Joliet 68.6716
Naperville 68.1029
Tempe 67.0441
Peoria 66.5392
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 101-avg_temperatures.sql

Done! Help Check your code Get a sandbox QA Review

19. Temperatures #1

#advanced

Score: 65.0% (Checks completed: 100.0%)

Import in hbtn_0c_0 database this table dump: download (same as Temperatures #0)
Write a script that displays the top 3 of cities temperature during July and August ordered by
temperature (descending)

guillaume@ubuntu:~/$ cat 102-top_city.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
city avg_temp
Naperville 76.9412
San Diego 73.7941
Sunnyvale 73.2353
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 102-top_city.sql

Done! Help Check your code Get a sandbox QA Review

20. Temperatures #2

#advanced

Score: 65.0% (Checks completed: 100.0%)

Import in hbtn_0c_0 database this table dump: download (same as Temperatures #0)
Write a script that displays the max temperature of each state (ordered by State name).

guillaume@ubuntu:~/$ cat 103-max_state.sql | mysql -hlocalhost -uroot -p


hbtn_0c_0
Enter password:
state max_temp
AZ 110
CA 110
IL 110
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0D-SQL_introduction
● File: 103-max_state.sql

Done! Help Check your code Get a sandbox

0x0E. SQL - More queries


SQLMySQL

● By: Guillaume

● Weight: 1

● Project over - took place from May 17, 2023 6:00 AM to May 18, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…
● Auto QA review: 58.5/104 mandatory & 15.6/24 optional
● Altogether: 92.81%
○ Mandatory: 56.25%
○ Optional: 65.0%
○ Calculation: 56.25% + (56.25% * 65.0%) == 92.81%

Resources
Read or watch:

● How To Create a New User and Grant Permissions in MySQL


● How To Use MySQL GRANT Statement To Grant Privileges To a User
● MySQL constraints
● SQL technique: subqueries
● Basic query operation: the join
● SQL technique: multiple joins and the distinct keyword
● SQL technique: join types
● SQL technique: union and minus
● MySQL Cheat Sheet
● The Seven Types of SQL Joins
● MySQL Tutorial
● SQL Style Guide
● MySQL 8.0 SQL Statement Syntax

Extra resources around relational database model design:

● Design
● Normalization
● ER Modeling

Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of Google:

General

● How to create a new MySQL user


● How to manage privileges for a user to a database or table
● What’s a PRIMARY KEY
● What’s a FOREIGN KEY
● How to use NOT NULL and UNIQUE constraints
● How to retrieve datas from multiple tables in one request
● What are subqueries
● What are JOIN and UNION

Copyright - Plagiarism
● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and pasting
someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.

Requirements

General

● Allowed editors: vi, vim, emacs


● All your files will be executed on Ubuntu 20.04 LTS using MySQL 8.0 (version 8.0.25)
● All your files should end with a new line
● All your SQL queries should have a comment just before (i.e. syntax above)
● All your files should start by a comment describing the task
● All SQL keywords should be in uppercase (SELECT, WHERE…)
● A README.md file, at the root of the folder of the project, is mandatory
● The length of your files will be tested using wc

More Info

Comments for your SQL file:

$ cat my_script.sql
-- 3 first students in the Batch ID=3
-- because Batch 3 is the best!
SELECT id, name FROM students WHERE batch_id = 3 ORDER BY created_at DESC LIMIT
3;
$

Install MySQL 8.0 on Ubuntu 20.04 LTS

$ sudo apt update


$ sudo apt install mysql-server
...
$ mysql --version
mysql Ver 8.0.25-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
$

Connect to your MySQL server:

$ sudo mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.25-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> quit
Bye
$

Use “container-on-demand” to run MySQL

In the container, credentials are root/root

● Ask for container Ubuntu 20.04


● Connect via SSH
● OR connect via the Web terminal
● In the container, you should start MySQL before playing with it:

$ service mysql start


* Starting MySQL database server mysqld
$
$ cat 0-list_databases.sql | mysql -uroot -p
Database
information_schema
mysql
performance_schema
sys
$

In the container, credentials are root/root

How to import a SQL dump

$ echo "CREATE DATABASE hbtn_0d_tvshows;" | mysql -uroot -p


Enter password:
$ curl
"https://s3.amazonaws.com/intranet-projects-files/holbertonschool-higher-level_
programming+/274/hbtn_0d_tvshows.sql" -s | mysql -uroot -p hbtn_0d_tvshows
Enter password:
$ echo "SELECT * FROM tv_genres" | mysql -uroot -p hbtn_0d_tvshows
Enter password:
id name
1 Drama
2 Mystery
3 Adventure
4 Fantasy
5 Comedy
6 Crime
7 Suspense
8 Thriller
$
Quiz questions

Great! You've completed the quiz successfully! Keep going! (Show quiz)

Tasks
0. My privileges!

mandatory

Score: 65.0% (Checks completed: 100.0%)


Write a script that lists all privileges of the MySQL users user_0d_1 and user_0d_2 on your server (in
localhost).

guillaume@ubuntu:~/$ cat 0-privileges.sql | mysql -hlocalhost -uroot -p


Enter password:
ERROR 1141 (42000) at line 3: There is no such grant defined for user
'user_0d_1' on host 'localhost'
guillaume@ubuntu:~/$
guillaume@ubuntu:~/$ echo "CREATE USER 'user_0d_1'@'localhost';" | mysql
-hlocalhost -uroot -p
Enter password:
guillaume@ubuntu:~/$ echo "GRANT ALL PRIVILEGES ON *.* TO
'user_0d_1'@'localhost';" | mysql -hlocalhost -uroot -p
Enter password:
guillaume@ubuntu:~/$ cat 0-privileges.sql | mysql -hlocalhost -uroot -p
Enter password:
Grants for user_0d_1@localhost
GRANT SELECT, INSERT, UPDA..., DROP ROLE ON *.* TO `user_0d_1`@`localhost`
GRANT APPLICATION_PASSWORD_ADMIN,AUDIT...,XA_RECOVER_ADMIN ON *.* TO
`user_0d_1`@`localhost`
ERROR 1141 (42000) at line 4: There is no such grant defined for user
'user_0d_2' on host 'localhost'
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 0-privileges.sql

Done! Help Check your code Get a sandbox QA Review

1. Root user
mandatory

Score: 21.67% (Checks completed: 33.33%)

Write a script that creates the MySQL server user user_0d_1.

● user_0d_1 should have all privileges on your MySQL server


● The user_0d_1 password should be set to user_0d_1_pwd
● If the user user_0d_1 already exists, your script should not fail

guillaume@ubuntu:~/$ cat 1-create_user.sql | mysql -hlocalhost -uroot -p


Enter password:
guillaume@ubuntu:~/$ cat 0-privileges.sql | mysql -hlocalhost -uroot -p
Enter password:
Grants for user_0d_1@localhost
GRANT SELECT, INSERT..., DROP ROLE ON *.* TO `user_0d_1`@`localhost`
GRANT APPLICATION_PASSWORD_ADMIN,...,XA_RECOVER_ADMIN ON *.* TO
`user_0d_1`@`localhost`
ERROR 1141 (42000) at line 4: There is no such grant defined for user
'user_0d_2' on host 'localhost'
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 1-create_user.sql

Done? Help Check your code Ask for a new correction Get a sandbox QA Review
2. Read user

mandatory

Score: 21.67% (Checks completed: 33.33%)

Write a script that creates the database hbtn_0d_2 and the user user_0d_2.

● user_0d_2 should have only SELECT privilege in the database hbtn_0d_2


● The user_0d_2 password should be set to user_0d_2_pwd
● If the database hbtn_0d_2 already exists, your script should not fail
● If the user user_0d_2 already exists, your script should not fail

guillaume@ubuntu:~/$ cat 2-create_read_user.sql | mysql -hlocalhost -uroot -p


Enter password:
guillaume@ubuntu:~/$ cat 0-privileges.sql | mysql -hlocalhost -uroot -p
Enter password:
Grants for user_0d_1@localhost
GRANT SELECT, ..., DROP ROLE ON *.* TO `user_0d_1`@`localhost`
GRANT APPLICATION_PASSWORD_ADMIN,...,XA_RECOVER_ADMIN ON *.* TO
`user_0d_1`@`localhost`
Grants for user_0d_2@localhost
GRANT USAGE ON *.* TO `user_0d_2`@`localhost`
GRANT SELECT ON `hbtn_0d_2`.* TO `user_0d_2`@`localhost`
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 2-create_read_user.sql

Done? Help Check your code Ask for a new correction Get a sandbox QA Review

3. Always a name

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates the table force_name on your MySQL server.

● force_name description:
○ id INT
○ name VARCHAR(256) can’t be null
● The database name will be passed as an argument of the mysql command
● If the table force_name already exists, your script should not fail

guillaume@ubuntu:~/$ cat 3-force_name.sql | mysql -hlocalhost -uroot -p


hbtn_0d_2
Enter password:
guillaume@ubuntu:~/$ echo 'INSERT INTO force_name (id, name) VALUES (89, "Best
School");' | mysql -hlocalhost -uroot -p hbtn_0d_2
Enter password:
guillaume@ubuntu:~/$ echo 'SELECT * FROM force_name;' | mysql -hlocalhost
-uroot -p hbtn_0d_2
Enter password:
id name
89 Best School
guillaume@ubuntu:~/$ echo 'INSERT INTO force_name (id) VALUES (333);' | mysql
-hlocalhost -uroot -p hbtn_0d_2
Enter password:
ERROR 1364 (HY000) at line 1: Field 'name' doesn't have a default value
guillaume@ubuntu:~/$ echo 'SELECT * FROM force_name;' | mysql -hlocalhost
-uroot -p hbtn_0d_2
Enter password:
id name
89 Best School
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 3-force_name.sql

Done! Help Check your code Get a sandbox QA Review

4. ID can't be null

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates the table id_not_null on your MySQL server.

● id_not_null description:
○ id INT with the default value 1
○ name VARCHAR(256)
● The database name will be passed as an argument of the mysql command
● If the table id_not_null already exists, your script should not fail

guillaume@ubuntu:~/$ cat 4-never_empty.sql | mysql -hlocalhost -uroot -p


hbtn_0d_2
Enter password:
guillaume@ubuntu:~/$ echo 'INSERT INTO id_not_null (id, name) VALUES (89, "Best
School");' | mysql -hlocalhost -uroot -p hbtn_0d_2
Enter password:
guillaume@ubuntu:~/$ echo 'SELECT * FROM id_not_null;' | mysql -hlocalhost
-uroot -p hbtn_0d_2
Enter password:
id name
89 Best School
guillaume@ubuntu:~/$ echo 'INSERT INTO id_not_null (name) VALUES ("Best");' |
mysql -hlocalhost -uroot -p hbtn_0d_2
Enter password:
guillaume@ubuntu:~/$ echo 'SELECT * FROM id_not_null;' | mysql -hlocalhost
-uroot -p hbtn_0d_2
Enter password:
id name
89 Best School
1 Best
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 4-never_empty.sql

Done! Help Check your code Get a sandbox QA Review


5. Unique ID

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates the table unique_id on your MySQL server.

● unique_id description:
○ id INT with the default value 1 and must be unique
○ name VARCHAR(256)
● The database name will be passed as an argument of the mysql command
● If the table unique_id already exists, your script should not fail

guillaume@ubuntu:~/$ cat 5-unique_id.sql | mysql -hlocalhost -uroot -p


hbtn_0d_2
Enter password:
guillaume@ubuntu:~/$ echo 'INSERT INTO unique_id (id, name) VALUES (89, "Best
School");' | mysql -hlocalhost -uroot -p hbtn_0d_2
Enter password:
guillaume@ubuntu:~/$ echo 'SELECT * FROM unique_id;' | mysql -hlocalhost -uroot
-p hbtn_0d_2
Enter password:
id name
89 Best School
guillaume@ubuntu:~/$ echo 'INSERT INTO unique_id (id, name) VALUES (89,
"Best");' | mysql -hlocalhost -uroot -p hbtn_0d_2
Enter password:
ERROR 1062 (23000) at line 1: Duplicate entry '89' for key 'unique_id.id'
guillaume@ubuntu:~/$ echo 'SELECT * FROM unique_id;' | mysql -hlocalhost -uroot
-p hbtn_0d_2
Enter password:
id name
89 Best School
guillaume@ubuntu:~/$
Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 5-unique_id.sql

Done! Help Check your code Get a sandbox QA Review

6. States table

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates the database hbtn_0d_usa and the table states (in the database
hbtn_0d_usa) on your MySQL server.

● states description:
○ id INT unique, auto generated, can’t be null and is a primary key
○ name VARCHAR(256) can’t be null
● If the database hbtn_0d_usa already exists, your script should not fail
● If the table states already exists, your script should not fail

guillaume@ubuntu:~/$ cat 6-states.sql | mysql -hlocalhost -uroot -p


Enter password:
guillaume@ubuntu:~/$ echo 'INSERT INTO states (name) VALUES ("California"),
("Arizona"), ("Texas");' | mysql -hlocalhost -uroot -p hbtn_0d_usa
Enter password:
guillaume@ubuntu:~/$ echo 'SELECT * FROM states;' | mysql -hlocalhost -uroot -p
hbtn_0d_usa
Enter password:
id name
1 California
2 Arizona
3 Texas
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 6-states.sql

Done! Help Check your code Get a sandbox QA Review

7. Cities table

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that creates the database hbtn_0d_usa and the table cities (in the database
hbtn_0d_usa) on your MySQL server.

● cities description:
○ id INT unique, auto generated, can’t be null and is a primary key
○ state_id INT, can’t be null and must be a FOREIGN KEY that references to id of the
states table
○ name VARCHAR(256) can’t be null
● If the database hbtn_0d_usa already exists, your script should not fail
● If the table cities already exists, your script should not fail

guillaume@ubuntu:~/$ cat 7-cities.sql | mysql -hlocalhost -uroot -p


Enter password:
guillaume@ubuntu:~/$ echo 'INSERT INTO cities (state_id, name) VALUES (1, "San
Francisco");' | mysql -hlocalhost -uroot -p hbtn_0d_usa
Enter password:
guillaume@ubuntu:~/$ echo 'SELECT * FROM cities;' | mysql -hlocalhost -uroot -p
hbtn_0d_usa
Enter password:
id state_id name
1 1 San Francisco
guillaume@ubuntu:~/$ echo 'INSERT INTO cities (state_id, name) VALUES (10,
"Paris");' | mysql -hlocalhost -uroot -p hbtn_0d_usa
Enter password:
ERROR 1452 (23000) at line 1: Cannot add or update a child row: a foreign key
constraint fails (`hbtn_0d_usa`.`cities`, CONSTRAINT `cities_ibfk_1` FOREIGN
KEY (`state_id`) REFERENCES `states` (`id`))
guillaume@ubuntu:~/$ echo 'SELECT * FROM cities;' | mysql -hlocalhost -uroot -p
hbtn_0d_usa
Enter password:
id state_id name
1 1 San Francisco
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 7-cities.sql

Done! Help Check your code Get a sandbox QA Review


8. Cities of California

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that lists all the cities of California that can be found in the database hbtn_0d_usa.

● The states table contains only one record where name = California (but the id can be
different, as per the example)
● Results must be sorted in ascending order by cities.id
● You are not allowed to use the JOIN keyword
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ echo 'SELECT * FROM states;' | mysql -hlocalhost -uroot -p


hbtn_0d_usa
Enter password:
id name
1 California
2 Arizona
3 Texas
4 Utah
guillaume@ubuntu:~/$ echo 'SELECT * FROM cities;' | mysql -hlocalhost -uroot -p
hbtn_0d_usa
Enter password:
id state_id name
1 1 San Francisco
2 1 San Jose
4 2 Page
6 3 Paris
7 3 Houston
8 3 Dallas
guillaume@ubuntu:~/$ cat 8-cities_of_california_subquery.sql | mysql
-hlocalhost -uroot -p hbtn_0d_usa
Enter password:
id name
1 San Francisco
2 San Jose
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 8-cities_of_california_subquery.sql

Done! Help Check your code Get a sandbox QA Review

9. Cities by States

mandatory

Score: 65.0% (Checks completed: 100.0%)

Write a script that lists all cities contained in the database hbtn_0d_usa.

● Each record should display: cities.id - cities.name - states.name


● Results must be sorted in ascending order by cities.id
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command
guillaume@ubuntu:~/$ echo 'SELECT * FROM states;' | mysql -hlocalhost -uroot -p
hbtn_0d_usa
Enter password:
id name
1 California
2 Arizona
3 Texas
4 Utah
guillaume@ubuntu:~/$ echo 'SELECT * FROM cities;' | mysql -hlocalhost -uroot -p
hbtn_0d_usa
Enter password:
id state_id name
1 1 San Francisco
2 1 San Jose
4 2 Page
6 3 Paris
7 3 Houston
8 3 Dallas
guillaume@ubuntu:~/$ cat 9-cities_by_state_join.sql | mysql -hlocalhost -uroot
-p hbtn_0d_usa
Enter password:
id name name
1 San Francisco California
2 San Jose California
4 Page Arizona
6 Paris Texas
7 Houston Texas
8 Dallas Texas
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 9-cities_by_state_join.sql

Done! Help Check your code Get a sandbox QA Review


10. Genre ID by show

mandatory

Score: 65.0% (Checks completed: 100.0%)

Import the database dump from hbtn_0d_tvshows to your MySQL server: download

Write a script that lists all shows contained in hbtn_0d_tvshows that have at least one genre linked.

● Each record should display: tv_shows.title - tv_show_genres.genre_id


● Results must be sorted in ascending order by tv_shows.title and tv_show_genres.genre_id
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 10-genre_id_by_show.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows
Enter password:
title genre_id
Breaking Bad 1
Breaking Bad 6
Breaking Bad 7
Breaking Bad 8
Dexter 1
Dexter 2
Dexter 6
Dexter 7
Dexter 8
Game of Thrones 1
Game of Thrones 3
Game of Thrones 4
House 1
House 2
New Girl 5
Silicon Valley 5
The Big Bang Theory 5
The Last Man on Earth 1
The Last Man on Earth 5
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 10-genre_id_by_show.sql

Done! Help Check your code Get a sandbox QA Review

11. Genre ID for all shows

mandatory

Score: 65.0% (Checks completed: 100.0%)

Import the database dump of hbtn_0d_tvshows to your MySQL server: download (same as
10-genre_id_by_show.sql)

Write a script that lists all shows contained in the database hbtn_0d_tvshows.
● Each record should display: tv_shows.title - tv_show_genres.genre_id
● Results must be sorted in ascending order by tv_shows.title and tv_show_genres.genre_id
● If a show doesn’t have a genre, display NULL
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 11-genre_id_all_shows.sql | mysql -hlocalhost -uroot


-p hbtn_0d_tvshows
Enter password:
title genre_id
Better Call Saul NULL
Breaking Bad 1
Breaking Bad 6
Breaking Bad 7
Breaking Bad 8
Dexter 1
Dexter 2
Dexter 6
Dexter 7
Dexter 8
Game of Thrones 1
Game of Thrones 3
Game of Thrones 4
Homeland NULL
House 1
House 2
New Girl 5
Silicon Valley 5
The Big Bang Theory 5
The Last Man on Earth 1
The Last Man on Earth 5
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 11-genre_id_all_shows.sql
Done! Help Check your code Get a sandbox QA Review

12. No genre

mandatory

Score: 0.0% (Checks completed: 0.0%)

Import the database dump from hbtn_0d_tvshows to your MySQL server: download (same as
11-genre_id_all_shows.sql)

Write a script that lists all shows contained in hbtn_0d_tvshows without a genre linked.

● Each record should display: tv_shows.title - tv_show_genres.genre_id


● Results must be sorted in ascending order by tv_shows.title and tv_show_genres.genre_id
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 12-no_genre.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows
Enter password:
title genre_id
Better Call Saul NULL
Homeland NULL
guillaume@ubuntu:~/$

Repo:
● GitHub repository: alx-higher_level_programming
● Directory: 0x0E-SQL_more_queries
● File: 12-no_genre.sql

Done? Help Check your code Ask for a new correction Get a sandbox QA Review

13. Number of shows by genre

mandatory

Score: 65.0% (Checks completed: 100.0%)

Import the database dump from hbtn_0d_tvshows to your MySQL server: download (same as
12-no_genre.sql)

Write a script that lists all genres from hbtn_0d_tvshows and displays the number of shows linked to
each.

● Each record should display: <TV Show genre> - <Number of shows linked to this genre>
● First column must be called genre
● Second column must be called number_of_shows
● Don’t display a genre that doesn’t have any shows linked
● Results must be sorted in descending order by the number of shows linked
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 13-count_shows_by_genre.sql | mysql -hlocalhost -uroot


-p hbtn_0d_tvshows
Enter password:
genre number_of_shows
Drama 5
Comedy 4
Mystery 2
Crime 2
Suspense 2
Thriller 2
Adventure 1
Fantasy 1
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 13-count_shows_by_genre.sql

Done! Help Check your code Get a sandbox QA Review

14. My genres

mandatory

Score: 65.0% (Checks completed: 100.0%)

Import the database dump from hbtn_0d_tvshows to your MySQL server: download (same as
13-count_shows_by_genre.sql)
Write a script that uses the hbtn_0d_tvshows database to lists all genres of the show Dexter.

● The tv_shows table contains only one record where title = Dexter (but the id can be different)
● Each record should display: tv_genres.name
● Results must be sorted in ascending order by the genre name
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 14-my_genres.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows
Enter password:
name
Crime
Drama
Mystery
Suspense
Thriller
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 14-my_genres.sql

Done! Help Check your code Get a sandbox QA Review

15. Only Comedy

mandatory
Score: 65.0% (Checks completed: 100.0%)

Import the database dump from hbtn_0d_tvshows to your MySQL server: download (same as
14-my_genres.sql)

Write a script that lists all Comedy shows in the database hbtn_0d_tvshows.

● The tv_genres table contains only one record where name = Comedy (but the id can be different)
● Each record should display: tv_shows.title
● Results must be sorted in ascending order by the show title
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 15-comedy_only.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows
Enter password:
title
New Girl
Silicon Valley
The Big Bang Theory
The Last Man on Earth
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 15-comedy_only.sql
Done! Help Check your code Get a sandbox QA Review

16. List shows and genres

mandatory

Score: 65.0% (Checks completed: 100.0%)

Import the database dump from hbtn_0d_tvshows to your MySQL server: download (same as
15-comedy_only.sql)

Write a script that lists all shows, and all genres linked to that show, from the database
hbtn_0d_tvshows.

● If a show doesn’t have a genre, display NULL in the genre column


● Each record should display: tv_shows.title - tv_genres.name
● Results must be sorted in ascending order by the show title and genre name
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 16-shows_by_genre.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows
Enter password:
title name
Better Call Saul NULL
Breaking Bad Crime
Breaking Bad Drama
Breaking Bad Suspense
Breaking Bad Thriller
Dexter Crime
Dexter Drama
Dexter Mystery
Dexter Suspense
Dexter Thriller
Game of Thrones Adventure
Game of Thrones Drama
Game of Thrones Fantasy
Homeland NULL
House Drama
House Mystery
New Girl Comedy
Silicon Valley Comedy
The Big Bang Theory Comedy
The Last Man on Earth Comedy
The Last Man on Earth Drama
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 16-shows_by_genre.sql

Done! Help Check your code Get a sandbox QA Review

17. Not my genre

#advanced

Score: 65.0% (Checks completed: 100.0%)


Import the database dump from hbtn_0d_tvshows to your MySQL server: download (same as
16-shows_by_genre.sql)

Write a script that uses the hbtn_0d_tvshows database to list all genres not linked to the show Dexter

● The tv_shows table contains only one record where title = Dexter (but the id can be different)
● Each record should display: tv_genres.name
● Results must be sorted in ascending order by the genre name
● You can use a maximum of two SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 100-not_my_genres.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows
Enter password:
name
Adventure
Comedy
Fantasy
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 100-not_my_genres.sql

Done! Help Check your code Get a sandbox QA Review

18. No Comedy tonight!


#advanced

Score: 65.0% (Checks completed: 100.0%)

Import the database dump from hbtn_0d_tvshows to your MySQL server: download (same as
100-not_my_genres.sql)

Write a script that lists all shows without the genre Comedy in the database hbtn_0d_tvshows.

● The tv_genres table contains only one record where name = Comedy (but the id can be different)
● Each record should display: tv_shows.title
● Results must be sorted in ascending order by the show title
● You can use a maximum of two SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 101-not_a_comedy.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows
Enter password:
title
Better Call Saul
Breaking Bad
Dexter
Game of Thrones
Homeland
House
guillaume@ubuntu:~/$

Repo:
● GitHub repository: alx-higher_level_programming
● Directory: 0x0E-SQL_more_queries
● File: 101-not_a_comedy.sql

Done! Help Check your code Get a sandbox QA Review

19. Rotten tomatoes

#advanced

Score: 65.0% (Checks completed: 100.0%)

Import the database hbtn_0d_tvshows_rate dump to your MySQL server: download

Write a script that lists all shows from hbtn_0d_tvshows_rate by their rating.

● Each record should display: tv_shows.title - rating sum


● Results must be sorted in descending order by the rating
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 102-rating_shows.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows_rate
Enter password:
title rating
Better Call Saul 163
Homeland 145
Silicon Valley 82
Game of Thrones 79
Dexter 24
House 21
Breaking Bad 16
The Last Man on Earth 10
The Big Bang Theory 0
New Girl 0
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 102-rating_shows.sql

Done! Help Check your code Get a sandbox QA Review

20. Best genre

#advanced

Score: 65.0% (Checks completed: 100.0%)

Import the database dump from hbtn_0d_tvshows_rate to your MySQL server: download (same as
102-rating_shows.sql)

Write a script that lists all genres in the database hbtn_0d_tvshows_rate by their rating.
● Each record should display: tv_genres.name - rating sum
● Results must be sorted in descending order by their rating
● You can use only one SELECT statement
● The database name will be passed as an argument of the mysql command

guillaume@ubuntu:~/$ cat 103-rating_genres.sql | mysql -hlocalhost -uroot -p


hbtn_0d_tvshows_rate
Enter password:
name rating
Drama 150
Comedy 92
Adventure 79
Fantasy 79
Mystery 45
Crime 40
Suspense 40
Thriller 40
guillaume@ubuntu:~/$

Repo:

● GitHub repository: alx-higher_level_programming


● Directory: 0x0E-SQL_more_queries
● File: 103-rating_genres.sql

Done! Help Check your code Get a sandbox QA Review

0x01. AirBnB clone - Web static


HTMLCSSFront-end
● By: Guillaume

● Weight: 1

● Project over - took place from May 18, 2023 6:00 AM to May 23, 2023 6:00 AM

● Manual QA review was done by Abel Udo on May 22, 2023 11:50 PM

In a nutshell…

● Manual QA review: 194.8/195 mandatory & 45.2/46 optional


● Altogether: 198.06%
○ Mandatory: 99.9%
○ Optional: 98.26%
○ Calculation: 99.9% + (99.9% * 98.26%) == 198.06%

Concepts

For this project, we expect you to look at these concepts:

● HTML/CSS
● The trinity of front-end quality

Background Context

Web static, what?

Now that you have a command interpreter for managing your AirBnB objects, it’s time to make them alive!

Before developing a big and complex web application, we will build the front end step-by-step.

The first step is to “design” / “sketch” / “prototype” each element:


● Create simple HTML static pages
● Style guide
● Fake contents
● No Javascript
● No data loaded from anything

During this project, you will learn how to manipulate HTML and CSS languages. HTML is the structure of
your page, it should be the first thing to write. CSS is the styling of your page, the design. I really
encourage you to fix your HTML part before starting the styling. Indeed, without any structure, you can’t
apply any design.

Before starting, please fork or clone the repository AirBnB_clone from your partner if you were not the
owner of the previous project.

Resources
Read or watch:

● Learn to Code HTML & CSS (until “Creating Lists” included)


● Inline Styles in HTML
● Specifics on CSS Specificity
● CSS SpeciFishity
● Introduction to HTML
● CSS
● MDN
● center boxes

Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of Google:

General

● What is HTML
● How to create an HTML page
● What is a markup language
● What is the DOM
● What is an element / tag
● What is an attribute
● How does the browser load a webpage
● What is CSS
● How to add style to an element
● What is a class
● What is a selector
● How to compute CSS Specificity Value
● What are Box properties in CSS

Copyright - Plagiarism

● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and pasting
someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.

Requirements

General

● Allowed editors: vi, vim, emacs


● All your files should end with a new line
● A README.md file, at the root of the folder of the project, is mandatory
● Your code should be W3C compliant and validate with W3C-Validator
● All your CSS files should be in styles folder
● All your images should be in images folder
● You are not allowed to use !important and id (#... in the CSS file)
● You are not allowed to use tags img, embed and iframe
● You are not allowed to use Javascript
● Current screenshots have been done on Chrome 56 or more.
● No cross browsers
● You have to follow all requirements but some margin/padding are missing - you should try to fit
as much as you can to screenshots

More Info
Quiz questions

Great! You've completed the quiz successfully! Keep going! (Show quiz)

Tasks
0. Inline styling

mandatory

Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header and a footer.


Layout:

● Body:
○ no margin
○ no padding
● Header:
○ color #FF0000 (red)
○ height: 70px
○ width: 100%
● Footer:
○ color #00FF00 (green)
○ height: 60px
○ width: 100%
○ text Best School center vertically and horizontally
○ always at the bottom at the page

Requirements:

● You must use the header and footer tags


● You are not allowed to import any files
● You are not allowed to use the style tag in the head tag
● Use inline styling for all your tags
Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 0-index.html

Done? Help QA Review

1. Head styling

mandatory
Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header and a footer by using the style tag in the head tag (same as
0-index.html)

Requirements:

● You must use the header and footer tags


● You are not allowed to import any files
● No inline styling
● You must use the style tag in the head tag

The layout must be exactly the same as 0-index.html

Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 1-index.html

Done? Help QA Review

2. CSS files

mandatory
Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header and a footer by using CSS files (same as 1-index.html)

Requirements:

● You must use the header and footer tags


● No inline styling
● You must have 3 CSS files:
○ styles/2-common.css: for global style (i.e. the body style)
○ styles/2-header.css: for header style
○ styles/2-footer.css: for footer style

The layout must be exactly the same as 1-index.html

Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 2-index.html, styles/2-common.css, styles/2-header.css,
styles/2-footer.css

Done? Help QA Review

3. Zoning done!
mandatory

Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header and footer by using CSS files (same as 2-index.html)

Layout:

● Common:
○ no margin
○ no padding
○ font color: #484848
○ font size: 14px
○ font family: Circular,"Helvetica Neue",Helvetica,Arial,sans-serif;
○ icon in the browser tab
● Header:
○ color: white
○ height: 70px
○ width: 100%
○ border bottom 1px #CCCCCC
○ logo align on left and center vertically (20px space at the left)
● Footer:
○ color white
○ height: 60px
○ width: 100%
○ border top 1px #CCCCCC
○ text Best School center vertically and horizontally
○ always at the bottom at the page

Requirements:

● No inline style
● You are not allowed to use the img tag
● You are not allowed to use the style tag in the head tag
● All images must be stored in the images folder
● You must have 3 CSS files:
○ styles/3-common.css: for the global style (i.e body style)
○ styles/3-header.css: for the header style
○ styles/3-footer.css: for the footer style

Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 3-index.html, styles/3-common.css, styles/3-header.css,
styles/3-footer.css, images/
Done? Help QA Review

4. Search!

mandatory

Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header, footer and a filters box with a search button.

Layout: (based on 3-index.html)

● Container:
○ between header and footer tags, add a div:
■ classname: container
■ max width 1000px
■ margin top and bottom 30px - it should be 30px under the bottom of the header
(screenshot)
■ center horizontally
● Filter section:
○ tag section
○ classname filters
○ inside the .container
○ color white
○ height: 70px
○ width: 100% of the container
○ border 1px #DDDDDD with radius 4px
● Button search:
○ tag button
○ text Search
○ font size: 18px
○ inside the section filters
○ background color #FF5A5F
○ text color #FFFFFF
○ height: 48px
○ width: 20% of the section filters
○ no borders
○ border radius: 4px
○ center vertically and at 30px of the right border
○ change opacity to 90% when the mouse is on the button

Requirements:

● You must use: header, footer, section, button tags


● No inline style
● You are not allowed to use the img tag
● You are not allowed to use the style tag in the head tag
● All images must be stored in the images folder
● You must have 4 CSS files:
○ styles/4-common.css: for the global style (body and .container styles)
○ styles/3-header.css: for the header style
○ styles/3-footer.css: for the footer style
○ styles/4-filters.css: for the filters style
● 4-index.html won’t be W3C valid, don’t worry, it’s temporary
Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 4-index.html, styles/4-common.css, styles/3-header.css,
styles/3-footer.css, styles/4-filters.css, images/

Done? Help QA Review

5. More filters

mandatory
Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header, footer and a filters box.

Layout: (based on 4-index.html)

● Locations and Amenities filters:


○ tag: div
○ classname: locations for location tag and amenities for the other
○ inside the section filters (same level as the button Search)
○ height: 100% of the section filters
○ width: 25% of the section filters
○ border right #DDDDDD 1px only for the first left filter
○ contains a title:
■ tag: h3
■ font weight: 600
■ text States or Amenities
○ contains a subtitle:
■ tag: h4
■ font weight: 400
■ font size: 14px
■ text with fake contents

Requirements:

● You must use: header, footer, section, button, h3, h4 tags


● No inline style
● You are not allowed to use the img tag
● You are not allowed to use the style tag in the head tag
● All images must be stored in the images folder
● You must have 4 CSS files:
○ styles/4-common.css: for the global style (body and .container styles)
○ styles/3-header.css: for the header style
○ styles/3-footer.css: for the footer style
○ styles/5-filters.css: for the filters style

Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 5-index.html, styles/4-common.css, styles/3-header.css,
styles/3-footer.css, styles/5-filters.css, images/

Done? Help QA Review


6. It's (h)over

mandatory

Score: 99.09% (Checks completed: 100.0%)

Write an HTML page that displays a header, footer and a filters box with dropdown.

Layout: (based on 5-index.html)

● Update Locations and Amenities filters to display a contextual dropdown when the mouse is on
the filter div:
○ tag ul
○ classname popover
○ text should be fake now
○ inside each div
○ not displayed by default
○ color #FAFAFA
○ width same as the div filter
○ border #DDDDDD 1px with border radius 4px
○ no list display
○ Location filter has 2 levels of ul/li:
■ state -> cities
■ state name must be display in a h2 tag (font size 16px)

Requirements:

● You must use: header, footer, section, button, h3, h4, ul, li tags
● No inline style
● You are not allowed to use the img tag
● You are not allowed to use the style tag in the head tag
● All images must be stored in the images folder
● You must have 4 CSS files:
○ styles/4-common.css: for the global style (body and .container styles)
○ styles/3-header.css: for the header style
○ styles/3-footer.css: for the footer style
○ styles/6-filters.css: for the filters style
Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 6-index.html, styles/4-common.css, styles/3-header.css,
styles/3-footer.css, styles/6-filters.css, images/

Done? Help QA Review

7. Display results

mandatory

Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header, footer, a filters box with dropdown and results.

Layout: (based on 6-index.html)

● Add Places section:


○ tag: section
○ classname: places
○ same level as the filters section, inside .container
○ contains a title:
■ tag: h1
■ text: Places
■ align in the top left
■ font size: 30px
○ contains multiple “Places” as listing (horizontal or vertical) describe by:
■ tag: article
■ width: 390px
■ padding and margin 20px
■ border #FF5A5F 1px with radius 4px
■ contains the place name:
■ tag: h2
■ font size: 30px
■ center horizontally

Requirements:

● You must use: header, footer, section, article, button, h1, h2, h3, h4, ul, li tags
● No inline style
● You are not allowed to use the img tag
● You are not allowed to use the style tag in the head tag
● All images must be stored in the images folder
● You must have 5 CSS files:
○ styles/4-common.css: for the global style (i.e. body and .container styles)
○ styles/3-header.css: for the header style
○ styles/3-footer.css: for footer style
○ styles/6-filters.css: for the filters style
○ styles/7-places.css: for the places style
Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 7-index.html, styles/4-common.css, styles/3-header.css,
styles/3-footer.css, styles/6-filters.css, styles/7-places.css, images/

Done? Help QA Review

8. More details

mandatory
Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header, a footer, a filter box (dropdown list) and the result of the
search.

Layout: (based on 7-index.html)

Add more information to a Place article:

● Price by night:
○ tag: div
○ classname: price_by_night
○ same level as the place name
○ font color: #FF5A5F
○ border: #FF5A5F 4px rounded
○ min width: 60px
○ height: 60px
○ font size: 30px
○ align: the top right (with space)
● Information section:
○ tag: div
○ classname: information
○ height: 80px
○ border: top and bottom #DDDDDD 1px
○ contains (align vertically):
■ Number of guests:
■ tag: div
■ classname: max_guest
■ width: 100px
■ fake text
■ icon
■ Number of bedrooms:
■ tag: div
■ classname: number_rooms
■ width: 100px
■ fake text
■ icon
■ Number of bathrooms:
■ tag: div
■ classname: number_bathrooms
■ width: 100px
■ fake text
■ icon
● User section:
○ tag: div
○ classname: user
○ text Owner: <fake text>
○ Owner text should be in bold
● Description section:
○ tag: div
○ classname: description

Requirements:

● You must use: header, footer, section, article, button, h1, h2, h3, h4, ul, li tags
● No inline style
● You are not allowed to use the img tag
● You are not allowed to use the style tag in the head tag
● All images must be stored in the images folder
● You must have 5 CSS files:
○ styles/4-common.css: for the global style (i.e. body and .container styles)
○ styles/3-header.css: for the header style
○ styles/3-footer.css: for the footer style
○ styles/6-filters.css: for the filters style
○ styles/8-places.css: for the places style
Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 8-index.html, styles/4-common.css, styles/3-header.css,
styles/3-footer.css, styles/6-filters.css, styles/8-places.css, images/

Done? Help QA Review

9. Full details

#advanced
Score: 100.0% (Checks completed: 100.0%)

Write an HTML page that displays a header, footer, a filters box with dropdown and results.

Layout: (based on 8-index.html)

Add more information to a Place article:

● List of Amenities:
○ tag div
○ classname amenities
○ margin top 40px
○ contains:
■ title:
■ tag h2
■ text Amenities
■ font size 16px
■ border bottom #DDDDDD 1px
■ list of amenities:
■ tag ul / li
■ no list style
■ icons on the left: Pet friendly, TV, Wifi, etc… feel free to add more
● List of Reviews:
○ tag div
○ classname reviews
○ margin top 40px
○ contains:
■ title:
■ tag h2
■ text Reviews
■ font size 16px
■ border bottom #DDDDDD 1px
■ list of review:
■ tag ul / li
■ no list style
■ a review is described by:
■ h3 tag for the user/date description (font size 14px). Ex: “From
Bob Dylan the 27th January 2017”
■ p tag for the text (font size 12px)

Requirements:

● You must use: header, footer, section, article, button, h1, h2, h3, h4, ul, li tags
● No inline style
● You are not allowed to use the img tag
● You are not allowed to use the style tag in the head tag
● All images must be stored in the images folder
● You must have 5 CSS files:
○ styles/4-common.css: for the global style (body and .container styles)
○ styles/3-header.css: for the header style
○ styles/3-footer.css: for the footer style
○ styles/6-filters.css: for the filters style
○ styles/100-places.css: for the places style
Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 100-index.html, styles/4-common.css, styles/3-header.css,
styles/3-footer.css, styles/6-filters.css, styles/100-places.css, images/

Done? Help QA Review

10. Flex

#advanced
Score: 84.0% (Checks completed: 100.0%)

Improve the Places section by using Flexible boxes for all Place articles

Flexbox Froggy

Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 101-index.html, styles/4-common.css, styles/3-header.css,
styles/3-footer.css, styles/6-filters.css, styles/101-places.css, images/

Done? Help QA Review

11. Responsive design

#advanced

Score: 100.0% (Checks completed: 100.0%)

Improve the page by adding responsive design to display correctly in mobile or small screens.
Examples:

● no horizontal scrolling
● redesign search bar depending of the width
● etc.

Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 102-index.html, styles/102-common.css, styles/102-header.css,
styles/102-footer.css, styles/102-filters.css, styles/102-places.css, images/

Done? Help QA Review

12. Accessibility

#advanced

Score: 100.0% (Checks completed: 100.0%)

Improve the page by adding Accessibility support

Examples:
● Colors contrast
● Header tags
● etc.

Repo:

● GitHub repository: AirBnB_clone


● Directory: web_static
● File: 103-index.html, styles/103-common.css, styles/103-header.css,
styles/103-footer.css, styles/103-filters.css, styles/103-places.css, images/

Done? Help QA Review

Ready for a new manual review

0x1C. C - Makefiles
C

● By: Julien Barbier

● Weight: 1

● Project over - took place from May 24, 2023 6:00 AM to May 25, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…
● Auto QA review: 33.8/52 mandatory & 8.45/13 optional
● Altogether: 107.25%
○ Mandatory: 65.0%
○ Optional: 65.0%
○ Calculation: 65.0% + (65.0% * 65.0%) == 107.25%

Resources
Read or watch:

● Makefile
● Installing the make utility
● make-official documentation

Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of
Google:

General

● What are make, Makefiles


● When, why and how to use Makefiles
● What are rules and how to set and use them
● What are explicit and implicit rules
● What are the most common / useful rules
● What are variables and how to set and use them
Copyright - Plagiarism

● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and
pasting someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.

Requirements

General

● Allowed editors: vi, vim, emacs


● OS: Ubuntu 20.04 LTS
● Version of gcc: 9.3.0
● Version of make: GNU Make 4.2.1
● All your files should end with a new line
● A README.md file, at the root of the folder of the project, is mandatory

More Info

Files

In the following tasks, we are going to use these files. We want to compile these only.

Tasks
0. make -f 0-Makefile

mandatory
Score: 65.0% (Checks completed: 100.0%)

Create your first Makefile.

Requirements:

● name of the executable: school


● rules: all
○ The all rule builds your executable
● variables: none

julien@ubuntu:~/0x1C. Makefiles$ make -f 0-Makefile


gcc main.c school.c -o school
julien@ubuntu:~/0x1C. Makefiles$ ./school
j#0000000000000000000000000000000000000
j#000000000000000000@Q**g00000000000000
j#0000000000000000*]++]4000000000000000
j#000000000000000k]++]++*N#000000000000
j#0000000000000*C+++]++]++]J*0000000000
j#00000000000@+]++qwwwp=]++++]*00000000
j#0000000000*+++]q#0000k+]+]++]4#000000
j#00000000*C+]+]w#0000*]+++]+]++0000000
j#0000we+]wW000***C++]++]+]++++40000000
j#000000000*C+]+]]+]++]++]++]+q#0000000
j#0000000*]+]+++++++]++]+++]+++J0000000
j#000000C++]=]+]+]+]++]++]+]+]+]=000000
j#00000k+]++]+++]+]++qwW0000000AgW00000
j#00000k++]++]+]+++qW#00000000000000000
j#00000A]++]++]++]++J**0000000000000000
j#000000e]++]+++]++]++]J000000000000000
j#0000000A]++]+]++]++]++000000000000000
j#000000000w]++]+]++]+qW#00000000000000
j#00000000000w]++++]*0##000000000000000
j#0000000000000Ag]+]++*0000000000000000
j#00000000000000000we]+]Q00000000000000
j#0000000000000@@+wgdA]+J00000000000000
j#0000000000000k?qwgdC=]4#0000000000000
j#00000000000000w]+]++qw#00000000000000
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
julien@ubuntu:~/0x1C. Makefiles$

Repo:

● GitHub repository: alx-low_level_programming


● Directory: 0x1C-makefiles
● File: 0-Makefile

Done! Help Check your code Get a sandbox QA Review

1. make -f 1-Makefile

mandatory

Score: 65.0% (Checks completed: 100.0%)

Requirements:

● name of the executable: school


● rules: all
○ The all rule builds your executable
● variables: CC, SRC
○ CC: the compiler to be used
○ SRC: the .c files
julien@ubuntu:~/0x1C. Makefiles$ make -f 1-Makefile
gcc main.c school.c -o school
julien@ubuntu:~/0x1C. Makefiles$ make -f 1-Makefile
gcc main.c school.c -o school
julien@ubuntu:~/0x1C. Makefiles$

Repo:

● GitHub repository: alx-low_level_programming


● Directory: 0x1C-makefiles
● File: 1-Makefile

Done! Help Check your code Get a sandbox QA Review

2. make -f 2-Makefile

mandatory

Score: 65.0% (Checks completed: 100.0%)

Create your first useful Makefile.

Requirements:

● name of the executable: school


● rules: all
○ The all rule builds your executable
● variables: CC, SRC, OBJ, NAME
○ CC: the compiler to be used
○ SRC: the .c files
○ OBJ: the .o files
○ NAME: the name of the executable
● The all rule should recompile only the updated source files
● You are not allowed to have a list of all the .o files

julien@ubuntu:~/0x1C. Makefiles$ make -f 2-Makefile


gcc -c -o main.o main.c
gcc -c -o school.o school.c
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$ make -f 2-Makefile
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$ echo "/* School */" >> main.c
julien@ubuntu:~/0x1C. Makefiles$ make -f 2-Makefile
gcc -c -o main.o main.c
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$

Repo:

● GitHub repository: alx-low_level_programming


● Directory: 0x1C-makefiles
● File: 2-Makefile

Done! Help Check your code Get a sandbox QA Review

3. make -f 3-Makefile

mandatory
Score: 65.0% (Checks completed: 100.0%)

Requirements:

● name of the executable: school


● rules: all, clean, oclean, fclean, re
○ all: builds your executable
○ clean: deletes all Emacs and Vim temporary files along with the executable
○ oclean: deletes the object files
○ fclean: deletes all Emacs and Vim temporary files, the executable, and the object
files
○ re: forces recompilation of all source files
● variables: CC, SRC, OBJ, NAME, RM
○ CC: the compiler to be used
○ SRC: the .c files
○ OBJ: the .o files
○ NAME: the name of the executable
○ RM: the program to delete files
● The all rule should recompile only the updated source files
● The clean, oclean, fclean, re rules should never fail
● You are not allowed to have a list of all the .o files

julien@ubuntu:~//0x1C. Makefiles$ ls -1
0-Makefile
1-Makefile
2-Makefile
3-Makefile
school.c
main.c
main.c~
m.h
julien@ubuntu:~/0x1C. Makefiles$ make -f 3-Makefile
gcc -c -o main.o main.c
gcc -c -o school.o school.c
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$ make all -f 3-Makefile
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$ ls -1
0-Makefile
1-Makefile
2-Makefile
3-Makefile
school
school.c
school.o
main.c
main.c~
main.o
m.h
julien@ubuntu:~/0x1C. Makefiles$ make clean -f 3-Makefile
rm -f *~ school
julien@ubuntu:~/0x1C. Makefiles$ make oclean -f 3-Makefile
rm -f main.o school.o
julien@ubuntu:~/0x1C. Makefiles$ make fclean -f 3-Makefile
rm -f *~ school
rm -f main.o school.o
julien@ubuntu:~/0x1C. Makefiles$ make all -f 3-Makefile
gcc -c -o main.o main.c
gcc -c -o school.o school.c
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$ make all -f 3-Makefile
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$ make re -f 3-Makefile
rm -f main.o school.o
gcc -c -o main.o main.c
gcc -c -o school.o school.c
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$

Repo:

● GitHub repository: alx-low_level_programming


● Directory: 0x1C-makefiles
● File: 3-Makefile

Done! Help Check your code Get a sandbox QA Review


4. A complete Makefile

mandatory

Score: 65.0% (Checks completed: 100.0%)

Requirements:

● name of the executable: school


● rules: all, clean, fclean, oclean, re
○ all: builds your executable
○ clean: deletes all Emacs and Vim temporary files along with the executable
○ oclean: deletes the object files
○ fclean: deletes all Emacs and Vim temporary files, the executable, and the object
files
○ re: forces recompilation of all source files
● variables: CC, SRC, OBJ, NAME, RM, CFLAGS
○ CC: the compiler to be used
○ SRC: the .c files
○ OBJ: the .o files
○ NAME: the name of the executable
○ RM: the program to delete files
○ CFLAGS: your favorite compiler flags: -Wall -Werror -Wextra -pedantic
● The all rule should recompile only the updated source files
● The clean, oclean, fclean, re rules should never fail
● You are not allowed to have a list of all the .o files

julien@ubuntu:~/0x1C. Makefiles$ make all -f 4-Makefile


gcc -Wall -Werror -Wextra -pedantic -c -o main.o main.c
gcc -Wall -Werror -Wextra -pedantic -c -o school.o school.c
gcc main.o school.o -o school
julien@ubuntu:~/0x1C. Makefiles$
Repo:

● GitHub repository: alx-low_level_programming


● Directory: 0x1C-makefiles
● File: 4-Makefile

Done? Help Check your code Get a sandbox QA Review

5. Island Perimeter

mandatory

Score: 65.0% (Checks completed: 100.0%)

Technical interview preparation:

● You are not allowed to google anything


● Whiteboard first

Create a function def island_perimeter(grid): that returns the perimeter of the island
described in grid:

● grid is a list of list of integers:


○ 0 represents a water zone
○ 1 represents a land zone
○ One cell is a square with side length 1
○ Grid cells are connected horizontally/vertically (not diagonally).
○ Grid is rectangular, width and height don’t exceed 100
● Grid is completely surrounded by water, and there is one island (or nothing).
● The island doesn’t have “lakes” (water inside that isn’t connected to the water around the
island).

Requirements:

● First line contains #!/usr/bin/python3


● You are not allowed to import any module
● Module and function must be documented

guillaume@ubuntu:~/0x1C$ cat 5-main.py


#!/usr/bin/python3
"""
5-main
"""
island_perimeter = __import__('5-island_perimeter').island_perimeter

if __name__ == "__main__":
grid = [
[0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0],
[0, 0, 0, 0, 0, 0]
]
print(island_perimeter(grid))

guillaume@ubuntu:~/0x1C$
guillaume@ubuntu:~/0x1C$ ./5-main.py
12
guillaume@ubuntu:~/0x1C$

Repo:
● GitHub repository: alx-low_level_programming
● Directory: 0x1C-makefiles
● File: 5-island_perimeter.py

Done! Help Check your code Get a sandbox QA Review

6. make -f 100-Makefile

#advanced

Score: 65.0% (Checks completed: 100.0%)

Requirements:

● name of the executable: school


● rules: all, clean, fclean, oclean, re
○ all: builds your executable
○ clean: deletes all Emacs and Vim temporary files along with the executable
○ oclean: deletes the object files
○ fclean: deletes all Emacs and Vim temporary files, the executable, and the object
files
○ re: forces recompilation of all source files
● variables: CC, SRC, OBJ, NAME, RM, CFLAGS
○ CC: the compiler to be used
○ SRC: the .c files
○ OBJ: the .o files
○ NAME: the name of the executable
○ RM: the program to delete files
○ CFLAGS: your favorite compiler flags: -Wall -Werror -Wextra -pedantic
● The all rule should recompile only the updated source files
● The clean, oclean, fclean, re rules should never fail
● You are not allowed to have a list of all the .o files
● You have to use $(RM) for the cleaning up rules, but you are not allowed to set the RM
variable
● You are not allowed to use the string $(CC) more than once in your Makefile
● You are only allowed to use the string $(RM) twice in your Makefile
● You are not allowed to use the string $(CFLAGS) (but the compiler should still use the flags
you set in this variable)
● You are not allowed to have an $(OBJ) rule
● You are not allowed to use the %.o: %.c rule
● Your Makefile should work even if there is a file in the folder that has the same name as one
of your rule
● Your Makefile should not compile if the header file m.h is missing

Repo:

● GitHub repository: alx-low_level_programming


● Directory: 0x1C-makefiles
● File: 100-Makefile

Done! Help Check your code Get a sandbox

0x09. Web infrastructure design


DevOpsSysAdminweb infrastructure

● By: Sylvain Kalache, co-founder at Holberton School

● Weight: 1

● Project to be done in teams of 3 people (your team: )

● Project over - took place from May 25, 2023 6:00 AM to May 29, 2023 6:00 AM

● Manual QA review was done by on Jun 10, 2023 9:19 AM

In a nutshell…
● Manual QA review: 0.0/42 mandatory & 0.0/5 optional
● Altogether: 0.0%
○ Mandatory: 0.0%
○ Optional: 0.0%
○ Calculation: 0.0% + (0.0% * 0.0%) == 0.0%

Concepts

For this project, we expect you to look at these concepts:

● DNS
● Monitoring
● Web Server
● Network basics
● Load balancer
● Server

Resources
Read or watch:

● Network basics concept page


● Server concept page
● Web server concept page
● DNS concept page
● Load balancer concept page
● Monitoring concept page
● What is a database
● What’s the difference between a web server and an app server?
● DNS record types
● Single point of failure
● How to avoid downtime when deploying new code
● High availability cluster (active-active/active-passive)
● What is HTTPS
● What is a firewall

Learning Objectives
At the end of this project, you are expected to be able to explain to anyone, without the help of Google:
General

● You must be able to draw a diagram covering the web stack you built with the sysadmin/devops
track projects
● You must be able to explain what each component is doing
● You must be able to explain system redundancy
● Know all the mentioned acronyms: LAMP, SPOF, QPS

Copyright - Plagiarism

● You are tasked to come up with solutions for the tasks below yourself to meet with the above
learning objectives.
● You will not be able to meet the objectives of this or any following project by copying and pasting
someone else’s work.
● You are not allowed to publish any content of this project.
● Any form of plagiarism is strictly forbidden and will result in removal from the program.

Requirements

General

● A README.md file, at the root of the folder of the project, is mandatory


● For each task, once you are done whiteboarding (on a whiteboard, piece of paper or software or
your choice), take a picture/screenshot of your diagram
● This project will be manually reviewed:
● As each task is completed, the name of that task will turn green
● Upload a screenshot, showing that you completed the required levels, to any image hosting
service (I personally use imgur but feel free to use anything you want).
● For the following tasks, insert the link from of your screenshot into the answer file
● After pushing your answer file to GitHub, insert the GitHub file link into the URL box
● You will also have to whiteboard each task in front of a mentor, staff or student - no computer or
notes will be allowed during the whiteboarding session
● Focus on what you are being asked:
● Cover what the requirements mention, we will explore details in a later project
● Keep in mind that you will have 30 minutes to perform the exercise, you will get points for what is
asked in requirements
● Similarly in a job interview, you should answer what the interviewer asked for, be careful about
being too verbose - always ask the interviewer if going into details is necessary - speaking too
much can play against you
● In this project, again, avoid going in details if not asked

Quiz questions

Great! You've completed the quiz successfully! Keep going! (Show quiz)

Tasks
0. Simple web stack

mandatory

Score: 0.0% (Checks completed: 0.0%)

A lot of websites are powered by simple web infrastructure, a lot of time it is composed of a single server
with a LAMP stack.

On a whiteboard, design a one server web infrastructure that hosts the website that is reachable via
www.foobar.com. Start your explanation by having a user wanting to access your website.

Requirements:

● You must use:


○ 1 server
○ 1 web server (Nginx)
○ 1 application server
○ 1 application files (your code base)
○ 1 database (MySQL)
○ 1 domain name foobar.com configured with a www record that points to your server IP
8.8.8.8
● You must be able to explain some specifics about this infrastructure:
○ What is a server
○ What is the role of the domain name
○ What type of DNS record www is in www.foobar.com
○ What is the role of the web server
○ What is the role of the application server
○ What is the role of the database
○ What is the server using to communicate with the computer of the user requesting the
website
● You must be able to explain what the issues are with this infrastructure:
○ SPOF
○ Downtime when maintenance needed (like deploying new code web server needs to be
restarted)
○ Cannot scale if too much incoming traffic

Please, remember that everything must be written in English to further your technical ability in a variety of
settings.

Add URLs here:

Save

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x09-web_infrastructure_design
● File: 0-simple_web_stack

Done? Help QA Review


1. Distributed web infrastructure

mandatory

Score: 0.0% (Checks completed: 0.0%)

On a whiteboard, design a three server web infrastructure that hosts the website www.foobar.com.

Requirements:

● You must add:


○ 2 servers
○ 1 web server (Nginx)
○ 1 application server
○ 1 load-balancer (HAproxy)
○ 1 set of application files (your code base)
○ 1 database (MySQL)
● You must be able to explain some specifics about this infrastructure:
○ For every additional element, why you are adding it
○ What distribution algorithm your load balancer is configured with and how it works
○ Is your load-balancer enabling an Active-Active or Active-Passive setup, explain the
difference between both
○ How a database Primary-Replica (Master-Slave) cluster works
○ What is the difference between the Primary node and the Replica node in regard to the
application
● You must be able to explain what the issues are with this infrastructure:
○ Where are SPOF
○ Security issues (no firewall, no HTTPS)
○ No monitoring

Please, remember that everything must be written in English to further your technical ability in a variety of
settings.
Add URLs here:

Save

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x09-web_infrastructure_design
● File: 1-distributed_web_infrastructure

Done? Help QA Review

2. Secured and monitored web infrastructure

mandatory

Score: 0.0% (Checks completed: 0.0%)

On a whiteboard, design a three server web infrastructure that hosts the website www.foobar.com, it
must be secured, serve encrypted traffic, and be monitored.

Requirements:

● You must add:


○ 3 firewalls
○ 1 SSL certificate to serve www.foobar.com over HTTPS
○ 3 monitoring clients (data collector for Sumologic or other monitoring services)
● You must be able to explain some specifics about this infrastructure:
○ For every additional element, why you are adding it
○ What are firewalls for
○ Why is the traffic served over HTTPS
○ What monitoring is used for
○ How the monitoring tool is collecting data
○ Explain what to do if you want to monitor your web server QPS
● You must be able to explain what the issues are with this infrastructure:
○ Why terminating SSL at the load balancer level is an issue
○ Why having only one MySQL server capable of accepting writes is an issue
○ Why having servers with all the same components (database, web server and application
server) might be a problem

Please, remember that everything must be written in English to further your technical ability in a variety of
settings.

Add URLs here:

Save

Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x09-web_infrastructure_design
● File: 2-secured_and_monitored_web_infrastructure

Done? Help QA Review


3. Scale up

#advanced

Score: 0.0% (Checks completed: 0.0%)

Readme

● Application server vs web server

Requirements:

● You must add:


○ 1 server
○ 1 load-balancer (HAproxy) configured as cluster with the other one
○ Split components (web server, application server, database) with their own server
● You must be able to explain some specifics about this infrastructure:
○ For every additional element, why you are adding it

Please, remember that everything must be written in English to further your technical ability in a variety of
settings.

Add URLs here:

Save
Repo:

● GitHub repository: alx-system_engineering-devops


● Directory: 0x09-web_infrastructure_design
● File: 3-scale_up

Done? Help QA Review

Ready for a new manual review

0x1D. C - Binary trees


CGroup projectAlgorithmData structure

● By: Alexandre Gautier

● Weight: 5

● Project to be done in teams of 2 people (your team:)

● Project over - took place from May 29, 2023 6:00 AM to Jun 2, 2023 6:00 AM

● An auto review will be launched at the deadline

In a nutshell…

● Contribution: 100.0%
● Auto QA review: 78.5/157 mandatory & 97.5/196 optional
● Altogether: 74.87%
○ Mandatory: 50.0%
○ Optional: 49.74%
○ Contribution: 100.0%
○ Calculation: 100.0% * (50.0% + (50.0% * 49.74%) ) == 74.87%

You might also like