Skip to content

Instantly share code, notes, and snippets.

View ImIOImI's full-sized avatar

Troy Knapp ImIOImI

  • SumerSports
  • OKC
View GitHub Profile
@ImIOImI
ImIOImI / lf2crlf
Created June 28, 2016 19:08
This is a bash script I ran on cygwin that finds all the php files in a directory tree and converts them from lf to crlf
#!/bin/bash
FOLDER=$(pwd)
arrayname=( $(find $FOLDER -name '*.php') )
fixarray=()
for element in $(seq 0 $((${#arrayname[@]} - 1)))
do
filename=${arrayname[$element]};
fileOut="$(file $filename)";
if [[ $fileOut != *"CRLF"* ]];
@ImIOImI
ImIOImI / aws-profile-switch.ps1
Created July 29, 2019 20:40
Simple Powershell script for switching a named profile into the default profile
Param(
[Parameter(Mandatory = $false)][string]$profile = ""
)
if ($profile -eq "")
{
$profile = Read-Host -Prompt "What profile should we switch to?"
}
Write-Host "Using profile $profile" -ForegroundColor Green
@ImIOImI
ImIOImI / simple-map.tf
Last active March 30, 2020 22:20
Simple Terraform 12 Map Example
####Simple Map example####
output "out" {
value = var.project-map[var.environment]
}
variable "environment" {
default = "stage"
}
variable "project-map" {
@ImIOImI
ImIOImI / Microsoft.PowerShell_profile.ps1
Created May 8, 2020 14:29
Add Terraform workspace to command prompt when using Posh-Git
$GitPromptSettings.DefaultPromptPrefix.Text = '$(if(Test-Path -Path ".terraform"){terraform workspace show}) '
$GitPromptSettings.DefaultPromptPrefix.ForegroundColor = [ConsoleColor]::Magenta
@ImIOImI
ImIOImI / add2bin.ps1
Last active July 15, 2020 02:20
Simple script to add a symbolic link into a user's bin folder
param (
[Parameter(Mandatory=$true)][string]$path
)
$file = Split-Path $path -leaf
$file = "~/bin/$file"
if(Test-Path $file){
Write-Host "$file already exists" -ForegroundColor Red
exit
}
@ImIOImI
ImIOImI / add2path.ps1
Created July 29, 2020 22:21
Adds a given folder to the windows path.
#Requires -RunAsAdministrator
param (
[Parameter(Mandatory=$true)][string]$folder
)
if((Get-Item $folder) -is [System.IO.DirectoryInfo])
{
$folder = Resolve-Path $folder
}
@ImIOImI
ImIOImI / terraform-delete-state.ps1
Created March 23, 2021 01:29
Delete Terraform State By Simple Pattern
param (
[Parameter(Mandatory=$true)][string]$Pattern = "*"
)
$currentState = terraform state list
foreach($line in $currentState) {
if ($line -like $Pattern) {
terraform state rm $line
}
}
@ImIOImI
ImIOImI / route53-ingress.tf
Last active March 23, 2021 17:28
Get the address for an NGINX ingress controller's load balancer and create a route53 address for it.
resource "local_file" "get-ingress" {
content = <<EOF
$info=kubectl describe svc ingress-nginx-controller -n ingress-nginx
$string = $false
foreach($line in $info) {
if ($line -like "LoadBalancer Ingress:*") {
$string = $line -replace "LoadBalancer Ingress:", ""
$string=$string.trim()
break
@ImIOImI
ImIOImI / cloudshell-init.sh
Last active May 9, 2024 15:46
AWS Cloudshell init script
#!/bin/sh
defaultUser="ImIOImI"
defaultEmail="troy.knapp@gmail.com"
rsaKeyFile=/home/cloudshell-user/.ssh/id_rsa
if [ ! -f "$rsaKeyFile" ]; then
#add rsa key
ssh-keygen -b 2048 -t rsa -f "$rsaKeyFile" -q -N ""
echo "Please copy the following into your GitHub profile here: https://github.com/settings/ssh/new
"
@ImIOImI
ImIOImI / storage-endpoint.tf
Created December 8, 2021 15:45
Azure Storage Account With Private Endpoint
terraform {
required_providers {
}
required_version = "~> 1.0.5"
}
provider "azurerm" {
subscription_id = var.us-dev-subscription-id
alias = "us"