Skip to content

Instantly share code, notes, and snippets.

View magnetikonline's full-sized avatar
💡
I have an idea!

Peter Mescalchin magnetikonline

💡
I have an idea!
View GitHub Profile

Microsoft DNS server list all records

PowerShell script to query a given Microsoft DNS server for all available primary zones and list all records defined within of types:

  • A
  • AAAA
  • CNAME
  • MX
  • NS
  • PTR
  • TXT
@magnetikonline
magnetikonline / README.md
Last active February 14, 2023 23:42
AWS clone VPC route table and routes.

AWS clone VPC route table and routes

Python script to clone an existing VPC route table. Script output is a series of AWS CLI calls to create the route table and assign routes.

Update AWS_TARGET_REGION and SOURCE_ROUTE_TABLE_ID to suit.

Note: does not currently support NAT Gateways routes due to Boto 2 API limitation.

Example

@magnetikonline
magnetikonline / example.ps1
Created December 15, 2015 06:03
Creating a PowerShell PSCredential object with username/password using secure/encrypted strings.
Set-StrictMode -Version Latest
$PASSWORD = "mypassword"
# create secure string from plain-text string
$secureString = ConvertTo-SecureString -AsPlainText -Force -String $PASSWORD
Write-Host "Secure string:",$secureString
Write-Host
@magnetikonline
magnetikonline / example.ps1
Last active February 13, 2021 01:09
PowerShell push message to Slack incoming webhook.
Set-StrictMode -Version Latest
$payload = @{
"channel" = "#my-channel"
"icon_emoji" = ":bomb:"
"text" = "This is my message. Hello there!"
"username" = "Mr. Robot"
}
Invoke-WebRequest `
@magnetikonline
magnetikonline / randomchars.sh
Last active October 21, 2015 09:48
Generate some random characters in Bash.
#!/bin/bash
cat /dev/urandom | tr -dc A-Za-z0-9- | head -c 512
@magnetikonline
magnetikonline / README.md
Last active December 7, 2023 09:18
Semver package range definitions cheatsheet.
@magnetikonline
magnetikonline / README.md
Last active July 23, 2024 00:36
Fetch current Git commit SHA-1.

Fetch current Git commit SHA-1

Method 1

From within Git repository:

$ cd /path/to/git/repo
$ git rev-parse HEAD
c8f882b484eeb71068539fd02f04c5c2eada1c02
@magnetikonline
magnetikonline / README.md
Last active October 17, 2025 03:31
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set, value is returned.

Combine with a : no-op to discard/ignore return value.
${variable="value"}
: ${variable="value"}