Skip to content

Instantly share code, notes, and snippets.

View brikis98's full-sized avatar

Yevgeniy Brikman brikis98

View GitHub Profile
@brikis98
brikis98 / terraform-environments-comparison.md
Last active May 30, 2023 23:52
How to manage multiple environments with Terraform comparison table
Workspaces Branches Terragrunt
Minimize code duplication ■■■■■ □□□□□ ■■■■□
See and navigate environments □□□□□ ■■■□□ ■■■■■
Different settings in each environment ■■■■■ ■■■■□ ■■■■■
Different backends for each environment □□□□□ ■■■■□ ■■■■■
Easy to manage multiple backends □□□□□ ■■■■□ ■■■■■
Different versions in each environment □□□□□ ■■□□□ ■■■■■
Share data between modules ■■□□□ ■■□□□ ■■■■■
Work with multiple modules concurrently □□□□□ □□□□□ ■■■■■
@brikis98
brikis98 / main.tf
Last active March 14, 2023 23:43
A hacky way to create a dynamic list of maps in Terraform
# The goal: create a list of maps of subnet mappings so we don't have to statically hard-code them in aws_lb
# https://www.terraform.io/docs/providers/aws/r/lb.html#subnet_mapping
locals {
# These represent dynamic data we fetch from somewhere, such as subnet IDs and EIPs from a VPC module
subnet_ids = ["subnet-1", "subnet-2", "subnet-3"]
eips = ["eip-1", "eip-2", "eip-3"]
}
# Here's the hack! The null_resource has a map called triggers that we can set to arbitrary values.
# We can also use count to create a list of null_resources. By accessing the triggers map inside of
@brikis98
brikis98 / classic-comment
Created May 3, 2014 08:23
One of the best comments from the StackOverflow discussion "What is the best comment in source code you have ever encountered?" http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered
//
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 42
//
@brikis98
brikis98 / BuilderNew.io
Created February 6, 2012 08:03
Seven Languages in Seven Weeks: Io, Day 3
OperatorTable addAssignOperator(":", "atParseHash")
Builder := Object clone do (
indent := ""
atParseHash := method(
key := call evalArgAt(0) asMutable removePrefix("\"") removeSuffix("\"")
value := call evalArgAt(1)
" #{key}=\"#{value}\"" interpolate
)
@brikis98
brikis98 / LinkedInProfile.rb
Created February 1, 2012 05:17
Seven Languages in Seven Weeks: Ruby, Day 3
class LinkedInProfile
SIMPLE_PROFILE_FIELDS = %w[id summary headline honors interests specialties industry first_name last_name public_profile_url picture_url associations]
SIMPLE_PROFILE_FIELDS.each do |field|
define_method(field.to_sym) do
@json[field]
end
end
def initialize(json)
@brikis98
brikis98 / BinaryModules.js
Created December 1, 2011 00:45
Node.js performance tips
// Use built in or binary modules
var crypto = require('crypto');
var hash = crypto.createHmac("sha1",key).update(signatureBase).digest("base64");

Keybase proof

I hereby claim:

  • I am brikis98 on github.
  • I am brikis98 (https://keybase.io/brikis98) on keybase.
  • I have a public key whose fingerprint is 244F 9804 C5B4 EBB7 BBC6 CFD8 EFA1 0183 0BB0 B4DE

To claim this, I am signing this object:

@brikis98
brikis98 / slice.prolog
Created February 15, 2012 10:37
Seven Languages in Seven Weeks: Prolog, Day 3
slice([Head | Tail], Slice, Size, Type, I) :-
slice_position(Type, Size, I, X, Y),
insert_into_slice(Head, Slice, X, Y),
I1 is I + 1,
slice(Tail, Slice, Size, Type, I1).
@brikis98
brikis98 / Cache.scala
Last active February 1, 2021 05:24
A quick hack to wrap Java's ConcurrentHashMap with a slightly more scala-friendly API. Scala's built-in ConcurrentMap does the same thing, but its getOrElseUpdate is NOT atomic. Hopefully, the getOrElseUpdate in the version below works correctly :)
package com.linkedin.playplugins.common.util
import Cache._
import play.api.Configuration
import java.util.concurrent.ConcurrentHashMap
import collection.JavaConverters._
/**
* A Scala wrapper for a Java's ConcurrentHashMap (CHM). Exposes the basic underlying methods of CHM and adds a
* getOrElseUpdate(key, value) method that lazily evaluates the value parameter only if the key is not already present
@brikis98
brikis98 / CheckBoxes.html
Created July 26, 2011 07:38
Proposed syntax for a Markdown extension that would support form elements
<label>Phones:</label>
<input type="checkbox" name="phones" id="Android" value="Android"/><label for="Android">Android</label>
<input type="checkbox" name="phones" id="iPhone" value="iPhone" checked="checked"/><label for="iPhone">iPhone</label>
<input type="checkbox" name="phones" id="Blackberry" value="Blackberry" checked="checked"/><label for="Blackberry">Blackberry</label>