Skip to content

Instantly share code, notes, and snippets.

Avatar

Yevgeniy Brikman brikis98

View GitHub Profile
@brikis98
brikis98 / main.tf
Last active Jan 19, 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 / LinkedInProfile.rb
Created Feb 1, 2012
Seven Languages in Seven Weeks: Ruby, Day 3
View LinkedInProfile.rb
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 Dec 1, 2011
Node.js performance tips
View BinaryModules.js
// Use built in or binary modules
var crypto = require('crypto');
var hash = crypto.createHmac("sha1",key).update(signatureBase).digest("base64");
@brikis98
brikis98 / CheckBoxes.html
Created Jul 26, 2011
Proposed syntax for a Markdown extension that would support form elements
View CheckBoxes.html
<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>
@brikis98
brikis98 / echo.js
Last active Feb 15, 2019
Echo server in socket.io
View echo.js
var io = require('socket.io').listen(80);
io.sockets.on('connection', function (socket) {
console.log("Someone just connected!");
// Echo back messages from the client
socket.on('message', function (message) {
console.log("Got message: " + message);
socket.emit('message', message);
});
@brikis98
brikis98 / gist:1024230
Created Jun 14, 2011
Java GC log explanation (Young Generation collections)
View gist:1024230
{Time since VM started, in seconds}: [GC {Time since VM started}: [{GC type}
Desired survivor size {size of one survivor space} bytes, new threshold {y} (max {x}) <- how many collections objects can stay in the young gen. More on this later
- age 1: {a} bytes, {a} total <- How many objects have survived one collection. Next collection, any surviving objects will appear in age 2
- age 2: {b} bytes, {a+b} total
: {pre-collection young gen[5] usage}K->{post-collection young gen usage}K({Total young gen size}K), {young gen time} secs]
{pre-collection heap size}K->{post-collection heap size}K({total heap size}K), {total collection time} secs]
@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 / gist:1024235
Created Jun 14, 2011
Java GC log explanation (CMS)
View gist:1024235
{Time since VM started, in seconds}: [GC
[1 CMS-initial-mark: {estimated old gen usage}K({total old gen size}K)] {estimated heap usage}K({total heap size}K), {pause time} secs]
{Time since VM started, in seconds}: [Rescan (parallel) , {pause time} secs]
{Time since VM started, in seconds}: [weak refs processing, {pause time} secs]
[1 CMS-remark: {old gen usage}K({total old gen size}K)] {heap usage}K({total heap size}K), {pause time} secs]
{Time since VM started, in seconds}: [CMS-concurrent-reset: 0.019/0.019 secs]
@brikis98
brikis98 / gist:1024233
Created Jun 14, 2011
Java GC log example (CMS)
View gist:1024233
294989.748: [GC
[1 CMS-initial-mark: 1782676K(2097152K)] 1784501K(3137664K), 0.0067714 secs]
295047.329: [Rescan (parallel) , 0.2497803 secs]
295047.579: [weak refs processing, 0.1272999 secs]
[1 CMS-remark: 1782929K(2097152K)] 2303079K(3137664K), 0.3816787 secs]
295049.065: [CMS-concurrent-reset: 0.019/0.019 secs]
@brikis98
brikis98 / gist:1024228
Created Jun 14, 2011
Java GC log example (Young Generation collections)
View gist:1024228
325209.429: [GC 325209.429: [ParNew
Desired survivor size 4128768 bytes, new threshold 2 (max 2)
- age 1: 1812544 bytes, 1812544 total
- age 2: 305568 bytes, 2118112 total
: 1034582K->2103K(1040512K), 0.0116910 secs]
2598263K->1565814K(3137664K), 0.0118312 secs]
You can’t perform that action at this time.