Technology Tales

Notes drawn from experiences in consumer and enterprise technology

16:10, 26th September 2024

Regular Expressions 101 is an interactive online tool designed to help developers learn, test and debug regular expressions, the pattern-matching syntax widely used across programming languages and command line tools. It features a live editor in which a pattern can be entered alongside sample data, with matches highlighted in real time and a plain language explanation generated that breaks down each component of the expression, covering constructs such as character classes, quantifiers, groups and anchors.

A step-by-step debugger traces how the regex engine processes input character by character, which proves particularly useful when troubleshooting complex or unexpected behaviour. The tool supports multiple regex engines including PCRE, JavaScript and Python, allowing differences between implementations to be explored directly. Users can also save expressions, build a small library of tested patterns and generate shareable links.

Common use cases include parsing logs, validating input, extracting data and writing search expressions for tools such as grep or various text editors. By combining testing, explanation and debugging in a single environment, the tool has become a widely used reference for both learning regex syntax and resolving patterns that do not behave as expected.

14:24, 25th September 2024

TimeAPI is a service offering developers and businesses access to accurate, real-time global time and time zone data through a pair of dedicated APIs. The Time Zone API enables users to retrieve time zone information, convert times between locations and monitor daylight saving time changes, while the Time API provides current time data for any location worldwide. Documentation is presented through a Swagger interface to make integration straightforward, and the service supports multiple calendar formats including ISO 8601, Unix Time and Julian Day. The platform handles approximately 2.5 billion requests per month, maintains a response time of under one millisecond and boasts an uptime of 99.99%.

21:45, 22nd September 2024

How to delete all files in a directory with Python?

Deleting files in a directory using Python can be achieved through built-in modules that offer different approaches for managing file removal. The os module provides functions like listdir() and remove() to iterate over files and delete them individually, ensuring simplicity and readability. Introduced in Python 3.4, the pathlib module uses an object-oriented approach with methods such as iterdir() and unlink() to perform similar tasks. For scenarios involving subdirectories, the shutil module extends functionality by allowing the deletion of both files and folders recursively.

Each method requires careful validation of file paths and permissions to avoid unintended data loss, particularly when handling large-scale or automated operations. The choice of module depends on the specific requirements, such as whether to remove only files, include subdirectories, or maintain structured control over the deletion process.

22:32, 13th September 2024

Harness AIDA

Harness AI automates repetitive tasks in software delivery by integrating intelligence across DevOps, testing, security and cost management, using contextual learning to optimise workflows, predict failures and enforce governance while reducing manual intervention through adaptive automation and real-time recommendations.

20:33, 26th August 2024

How to loop blocks of code in Ansible

Ansible does not natively support looping over blocks of tasks using the block directive, which causes issues when multiple related tasks need to share the same loop variable. A practical workaround is to move the grouped tasks into a separate file and use the include\_tasks directive in the main playbook to reference it, applying the loop at that level instead.

Each task within the included file can then reference the loop variable using the standard {{ item }} syntax, allowing the entire group to iterate correctly over a list of values, such as IP addresses. While this approach requires splitting logic across multiple files, it remains the only reliable method for achieving this behaviour in Ansible.

20:47, 17th April 2024

The Many Ways to Exit in Python

Python offers several methods for terminating a programme, each with varying levels of suitability depending on the context. The most straightforward approach is raising a SystemExit exception, which triggers Python's standard exit routine, including running any registered atexit functions and accepting an optional integer exit code to signal success or failure.

A closely related option is sys.exit(), which ultimately performs the same operation but requires an import and obscures the fact that an exception is being raised. The built-in functions exit() and quit() are also available without importing anything, though they depend on the optional site module and are best reserved for interactive use in the Python REPL rather than in production code.

At the REPL, pressing Ctrl-D is a universally applicable shortcut that sends an end-of-file signal and works across many command-line programmes beyond Python alone. Finally, os._exit() exists as a lower-level option that bypasses Python's normal exit process entirely, making it highly disruptive and generally unsuitable for everyday use, though it can prove useful in specific debugging scenarios such as stopping a multithreaded programme where raising SystemExit would only halt the current thread.

15:20, 14th March 2024

Python Enum: How To Build Enumerations in Python

