Skip to content

Instantly share code, notes, and snippets.

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

nicerobot nicerobot

🤖
☯️ ☮️ 🐶 🐾 👾 🎮 🎼 🎶 🕺 🎧 🌻 🌱 🏞 🌊 🌔 🌎
View GitHub Profile
@nicerobot
nicerobot / Makefile
Last active Feb 22, 2021 — forked from teivah/pointer_test.go
Notice that the issue is with returning a pointer, not with passing a pointer. Passing the pointer is indeed faster than passing the value, as expected. This discrepancy is likely the effect of [having to escape the pointer's data to the heap](https://www.ardanlabs.com/blog/2017/05/language-mechanics-on-escape-analysis.html).
View Makefile
bench:
go test -bench=. 2>&1 | tee bench.out
@nicerobot
nicerobot / README.md
Last active Nov 26, 2020
Simple demonstration of how nil pointers are not nil interfaces
@nicerobot
nicerobot / .inputrc
Last active Nov 17, 2020
For systems that aren't respecting special characters during blackward-kill-word
View .inputrc
# Respect extended word-boundaries
set bind-tty-special-chars off
Control-u: kill-whole-line
Control-w: backward-kill-word
# Enable Alt- <- -> for jumping by words
"\e[1;5D": backward-word
"\eOd": backward-word
"\e[1;5C": forward-word
"\eOc": forward-word
@nicerobot
nicerobot / delete-activity.js
Last active Nov 22, 2020
JavaScript to Delete all (most) Facebook Activity as of 20201103
View delete-activity.js
// 1. Navigate to your Activity Log
// 2. Paste this into the JavaScript Console
function clickDelete() {
document.querySelectorAll('[aria-label="Move to Trash"]')[0].click()
}
function clickMenu() {
document.querySelectorAll('[role="menuitem"]')[2].click();
setTimeout(clickDelete, 250);
}
@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"
}
}