Skip to content

Commit

Permalink
Add a couple of questions
Browse files Browse the repository at this point in the history
  • Loading branch information
abregman committed Dec 29, 2019
1 parent d36288c commit 37684a9
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 71 deletions.
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ Stick to the following format:

* If you added several questions and you would like to know how many questions are there you can use the script "count_questions.sh" in scripts directory.


## What to avoid

* Avoid adding installation questions. Those are the worst type of questions...
* Don't copy questions and answers from other sources. They probably worked hard for adding them.
* If you add new images, make sure they are free and can be used.

## Before submitting the pull request

You can test your changes locally with the script `run_ci.sh` in scripts directory.
177 changes: 107 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

:information_source:  This repository contains questions on various DevOps and SRE related topics

:bar_chart:  There are currently **714** questions
:bar_chart:  There are currently **720** questions

:books:  To learn more about DevOps check the resources in [DevOpsBit.com](https://devopsbit.com)

Expand Down Expand Up @@ -1678,14 +1678,20 @@ Re-install the OS IS NOT the right answer :)
<summary>What is sudo? How do you set it up?</summary><br><b>
</b></details>

#### Random and Strange :)
#### Random and perhaps useless :)

<details>
<summary>Give 5 commands which are two letters long</summary><br><b>

ls, wc, dd, df, du, ps, ip, cp, cd ...
</b></details>

<details>
<summary>What a double dash (--) mean?</summary><br><b>

It's used in commands to mark the end of commands options. One common example is when used with git to discard local changes: `git checkout -- some_file`
</b></details>

#### Commands

<details>
Expand All @@ -1699,10 +1705,45 @@ ls, wc, dd, df, du, ps, ip, cp, cd ...
<a name="linux-advanced"></a>
#### :star: Advanced

#### System Calls

<details>
<summary>Explain the fork system call</summary><br><b>

fork() is used for creating a new process. It does so by cloning the calling process but the child process has its own PID and any memory locks, I/O operations and semaphores are not inherited.
</b></details>

<details>
<summary>Explain the exec system call</summary><br><b>
</b></details>

<details>
<summary>What are the differences between exec() and fork()?</summary><br><b>
</b></details>

<details>
<summary>Why do we need the wait system call?</summary><br><b>

wait() is used by a parent process to wait for the child process to finish execution.
If wait is not used by a parent process then a child process might become a zombie process.
</b></details>

<details>
<summary>What happens when you execute <code>ls</code>?. Provide a detailed answer</summary><br><b>
</b></details>

#### Linux Filesystem & Files

<details>
<summary>How to create a file of a certain size?</summary><br><b>

There are a couple of ways to do that:

* dd if=/dev/urandom of=new_file.txt bs=2MB count=1
* truncate -s 2M new_file.txt
* fallocate -l 2097152 new_file.txt
</b></details>

<details>
<summary>Can you describe how processes are being created?</summary><br><b>
</b></details>
Expand Down Expand Up @@ -1759,37 +1800,6 @@ Another common way to task this questions is "what part of the tcp header does t
<summary>What are cgroups?</summary><br><b>
</b></details>

<details>
<summary>How to create a file of a certain size?</summary><br><b>

There are a couple of ways to do that:

* dd if=/dev/urandom of=new_file.txt bs=2MB count=1
* truncate -s 2M new_file.txt
* fallocate -l 2097152 new_file.txt
</b></details>

<details>
<summary>Explain the fork system call</summary><br><b>

fork() is used for creating a new process.
</b></details>

<details>
<summary>Explain the fork system call</summary><br><b>
</b></details>

<details>
<summary>What are the differences between exec() and fork()?</summary><br><b>
</b></details>

<details>
<summary>Why do we need the wait system call?</summary><br><b>

wait() is used by a parent process to wait for the child process to finish execution.
If wait is not used by a parent process then a child process might become a zombie process.
</b></details>

