Skip to content

Instantly share code, notes, and snippets.

@markhallen
markhallen / sanitize_filename
Last active September 19, 2018 12:50
Remove characters that are invalid for file names
[System.IO.Path]::GetInvalidFileNameChars() | % {$text = $text.replace($_,'.')}
function Get-ArpPropertyByDisplayName {
<#
.SYNOPSIS
Get an application property from Programs and Features
.DESCRIPTION
Will accept a DisplayName value that will be searched for in Programs and Features and will
return the property.
.PARAMETER DisplayName
The DisplayName as it found in Programs and Features
.NOTES
class CommandString {
[String]$Command
CommandString([String]$Command)
{
$this.Command = $Command
}
[String] ToUninstall()
{
<#
.SYNOPSIS
Uninstall an application based on the exact name in Programs and Features
.DESCRIPTION
Will accept a DisplayNamee value that will be searched for in Programs and Features.
.PARAMETER DisplayName
The DisplayName as it found in Programs and Features
.PARAMETER LogPath
[Optional] Full path to the client logs folder
.PARAMETER LogName
def sumInRange(nums, queries)
sum = 0
startIndices = {}
endIndices = {}
m = 1000000007
queries.each do |q|
startIndices[q[0]].nil? ? startIndices[q[0]] = 1 : startIndices[q[0]] += 1
endIndices[q[1]].nil? ? endIndices[q[1]] = 1 : endIndices[q[1]] += 1
end
function Add-Numbers($a, $b) {
return $a + $b
}
Describe "Add-Numbers" {
$testCases = @(
@{ a = 2; b = 3; expectedResult = 5 }
@{ a = -2; b = -2; expectedResult = -4 }
@{ a = -2; b = 2; expectedResult = 0 }
@{ a = 'two'; b = 'three'; expectedResult = 'twothree' }