Skip to content

Instantly share code, notes, and snippets.

View 2tony2's full-sized avatar
🏠
Working from home

Tony Zeljkovic 2tony2

🏠
Working from home
View GitHub Profile
@2tony2
2tony2 / Dockerfile
Created February 24, 2024 15:45
A example Dockerfile configuration for dbt devcontainer
###################################################
##### SETTING OPERATING SYSTEM #####
###################################################
# This is an official python image.
FROM python:3.11.6-bookworm
# Set the user to root.
USER root
@2tony2
2tony2 / Docker-compose.yml
Created February 24, 2024 15:46
Example Docker Compose for DBT devcontainer
version: '3'
volumes:
local-dbt-env-shell-history: # This basically let's docker auto-manage this volume.
services:
local-dbt-env:
profiles:
- development
platform: linux/amd64 # We force the platform for consistency.
@2tony2
2tony2 / docker-compose-sso.yml
Created February 24, 2024 15:49
An example docker compose for setting up dbt dev env with SSO
version: '3'
networks:
local_dev_network:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.23.0.0/16
gateway: 172.23.0.1
@2tony2
2tony2 / devcontainer.json
Created February 24, 2024 15:51
Example devcontainer json for dbt dev env
{
"name": "dbt dev env",
"dockerComposeFile": "./docker-compose.yml",
"service": "local-dbt-env",
"runServices": ["local-dbt-env"],
"hostRequirements": {
"cpus": 4,
"memory": "8gb",
"storage": "30gb"
},
@2tony2
2tony2 / abstract_class_example.py
Last active April 28, 2024 08:50
Example of Python Abstract Base Class
from abc import ABC, abstractmethod
class Animal(ABC):
@abstractmethod
def make_sound(self):
"""Each subclass must implement a method to make a specific animal sound."""
pass
@abstractmethod
def move(self):
@2tony2
2tony2 / abstract_classmethod.py
Last active April 26, 2024 10:24
abstract classmethod example
from abc import ABC, abstractmethod
class DataSource(ABC):
@classmethod
@abstractmethod
def configure(cls, config):
"""
Configures database connection parameters. Each subclass must implement this
method based on its database type specifications.
"""
from abc import ABC, abstractmethod
class DataFormatter(ABC):
@staticmethod
@abstractmethod
def format_data(data):
"""Define a standard way to format data."""
pass
class JSONFormatter(DataFormatter):
from abc import ABC, abstractmethod
class DatabaseConfig(ABC):
@property
@abstractmethod
def connection_string(self):
"""Define a standardized property to get a database connection string."""
pass
class ProductionDatabaseConfig(DatabaseConfig):
from abc import ABC, abstractmethod
from contextlib import contextmanager
from cryptography.fernet import Fernet
class CryptoFileManager(ABC):
@abstractmethod
@contextmanager
def secure_file_handler(self, path, mode, key):
"""A context manager for encrypting or decrypting files."""
pass