<details>
<summary>Explain Process Descriptor and Task Structure</summary><br><b>
</b></details>
Expand Down Expand Up @@ -1825,21 +1835,25 @@ There are many ways to answer that. For those who look for simplicity, the book
"responsible for making it easy to run programs (even allowing you to seemingly run many at the same time), allowing programs to share memory, enabling programs to interact with devices, and other fun stuff like that"
</b></details>

#### Processes

<details>
<summary>Can you explain what is a process?</summary><br><b>

A process is a running program. A program is one or more instructions and the program (or process) is executed by the operating system.
</b></details>

<details>
<summary>If you had to design an API for processes in an operating system, what would this API look like?</summary><br><b>

It would support the following:

* Create - allow to create new processes
* Delete - allow to remove/destroy processes
* State - allow to check the state of the process, whether it's running, stopped, waiting, etc.
* Stop - allow to stop a running process
</b></details>

<details>
<summary>Can you explain what is a process?</summary><br><b>

A process is a running program. A program is one or more instructions and the program (or process) is executed by the operating system.
</b></details>

<details>
<summary>How a process is created?</summary><br><b>

Expand Down Expand Up @@ -1867,6 +1881,12 @@ False. It was true in the past but today's operating systems perform lazy loadin
* Blocked - it's waiting for some operation to complete. For example I/O disk request
</b></details>

#### Concurrency

<details>
<summary>Explain what is Semaphore and what its role in operating systems</summary><br><b>
</b></details>

## Virtualization

<a name="virtualization-beginner"></a>
Expand Down Expand Up @@ -2629,7 +2649,6 @@ def find_triplets_sum_to_zero(li):
7. In python **Everything** is an object.
There are many other characteristics but these are the main ones that every python programmer should know.
```
</b></details>

Expand All @@ -2650,13 +2669,13 @@ The immutable data types are:
Tuple
Frozenset

You can usually use the function hash() to check an object mutability, if it is hashable it is immutable, although this does not always work as intended as user defined objects might be mutable and hashable
You can usually use the function hash() to check an object mutability. If an object is hashable, it is immutable (although this does not always work as intended as user defined objects might be mutable and hashable).
</b></details>

<details>
<summary>In Python, functions are first-class objects. What does it mean?</summary><br><b>

In general, first class objects in programming languages are objects which can assigned to variable, used as a return value and can be used as arguments or parameters.<br>
In general, first class objects in programming languages are objects which can be assigned to variable, used as a return value and can be used as arguments or parameters.<br>
In python you can treat functions this way. Let's say we have the following function

```
Expand All @@ -2667,6 +2686,10 @@ def my_function():
You can then assign a function to a variables like this `x = my_function` or you can return functions as return values like this `return my_function`
</b></details>

<details>
<summary>Explain expressions and statements</summary><br><b>
</b></details>

<details>
<summary>What is PEP8? Give an example of 3 style guidelines</summary><br><b>

Expand Down Expand Up @@ -2822,25 +2845,19 @@ Generally, every compiling process have a two steps.
</b></details>

<details>
<summary>What <code>//</code> is used for?</summary><br><b>
<summary>Explain Exception Handling and how to use it in Python</summary><br><b>
</b></details>

<details>
<summary>Write a program which will revert a string (e.g. pizza -> azzip)</summary><br><b>

```
Shortest way is str[::-1] but not the most efficient.
"Classic" way:
foo = ''
for char in 'pizza':
foo = char + foo
<summary>Explain what is GIL</summary><br><b>
</b></details>

>> 'azzip'
<details>
<summary>What is Lambda? How is it used?</summary><br><b>
</b></details>

```
<details>
<summary>What <code>//</code> is used for?</summary><br><b>
</b></details>

<details>
Expand Down Expand Up @@ -2957,7 +2974,7 @@ def is_unique4(l:list) -> bool:
[Solution](coding/python/binary_search.py)
</b></details>

##### Files
#### Files

<details>
<summary>How to write to a file?</summary><br><b>
Expand All @@ -2976,6 +2993,10 @@ with open('file.txt', 'w') as file:
<summary>Sum all the integers in a given file</summary><br><b>
</b></details>

<details>
<summary>Can you write a function which will print all the file in a given directory? including sub-directories</summary><br><b>
</b></details>

#### Regex

<details>
Expand All @@ -3002,10 +3023,6 @@ sorted(x, key=lambda l: l[1])
```
</b></details>

<details>
<summary>Can you write a function which will print all the file in a given directory? including sub-directories</summary><br><b>
</b></details>

<details>
<summary>You have the following list: <code>[{'name': 'Mario', 'food': ['mushrooms', 'goombas']}, {'name': 'Luigi', 'food': ['mushrooms', 'turtles']}]</code>
Extract all type of foods. Final output should be: {'mushrooms', 'goombas', 'turtles'}</summary><br><b>
Expand All @@ -3027,18 +3044,26 @@ def get_food(brothers_menu) -> set:
# One liner way (Using list comprehension)
set([food for bro in x for food in bro['food']])
```

</b></details>

<details>
<summary>What is List Comprehension? Is it better than a typical loop? Why? Can you demonstrate how to use it?</summary><br><b>
</b></details>

#### Practical

<details>
<summary>How to reverse a string?</summary><br><b>
<summary>How to reverse a string? (e.g. pizza -> azzip)</summary><br><b>

Shortest way is:

```
my_string[::-1]
```

But it doesn't mean it's the most efficient one. <br>

Shortest way is: <code>my_string[::-1]</code> but it doesn't mean it's the most efficient one. <br>
Cassic way is:
The Classic way is:
```
def reverse_string(string):
temp = ""
Expand All @@ -3064,10 +3089,6 @@ def reverse_string(string):
<summary>How do you handle argument parsing in Python?</summary><br><b>
</b></details>

<details>
<summary>Explain what is GIL</summary><br><b>
</b></details>

<details>
<summary>What is an iterator?</summary><br><b>
</b></details>
Expand All @@ -3092,6 +3113,14 @@ def reverse_string(string):
<summary>How to combine list of strings into one string with spaces between the strings</summary><br><b>
</b></details>

<details>
<summary>You have the following list of nested lists: <code>[['Mario', 90], ['Geralt', 82], ['Gordon', 88]]</code> How to sort the list by the numbers in the nested lists?</code></summary><br><b>

One way is:

the_list.sort(key=lambda x: x[1])
</b></details>

<details>
<summary>Explain the following:
* zip()
Expand All @@ -3101,6 +3130,8 @@ def reverse_string(string):

<details>
<summary>How do you debug Python code?</summary><br><b>

pdb :D
</b></details>

<details>
Expand Down Expand Up @@ -3238,7 +3269,7 @@ What would be the result of is_int(2) and is_int(False)?
##### Flask

<details>
<summary>You wrote you have experience with Django/Flask. Can you describe what is Django/Flask and how you used it? Why Flask and not Djano? (or vice versa)</summary><br><b>
<summary>You wrote you have experience with Django/Flask. Can you describe what is Django/Flask and how you have used it? Why Flask and not Djano? (or vice versa)</summary><br><b>
</b></details>

<details>
Expand Down Expand Up @@ -3660,6 +3691,12 @@ gitattributes allow you to define attributes per pathname or path pattern.<br>
You can use it for example to control endlines in files. In Windows and Unix based systems, you have different characters for new lines (\r\n and \n accordingly). So using gitattributes we can align it for both Windows and Unix with `* text=auto` in .gitattributes for anyone working with git. This is way, if you use the Git project in Windows you'll get \r\n and if you are using Unix or Linux, you'll get \n.
</b></details>

<details>
<summary>How do you discard local file changes?</summary><br><b>

You can use `git checkout -- <file_name>`
</b></details>

<a name="git-advanced"></a>
#### :star: Advanced

Expand Down

0 comments on commit 37684a9

Please sign in to comment.