Stavis Dev Documentation Collection

website·Indexed 29 days ago

https://stavis-dev.github.io/

A personal collection of IT documentation and guides covering Python (data types, regex, unittest, binary search, and comprehensions), Linux command-line tips, and tool-specific manuals for UFW, ADB, GPG, WireGuard, and Docker. Also includes notes on Docusaurus and general soft skills.

Tokens
66K
Snippets
478
Records
613
Agent score
72%

What's inside Stavis Dev

  1. Understand Python Mappings and Dictionary types

    A mapping is a container object that supports arbitrary access to elements via keys. It implements the interface defined in collections.Mapping (read-only) or collections.MutableMapping (read-write). Common mapping classes include dict, collections.defaultdict, collections.OrderedDict, and collections.Counter.
  2. Understand Python's mutable and immutable types

    Python distinguishes between mutable and immutable types. For immutable types (e.g., numbers), arithmetic operations do not change the existing object but create a new object, and the variable name is rebound to this new object. If the old object has no remaining references, it is removed via reference counting. For mutable types, operations modify the object's memory directly, meaning all names bound to that memory location will see the changes.
  3. Understand Python list characteristics

    A list in Python is a mutable data structure used to store a collection of objects. Unlike arrays in some other languages, Python lists can contain objects of different types. A list variable holds a reference to a container in memory, which in turn holds references to the actual data objects. Because lists are mutable, their size and contents can be changed after creation.
  4. Understand Python string fundamentals

    Strings in Python are immutable, ordered sequences of characters enclosed in quotes. Because they are sequences, they support iteration, indexing (similar to tuples), and slicing. Since strings are immutable, any method that transforms a string returns a new string rather than modifying the original.
    str_one = 'Hello'
    str_two = "Hello"
    # Multi-line string
    tunnel = """
    interface Tunnel0
    ip address 10.10.10.1 255.255.0.0
    """
  5. Understand Python Sequences

    A sequence in Python is an iterable object that supports efficient access to elements using integer indices via the __getitem__() method and provides its length via the __len__() method. Common built-in sequence types include list, tuple, range, str, and bytes. Many sequences also optionally implement count(), index(), __contains__(), and __reversed__().
  6. Update the system and check package versions

    Synchronize package databases and update all installed packages using -Syu. To check detailed information about a specific package version before updating, use -Qi.
    # Update system
    sudo pacman -Syu
    
    # Check package information/version
    pacman -Qi visual-studio-code-bin
  7. Distinguish between mutable and immutable data types in Python

    Python data types are categorized as either mutable or immutable.

    • Immutable objects: When a value is assigned to an immutable object or modified, Python does not overwrite the existing object but creates a new object with a new unique identifier (id). Examples include numbers (int, float), strings, and tuples.
    • Mutable objects: These can be modified in place without changing their unique identifier (id). Examples include lists, dictionaries, and sets.

    This distinction is critical when passing objects to functions; to prevent a function from modifying an original list, a copy of the list should be passed instead.

    # Immutable example: integers
    int_var = 5
    print(f"first id: {id(int_var)}")
    int_var += 10
    print(f"second id: {id(int_var)}") # The id changes because a new object is created
    
    # Mutable example: lists
    list_var = [10, 20, 30]
    print(f"first id: {id(list_var)}")
    list_var += [40]
    print(f"second id: {id(list_var)}") # The id remains the same
  8. Use the Python re module for regular expressions

    Python provides the re module to work with regular expressions, allowing developers to match strings or find specific patterns using specialized syntax. The module includes functions for searching, matching, replacing, and splitting strings based on regex patterns.
  9. Identify and counter source discredit fallacies

    The 'Discrediting the Source' fallacy occurs when attention is diverted from an argument by presenting negative information about the person making the argument. The goal is to create the false impression that the argument itself has been refuted simply because the source is flawed.
  10. Understand Python dictionary (hash table) internals

    Python dictionaries are implemented as sparse arrays of 'buckets'. Each bucket contains a reference to the key and the value.

    1. Insertion/Lookup: Python calls hash(key) to get a hash value. The lower bits of this value are used as an offset to find the bucket.
    2. Collision: A hash collision occurs when the hash function returns the same value for different inputs. Python resolves this by using different bits of the hash value to calculate a new offset.
    3. Verification: Once a bucket is found, Python verifies that search_key == found_key to ensure the correct element is retrieved. If the bucket is empty, a KeyError is raised.
    4. Resizing: To maintain performance, Python ensures at least one-third of the buckets remain empty; if the table becomes too full, it is copied to a larger memory area.
  11. Identify the Tu Quoque ('And what about you!') fallacy

    The Tu Quoque fallacy occurs when a person avoids arguing their position by pointing out that the opponent is acting inconsistently with their own argument. It focuses on the character or behavior of the speaker to distract from the validity of the claim.

    Example: Person A: "Smoking is harmful to health; people should not smoke." Person B: "But you were smoking a few minutes ago. Therefore, smoking is allowed."

  12. Understand Python Generators

    A generator can refer to either a generator function or the resulting generator iterator. Generators automatically implement the __iter__ and __next__ methods, making them both iterables and iterators.