Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
89b7b94
Added the American choise answer
dorondollev Mar 16, 2022
49b7805
provided hand shake script over TLS
dorondollev Mar 22, 2022
5051c3b
Merge remote-tracking branch 'origin/main'
dorondollev Mar 27, 2022
eeabafa
Merge remote-tracking branch 'origin/main'
dorondollev Mar 30, 2022
9fd8e36
Merge remote-tracking branch 'origin/main'
dorondollev Apr 3, 2022
18c9dc3
added sum for elements
dorondollev Apr 5, 2022
9f67be3
added verbing
dorondollev Apr 5, 2022
5fa00df
added words_concatenation
dorondollev Apr 5, 2022
3e92edf
added reverse_words_concatenation
dorondollev Apr 5, 2022
8a869c3
fixed verbing
dorondollev Apr 5, 2022
fc88019
Merge remote-tracking branch 'origin/main'
dorondollev Apr 6, 2022
df0c5e2
Merge branch 'main' into katas1_tests
dorondollev Apr 6, 2022
2cbd23c
created prime_number
dorondollev Apr 7, 2022
cfa098b
finished my tests: 3, 10
dorondollev Apr 7, 2022
868b908
finished my tests: 4, 11
dorondollev Apr 8, 2022
d81fd55
Merge branch 'katas1_tests' of https://github.com/alonitac/DevOpsJan2…
DustyMadDude Apr 10, 2022
9db5b54
Merge branch 'katas1_tests' of https://github.com/alonitac/DevOpsJan2…
DustyMadDude Apr 10, 2022
cd9368f
Merge branch 'python_katas_YuvalFidler' into katas1_Yftest
DustyMadDude Apr 10, 2022
b819000
Merge remote-tracking branch 'origin/python_katas1_tests' into katas1…
Apr 10, 2022
6ca2962
Merge branch 'katas1_Yftest' into katas1_tests
DustyMadDude Apr 10, 2022
ffac302
Update test.py
dorondollev Apr 10, 2022
315b745
finished my tests: 4, 11
dorondollev Apr 11, 2022
91066c5
Merge remote-tracking branch 'origin/katas1_tests' into katas1_tests
dorondollev Apr 11, 2022
43d15d2
finished test: 4
dorondollev Apr 11, 2022
8fb48d3
finished test: 11
dorondollev Apr 11, 2022
80a5dd2
Merge branch 'katas1_tests' into kata_1
dorondollev Apr 12, 2022
c28a6c2
added best student
dorondollev Apr 12, 2022
19a4c92
Merge branch 'python_katas_dorondollev' into kata_1
dorondollev Apr 12, 2022
9b93e64
added print_dict_as_table
dorondollev Apr 12, 2022
bbbf6b0
fixed best_student
dorondollev Apr 12, 2022
da52e0e
fixed merge_dicts
dorondollev Apr 12, 2022
5344660
added 7 boom
dorondollev Apr 13, 2022
1380cef
added 7 boom
dorondollev Apr 13, 2022
2f2f8a5
added caesar_cipher
dorondollev Apr 13, 2022
fd54ee8
added sum_of_digits string
dorondollev Apr 14, 2022
c8bd91f
added sum_of_digits string
dorondollev Apr 14, 2022
9e314d3
added pair_match
dorondollev Apr 17, 2022
f5d36f4
fixed print_dict_as_table
dorondollev Apr 18, 2022
785c02c
Merge branch 'main' into python_katas_dorondollev
dorondollev Apr 25, 2022
f92d402
Merge branch 'kata_1' into python_katas_dorondollev
dorondollev Apr 25, 2022
86f537e
finished valid_parentheses
dorondollev Apr 25, 2022
9354343
finished fibonacci_fixme
dorondollev Apr 25, 2022
a7b4be8
fixed valid_parentheses
dorondollev Apr 26, 2022
63d3500
fixed fibonacci_fixme
dorondollev Apr 26, 2022
afb0719
added most_frequent_name
dorondollev Apr 27, 2022
ec47cc1
added files_backup
dorondollev Apr 28, 2022
abab328
added replace_in_file
dorondollev Apr 28, 2022
a205a77
added merge json files
dorondollev May 9, 2022
19576b8
added merge json files
dorondollev May 9, 2022
cb68ff4
created monotonic_array
dorondollev May 10, 2022
6870a4f
created strong password
dorondollev May 17, 2022
d06de48
created strong password
dorondollev May 17, 2022
3b28e83
created str_compression
dorondollev May 17, 2022
f982814
removed redundant parenthesis in sum(int_array)
dorondollev May 24, 2022
b973fb9
commit matrix_avg
dorondollev May 24, 2022
4245de0
commit matrix_avg + fix
dorondollev May 24, 2022
06f8712
Merge remote-tracking branch 'origin/python_katas_dorondollev' into p…
dorondollev May 25, 2022
535692f
commit matrix_avg + fix
dorondollev May 25, 2022
38ff9bd
fixed main run
dorondollev May 31, 2022
5a85a49
monotonic array one line
dorondollev Jun 1, 2022
099059f
committing the longest common string
dorondollev Jun 1, 2022
74f85bc
committing longest_common_prefix
dorondollev Jun 1, 2022
5ad6498
committing list_flatten
dorondollev Jun 1, 2022
a270b41
committing pascal_triangle
dorondollev Jun 2, 2022
fbf7cb8
finished rotate_matrix
dorondollev Jun 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 02_linux_ex1/README
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Kernel System Calls

