From 051fea2c9b34928bf29749f0d6b00bcff6fc8723 Mon Sep 17 00:00:00 2001 From: surister Date: Fri, 20 Dec 2019 18:11:43 +0100 Subject: [PATCH] First commit syntax checker --- README.md | 17 +++--- coding/python/binary_search.py | 3 +- scripts/main.py | 91 +++++++++++++++++++++++++++++ scripts/tests/test.py | 29 ++++++++++ scripts/tests/testcase1.md | 101 +++++++++++++++++++++++++++++++++ scripts/tests/testcase2.md | 92 ++++++++++++++++++++++++++++++ scripts/tests/testcase3.md | 0 scripts/tests/testcase4.md | 0 scripts/tests/testcase5.md | 0 9 files changed, 325 insertions(+), 8 deletions(-) create mode 100644 scripts/main.py create mode 100644 scripts/tests/test.py create mode 100644 scripts/tests/testcase1.md create mode 100644 scripts/tests/testcase2.md create mode 100644 scripts/tests/testcase3.md create mode 100644 scripts/tests/testcase4.md create mode 100644 scripts/tests/testcase5.md diff --git a/README.md b/README.md index 76395fc..fe9ab38 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,7 @@ You can describe the UI way to add new slaves but better to explain how to do in
-How would you implement an option of a starting a build from a certain stage and not from the beginning?
+How would you implement an option of a starting a build from a certain stage and not from the beginning?
##### Jenkins Dev @@ -589,9 +589,11 @@ Stop the instance, the type of the instance to match the desired RAM and start t What is AWS WAF? Give an example of how it can used and describe what resources or services you can use it with
+
What AWS VPN is usef for?
+
What is the difference between Site-to-Site VPN and Client VPN?
@@ -927,7 +929,8 @@ As to fix it there are serveral options: 3. You would look for your distro default $PATH variable, copy paste using method #1 Note: There are many ways of getting errors like this: if bash_profile or any configuration file of your interpreter was wrongly modified; causing erratics behaviours, -permissions issues, bad compiled software (if you compiled it by yourself)... there is no answer that will be true 100% of the time.
+permissions issues, bad compiled software (if you compiled it by yourself)... there is no answer that will be true 100% of the time. +

@@ -1241,7 +1244,7 @@ execution or run forever
-What signal is used by default when you run 'kill '?
+What signal is used by default when you run 'kill *process id*'?
 The default signal is SIGTERM (15). This signal kills
 process gracefully which means it allows it to save current
@@ -1310,7 +1313,7 @@ You can also try closing/terminating the parent process. This will make the zomb
 
