using System.Collections.Generic;
using System.Linq;
namespace Utility.Extensions
{
public static class IEnumerableExtensions
{
public static IEnumerable<(T item, int index)> WithIndex<T>(this IEnumerable<T> self)
=> self?.Select((item, index) => (item, index)) ?? new List<(T, int)>();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Join-Strings | |
{ | |
<# | |
.SYNOPSIS | |
Join strings with a specified separator. | |
.DESCRIPTION | |
Join strings with a specified separator. | |
This strips out null values and any duplicate separator characters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-Repo { | |
param ( | |
[Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [String] $Repo | |
) | |
$repoName = $NULL | |
try { | |
$testUri = "https://api.github.com/repos/$Repo" | |
$temp = (Invoke-RestMethod -Method GET -Uri $testUri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-InstalledDotNetFrameworkFromRegistry { | |
<# | |
.SYNOPSIS | |
Display version of .net installed on a system | |
.DESCRIPTION | |
Query the registry on a local or remote system to display the version of .net installed | |
.PARAMETER ComputerName | |
The name of the computer to run the query on | |
#> | |
Inspired by this article. Neat tricks for speeding up integer computations.
Note: cin.sync_with_stdio(false);
disables synchronous IO and gives you a performance boost.
If used, you should only use cin
for reading input
(don't use both cin
and scanf
when sync is disabled, for example)
or you will get unexpected results.
x = x << 1; // x = x * 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
A brief description of the function or script. This keyword can be used only once in each topic. | |
.DESCRIPTION | |
A detailed description of the function or script. This keyword can be used only once in each topic. | |
.COMPONENT | |
The name of the technology or feature that the function or script uses, or to which it is related. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
This function performs a search of a hash table using a provided key. | |
.DESCRIPTION | |
This function performs a search of a hash table using a provided key. | |
It returns the value matching the key if found, and null otherwise. | |
The case sensitive search has O(1) time complexity while the case insensitive search has | |
O(N) time complexity, where N is the number of key-value pairs in the hash table. | |
#> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-SystemSoftware{ | |
<# | |
.SYNOPSIS | |
Gather software installed on a local or remote device | |
.DESCRIPTION | |
Gather Software and information about the software installed on a local or remote device using the registry or WMI | |
.PARAMETER ComputerName | |
Computer to gather software on | |
.PARAMETER QueryType | |
Specify how you want to gather the information |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-InstalledDotNet { | |
<# | |
.SYNOPSIS | |
Display version of .net installed on a system | |
.DESCRIPTION | |
Query the registry on a local or remote system to display the version of .net installed | |
.PARAMETER ComputerName | |
The name of the computer to run the query on | |
#> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function Get-SysInfo { | |
<# | |
.SYNOPSIS | |
Gether system inforamtion | |
.DESCRIPTION | |
Gather information such as the Computer Name, OS, Memory Information, Disk Information and CPU Information on a local or remote system. | |
.PARAMETER Computer | |
The local or remote system to gather information from | |
#> | |
[CmdletBinding()] |
NewerOlder