Binary Numbers
--------------
< Your Answer >
< Your Answer >
58 changes: 57 additions & 1 deletion 06_linux_ex2/README
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
name@example.com
doron.dollev@gmail.com

### Processes handling

**(Q1)** A user started a process and logged out from the terminal. Which command he used if the process still running in the background:

* nohup


**(Q2)** The `kill` command always terminates a process.

* False


**(Q3)** Which command could be used to know how many processes are running in the background terminal session?

* jobs


**(Q4)** Given a terminal session with long process running in it, how will you ask this process to terminate?

* CTRL+c


**(Q5)** Given a terminal session with long process running in it, how will you ask this process the stop?

* CTRL+z


**(Q6)** How would you run the `sleep 10` command as a foreground process?

* sleep 10


**(Q7)** Which of the following command would deliver a SIGTERM to the `xscreensaver` process?

* None of the above


**(Q8)** Which of the following would deliver a SIGKILL to the `xscreensaver` command?

* kill -9 4846


**(Q9)** Which of the following would send a SIGCHLD (signal number 17) to the `ssh-agent` process?

* kill -CHLD 4828


**(Q10)** Which key pressed within the `top` command allows the user to send a signal to a process?

* k


**(Q11 - easy 5 points bonus)** Open a new terminal session and type the command `python`. Then send a SIGINT signal using your keyboard. What best describes
how the python process responds to the SIGINT signal?

* The program has implemented a custom signal handler for the SIGINT signal.
46 changes: 46 additions & 0 deletions 06_linux_ex2/tlsHandshake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
echo "Initializing random number generator..."
openssl rand -out masterKey.txt -base64 32
if [ $? -gt 0 ]
then
echo "couldn't generate key 32 based"
exit 1
fi
curl -X POST -H "Content-Type: application/json" -d '{"clientVersion":"3.2","message":"Client Hello"}' http://devops-jan22-1273001359.eu-north-1.elb.amazonaws.com:8080/clienthello | jq -r '.serverCert,.sessionID' >tmp.txt
STATUS=$?
if [ $STATUS -gt 0 ]
then
echo "run \"man curl|jq\" end check for details for error status number $STATUS"
# for example: "error 20 at 0 depth lookup: unable to get local issuer certificate"
# This is Eve that is the reason error 20 is unlisted in curl
exit 1
fi
# Instead could be used /clienthello -o (>) tmp.txt and use twice jq -r on cert.pem and sessionID
head --lines=-1 tmp.txt>cert.pem
export SESSION_ID=$( tail -1 tmp.txt )
rm -f tmp.txt
export VERIFICATION_RESULT=$( openssl verify -CAfile cert-ca-aws.pem cert.pem )