-Can you explain how network process/connection is established and how it's terminated?>
+Can you explain how network process/connection is established and how it's terminated?>
@@ -2299,7 +2302,7 @@ Setting the replicas to 0 will shut down the process. Now start it with `kubectl
-Explain recursion +Explain recursion
@@ -3130,7 +3133,7 @@ a = f()
-Can you implement Linked List in Python?
+Can you implement Linked List in Python?
@@ -3962,7 +3965,7 @@ the pseudo table to retrieve the sum of the prices spent by each customer, then
-Describe in detail how you bring up an instance with an IP you can reach from outside the cloud
+Describe in detail how you bring up an instance with an IP you can reach from outside the cloud
diff --git a/coding/python/binary_search.py b/coding/python/binary_search.py index cd9601c..0efe132 100644 --- a/coding/python/binary_search.py +++ b/coding/python/binary_search.py @@ -2,9 +2,10 @@ import random -rand_num_li = sorted([random.randint(1, 50) for iter in range(10)]) +rand_num_li = sorted([random.randint(1, 50) for _ in range(10)]) target = random.randint(1, 50) + def binary_search(li, le, ri, target): if le <= ri: mid = ri + le // 2 diff --git a/scripts/main.py b/scripts/main.py new file mode 100644 index 0000000..5f969fb --- /dev/null +++ b/scripts/main.py @@ -0,0 +1,91 @@ +import pathlib + +p = pathlib.Path(__file__).parent.parent.joinpath('README.md') + +with open(p, 'rb') as f: + file_list = [line.rstrip() for line in f.readlines()] + +details_final_count = 0 +details_count = 0 +print(len(file_list)) +for q in file_list: + if b'
' in q: + details_count += 1 + if b'
' in q: + details_final_count += 1 +print(details_count, details_final_count) + +# TODO Checkear que tenemos mismo numero de details tabs, aunque esto no asegura al 100% que esta bien formateado. +# Una vez que tenemos un número par, podemos más o menos estar seguros de que la cosa va bien, y hacer ya entonces +# el checkeo de las demás tags. +# Problema: No obtenemos el lugar de donde esta mal el details, entonces; hacerlo. +# IDEA: comprobar que despues de un detail va un /detail y mas o menos supongo que podremos acotar, hacer pruebas. + + +def get_question_list(f): + + questions_list = [] + temp = [] + after_summary_tag = False + + for line in f: + if line.startswith(b'
'): + temp.append(line) + after_summary_tag = True + + elif after_summary_tag and line != b'' and b'
' not in line: + temp.append(line) + + elif after_summary_tag and b'
' in line: + temp.append(line) + after_summary_tag = False + + questions_list.append(temp) + temp = [] + + return questions_list + + +def get_answered_questions(question_list) -> int: + c = 0 + for q in question_list: + index = 0 + for i in q: + if b'' in i: + index = q.index(i) + if q[index+1: len(q) - 1]: + # print(q[2: len(q) - 1], '-->', q) + c += 1 + return c + + +def check_even_tags(question_list): + summary_count = 0 + details_count = 0 + # details count not necessary cus we already have that checked beforehand + for q in question_list: + print(q) + for l in q: + print(l) + if b'
' in l: + details_count += 1 + if b'' in l: + summary_count += 1 + if b'
' in l: + details_count += 1 + if b'' in l: + summary_count += 1 + print(summary_count, details_count) + if summary_count != 2 or details_count != 2: + raise Exception(f'You are missing a tag in {q}') + details_count = 0 + summary_count = 0 + + +# check_even_tags(get_question_list(file_list)) + + +# if __name__ == '__main__': +# q_list = get_question_list(file_list) +# print(len(q_list)) +# print(get_answered_questions(q_list)) diff --git a/scripts/tests/test.py b/scripts/tests/test.py new file mode 100644 index 0000000..bc2ae74 --- /dev/null +++ b/scripts/tests/test.py @@ -0,0 +1,29 @@ +import unittest +import pathlib + +from scripts.main import get_answered_questions, get_question_list + + +def open_test_case_file(n: int): + p = pathlib.Path(rf'D:\PycharmProjects\devops-interview-questions\scripts\tests\testcase{n}.md') + + with open(p, 'rb') as f: + file_list = [line.rstrip() for line in f.readlines()] + return file_list + + +class QuestionCount(unittest.TestCase): + solutions = ( + + ) + + def test_count_case_1(self): + raw_list = open_test_case_file(1) + question_list = get_question_list(raw_list) + answers = get_answered_questions(question_list) + + self.assertEqual(len(question_list), 21) + self.assertEqual(answers, 2) + + def test_count_case_2(self): + pass \ No newline at end of file diff --git a/scripts/tests/testcase1.md b/scripts/tests/testcase1.md new file mode 100644 index 0000000..194e212 --- /dev/null +++ b/scripts/tests/testcase1.md @@ -0,0 +1,101 @@ +
+What objects in S3 consists of? + * Another way to ask it: explain key, value, version id and meta data in context of objects
+
+ +
+Explain data consistency
+
+ +
+Can you host dynamic websites on S3?. What about static websites?
+
+ +
+What security measures have you taken in context of S3?
+
+ +
+What is a storage class? What storage classes are you familiar with?
+
+ +##### EC2 + +
+What is EC2? What is it used for?
+
+ +
+What EC2 pricing models are there?
+
+ +
+How to increase RAM for a given EC2 instance?
+ +Stop the instance, the type of the instance to match the desired RAM and start the instance. +
+ +
+What is an AMI?
+
+ +
+How many storage options are there for EC2 Instances?
+
+ +
+What happens when an EC2 instance is stopped or terminated?
+
+ +
+What are Security Groups?
+
+ +
+How to migrate an instance to another availability zone?
+
+ +
+What are spot instances?
+
+ +##### CloudFront + +
+Explain what is CloudFront and what is it used for
+
+ +
+Explain the following + * Origin + * Edge location + * Distribution
+
+ +
+What delivery methods available for the user with CDN?
+
+ +
+True or False?. Objects are cached for the life of TTL
+
+ +##### Load Balancers + +
+What types of load balancers are supported in EC2 and what are they used for?
+ + * Application LB - layer 7 traffic + * Network LB - ultra-high performances or static IP address + * Classic LB - low costs, good for test or dev environments +
+ +##### AWS Security + +
+What is the shared responsibility model? In other words, what AWS is responsible for and what the user is responsible for in regards to Security?
+
+ +
+What is the AWS compliance program?
+
\ No newline at end of file diff --git a/scripts/tests/testcase2.md b/scripts/tests/testcase2.md new file mode 100644 index 0000000..1a5451a --- /dev/null +++ b/scripts/tests/testcase2.md @@ -0,0 +1,92 @@ +
+Explain what each of the following services is used for + + * AWS Inspector + * AWS Artifact + * AWS Shield
+
+ +
+What is AWS WAF? Give an example of how it can used and describe what resources or services you can use it with
+
+ +
+What AWS VPN is usef for?
+
+ +
+What is the difference between Site-to-Site VPN and Client VPN?
+
+ +
+True or False? AWS Inspector can perform both network and host assessments
+ +True +
+ +#### AWS Databases + +
+What is RDS?
+
+ +
+What are some features or benefits of using RDS?
+ +1. Multi AZ - great for Disaster Recovery +2. Read Replicas - for better performances +
+ +
+What is EBS?
+
+ +#### AWS Networking + +
+What is VPC?
+
+ +
+Explain Security Groups and Network ACLs
+
+ +#### Misc + +
+Explain what are the following services and give an use case example for each one them: + + * CloudTrail + * CloudWatch + * CloudSearch
+
+ + +## Network + + +#### :baby: Beginner + +
+What is Ethernet?
+
+ +
+What is a MAC address? What is it used for?
+
+ +
+When is this MAC address used?: ff:ff:ff:ff:ff:ff
+
+ +
+What is an IP address?
+
+ +
+Explain subnet mask and given an example
+
+ +
+What is a private IP address? What do we need it for?
+
diff --git a/scripts/tests/testcase3.md b/scripts/tests/testcase3.md new file mode 100644 index 0000000..e69de29 diff --git a/scripts/tests/testcase4.md b/scripts/tests/testcase4.md new file mode 100644 index 0000000..e69de29 diff --git a/scripts/tests/testcase5.md b/scripts/tests/testcase5.md new file mode 100644 index 0000000..e69de29