This file contains hidden or 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
| import sys, getopt, os, random, string | |
| def generate_random_string(character_space: str, size_in_bytes: int) -> str: | |
| return "".join([random.choice(character_space) for i in range(size_in_bytes)]) | |
| def generate_random_string_file(filepath: str, size_in_bytes: int) -> None: | |
| """ | |
| Generate big random letters/alphabets to a file. |
This file contains hidden or 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
| <# | |
| .DESCRIPTION | |
| Powershell script to continuously ping a target host. | |
| If logPath is specified, will output rolling logs based off size parameter. | |
| .OUTPUTS | |
| Set-Acl result | |
| .EXAMPLE | |
| PS> .\PingUntil.ps1 'DateTime_to_Stop' 'your_target_host' 'delayInMs' 'logPath' 'maxFileSizeInMB' | |
| or | |
| PS> .\PingUntil.ps1 (Get-Date).AddSeconds(10) 'www.google.com' 100 'C:\somedir\logs\ping.log' 100 |
This file contains hidden or 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
| <# | |
| .DESCRIPTION | |
| Powershell functions to Flatten JSON to the expected Key/Value format used by Azure. | |
| .OUTPUTS | |
| HashTable that contains the flattened json properties and values. | |
| .EXAMPLE USAGE | |
| . /Flatten-Json.ps1 # Source the file to load the functions. | |
| $json = Get-Content '.\appSettings.json' -Raw | ConvertFrom-Json | |
| Flatten-Json $json |
This file contains hidden or 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
| <# | |
| .DESCRIPTION | |
| Powershell script to add permissions to X509 certificate private key for specific user. | |
| .OUTPUTS | |
| Set-Acl result | |
| .EXAMPLE | |
| PS> .\Set-AclForCertificate.ps1 'your_cert_thumbprint' 'domain\username' 'Read' | |
| or | |
| PS> .\Set-AclForCertificate.ps1 'your_cert_thumbprint' 'domain\username' 'FullControl' | |
This file contains hidden or 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
| $bits_in_a_byte = 8 | |
| $base2 = 2 | |
| $base16 = 16 | |
| Function ConvertTo-HexFromByteArray | |
| { | |
| param( | |
| [parameter(Mandatory=$true)] | |
| [Byte[]] | |
| $bytes |
This file contains hidden or 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
| <# | |
| .DESCRIPTION | |
| Powershell script to diff two files with SHA256 hash. | |
| .OUTPUTS | |
| System.String. Add-Extension returns a string with the extension or file name. | |
| .EXAMPLE | |
| PS> .\AreSameFile.ps1 .\deployed.json .\expected_different.json | |
| #> |
This file contains hidden or 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
| ### Requires openssl (https://www.openssl.org/). | |
| ### Usage: | |
| ### .\extract_rsa_privatekey.ps1 .\YOUR_CERTIFICATE.pfx (ConvertTo-SecureString "YOUR_STRONG_PASSWORD" -AsPlainText -Force) | |
| param( | |
| [Parameter(Mandatory=$true)][string] $certificatePfxPath, | |
| [SecureString] $password, | |
| [string] $pathToOpenSsl = '.' | |
| ) |
This file contains hidden or 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
| -- Setup | |
| CREATE TABLE Test_INT ([Id] [int] NOT NULL primary key clustered, | |
| [col1] [int] NULL, | |
| [col2] [int] NULL, | |
| [col3] [varchar](50) NULL); | |
| CREATE TABLE Test_GUID ([Id] [uniqueidentifier] NOT NULL primary key clustered, | |
| [col1] [int] NULL, | |
| [col2] [int] NULL, | |
| [col3] [varchar](50) NULL); |
This file contains hidden or 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
| # .NET Core Function App to Windows on Azure | |
| # Build a .NET Core function app and deploy it to Azure as a Windows function App. | |
| # Add steps that analyze code, save build artifacts, deploy, and more: | |
| # https://docs.microsoft.com/en-us/azure/devops/pipelines/languages/dotnet-core | |
| name: $(Date:yyyyMMdd)$(Rev:.r)-$(SourceBranchName) | |
| trigger: | |
| - master | |
| - develop |
This file contains hidden or 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
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading; | |
| using System.Threading.Tasks; | |
| namespace Misc.Engines | |
| { | |
| /// <summary> | |
| /// Meant for CPU bound operations. Long running I/O operations should be run |