if [ "$VERIFICATION_RESULT" != "cert.pem: OK" ]
then
echo "Server Certificate is invalid."
exit 1
fi

MASTER_KEY=$( openssl smime -encrypt -aes-256-cbc -in masterKey.txt -outform DER cert.pem | base64 -w 0 )
curl -X POST -H 'Content-Type: application/json' -d '{"sessionID": "'$SESSION_ID'","masterKey": "'$MASTER_KEY'","sampleMessage": "Hi server, please encrypt me and send to client!"}' http://devops-jan22-1273001359.eu-north-1.elb.amazonaws.com:8080/keyexchange | jq -r '.encryptedSampleMessage' > encSampleMsg.txt
STATUS=$?
if [ $STATUS -gt 0 ]
then
echo "run \"man curl|jq\" end check for details for error status number $STATUS"
exit 1
fi
cat encSampleMsg.txt | base64 -d > encSampleMsgReady.txt
openssl enc -d -aes-256-cbc -pbkdf2 -kfile masterKey.txt -in encSampleMsgReady.txt -out decrypted_secret.txt
export DECRYPTED_SAMPLE_MESSAGE=`cat decrypted_secret.txt`
if [ "$DECRYPTED_SAMPLE_MESSAGE" != "Hi server, please encrypt me and send to client!" ]; then
echo "Server symmetric encryption using the exchanged master-key has failed."
exit 1
else
echo "Client-Server TLS handshake has been completed successfully"
fi
129 changes: 99 additions & 30 deletions python_katas/kata_1/questions.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@

def sum_of_element(elements):
"""
1 Kata

:param elements: list of integers
:return: Return int - the sum of all elements.
"""
s = 0
for num in elements:
s = s + num

return s
return sum(elements)


def verbing(word):
Expand All @@ -28,7 +25,15 @@ def verbing(word):
:param word: str
:return: Return the resulting string.
"""
return None
my_str = word
if len(my_str) < 3:
return my_str
elif my_str[-3:] == 'ing':
my_str = my_str[:-3]
my_str += 'ly'
else:
my_str += 'ing'
return my_str


def words_concatenation(words):
Expand All @@ -43,29 +48,33 @@ def words_concatenation(words):
:param words: list of str
:return: Return the resulting string.
"""
return None
my_lst = ' '.join(words)
return my_lst


def reverse_words_concatenation(words):
"""
1 Kata

Given a list of words, write a program that concatenates the words in a reverse way
Given a list of words, write a program that concatenates the words in a reverse way (both words and each word itself)

For example:
reverse_words_concatenation(['take', 'me', 'home']) returns 'home me take'

:param words: list of str
:return: Return the resulting string.
"""
return None
strings = words
strings.reverse()
my_lst = words_concatenation(strings)
return my_lst


def is_unique_string(some_str):
"""
2 Kata

Given a string, the function returns True if all characters in the string are unique, False otherwise
Given a string, the function returns True is all characters in the string are unique, False otherwise

e.g
'abcd' -> True
Expand All @@ -75,38 +84,53 @@ def is_unique_string(some_str):
:param some_str:
:return: bool
"""
return None
if len(set(some_str)) == len(some_str):
return True
else:
return False


def list_diff(elements):

"""
1 Kata

Given a list of integers as an input, return the "diff" list - each element is
reduces by its previous one. The first element should be None

e.g.
[1, 2, 3, 4, 7, 11] -> [None, 1, 1, 1, 3, 4]
[1, 2, 3, 4, 7, 11] -> [None, 1, 1, 3, 4]
[] -> []
[1, 5, 0, 4, 1, 1, 1] -> [None, 4, -5, 4, -3, 0, 0]

:param elements: list of integers
:return: the diff list
"""
return None
if len(elements) > 1:
diff_list = [elements[i] - elements[i - 1] for i in range(1, len(elements))]
diff_list.insert(0, None)
return diff_list
elif len(elements) > 0:
return [None]
else:
return []


