Skip to content

Instantly share code, notes, and snippets.

Avatar

Yevgeniy Brikman brikis98

View GitHub Profile
View keybase.md

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 / main.tf
Last active Dec 13, 2021
A hacky way to create a dynamic list of maps in Terraform
View main.tf
# 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 / script.js
Last active Mar 7, 2018
Get course summary from Teachable
View script.js
var result = $('.section-item .item').get().reduce(function(total, item) {
var text = $(item).text().split("\n").join(" ");
var matches = /.+\((\d):(\d\d)\)/g.exec(text);
var minutes = parseInt(matches[1]);
var seconds = parseInt(matches[2]);
var totalMin = total[0] + minutes;
var totalSec = total[1] + seconds;
@brikis98
brikis98 / main.tf
Last active Oct 12, 2016
Conditionals with inline attributes in Terraform
View main.tf
resource "aws_dynamodb_table" "one_attribute" {
count = "${replace(replace(var.num_attributes, "1", "1"), "/^[^1]$/", 0)}"
name = "${var.name}"
attribute {
name = "${var.first_attribute_name}"
type = "${var.first_attribute_type}"
}
}
View keybase.md

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 2543 515A DE47 7C73 3388 F250 5B46 DF05 5BAD 069A

To claim this, I am signing this object:

View MyEnvironment.scala
class MyEnvironment extends Environment[MyUser, CookieAuthenticator] {
override val identityService: IdentityService[MyUser] = new MyIdentityService()
override val authenticatorService: AuthenticatorService[CookieAuthenticator] = new CookieAuthenticatorService(
settings = CookieAuthenticatorSettings(),
dao = None,
fingerprintGenerator = new DefaultFingerprintGenerator(),
idGenerator = new SecureRandomIDGenerator(),
clock = Clock()
)
@brikis98
brikis98 / gist:4c7a7432f70699d88841
Created Jun 7, 2015
bashprof output on running a sourced function using the run method in bats
View gist:4c7a7432f70699d88841
brikis98-pro:docker-osx-dev brikis98$ ../bashprof/bin/bashprof bats test/docker-osx-dev.bats
✓ configure_paths_to_sync with non-existent docker-compose file results in syncing the current directory
1 test, 0 failures
Statement breakdown
===================
Total µs Total % Count Statement
123368 15.4% 306 [[ "$line" =~ $pattern ]]
@brikis98
brikis98 / gist:cc86ff010ac2838a00fe
Created Jun 7, 2015
bashprof output on running a sourced function directly in bats
View gist:cc86ff010ac2838a00fe
brikis98-pro:docker-osx-dev brikis98$ ../bashprof/bin/bashprof bats test/docker-osx-dev.bats
✓ configure_paths_to_sync with non-existent docker-compose file results in syncing the current directory
1 test, 0 failures
Statement breakdown
===================
Total µs Total % Count Statement
814081 51.5% 3 IFS= read -r line
@brikis98
brikis98 / gist:e71d6c736158080968f5
Created Apr 16, 2015
Getting a sorted list of tags in Jekyll with no plugins
View gist:e71d6c736158080968f5
{% capture tags %}{% for tag in site.tags %}{{ tag[0] }}|{% endfor %}{% endcapture %}
{% assign sortedtags = tags | split:'|' | sort %}
{% for tag in sortedtags %}
<a name="{{ tag }}"></a>
<h2>{{ tag }}</h2>
<ul>
{% for post in site.tags[tag] %}
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}
@brikis98
brikis98 / CacheFilter.scala
Last active Aug 4, 2017
An outline of how to de-dupe remote service calls in Play.
View CacheFilter.scala
// Put this filter early in your filter chain so it can initialize and clean up
// the cache
object CacheFilter extends Filter {
def apply(next: RequestHeader => Future[Result])(request: RequestHeader): Future[Result] = {
def init = RestClient.initCacheForRequest(request)
def cleanup = RestClient.cleanupCacheForRequest(request)
// You have to be very careful with error handling to garauntee the cache gets cleaned
// up, or you'll have a memory leak.