menu
We can use the following method to ensure a variable value is between a specific range

# Ensure between 1 and 100
111.clamp(1, 100)
# => 100
-1.clamp(1, 100)
We can use the following methods to ensure a variable is always min or max value:

# Ensure the value is one or more
[value, 1].min

# Ensure the value is 100 or less
[value, 100].max
The docker system prune command is a shortcut that prunes images, containers, and networks.

docker system prune
It is an approach where the result of one function is passed on to the next function, which is passed to another until the final function is executed for the final result.

//example
const double = (x) => x * 2;
const square = (x) => x * x;

var output1 = double(2);
var output2 = square(output1);
console.log(output2);

var output_final = square(double(2));
console.log(output_final);
Lambdas in Python are a concise way to define anonymous functions. They are useful for short, inline functions that are used only once or in situations where a full function definition would be cumbersome.

# Syntax
lambda arguments: expression

# Example of use
add = lambda x, y: x + y  # Defines a lambda function that adds two numbers
result = add(5, 3)  # Calls the lambda function with arguments 5 and 3
print(result)  # Output: 8
There is not something like a keyword to user encapsulation but you can address the same behavior by using Python convention "_" and "__"

class Example:
    def __init__(self):
        self.public_var = "public"
        self._protected_var = "protected"
        self.__private_var = "private"

    def public_method(self):
        print("This is a public method")

    def _protected_method(self):
        print("This is a protected method")

    def __private_method(self):
        print("This is a private method")

# Creating an instance of the class
example_instance = Example()

# Accessing public method and variable
example_instance.public_method()
print(example_instance.public_var)

# Accessing protected method and variable
example_instance._protected_method()
print(example_instance._protected_var)

# Trying to access private method and variable (will raise AttributeError)
# example_instance.__private_method()
# print(example_instance.__private_var)

The class Example has three types of methods and variables:
  • Public methods and variables are accessible from outside the class.
  • Protected methods and variables have a single underscore _ prefix and are typically considered non-public, although Python does not enforce this.
  • Private methods and variables have a double underscore __ prefix and are only accessible within the class itself.

In the example code:
  • public_var, public_method(), _protected_var, and _protected_method() are respectively public and protected variables and methods.
  • _protected_var and _protected_method() can be accessed from outside the class but are typically considered non-public.
  • __private_var and __private_method() are private variables and methods and can only be accessed within the class itself. Trying to access them from outside the class will raise an AttributeError.
You can use the method type() to know the type of a variable for example:
type(123) # <class 'int'>
Using Python you can separate numbers with "_" value for example:
123_145_877
This does not affect the value or type of the number, it is only for improving human reading!
The following will show a table of information about all tables available, including which are views and which are tables:

SELECT * FROM information_schema.tables


See Information Schema for more details.
HATEOAS (Hypermedia as the Engine of Application State) is a design principle within RESTful APIs. It dictates that the server dynamically informs the client of available actions and related resources through hypermedia elements embedded within the response.

Imagine you're exploring a choose-your-own-adventure storybook. HATEOAS (Hypermedia as the Engine of Application State) is like the book itself guiding you through the adventure.

How it works:
  1. You reach a point in the story (like a new level in a game).
  2. The book (the application) presents you with the available options for what you can do next (like fight a monster or solve a puzzle). These are the hypermedia elements.
  3. You choose an option by following the provided link or instructions.
  4. The story then unfolds based on your choice, revealing new options and progressing the state of the application.


{
  "orderID":3,
  "productID":2,
  "quantity":4,
  "orderValue":16.60,
  "links":[
    {
      "rel":"customer",
      "href":"https://adventure-works.com/customers/3",
      "action":"GET",
      "types":["text/xml","application/json"]
    },
    {
      "rel":"customer",
      "href":"https://adventure-works.com/customers/3",
      "action":"PUT",
      "types":["application/x-www-form-urlencoded"]
    },
    {
      "rel":"customer",
      "href":"https://adventure-works.com/customers/3",
      "action":"DELETE",
      "types":[]
    },
    {
      "rel":"self",
      "href":"https://adventure-works.com/orders/3",
      "action":"GET",
      "types":["text/xml","application/json"]
    },
    {
      "rel":"self",
      "href":"https://adventure-works.com/orders/3",
      "action":"PUT",
      "types":["application/x-www-form-urlencoded"]
    },
    {
      "rel":"self",
      "href":"https://adventure-works.com/orders/3",
      "action":"DELETE",
      "types":[]
    }]
}
Imagine a busy restaurant. A Denial-of-Service (DoS) attack is like someone calling in a ton of fake orders overwhelming the kitchen. The real customers can't get their food because the kitchen is stuck dealing with the fakes.

In the computer world, DoS attacks try to overwhelm a website or online service with fake traffic, like those fake orders. This overload prevents real users from accessing the service. It's like the restaurant being too busy with the fakes to serve real customers.

DoS attacks are usually temporary, but they can be disruptive and costly.

In 2008, Leonard Richardson proposed the following maturity model for web APIs:
  • Level 0: Define one URI, and all operations are POST requests to this URI.
  • Level 1: Create separate URIs for individual resources.
  • Level 2: Use HTTP methods to define operations on resources.
  • Level 3: Use hypermedia (HATEOAS, described below).

Level 3 corresponds to a truly RESTful API according to Fielding's definition. In practice, many published web APIs fall somewhere around level 2.

We use pass in Python functions as a placeholder for empty code.
It basically tells Python to do nothing in that specific spot. It's useful for:

  • Marking incomplete functions: When you're defining a function but haven't written its logic yet, pass prevents errors.
  • Skipping code sections: Within a function, pass can be used to intentionally skip a block of code if a certain condition isn't met.
In IPython 7.3 and later, there is a magic %pip and %conda command that will run in the current kernel.

%pip install geocoder

In earlier versions, you need to use sys to fix the problem like in the answer by FlyingZebra1

import sys
!{sys.executable} -m pip install geocoder
You can adjust output from this with the --progress option:
  --progress string         Set type of progress output (auto, plain, tty). Use plain to show container output
                            (default "auto")

Adding --progress=plain will show the output of the run commands that were not loaded from the cache. This can also be done by setting the BUILDKIT_PROGRESS 

variable:
export BUILDKIT_PROGRESS=plain


If you are debugging a build, and the steps have already been cached, add --no-cache to your build to rerun the steps and redisplay the output:
docker build --progress=plain --no-cache ...


If you don't want to use buildkit, you can revert to the older build engine by exporting DOCKER_BUILDKIT=0 in your shell, e.g.:
DOCKER_BUILDKIT=0 docker build ...


or
export DOCKER_BUILDKIT=0
docker build ...


Source: https://stackoverflow.com/questions/64804749/why-is-docker-build-not-showing-any-output-from-commands