Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
☯️ ☮️ 🐶 🐾 👾 🎮 🎼 🎶 🕺 🎧 🌻 🌱 🏞 🌊 🌔 🌎

nicerobot nicerobot

🤖
☯️ ☮️ 🐶 🐾 👾 🎮 🎼 🎶 🕺 🎧 🌻 🌱 🏞 🌊 🌔 🌎
View GitHub Profile
@nicerobot
nicerobot / Makefile
Created Aug 21, 2020
A Makefile for Terraform
View Makefile
.PRECIOUS: output.json terraform.tfplan terraform.tfstate
output.json: terraform.tfstate
terraform output -no-color -json | tee $@
plan: terraform.tfplan
terraform.tfplan:
terraform plan -out $@
View kubectl-extras
#!/bin/zsh
# expects https://github.com/ahmetb/kubectl-aliases
# implements lots of https://kubernetes.io/docs/reference/kubectl/cheatsheet/
alias kgpos='kgpo --sort-by=.metadata.creationTimestamp'
alias kgpoy='kgpo -o yaml'
### config view
alias kcv='k config'
View _shellcheck.md
  • SC1000 $ is not used specially and should therefore be escaped.
  • SC1001 This \o will be a regular 'o' in this context.
  • SC1003 Want to escape a single quote? echo 'This is how it'\''s done'.
  • SC1004 This backslash+linefeed is literal. Break outside single quotes if you just want to break the line.
  • SC1007 Remove space after = if trying to assign a value (or for empty string, use var='' ... ).
  • SC1008 This shebang was unrecognized. ShellCheck only supports sh/bash/dash/ksh. Add a 'shell' directive to specify.
  • SC1009 The mentioned parser error was in ...
  • SC1010 Use semicolo
View input-validation-example.tf
### Test scenario for "can"
variable "word-length" {
validation {
# The condition here identifies if the integer if greater than 1
condition = var.word-length > 1
error_message = "The variable is not greater than 5. Word length has to be at a minimum > 1."
}
}
View variable-input.tf
variable "os" {
default = "linux"
validation {
# The condition here identifies if the variable contains the string "linxu" OR "windows".
condition = can(regex("linux|windows", var.os))
error_message = "ERROR: Operating System must be Windows OR Linux."
}
}
@nicerobot
nicerobot / try.tf
Created May 29, 2020 — forked from karl-cardenas-coding/try.tf
Example of using try in Terraform
View try.tf
# Try example
data "http" "primary-server" {
url = "https://ip-ranges.amazonaws.com/ip-ranges.json"
# Optional request headers
request_headers = {
Accept = "application/json"
}
}
@nicerobot
nicerobot / chrome-laiuncher.sh
Created May 25, 2020
Open URLs based on contents of a Chrome bookmarks-folder
View chrome-laiuncher.sh
#!/bin/bash
folder="${1:-open}"
profile="${2:-Default}"
jq -r \
'.roots.bookmark_bar.children[] | select(.name == "'"${folder}"'") .children[].url' \
"${HOME}/Library/Application Support/Google/Chrome/${profile}/Bookmarks" \
| while read url; do
open "${url}"
done
@nicerobot
nicerobot / go-shebang-story.md
Created Apr 26, 2020 — forked from posener/go-shebang-story.md
Story: Writing Scripts with Go
View go-shebang-story.md

Story: Writing Scripts with Go

This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.

Why Go is good for scripting?

While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.

@nicerobot
nicerobot / perm.go
Created Nov 17, 2019
Go string-permutation generator (not ideal since it doesn't nicely handle the channel and goroutine)
View perm.go
func PermutationGenerator(in string) chan string {
r := make(chan string, 0)
var perm func([]rune, int)
perm = func(a []rune, i int) {
if i > len(a) {
r <- string(a)
return
}
perm(a, i+1)
for j := i + 1; j < len(a); j++ {
@nicerobot
nicerobot / render.sh
Last active Oct 5, 2019
Python one-liner Jinja2 Template renderer
View render.sh
python -c 'import os, sys, jinja2; print(jinja2.Template(sys.stdin.read()).render(**os.environ))'
You can’t perform that action at this time.