Skip to content

Instantly share code, notes, and snippets.

Avatar

M. Casqueira 20k-ultra

View GitHub Profile
View breadth_first_search.js
class Node {
constructor(val) {
this.data = val;
this.left = null;
this.right = null;
}
getChildren() {
let children = []
if (this.left) {
@20k-ultra
20k-ultra / depth_first_search.js
Last active February 29, 2020 03:53
Depth First search algorithm in JS
View depth_first_search.js
class Node {
constructor(val) {
this.data = val;
this.left = null;
this.right = null;
}
getChildren() {
let children = []
View binary_tree_levels.js
let nodes = [] // list of nodes
const ROOT //binary tree with getChildren function implemented
getNodes(ROOT.getChildren()) // start recursion with no level_index so default is used
function getNodes(level, level_index = 0) {
level.forEach(node => { // loop threw nodes in the level
if (Array.isArray(nodes[level_index])) {
nodes[level_index].push(node) // if node already in this level then add
@20k-ultra
20k-ultra / theme.js
Last active December 10, 2019 03:53
Standard functions for getting/setting themes
View theme.js
function rememberTheme (theme) {
// Persist in sessionStorage so theme is applied
// across pages with file:/// apply remembered theme
sessionStorage.setItem('mdbook-theme', theme)
// Persist to localStorage for normal usage as well
localStorage.setItem('mdbook-theme', theme)
}
function getTheme () {
var theme
View main.tf
resource "aws_alb" "alb_qriket" {
name = "${var.environment}-alb-qriket"
subnets = ["${var.public_subnet_ids}"]
security_groups = ["${var.security_groups_ids}", "${aws_security_group.web_inbound_sg.id}"]
tags {
Name = "${var.environment}-alb-qriket"
Environment = "${var.environment}"
}
}
View main.tf
data "template_file" "web_task" {
template = "${file("${path.module}/tasks/web_task_definition.json")}"
vars {
image = "${aws_ecr_repository.qriket_app.repository_url}"
secret_key_base = "${var.secret_key_base}"
database_host = "${var.database_endpoint}"
database_user = "${var.database_username}"
database_pass = "${var.database_password}"
database_name = "${var.database_name}"
View main.tf
resource "aws_security_group" "ecs_service" {
vpc_id = "${var.vpc_id}"
name_prefix = "${var.environment}-ecs-service-sg"
description = "Allow egress from container"
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
View main.tf
/*====
Cloudwatch Log Group
======*/
resource "aws_cloudwatch_log_group" "qriket" {
name = "qriket"
tags {
Environment = "${var.environment}"
Application = "Qriket API"
}
@20k-ultra
20k-ultra / main.tf
Created December 12, 2018 03:26
AWS ALB forwarding HTTP (443) to HTTP (80)
View main.tf
resource "aws_alb" "api_alb" {
name = "${var.environment}-alb"
subnets = ["${var.public_subnet_ids}"]
security_groups = ["${var.security_groups_ids}", "${aws_security_group.web_inbound_sg.id}"]
tags {
Name = "${var.environment}-alb"
Environment = "${var.environment}"
}
}