Although Python does not have a built-in enumeration data type, its standard library includes the enum module, which allows developers to create named constants grouped under a class. Enumerations are particularly useful when a variable can only take one of a fixed set of related values, such as days of the week, order statuses or task states, as they improve code clarity, maintainability and type safety by replacing arbitrary numbers or strings with meaningful labels.

Using the Enum class, developers can define members with custom names and values or rely on the auto() helper function to assign values automatically, starting from one or a specified number. Enum members can be accessed by name or value, counted using len() and iterated over just like any standard Python iterable. A practical application of this is a task management system in which a TaskStatus enum defines states such as TODO, IN_PROGRESS, DONE and ABANDONED, with a corresponding Task class that enforces valid state transitions and raises a ValueError when an invalid change is attempted.

16:59, 26th February 2024

Python args and kwargs: Demystified

Understanding how to use *args and **kwargs in Python functions allows for greater flexibility in handling variable numbers of arguments. These constructs enable functions to accept an arbitrary number of positional or keyword arguments, which can then be processed within the function body.

The * operator is used to unpack iterables such as lists or strings, allowing their elements to be passed individually to a function. Similarly, the ** operator unpacks dictionaries, merging their key-value pairs into another dictionary.

While these features offer powerful capabilities, readability should remain a priority, as overly complex unpacking can obscure the intent of the code. Mastery of these tools enhances the ability to write adaptable and efficient functions, making them essential for developers working with dynamic input scenarios.

16:29, 2nd February 2024

Usage Note 69994: SAS® Life Science Analytics Framework 5.4.x - Documenting various log and listing limits within the UI for each browser client

Stress testing of SAS Life Science Analytics Framework versions 5.4 and 5.4.1 identified specific limits for log and listing files when using supported browsers such as Google Chrome, Microsoft Edge and Mozilla Firefox. These limits include maximum line counts for logs and listings, as well as thresholds for errors, warnings and notes, with variations between Edge and Chrome.

Exceeding these thresholds may lead to unpredictable performance issues, such as delayed responses, memory errors, or session termination. Factors like system resources, browser settings and version differences can influence how these limits are experienced.

Recommendations include following best practices to reduce log and listing output, such as using ODS EXCLUDE or suppressing unnecessary information, to mitigate potential disruptions. Differences in architecture between 5.4.x and earlier versions may also affect the likelihood of encountering these issues.

22:26, 31st January 2024

SAS Arrays and DO Loop Made Easy

SAS arrays and DO loops are two fundamental programming tools used in SAS data steps to process multiple variables efficiently. An array groups a set of variables under a single name, allowing operations to be performed across all of them without writing repetitive code, and can handle both numeric and character variables.

The syntax requires specifying an array name, the number of elements and a list of variables, though SAS can automatically calculate the element count using an asterisk. The DO loop complements arrays by enabling iterative processing across a defined range of values, using an index variable to track each iteration.

Together, these tools support a wide range of practical tasks, such as replacing values that exceed a threshold with missing data, extracting substrings from character variables, assigning results to new variables, multiplying values by predefined factors stored in temporary arrays and calculating percentage differences between consecutive variables.

The DIM function is commonly used to determine the number of elements in an array dynamically, while the OF operator allows functions such as sum, mean and min to be applied across all array elements. An alternative to the standard indexed DO loop is the DO OVER loop, which iterates directly over array elements without requiring an explicit index variable.

  • The content, images, and materials on this website are protected by copyright law and may not be reproduced, distributed, transmitted, displayed, or published in any form without the prior written permission of the copyright holder. All trademarks, logos, and brand names mentioned on this website are the property of their respective owners. Unauthorised use or duplication of these materials may violate copyright, trademark and other applicable laws, and could result in criminal or civil penalties.

  • All comments on this website are moderated and should contribute meaningfully to the discussion. We welcome diverse viewpoints expressed respectfully, but reserve the right to remove any comments containing hate speech, profanity, personal attacks, spam, promotional content or other inappropriate material without notice. Please note that comment moderation may take up to 24 hours, and that repeatedly violating these guidelines may result in being banned from future participation.

  • By submitting a comment, you grant us the right to publish and edit it as needed, whilst retaining your ownership of the content. Your email address will never be published or shared, though it is required for moderation purposes.