This article discusses ways of finding a substring’s position in a PowerShell string. We will, in particular, discuss the following three methods, each serving a unique purpose.
Continue readingAuthor Archives: Kiprono Koech
Convert 2d List to String in Python
A 2-dimensional (2D) list is simply a list of lists (lists within a list). Here are some examples of 2D lists in Python.
Continue readingWrite to Table in Powershell
This article uses examples to discuss different methods of writing data into a table in PowerShell. In particular, we will discuss how to write user-defined data to a PowerShell table, read data from a file and write it to a table, format PowerShell output as a table, and write output into a tabular form data file like a CSV.
Continue readingDelete Windows Service in Powershell
Sometimes, we may need to remove Windows services installed on our PCs. For example, we may want to delete orphaned services left over after uninstalling the application running them, or you may want to delete Windows Services simply because you don’t need them.
Continue readingList Windows Services using PowerShell
Windows services are Windows executables that run in the background to support the working of some Windows processes. These services can be started, stopped, restarted, suspended, resumed, or even removed.
Continue readingConvert Bytes to Float Numbers in Python
This article discusses how to use struct and Numpy packages in Python to convert bytes to floats and vice-versa. Before we do that, however, let’s briefly discuss the difference between bytes and floating-point numbers.
Continue readingSplit Input by Space in Python
There are two key functions we need to use here: input(<prompt>) and str.split(<char>).
Continue readingRedirect Stdout to a File in Python
Python uses the following two file objects on the sys library as output streams:
- sys.stdout – used for output of print() function and the prompt in input() function,
- sys.stderr – is an output stream for Python’s prompts (like the help() function), errors, and exceptions.
Check if an Argument in a Function Is Passed in Python
Consider the following Python function:
1 2 3 4 5 |
def func1(val1, val2, val3): return val1 * val2 + val3 # Calling the function. result = func1(3, 4, 6) |
Suppress Console Output in Python
Python interpreter uses the following three file objects on the sys library for standard input, output, and errors (exceptions):
Continue reading