<commit_before>---
layout: post
title: Introducing xUtility
---

Part of my strategy outlined at my [Project Roadmap](https://hobelinm.github.io/Project-Roadmap/) is to create several utilities. 
I've come up with different utilities that have helped me in the past or currently help me automate several tasks. 
Those are based on previous needs for automation or I saw the pattern to be useful in other languages and I thought of making the same pattern available on PowerShell or at least the core concepts which could be helpful in some situations. 
Based on those premises I've introduced xUtility module to the online community through [GitHub](https://github.com/hobelinm/PsxUtility) to make the source code available, and through [PowerShell Gallery](https://www.powershellgallery.com/packages/xUtility/) and [NPM](https://www.npmjs.com/package/ps-xutilities) for direct use.

This module is devoted to address some of those common problems in a general and extensible way. 
The features currently addressed are:

- Execution of ScriptBlock with retry policies. This is useful for several scenarios, for example accessing a file in multiple process can lock it making it unavailable for the other process for small periods of time. 
By using retrievable blocks scripts are no longer waiting or retrying for such operations on their own. 
Developers can create custom retry policies which dictate the behavior (number of retries, time between retries, exceptions to catch, etc.)
- Expiring cache. This is a special dictionary which allows developers to store the definition of an operation under a given key and with a desired expiration. This is useful to consult web resources, or perform expensive operations such as reading from a file. When reading from a file these cmdlets avoid hitting the hard drive every time we desire to access its contents and automatically read from disk after expiration
- Custom Prompt. This is designed to highlight the components of the current path, separate it for easy copy (double click only selects the path), display any error with the previous operation (sometimes hidden), and allow for extensiblity for displaying additional stuff defined by the user (something on the works for me is to reflect current state of git branches)<commit_msg>Adding category<commit_after>---
layout: post
title: Introducing xUtility
category: projects
---

Part of my strategy outlined at my [Project Roadmap](https://hobelinm.github.io/Project-Roadmap/) is to create several utilities. 
I've come up with different utilities that have helped me in the past or currently help me automate several tasks. 
Those are based on previous needs for automation or I saw the pattern to be useful in other languages and I thought of making the same pattern available on PowerShell or at least the core concepts which could be helpful in some situations. 
Based on those premises I've introduced xUtility module to the online community through [GitHub](https://github.com/hobelinm/PsxUtility) to make the source code available, and through [PowerShell Gallery](https://www.powershellgallery.com/packages/xUtility/) and [NPM](https://www.npmjs.com/package/ps-xutilities) for direct use.

This module is devoted to address some of those common problems in a general and extensible way. 
The features currently addressed are:

- Execution of ScriptBlock with retry policies. This is useful for several scenarios, for example accessing a file in multiple process can lock it making it unavailable for the other process for small periods of time. 
By using retrievable blocks scripts are no longer waiting or retrying for such operations on their own. 
Developers can create custom retry policies which dictate the behavior (number of retries, time between retries, exceptions to catch, etc.)
- Expiring cache. This is a special dictionary which allows developers to store the definition of an operation under a given key and with a desired expiration. This is useful to consult web resources, or perform expensive operations such as reading from a file. When reading from a file these cmdlets avoid hitting the hard drive every time we desire to access its contents and automatically read from disk after expiration
- Custom Prompt. This is designed to highlight the components of the current path, separate it for easy copy (double click only selects the path), display any error with the previous operation (sometimes hidden), and allow for extensiblity for displaying additional stuff defined by the user (something on the works for me is to reflect current state of git branches)
{'fraction_non_alphanumeric': 0.0406787035022841, 'fraction_numerical': 0.0, 'mean_word_length': 4.790931989924434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2006878', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1004, 'n_words': 672}