### JavaScript Event Listener Example Source: https://github.com/oban-bg/oban_training/blob/main/notebooks/samples/reviews.txt This JavaScript code snippet shows how to attach an event listener to an HTML button. When the button is clicked, it logs a message to the console. ```javascript document.getElementById('myButton').addEventListener('click', function() { console.log('Button clicked!'); }); // HTML equivalent: // ``` -------------------------------- ### Python Data Processing Example Source: https://github.com/oban-bg/oban_training/blob/main/notebooks/samples/reviews.txt This snippet demonstrates a basic data processing function in Python. It takes a list of numbers and returns their sum. No external dependencies are required. ```python def process_data(data): """Processes a list of numbers and returns their sum.""" total = sum(data) return total # Example usage: numbers = [1, 2, 3, 4, 5] result = process_data(numbers) print(f"The sum is: {result}") ``` -------------------------------- ### JavaScript DOM Manipulation Example Source: https://github.com/oban-bg/oban_training/blob/main/notebooks/samples/reviews.txt This JavaScript snippet shows how to manipulate the Document Object Model (DOM) to change the text content of an HTML element. It requires a corresponding HTML structure with an element having the ID 'myElement'. ```javascript document.addEventListener('DOMContentLoaded', function() { const element = document.getElementById('myElement'); if (element) { element.textContent = 'New text content!'; } }); ``` -------------------------------- ### Redis Sorted Set Commands Source: https://github.com/oban-bg/oban_training/blob/main/notebooks/samples/reviews.txt This section details common Redis commands for managing sorted sets. It covers adding members, removing members, and retrieving ranges of members based on score or lexicographical order. ```APIDOC Redis Sorted Set Commands: ZADD key score member [score member ...] - Adds one or more members to a sorted set, or updates their scores if they already exist. - Parameters: - key: The key of the sorted set. - score: The score associated with the member. - member: The member to add. - Returns: The number of new elements added to the sorted set. ZREM key member [member ...] - Removes one or more members from a sorted set. - Parameters: - key: The key of the sorted set. - member: The member(s) to remove. - Returns: The number of members removed from the sorted set. ZRANGE key start stop [WITHSCORES] - Returns a range of members in a sorted set, by index. - Parameters: - key: The key of the sorted set. - start: The starting index. - stop: The ending index. - WITHSCORES: Optional. If specified, return the scores of the members. - Returns: A list of members (and optionally their scores) in the specified range. ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count] - Returns a range of members in a sorted set, by score. - Parameters: - key: The key of the sorted set. - min: The minimum score. - max: The maximum score. - WITHSCORES: Optional. If specified, return the scores of the members. - LIMIT offset count: Optional. Limit the number of returned elements. - Returns: A list of members (and optionally their scores) within the specified score range. ``` -------------------------------- ### Redis Sorted Set Commands Source: https://github.com/oban-bg/oban_training/blob/main/notebooks/samples/reviews.txt This section details common Redis commands for managing sorted sets, including adding members, removing members, and retrieving ranges of members based on score or lexicographical order. It also covers options for reversing the order and limiting the number of results. ```APIDOC Redis Sorted Set Commands: ZADD key score member [score member ...] - Adds one or more members to a sorted set, or updates the score of existing members. - Parameters: - key: The key of the sorted set. - score: The score associated with the member. - member: The member to add. - Returns: The number of elements added to the sorted set. ZREM key member [member ...] - Removes one or more members from a sorted set. - Parameters: - key: The key of the sorted set. - member: The member to remove. - Returns: The number of members removed from the sorted set. ZRANGE key start stop [WITHSCORES] - Returns a range of members in a sorted set, by index. - Parameters: - key: The key of the sorted set. - start: The starting index. - stop: The ending index. - WITHSCORES: Optional. If specified, return the scores of the members. - Returns: A list of members (and their scores, if requested) in the specified range. ZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count] - Returns a range of members in a sorted set, by score. - Parameters: - key: The key of the sorted set. - min: The minimum score. - max: The maximum score. - WITHSCORES: Optional. If specified, return the scores of the members. - LIMIT offset count: Optional. Limit the number of returned elements. - Returns: A list of members (and their scores, if requested) within the specified score range. ZREVRANGE key start stop [WITHSCORES] - Returns a range of members in a sorted set, by index, with the highest scores first. - Parameters: - key: The key of the sorted set. - start: The starting index. - stop: The ending index. - WITHSCORES: Optional. If specified, return the scores of the members. - Returns: A list of members (and their scores, if requested) in reverse order. ZCARD key - Returns the number of members in a sorted set. - Parameters: - key: The key of the sorted set. - Returns: The number of members in the sorted set. ZSCORE key member - Returns the score of a member in a sorted set. - Parameters: - key: The key of the sorted set. - member: The member whose score to retrieve. - Returns: The score of the member, or nil if the member does not exist. ``` -------------------------------- ### Python Function for Data Processing Source: https://github.com/oban-bg/oban_training/blob/main/notebooks/samples/reviews.txt This Python function processes a list of data items, performing a specific transformation on each item. It demonstrates basic list comprehension and conditional logic in Python. ```python def process_data(data_list): processed_items = [] for item in data_list: if item > 10: processed_items.append(item * 2) else: processed_items.append(item + 5) return processed_items # Example usage: my_data = [5, 12, 8, 15, 3] result = process_data(my_data) print(result) # Output: [10, 24, 13, 30, 8] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.