Skip to content

Instantly share code, notes, and snippets.

View madagra's full-sized avatar

Mario Dagrada madagra

View GitHub Profile
import re
from anytree.search import findall
def find_by_keyword(self, keyword) -> Node:
"""
Find the node whose regex matches the keyword given as input
"""
def match_regex(node):
has_regex = hasattr(node, "regex") and node.regex is not None
if has_regex:
Strategy Cross-validation set Test set Forecast
Direct 14.302 8.378 13.124
Recursive 14.302 8.378 16.471
#!/bin/bash
# Publish a container to a given repository in the AWS ECR service
# Use the --help option to see it usage
set -e
AWS_PROFILE="default"
CLUSTER_NAME="qubec-cluster"
UPDATE_SRV=0
variable "cluster_name" {
description = "The ECS cluster to start the instances in"
type = string
default = "qubec-cluster"
}
module "ecs_cluster" {
source = "github.com/jetbrains-infra/terraform-aws-ecs-cluster?ref=v0.4.8"
cluster_name = var.cluster_name
spot = true
module "sample_app" {
source = "github.com/madagra/terraform-aws-single-task-service"
ecs_cluster = aws_ecs_cluster._.id
task_name = "sample_app"
container_image = "mongo:latest"
task_exec_role = aws_iam_role.ecs_execution.arn
vpc_id = module.vpc.vpc_id
data "aws_availability_zones" "available" {
state = "available"
}
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 2.48.0"
name = "example_vpc"
cidr = "10.0.0.0/16"
resource "aws_route53_zone" "this" {
name = var.domain_name
}
module "acm" {
source = "terraform-aws-modules/acm/aws"
domain_name = var.domain_name
zone_id = aws_route53_zone.this.zone_id
@madagra
madagra / pypi_server_init_template.tf
Created January 10, 2021 12:59
Cloud init template for private PyPi repo on AWS
data "template_cloudinit_config" "config" {
gzip = false
base64_encode = true
part {
content_type = "text/x-shellscript"
content = <<EOT
#!/bin/bash
sudo mkdir -p /opt/pypi_server
data "aws_ssm_parameter" "ec2_ami" {
name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2"
}
resource "aws_instance" "pypi" {
ami = data.aws_ssm_parameter.ec2_ami.value
instance_type = "t3.nano"
user_data = data.template_file.cloud-init.rendered
key_name = "my-keypair"
#cloud-config
repo_update: true
repo_upgrade: all
write_files:
- path: /opt/run_pypi_server.sh
content: |
#!/usr/bin/env bash
sudo yum update -y