Skip to content

Instantly share code, notes, and snippets.

View criscunhasantos's full-sized avatar

criscunhasantos

View GitHub Profile
@criscunhasantos
criscunhasantos / transfer_ssm_file.sh
Created October 29, 2024 13:32 — forked from lukeplausin/transfer_ssm_file.sh
Transfer a file to EC2 SSM instance without using S3 (SSM only)
# This script will explain how to transfer a file to EC2 using SSM ONLY!
# You will need to have permission to run SSM commands on the target machine and have sudo access as well
# Infos
INSTANCE_ID=i-1234567890
FILE_NAME=the_file.tar.gz
# Step 1: Run command on machine to install netcat and dump from port to filename
# < Start session
@criscunhasantos
criscunhasantos / WSL2-recovery.md
Created September 30, 2024 00:28 — forked from PatrickLang/WSL2-recovery.md
How to restore a WSL2 distribution and your data after a Windows Reset

I had some bad driver issues that led to me need to 'reset' Windows from the local recovery partition. This recovered my machine and got it bootable again. Afterwards, WSL2 wasn't installed, so I tried to install it. It rebooted, etc, then fetched Ubuntu 22.04 from the Microsoft Store as usual. However, instead of keeping my previous WSL2 content it started a new user:

Ubuntu is already installed.
Launching Ubuntu...
Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
@criscunhasantos
criscunhasantos / ami-clean.sh
Created December 26, 2023 20:09 — forked from jdowning/ami-clean.sh
Script to clean up Ubuntu EC2 instance before packaging as an AMI
#!/bin/bash
# This script cleans up your EC2 instance before baking a new AMI.
# Run the following command in a root shell:
#
# bash <(curl -s https://gist.github.com/justindowning/5921369/raw/ami-clean.sh)
function print_green {
echo -e "\e[32m${1}\e[0m"
}
aws ec2 describe-vpn-connections --query 'VpnConnections[*].{Nome:Tags[?Key==`Name`]|[0].Value,Rotas:Routes[*].DestinationCidrBlock}' --output yaml
<#
.Synopsis
Converts plain text IIS logs into a ps Object
.DESCRIPTION
Converts plain text IIS logs into a ps Object
.EXAMPLE
Get-ChildItem '<path to logs>\*.log' | Convert-IISLogsToObject | Sort-Object c-ip -Unique
.EXAMPLE
Convert-IISLogsToObject -path (Get-ChildItem '<path to logs>\*log') | Where-Object { $_.'cs-username' -eq '<userName>' } | Sort-Object c-ip -Unique
.NOTES
@criscunhasantos
criscunhasantos / git_cheat_sheet.sh
Last active June 28, 2022 11:48
Git Cheat Sheet
git pull origin develop
git add .
git commit -m "UPDATED vpn"
git push origin develop
git tag
git checkout v1.2.0
code .
git add .
@criscunhasantos
criscunhasantos / ThrowTerminatingError.ps1
Last active June 28, 2023 17:01
PowerShell Cheat Sheet
try
{
1/(1-1)
}
catch
{
$PSCmdlet.ThrowTerminatingError($PSItem)
}
$RG = ''
$VMNAME = ''
$vm = Get-AzVM -ResourceGroup $RG -Name $VMNAME
$vm.LicenseType = "Windows_Server"
Update-AzVM -ResourceGroupName $RG -VM $vm
@criscunhasantos
criscunhasantos / show-kv-secret-value.sh
Created April 20, 2022 17:15
Show KeyVault secret value
VAULT="akv-xxxxx"
NAME="mysecret"
az keyvault secret show --name $NAME --vault-name $VAULT
@criscunhasantos
criscunhasantos / speed_test.sh
Created April 1, 2022 17:10
Internet speed test on Linux
curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -