Skip to content

Instantly share code, notes, and snippets.

View igoravl's full-sized avatar

Igor Abade igoravl

View GitHub Profile
@igoravl
igoravl / GetTerminalWindowHandle.cs
Created July 8, 2024 03:04
GetTerminalWindowHandle.cs
private static IntPtr GetTerminalWindowHandle()
{
try
{
var currentProcess = Process.GetCurrentProcess();
do
{
var parentProcess = GetParentProcess(currentProcess.Handle);
@igoravl
igoravl / pre-commit
Created June 17, 2024 22:36
Pre-commit hook to require UTF-8 BOM encoding in PowerShell scripts
#!/bin/bash
# Função para verificar BOM UTF-8
check_bom() {
local file=$1
if [[ $(head -c 3 "$file") == $'\xEF\xBB\xBF' ]]; then
return 0
else
return 1
fi
@igoravl
igoravl / Script.ps1
Last active August 25, 2023 13:40
Ordena arquivos COBOL do Mercantil
class MBStringComparer : System.Collections.IComparer {
[int] Compare([object] $x, [object] $y) {
if($x.Contains('/'))
{
$x = $x.Substring($x.LastIndexOf('/') + 1)
}
if($y.Contains('/'))
{
@igoravl
igoravl / create-terraform-storage-account.bicep
Last active May 4, 2023 02:15
Create a storage account for subsequent Terraform usage
@description('Specifies the name of the Azure Storage account.')
param storageAccountName string
@description('Specifies the name of the blob container.')
param containerName string = 'tfstate'
@description('Specifies the location in which the Azure Storage resources should be deployed.')
param location string = resourceGroup().location
@description('Specifies the SKU for the Storage Account.')
@igoravl
igoravl / Set-TfsGitRepositorySetting.ps1
Last active February 9, 2023 06:05
Modifies the settings of a Git repository in Azure DevOps Services, using cmdlets from TfsCmdlets
#requires -Modules TfsCmdlets
<#
.SYNOPSIS
Modifies the settings of a Git repository.
#>
Function Set-TfsGitRepositorySetting {
[CmdletBinding(SupportsShouldProcess = $true)]
Param (
# Specifies the name of the setting to modify.
@igoravl
igoravl / Get-TfsGitRepositorySetting.ps1
Created February 9, 2023 05:21
Gets the settings of a Git repository in Azure DevOps Services, using cmdlets from TfsCmdlets
<#
.SYNOPSIS
Gets the settings of a Git repository.
#>
Function Get-TfsGitRepositorySetting {
[CmdletBinding()]
Param (
# Specifies the name of the setting to retrieve. If not specified, all settings are returned.
[Parameter(Position = 0)]
[SupportsWildcards()]
@igoravl
igoravl / Post-Message-to-AzDO-Webhook.ps1
Created April 3, 2021 00:36
Post authenticated message to Azure DevOps Incoming Webhook
Param
(
# URL to the Azure DevOps incoming webhook endpoint. Expected format is
# https://dev.azure.com/<org>/_apis/public/distributedtask/webhooks/<svc-trig>/?api-version=6.0-preview.
[uri]
$Url,
# Shared secret used to sign the JSON payload. Must be the same value supplied during
# the creation of the Incoming Webhook service connection
[string]
@igoravl
igoravl / InstallDeploymentAgent.ps1
Last active May 4, 2020 19:29
Install Azure DevOps Deployment Agent (off-line)
param (
[string]
$AgentZip = 'agent.zip',
[string]
$AgentDirectory = "$($env:SystemDrive\Agent)",
[Parameter(Mandatory=$true)]
[string]
$DeploymentPoolName,
@igoravl
igoravl / azure-pipelines.yml
Created April 29, 2020 19:55
Whitelist build agent on demand when pushing to ACR with firewall enabled
trigger:
- master
resources:
- repo: self
variables:
azureSubscription: '<azure-subscription>'
dockerRegistryServiceConnection: '<service-connection>'
imageRepository: '<repository-name>'
@igoravl
igoravl / Get-IfNull.ps1
Created June 8, 2018 20:12
Function ?? (IfNull)
Function Get-IfNull($Value, $DefaultValue)
{
if($Value -eq $null)
{
return $DefaultValue
}
return $Value
}
Set-Alias '??' Get-IfNull