Skip to content

Instantly share code, notes, and snippets.

Avatar

Adrian Macal amacal

  • FlixBus
  • Munich, Germany
View GitHub Profile
View python-zipfile-opening.py
from zipfile import ZipFile
with ZipFile('terraform_0.13.4_linux_amd64.zip') as archive:
# archive filename
assert archive.filename == 'terraform_0.13.4_linux_amd64.zip'
# its consistency
assert archive.testzip() == None
View python-zipfile-exploring.py
from zipfile import ZipFile, Path
with ZipFile('python-3.9.0-docs-pdf-a4.zip') as archive:
# all-at-once way
for info in archive.infolist():
assert info.filename.startswith('docs-pdf')
# or pathlike way
root = Path(archive)
assert root.is_dir()
View python-zipfile-extracting.py
from zipfile import ZipFile, Path
with ZipFile('python-3.9.0-docs-pdf-a4.zip') as archive:
# extract everything
archive.extractall()
# just one file
archive.extract('docs-pdf/faq.pdf', 'docs')
# pathlike way
View python-zipfile-creating.py
from zipfile import ZipFile, Path
with ZipFile('archive.zip', 'w') as archive:
# include single file
archive.write('terraform')
# nested file
archive.write('docs-pdf/faq.pdf')
# or inline content
View terraform-simpler-start-small-main.tf
provider "aws" {
region = var.region
}
variable "region" {}
variable "plan_name" {}
resource "aws_s3_bucket" "data_bucket" {
bucket = "${var.plan_name}-data"
acl = "private"
View terraform-simpler-use-backend-main.tf
provider "aws" {
region = var.region
}
terraform {
backend "s3" {}
}
variable "region" {}
variable "plan_name" {}
View terraform-simpler-use-makefile
PLAN_NAME := booking-system
LOCKS_TABLE := terraform-locks
REGION_NAME := eu-west-1
BUCKET_NAME := terraform-state-$(shell aws sts get-caller-identity --query Account --output text)
init:
@terraform init \
-backend-config="region=$(REGION_NAME)" \
-backend-config="bucket=$(BUCKET_NAME)" \
View bootstrapping-csharp-init.sh
# create empty solution
dotnet new sln -o blocks
cd blocks
# create projects
dotnet new console -o Blocks
dotnet new classlib -o Blocks.Core
dotnet new nunit -o Blocks.Core.Tests
# include in solution
View snowflake-append-only-table.sql
create transient table ecds_db.playground.orders
(
-- meta
_etl_id bigint autoincrement start 1 increment 1,
_etl_id_prev bigint,
_etl_updated_at timestamp_ntz,
_etl_deleted_at timestamp_ntz,
-- key
id bigint,
-- attributes
View snowflake-append-only-querying.sql
select count(1)
from ecds_db.playground.orders
where and _etl_deleted_at is null
and _etl_id not in
(
select _etl_id_prev
from ecds_db.playground.orders
where _etl_id_prev is not null
)