Skip to content

Instantly share code, notes, and snippets.

View nicerobot's full-sized avatar
🤖
☯️ ☮️ 🐶 🐾 👾 🎮 🎼 🎶 🕺 🎧 🌻 🌱 🏞 🌊 🌔 🌎

nicerobot nicerobot

🤖
☯️ ☮️ 🐶 🐾 👾 🎮 🎼 🎶 🕺 🎧 🌻 🌱 🏞 🌊 🌔 🌎
View GitHub Profile
@nicerobot
nicerobot / Makefile
Last active February 22, 2021 13:02 — 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).
bench:
go test -bench=. 2>&1 | tee bench.out
### 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."
}
}
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 15:28 — forked from karl-cardenas-coding/try.tf
Example of using try in Terraform
# 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 / go-shebang-story.md
Created April 26, 2020 17:25 — forked from posener/go-shebang-story.md
Story: Writing Scripts with Go

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 / locks.sql
Created April 21, 2019 20:32 — forked from varunchitale/locks.sql
Get a list of queries and their details that hold locks over relations in a dB.
SELECT
blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process,
blocked_activity.application_name AS blocked_application,
blocking_activity.application_name AS blocking_application
FROM pg_catalog.pg_locks blocked_locks
@nicerobot
nicerobot / delete_duplicates.sql
Created April 21, 2019 20:32 — forked from varunchitale/delete_duplicates.sql
Efficiently delete duplicates rows from a table with a set of specific constraints.
DELETE FROM <table> a USING (
SELECT MIN(ctid) as ctid, var1, var2
FROM <same_table> b
GROUP BY 2,3 HAVING COUNT(*) > 1
) b
WHERE a.var1 = b.var1
and a.var2 = b.var2
AND a.ctid <> b.ctid
@nicerobot
nicerobot / .docker_aliases
Created December 26, 2018 03:17 — forked from cjus/.docker_aliases
Docker aliases
#!/bin/sh
alias dm='docker-machine'
alias dmx='docker-machine ssh'
alias dk='docker'
alias dki='docker images'
alias dks='docker service'
alias dkrm='docker rm'
alias dkl='docker logs'
alias dklf='docker logs -f'
@nicerobot
nicerobot / .gitignore
Created October 27, 2018 19:14 — forked from pepasflo/.gitignore
Scripts for encrypting / decrypting secrets (to prevent them from being accidentally checked into git)
secrets/
---
apiVersion: v1
kind: Service
metadata:
labels:
service: ambassador
name: ambassador
spec:
type: LoadBalancer
ports: