Skip to content

Instantly share code, notes, and snippets.

View pmatsinopoulos's full-sized avatar
💻
Programming

Panos Matsinopoulos pmatsinopoulos

💻
Programming
View GitHub Profile
@pmatsinopoulos
pmatsinopoulos / vpc_subnets.tf
Created August 27, 2023 12:02
AWS Private and Public Subnets - vpc_subnets.tf
resource "aws_subnet" "subnet_1" {
availability_zone = "eu-west-1a"
cidr_block = "172.18.0.0/28"
tags = {
"Name" = "private-subnet-1"
}
vpc_id = aws_vpc.private_and_public_subnets.id
}
@pmatsinopoulos
pmatsinopoulos / vpc.tf
Last active August 27, 2023 11:40
AWS Private and Public Subnets - vpc.tf
resource "aws_vpc" "private_and_public_subnets" {
cidr_block = "172.18.0.0/27" # 32 IPs
enable_dns_hostnames = true
enable_dns_support = true
instance_tenancy = "default"
tags = {
"Name" = "${local.project}-vpc"
}
}
@pmatsinopoulos
pmatsinopoulos / locals.tf
Created August 27, 2023 11:11
AWS Private and Public Subnets - locals.tf
locals {
project = "private-public-subnets"
region = "eu-west-1"
}
@pmatsinopoulos
pmatsinopoulos / providers.tf
Created August 27, 2023 11:10
AWS Private and Public Subnets - providers.tf
provider "aws" {
region = local.region
default_tags {
tags = {
project = local.project
terraform = "1"
}
}
}
@pmatsinopoulos
pmatsinopoulos / main.tf
Created August 27, 2023 10:37
AWS Private and Public Subnets - main.tf
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.8.0"
}
}
required_version = ">=1.5.3"
}
import java.util.Scanner;
public class IntegerToBinary {
public static void main(String[] args) {
System.out.print("Give me an integer number: ");
Scanner scanner = new Scanner(System.in);
if (scanner.hasNextInt()) {
int integer = scanner.nextInt();
System.out.printf("Binary: %s\n", Integer.toString(integer, 2));
import java.util.Scanner;
public class IntegerToBinaryRecursive {
/**
* Given an integer N, its binary representation is
* the binary representation of N/2 suffixed with the modulo of N % 2
*/
public static String toBinary(int integer) {
if (integer <= 1) {
return Integer.toString(integer);
import java.util.Scanner;
import java.util.Stack;
public class IntegerToBinary {
/**
* Takes an integer and returns its binary representation.
* It uses a Stack structure to print the digits.
*
*/
public static String toBinary(int integer) {
class IntegerToBinary
def initialize(integer)
@integer = integer
end
def binary
return integer.to_s if integer <= 1
"#{IntegerToBinary.new(integer / 2).binary}#{integer % 2}"
end
class IntegerToBinary
def initialize(integer)
@integer = integer
end
def binary
return '0' if integer.zero?
stack = []