Skip to content

Instantly share code, notes, and snippets.

View reegnz's full-sized avatar

Zoltán Reegn reegnz

View GitHub Profile
@reegnz
reegnz / timestamp.sh
Created May 10, 2018 14:58 — forked from johnmurch/timestamp.sh
Timestamp output options
#! /bin/bash
# An overly obvious reference for most commonly requested bash timestamps
# Now all you Mac fags can stop pestering me.
cat << EOD
Format/result | Command | Output
------------------------------+----------------------------+------------------------------
YY-MM-DD_hh:mm:ss | date +%F_%T | $(date +%F_%T)
YYMMDD_hhmmss | date +%Y%m%d_%H%M%S | $(date +%Y%m%d_%H%M%S)
@reegnz
reegnz / keybase.md
Created November 7, 2019 13:18
keybase.md

Keybase proof

I hereby claim:

  • I am reegnz on github.
  • I am reegnz (https://keybase.io/reegnz) on keybase.
  • I have a public key ASDBlhbcI0bttXoW_f8SOg86X51luqkFqD6uoNojYPHpgwo

To claim this, I am signing this object:

@reegnz
reegnz / README.md
Last active January 22, 2020 14:21
Emulating Terraform Module for_each

Emulating Terraform Module for_each

tl;dr

We want to create n resources, and 1:m relationships to each of these resources. In the end we expect n + n*m resources to be created.

Running the example:

@reegnz
reegnz / README.md
Last active October 15, 2024 20:10
Implementing a jq REPL with fzf

Implementing a jq REPL with fzf

Update: I created jq-zsh-plugin that does this.

One of my favourite tools of my trade is jq. It essentially enables you to process json streams with the same power that sed, awk and grep provide you with for editing line-based formats (csv, tsv, etc.).

Another one of my favourite tools is fzf.

@reegnz
reegnz / README.md
Created February 26, 2020 22:42
Using sshuttle to tunnel into kubernetes

Download kuttle:

wget https://raw.githubusercontent.com/kayrus/kuttle/master/kuttle
chmod +x kuttle
mv kuttle ~/bin

create tunnel:

@reegnz
reegnz / README.md
Last active October 25, 2024 07:39
Using terraform for_each and toset instead of count

Using terraform for_each and toset instead of count

Using terraform count and the pain of working with it

If you're using terraform extensively you probably ran into an issue like this.

This is a synthetic example but I still hope the problem is recognizable as something that also happens out in the wild.

First, you have a list variable (in terraform.tfvars)

@reegnz
reegnz / README.md
Last active June 5, 2020 18:16
Terraform interface design: list vs map

Terraform interface design: lists vs maps

The core problem

A lot of us have encountered this before: I need to create multiple instances of a resource, and we don't want to shoot ourselves in the foot with count, so we want to use for_each.

We define our input as a map of object, each key representing a resource instance. The key of the map will be the key of the resource in for_each.

@reegnz
reegnz / Dockerfile.eat-my-data
Created June 12, 2020 11:46
Docker image build speedup tricks
FROM ubuntu:focal
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y eatmydata \
&& eatmydata apt-get install -y \
openjdk-11-jdk awscli azure-cli # just some big packages to notice the speedup \
&& rm -rf /var/lib/apt/lists/*
@reegnz
reegnz / README.md
Created June 19, 2020 10:39
CamelCase <--> snake_case conversion in jq

CamelCase <--> snake_case conversion with jq

tl;dr

I provide you with 3 jq lib functions that will help you in converting between snake_case and CamelCase.

The interface

I want to change keys in my json from camelcase to snake_case.

@reegnz
reegnz / README.md
Last active October 22, 2024 13:55
The Terraform group_by you've been missing

The Terraform group_by you've been missing

I'm playing around a lot nowadays with Terraform 0.13 and I found a really interesting feature and that's the ... symbol (also called an ellipsis) to be used with for expressions.

The operator can be used for group_by operations.

Example

We have a list of entries. The list contains employee/manager/project triplets.