palasangha / Treasures-Of-Dhamma

GNU General Public License v3.0
0 stars 0 forks source link

Strawberry Field CLI Tool - code explaination #26

Closed paladhamma closed 2 years ago

paladhamma commented 2 years ago

Links given for reference

paladhamma commented 2 years ago
  1. Bash Interpreter --> https://earthly.dev/blog/understanding-bash/ --> Refer entire article

  2. Php Json Encode --> https://www.php.net/manual/en/function.json-encode.php

    a. json_encode — Returns the JSON representation of a value

    b. The following constants can be combined to form options for json_encode().

    - JSON_HEX_TAG (int): All < and > are converted to \u003C and \u003E.
    - JSON_HEX_AMP (int): All & are converted to \u0026.
    - JSON_HEX_APOS (int): All ' are converted to \u0027.
    - JSON_HEX_QUOT (int): All " are converted to \u0022. 

    Eg: <?php $a = array('',"'bar'",'"baz"','&blong&', "\xc3\xa9");

    echo "Normal: ", json_encode($a), "\n"; echo "Tags: ", json_encode($a, JSON_HEX_TAG), "\n"; echo "Apos: ", json_encode($a, JSON_HEX_APOS), "\n"; echo "Quot: ", json_encode($a, JSON_HEX_QUOT), "\n"; echo "Amp: ", json_encode($a, JSON_HEX_AMP), "\n"; echo "Unicode: ", json_encode($a, JSON_UNESCAPED_UNICODE), "\n"; echo "All: ", json_encode($a, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE), "\n\n";

  3. Case statement used in Bash --> https://linuxize.com/post/bash-case-statement/

    The bash case statement is generally used to simplify complex conditionals when you have multiple different choices. Eg: case EXPRESSION in

    PATTERN_1) STATEMENTS ;;

    PATTERN_2) STATEMENTS ;;

    PATTERN_N) STATEMENTS ;;

    *) STATEMENTS ;; esac

    a. Each case statement starts with the case keyword, followed by the case expression and the in keyword. The statement ends with the esac keyword. b. You can use multiple patterns separated by the | operator. The ) operator terminates a pattern list. c. A pattern can have special characters . d. A pattern and its associated commands are known as a clause. e. Each clause must be terminated with ;;. f. The commands corresponding to the first pattern that matches the expression are executed. g. It is a common practice to use the wildcard asterisk symbol (*) as a final pattern to define the default case. This pattern will always match. h. If no pattern is matched, the return status is zero. Otherwise, the return status is the exit status of the executed commands.

  4. jq command to Process JSON on the Command Line --> https://www.linode.com/docs/guides/using-jq-to-process-json-on-the-command-line/

    --> Refer entire article

  5. Shopt Command --> https://www.computerhope.com/unix/bash/shopt.htm && https://bash.cyberciti.biz/guide/Shopt_command

    a. On Unix-like operating systems, shopt is a builtin command of the Bash shell that enables or disables options for the current shell session. --> Then, https://www.cyberciti.biz/faq/bash-shell-check-for-any-mp3-files-in-directory/ for shopt- nullglob

    b. nullglob : If set, bash allows patterns which match no files to expand to a null string, rather than themselves. This is useful to check for any .mp3 or .cpp files in directory.

  6. Sed command --> https://www.geeksforgeeks.org/sed-command-in-linux-unix-with-examples/ && https://www.geeksforgeeks.org/sed-command-linux-set-2/

    --> Refer entire article, then --> https://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/x17375.html for address range example

  7. JSON API --> https://jsonapi.org/format/

    a. What is JSON:API used for? What Is JSON API (JSONAPI.org)? JSON API is a format that works with HTTP. It delineates how clients should request or edit data from a server, and how the server should respond to said requests.

    b. JSON:API requires use of the JSON:API media type (application/vnd.api+json) for exchanging data.