def prime_number(num):
"""
1 Kata
1 Kata

Check if the given number is prime or not.
Check if the given number is prime or not.

hint: use the built-in function "range"
:param num: the number to check
:return: bool. True if prime, else False
"""
return None
hint: use the built-in function "range"
:param num: the number to check
:return: bool. True if prime, else False
"""
if num > 1:
for i in range(2, num):
if (num % i) == 0:
return False
return True


def palindrome_num(num):
Expand All @@ -122,7 +146,12 @@ def palindrome_num(num):
:param num: int
:return: bool. True is palindrome, else False
"""
return None
my_num = str(num)
my_rnum = my_num[::-1]
if my_num == my_rnum:
return True
else:
return False


def pair_match(men, women):
Expand Down Expand Up @@ -153,19 +182,27 @@ def pair_match(men, women):
:param women: dict mapping name -> age
:return: tuple (men_name, women_name) such their age absolute difference is the minimal
"""
return None
minimum = 1000
# dict_diff = {} # empty dictionary
for m in men.keys(): # run over all men
for w in women.keys(): # run over all women
diff_age = abs(men[m] - women[w])
if diff_age < minimum:
minimum = diff_age
couple = (m, w)
return couple


def bad_average(a, b, c):
"""
1 Kata
1 Kata: fixed

This function gets 3 numbers and calculates the average.
There is a mistake in the following implementation, you are required to fix it

:return:
"""
return a + b + c / 3
return (a + b + c) / 3


def best_student(grades):
Expand All @@ -188,7 +225,10 @@ def best_student(grades):
:param grades: dict of name -> grade mapping
:return: str. some key from the dict
"""
return None
sorted_values = sorted(grades.values())
for key, value in grades.items():
if sorted_values[-1] == value:
return key


def print_dict_as_table(some_dict):
Expand Down Expand Up @@ -217,7 +257,10 @@ def print_dict_as_table(some_dict):
:param some_dict:
:return:
"""
return None
print("{:<7} {}".format('Key', 'Value'))
print("{}".format('-' * 13))
for key, value in some_dict.items():
print("{:<7} {}".format(key, value))


def merge_dicts(dict1, dict2):
Expand All @@ -237,7 +280,9 @@ def merge_dicts(dict1, dict2):
:param dict2:
:return:
"""
return dict1
dict3 = dict1.copy()
dict3.update(dict2)
return dict3


def seven_boom(n):
Expand All @@ -252,7 +297,9 @@ def seven_boom(n):
:param n: int. The last number for count for a 7-boom play
:return: list of integers
"""
return None
boom = []
[boom.append(x) if '7' in str(x) or x % 7 == 0 else x for x in range(0, n - 1)]
return boom


def caesar_cipher(str_to_encrypt):
Expand All @@ -267,7 +314,27 @@ def caesar_cipher(str_to_encrypt):

:return:
"""
return None
key = 3
encryption = ""

for c in str_to_encrypt:
if c.isspace():
encryption += c
elif c.isupper():
c_unicode = ord(c)
c_index = c_unicode - ord("A")
new_index = (c_index + key) % 26
new_unicode = new_index + ord("A")
new_c = chr(new_unicode)
encryption += new_c
elif c.islower:
c_unicode = ord(c)
c_index = c_unicode - ord("a")
new_index = (c_index + key) % 26
new_unicode = new_index + ord("a")
new_c = chr(new_unicode)
encryption += new_c
return encryption


def sum_of_digits(digits_str):
Expand All @@ -285,7 +352,9 @@ def sum_of_digits(digits_str):
:param digits_str: str of numerical digits only
:return: int representing the sum of digits
"""
return None
chars_array = [char for char in digits_str]
int_array = [int(c) for c in chars_array]
return sum(int_array)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion python_katas/kata_2/mnist-predictor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
terminationGracePeriodSeconds: 30
containers:
- name: mnist-predictor
image: {{REGISTRY_URL}}/{{IMG_NAME}}
image: {{REGISTRY_URL}}/mnist-pred:0.0.1
---
apiVersion: v1
kind: Service
Expand Down
Loading