Skip to content

Instantly share code, notes, and snippets.

View larribas's full-sized avatar

Lorenzo Arribas larribas

View GitHub Profile
@larribas
larribas / README.md
Created January 8, 2021 11:06
Kubernetes Cost Monitoring Dashboard (AWS EKS + DataDog + Terraform)

This gist was created to be referenced by this article.

It creates a DataDog dashboard that provides cost insights, given:

  • A specific AWS budget
  • The name of the kubernetes cluster

It should be fairly easy to adapt the dashboard to any other cloud platform by replacing the aws.billing metric by a similar one.

@larribas
larribas / tmux.md
Last active January 5, 2022 20:04
Tmux Cheat Sheet

Tmux Cheat Sheet

Sessions

Start a new session tmux || tmux new -s name || :new

Attach to last session tmux a || tmux a -t name

data "template_file" "demo" {
template = "${file("some_template_file.txt")}"
vars = {
IMAGE_NAME = "${var.image-name}"
}
}
resource "opennebula_template" "demo" {
name = "terraform-demo"
description = "${data.template_file.demo.rendered}"
Serialization
=============
json 10 102188152 ns/op 37040009 B/op 60000 allocs/op
msgpack 100 14042713 ns/op 11520000 B/op 10000 allocs/op
msgpack + JSONSChema 1 2751294087 ns/op 533524400 B/op 5790984 allocs/op
avro 10 110052083 ns/op 40160011 B/op 610000 allocs/op
protobufs 50 30927919 ns/op 19600000 B/op 70000 allocs/op
thrift 50 24031566 ns/op 10240000 B/op 10000 allocs/op
Deserialization
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Event",
"description": "Shared schema for domain events",
"properties": {
"data": {
"description": "Arbitrary data detailing the event",
"type": "object"
},
"id": {
@larribas
larribas / export_rake_stats_to_csv.rb
Last active February 25, 2016 14:13
Generate rake stats in a CSV format, fit for easy manipulation: `rake stats | bin/export_rake_stats_to_csv.rb >> tmp/rake_stats.csv`
#!/usr/bin/env ruby
# Read stats from input and get an array of arrays (a valid csv representation)
stats = STDIN.read.split("\n")[1..-2].reject { |line| line.start_with? '+' }.map { |line| line.split('|')[1..-1] }
# Write csv to output
require 'csv'
csv_string = CSV.generate do |csv|
stats.each { |row| csv << row }
end
require 'dry-validation'
class Schema < Dry::Validation::Schema
group :node do
key(:name) { |name| name.str? and name.filled? }
key(:children) do |children|
children.array? do
children.each { |child| child.group?(:node) }