From 7aebfc652c767adc04d472df4c89d2cf2bd3c75e Mon Sep 17 00:00:00 2001 From: Ayan Banerjee Date: Wed, 24 Feb 2021 17:52:44 +0530 Subject: [PATCH] mkdocs.yml: Add syntax highlighting (#89) * mkdocs.yml: Add syntax highlighting * Add languages to codeblocks --- courses/CONTRIBUTING.md | 2 +- courses/big_data/evolution.md | 4 ++-- courses/databases_sql/lab.md | 12 ++++++------ courses/linux_basics/command_line_basics.md | 14 +++++++------- courses/python_web/intro.md | 2 +- courses/python_web/python-concepts.md | 2 +- courses/python_web/python-web-flask.md | 2 +- courses/security/fundamentals.md | 6 +++--- courses/security/network_security.md | 4 ++-- courses/security/threats_attacks_defences.md | 2 +- mkdocs.yml | 3 +++ 11 files changed, 28 insertions(+), 25 deletions(-) diff --git a/courses/CONTRIBUTING.md b/courses/CONTRIBUTING.md index 97bb92e..4d629d2 100644 --- a/courses/CONTRIBUTING.md +++ b/courses/CONTRIBUTING.md @@ -16,7 +16,7 @@ Ensure that you adhere to the following guidelines: ### Building and testing locally Run the following commands to build and view the site locally before opening a PR. -``` +```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt diff --git a/courses/big_data/evolution.md b/courses/big_data/evolution.md index cb665b7..281efa8 100644 --- a/courses/big_data/evolution.md +++ b/courses/big_data/evolution.md @@ -57,7 +57,7 @@ ![Pig Example](images/pig_example.png) Output: - ``` + ```text 7,Komal,Nayak,24,9848022334,trivendram 8,Bharathi,Nambiayar,24,9848022333,Chennai 5,Trupthi,Mohanthy,23,9848022336,Bhuwaneshwar @@ -70,7 +70,7 @@ 1. Presto is a high performance, distributed SQL query engine for Big Data. 2. Its architecture allows users to query a variety of data sources such as Hadoop, AWS S3, Alluxio, MySQL, Cassandra, Kafka, and MongoDB. 3. Example presto query: - ``` + ```sql use studentDB; show tables; SELECT roll_no, name FROM studentDB.studentDetails where section=’A’ limit 5; diff --git a/courses/databases_sql/lab.md b/courses/databases_sql/lab.md index c946d41..b6f7227 100644 --- a/courses/databases_sql/lab.md +++ b/courses/databases_sql/lab.md @@ -10,7 +10,7 @@ Create a working directory named sos or something similar, and cd into it. Enter the following into a file named my.cnf under a directory named custom. -``` +```conf sos $ cat custom/my.cnf [mysqld] # These settings apply to MySQL server @@ -25,7 +25,7 @@ long_query_time=0.1 Start a container and enable slow query log with the following: -``` +```bash sos $ docker run --name db -v custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=realsecret -d mysql:8 sos $ docker cp custom/mysqld.cnf $(docker ps -qf "name=db"):/etc/mysql/conf.d/custom.cnf sos $ docker restart $(docker ps -qf "name=db") @@ -35,7 +35,7 @@ sos $ docker restart $(docker ps -qf "name=db") Import a sample database -``` +```bash sos $ git clone git@github.com:datacharmer/test_db.git sos $ docker cp test_db $(docker ps -qf "name=db"):/home/test_db/ sos $ docker exec -it $(docker ps -qf "name=db") bash @@ -48,7 +48,7 @@ root@3ab5b18b0c7d:/etc# chown mysql:mysql /var/log/mysqlslow.log _Workshop 1: Run some sample queries_ Run the following -``` +```bash $ mysql -uroot -prealsecret mysql mysql> @@ -92,7 +92,7 @@ mysql> select count(*) from employees where first_name = 'Sachin'; ``` _Workshop 2: Use explain and explain analyze to profile a query, identify and add indexes required for improving performance_ -``` +```bash # View all indexes on table #(\G is to output horizontally, replace it with a ; to get table output) mysql> show index from employees from employees\G @@ -178,7 +178,7 @@ mysql> explain analyze select first_name, last_name from employees where first_n ``` _Workshop 3: Identify slow queries on a MySQL server_ -``` +```bash # Run the command below in two terminal tabs to open two shells into the container. docker exec -it $(docker ps -qf "name=db") bash diff --git a/courses/linux_basics/command_line_basics.md b/courses/linux_basics/command_line_basics.md index 04b151c..ca188eb 100644 --- a/courses/linux_basics/command_line_basics.md +++ b/courses/linux_basics/command_line_basics.md @@ -135,7 +135,7 @@ the simplest use case of creating a new file. General syntax of using touch command -``` +```bash touch ``` @@ -148,7 +148,7 @@ to verify that the new directory is created. General syntax of using mkdir command -``` +```bash mkdir ``` @@ -164,7 +164,7 @@ run this command with care. General syntax of using rm command: -``` +```bash rm ``` @@ -183,7 +183,7 @@ their copy both co-exist after running cp command successfully. General syntax of using cp command: -``` +```bash cp ``` @@ -218,7 +218,7 @@ move the files or directories, the original copy is lost. General syntax of using mv command: -``` +```bash mv ``` @@ -385,7 +385,7 @@ an input to the grep command. General syntax of using grep command: -``` +```bash grep ``` @@ -401,7 +401,7 @@ file. General syntax of using the sed command for replacement: -``` +```bash sed 's///' ``` diff --git a/courses/python_web/intro.md b/courses/python_web/intro.md index db1abf3..5710788 100644 --- a/courses/python_web/intro.md +++ b/courses/python_web/intro.md @@ -73,7 +73,7 @@ We know compilation is involved in all 3 languages we are discussing. Just that Those bytecodes are language specific. Python has its own set of bytecode defined (more in `dis` module) and so does java. So naturally, your operating system will not know how to run it. To run this bytecode, we have something called Virtual Machines. Ie: The JVM or the Python VM (CPython, Jython). These so called Virtual Machines are the programs which can read the bytecode and run it on a given operating system. Python has multiple VMs available. Cpython is a python VM implemented in C language, similarly Jython is a Java implementation of python VM. **At the end of the day, what they should be capable of is to understand python language syntax, be able to compile it to bytecode and be able to run that bytecode.** You can implement a python VM in any language! (And people do so, just because it can be done) -``` +```text The Operating System +------------------------------------+ diff --git a/courses/python_web/python-concepts.md b/courses/python_web/python-concepts.md index 8a7062a..ca444ae 100644 --- a/courses/python_web/python-concepts.md +++ b/courses/python_web/python-concepts.md @@ -122,7 +122,7 @@ What goes inside the `deco` function might seem complex. Let's try to uncover it Let's visualize it for better understanding -``` +```text BEFORE function_object (ID: 100) "hello_world" +--------------------+ diff --git a/courses/python_web/python-web-flask.md b/courses/python_web/python-web-flask.md index c797830..8a6a151 100644 --- a/courses/python_web/python-web-flask.md +++ b/courses/python_web/python-web-flask.md @@ -36,7 +36,7 @@ b'GET / HTTP/1.1\r\nHost: localhost:65432\r\nConnection: keep-alive\r\nDNT: 1\r\ Examine closely and the content will look like the HTTP protocol's format. ie: -``` +```text HTTP_METHOD URI_PATH HTTP_VERSION HEADERS_SEPARATED_BY_SEPARATOR ``` diff --git a/courses/security/fundamentals.md b/courses/security/fundamentals.md index 5c82e67..5228eb1 100644 --- a/courses/security/fundamentals.md +++ b/courses/security/fundamentals.md @@ -42,7 +42,7 @@ - Fail securely - Applications regularly fail to process transactions for many reasons. How they fail can determine if an application is secure or not. - ``` + ```java is_admin = true; try { @@ -113,7 +113,7 @@ - Ciphers are the cornerstone of cryptography. A cipher is a set of algorithms that performs encryption or decryption on a message. An encryption algorithm (E) takes a secret key (k) and a message (m) and produces a ciphertext (c). Similarly, a Decryption algorithm (D) takes a secret key (K) and the previous resulting Ciphertext (C). They are represented as follows: -``` +```text E(k,m) = c D(k,c) = m @@ -122,7 +122,7 @@ D(k,c) = m - This also means that for it to be a cipher, it must satisfy the consistency equation as follows, making it possible to decrypt. -``` +```text D(k,E(k,m)) = m ``` diff --git a/courses/security/network_security.md b/courses/security/network_security.md index 2ddf2f6..366b185 100644 --- a/courses/security/network_security.md +++ b/courses/security/network_security.md @@ -142,7 +142,7 @@ Let us see how we keep a check on the perimeter i.e the edges, the first layer o - Nmap is often used to determine alive hosts in a network, open ports on those hosts, services running on those open ports, and version identification of that service on that port. - More at http://scanme.nmap.org/ -``` +```bash nmap [scan type] [options] [target specification] ``` @@ -417,7 +417,7 @@ TCP Flags - Abuse of the normal operation or settings of these flags can be used by attackers to launch DoS attacks. This causes network servers or web servers to crash or hang. -``` +```text | SYN | FIN | PSH | RST | Validity| |------|------|-------|------|---------| | 1 |1 |0 |0 |Illegal Combination diff --git a/courses/security/threats_attacks_defences.md b/courses/security/threats_attacks_defences.md index 145a17d..fbae0dc 100644 --- a/courses/security/threats_attacks_defences.md +++ b/courses/security/threats_attacks_defences.md @@ -100,7 +100,7 @@ BGP Security - A successful exploit will allow attackers to access, modify, or delete information in the database. - It permits attackers to steal sensitive information stored within the backend databases of affected websites, which may include such things as user credentials, email addresses, personal information, and credit card numbers -``` +```sql SELECT USERNAME,PASSWORD from USERS where USERNAME='' AND PASSWORD=''; Here the username & password is the input provided by the user. Suppose an attacker gives the input as " OR '1'='1'" in both fields. Therefore the SQL query will look like: diff --git a/mkdocs.yml b/mkdocs.yml index 14710ed..1454cf4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -76,6 +76,9 @@ nav: - Code of Conduct: CODE_OF_CONDUCT.md - SRE Community: sre_community.md copyright: "Copyright 2020 LinkedIn Corporation. All Rights Reserved. Licensed under the Creative Commons Attribution 4.0 International Public License" +markdown_extensions: + - pymdownx.highlight + - pymdownx.superfences extra: social: - icon: fontawesome/brands/github