Skip to content

Instantly share code, notes, and snippets.

View soerenmartius's full-sized avatar
🎯
focused

Sören Martius soerenmartius

🎯
focused
View GitHub Profile
@soerenmartius
soerenmartius / provider.tf
Created March 29, 2020 15:40
Terraform provider without s3 and state locks
# ---------------------------------------------------------------------------------------------------------------------
# SET TERRAFORM AND PROVIDER REQUIREMENTS
# ---------------------------------------------------------------------------------------------------------------------
terraform {
required_version = "~> 0.12.24"
required_providers {
aws = "~> 2.4"
}
@soerenmartius
soerenmartius / provider.tf
Created March 29, 2020 16:18
Terraform with S3 Remote State and DynamoDB State Locks
# ---------------------------------------------------------------------------------------------------------------------
# SET TERRAFORM AND PROVIDER REQUIREMENTS
# ---------------------------------------------------------------------------------------------------------------------
terraform {
required_version = "~> 0.12.24"
backend "s3" {
bucket = "github-terraform-example-terraform-state"
key = "organization/github-terraform-example/terraform.tfstate"
@soerenmartius
soerenmartius / Makefile
Created March 29, 2020 16:24
Makefile with Terraform targets
SHELL := /bin/bash
MOUNT_TARGET_DIRECTORY = /app/src
BUILD_TOOLS_DOCKER_REPO = mineiros/build-tools
# Set default value for environment variable if there aren't set already
ifndef BUILD_TOOLS_VERSION
BUILD_TOOLS_VERSION := latest
endif
@soerenmartius
soerenmartius / repository.tf
Created March 29, 2020 17:08
Create new GitHub Repository with Terraform
module "iac-github" {
source = "mineiros-io/repository/github"
version = "~>0.1.0"
name = "iac-github"
private = true
description = "An example on how to manage a GitHub organization with Terraform."
allow_merge_commit = true
@soerenmartius
soerenmartius / semaphore.yml
Created March 29, 2020 17:18
SemaphoreCI Pipeline Configuration
version: v1.0
name: "IaC-Github CI Pipeline"
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
global_job_config:
env_vars:
- name: BUILD_TOOLS_VERSION
@soerenmartius
soerenmartius / deploy.yml
Last active March 29, 2020 17:21
SemaphoreCI Terraform Deployment Pipeline.
version: v1.0
name: "Deploy to GitHub"
agent:
machine:
type: e1-standard-2
os_image: ubuntu1804
global_job_config:
env_vars:
- name: BUILD_TOOLS_VERSION
@soerenmartius
soerenmartius / repository.tf
Last active March 29, 2020 17:23
GitHub Repository with Branch Protection Rule
module "iac-github" {
source = "mineiros-io/repository/github"
version = "~> 0.1.0"
name = "iac-github"
private = true
description = "An example on how to manage a GitHub organization with Terraform."
allow_merge_commit = true
@soerenmartius
soerenmartius / multithreading.go
Created May 5, 2020 09:40
Multithreading Example with WaitGroups in Golang
package main
import (
"fmt"
"sync"
"time"
)
func worker(wg *sync.WaitGroup, id int) {
defer wg.Done()
@soerenmartius
soerenmartius / multi_processing.py
Created May 5, 2020 09:54
Multiprocessing Example in Python3
import multiprocessing
def spawn_process(number):
print(f'Runs in separate process {number}')
if __name__ == '__main__':
max_processes = 5
Process Thread
Processes are heavy-weight operations. Threads are lighter-weight operations.
Processes can start new processes using e.g. [fork()](http://man7.org/linux/man-pages/man2/fork.2.html) (system call). A process can start several threads using e.g [pthread_create()](http://man7.org/linux/man-pages/man3/pthread_create.3.html) (system call).
Each process lives in its own memory (address) space and holds a full copy of the program in memory which consume more memory. Processes don’t share memory with other processes. Threads share memory with other threads of the same process. Threads within the same process live within the same address space and can thus easily access each other's data structures. The shared memory heaps and pools allow for reduced overhead of shared components.
Inter-process communication is slow as processes have different memory addresses. Inter-thread communication can be faster than inter-process communication because threads of the same process share memory with the process they