Skip to content

Instantly share code, notes, and snippets.

View fprimex's full-sized avatar

Brent Woodruff fprimex

View GitHub Profile
@fprimex
fprimex / vimrc
Created September 13, 2023 19:08
vimrc bits to send buffer to interpreters
"Send the current buffer's complete path to various interpreters
" \[letter] - non-interactive execution
" \[shift+letter] - execute, then run interactive shell
noremap <leader>p :!clear && python %:p \| less<CR><CR>
noremap <leader>P :!clear && python -i %:p<CR>
"noremap <leader>P :!clear && ipython -i %:p<CR><CR>
noremap <leader>a :new \| r !clear && awk -f %:p input.txt
@fprimex
fprimex / main.tf
Created December 1, 2022 02:09
Terraform configuration to create an instance that can be SSH'd into
# You'll need to set AWS environment variables or use a credentials file
# or take the usual command line approach to authenticate to AWS. If the
# aws-cli is working for you, then Terraform probably will too.
# Specify which provider plugins to get from the registry.
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
}
@fprimex
fprimex / git
Created July 12, 2022 17:58
a-Shell git shim
#!/bin/sh
wrapper_script_contents () {
cat << 'EOF'
#!/bin/sh
lg2 "$@"
EOF
}
cat << EOF

Troubleshooting winrm usually involves running the automation (Packer build / Terraform apply) until winrm fails, then inspecting the system to see where the failure is occurring. To do so please try the following steps.

If you have destroyed the infrastructure, please spin it back up with the automation tool (Packer or Terraform) and let the provisioner or build fail.

Establish that you have connectivity to the network that the VM is hosted on. This can be done by checking the IP address(es) and using a tool like route.

Open a Powershell session on your Windows workstation. The winrm connectivity tools are not available on other operating systems. You can skip some steps or try to substitute for them, but it's best to use a Windows workstation. A Windows 10 VM can be spun up using Vagrant, for example.

Establish that a raw connection can be made to the winrm service from your workstation. Run the command Test-netConnection -Port 5985, providing the IP address that Packer or Terraform is

#!/bin/sh
makejs_arg () {
if [ "$1" = true ] || [ "$1" = false ] || [ "$1" = null ]; then
# TODO: ints/numbers
# non-quoted value
echo "$1"
else
# quoted value
#strip |tostring, wrap in quotes
// Copyright © 2018 Brian Shumate <brian@brianshumate.com>
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice,
@fprimex
fprimex / external.sh
Created February 7, 2020 20:27
External data source for container inspection
#!/bin/sh
find . -name 'errored.tfstate' >&2
echo {}
exit 1
ssh-keygen -b 4096 -C me@gmail.com -f ~/.ssh/id_rsa -P ''

[<!---

echo foo #-->

echo foo

command

@fprimex
fprimex / manage_sn_tags.tf
Last active May 24, 2021 00:39
Use Terraform to track a subnet's tags and add your own.
# Put the tags you wish to have added to the subnet in this map variable.
variable "my_tags" {
type = "map"
default = {
my_first_key = "my first value"
my_second_key = "my second value"
}
}
# This reads the subnet and supplies all of the information about it, including