Skip to content

Instantly share code, notes, and snippets.

@mike-seger
mike-seger / pg-data-growth.md
Created September 18, 2024 06:32
Postgres Data Growth

You:

In postgres, we have a table which contains 100MB of data with daily updates on most of the 250K records. All other data tables combined are 400MB. If the data partition size is 1 GB, is there a danger of running out of disk space over time?

ChatGPT:

Yes, there is a potential risk of running out of disk space over time, particularly due to a combination of factors such as daily updates and the partitioning strategy.

Here's a breakdown of the key considerations:

@mike-seger
mike-seger / Kubernetes MicroServices Setup.md
Last active September 8, 2024 21:30
Kubernetes MicroService Setup

You:

given an architecture consisting of 15 springboot applications, one of which is a springcloud gateway providing the entry point to the others. all other micro-services would not be accessible from the external network. how would you set these up using kubernetes?

ChatGPT:

To set up this architecture using Kubernetes (K8s), where you have 15 Spring Boot applications (microservices), one of which is a Spring Cloud Gateway that acts as the entry point to the others, here's a high-level approach. This setup ensures that the other services are not accessible from the external network, only the gateway service is.

Steps for Kubernetes Setup:

@mike-seger
mike-seger / Generic Queries.md
Last active August 23, 2024 15:24
Generic Queries

You:

can you provide a kotlin method to be used within a springboot application to check the existence of a table by name?

ChatGPT:

Certainly! Below is a Kotlin method that can be used within a Spring Boot application to check the existence of a table by name. This method uses JdbcTemplate to interact with the database.

@mike-seger
mike-seger / LiquibaseConfiguration.kt
Last active August 22, 2024 17:37
LiquibaseConfiguration
import liquibase.integration.spring.SpringLiquibase
import liquibase.database.Database
import liquibase.database.DatabaseFactory
import liquibase.database.AbstractJdbcDatabase
import liquibase.resource.ResourceAccessor
import java.sql.Connection
import javax.sql.DataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.beans.factory.annotation.Value

You:

Given a Kotlin / SpringBoot / Postgres application with a JPARepository for an Entity1. I would like to have two methods in the repository, backup(label) and restore(label). backup(label) should back up the entire table entity1 into entity1_label and restore(label) should restore the data from entity1_label back into entity1. can you provide the implementation for this?

ChatGPT:

@mike-seger
mike-seger / bashutils.md
Created August 19, 2024 17:11
Bash Utilities

You:

can you create a generic bash function which takes index and array as its parameters and returns the array element at index modulo the array length?

ChatGPT:

Certainly! Below is a generic Bash function that takes an index and an array as parameters and returns the array element at the index modulo the array length.

You:

is there any standard which allows me to deploy a set of java micro-services into azure using ansible?

ChatGPT:

Yes, deploying Java microservices to Azure using Ansible is a common use case and can be achieved by following certain best practices and standards. Here are some guidelines and steps to help you with the deployment:

  1. Infrastructure as Code (IaC) : Use Ansible to define and provision your infrastructure on Azure. This includes creating resource groups, virtual machines, load balancers, and other necessary resources.
// URL endpoints
const getUrl = 'https://example.com/api/get';
const postUrl = 'https://example.com/api/post';
// Number of requests
const numberOfRequests = 1000;
// Function to perform a GET request
const makeGetRequest = async () => {
try {
@mike-seger
mike-seger / RetryConfig.md
Last active June 28, 2024 17:31
Retry Executor

You:

when i have the yaml config values, can't i save on java

ChatGPT:

Yes, you can leverage Spring Boot's auto-configuration capabilities with resilience4j to avoid manually creating beans for retry and circuit breaker configurations. Spring Boot automatically configures resilience4j beans based on the properties defined in your application.yml file. Here's how you can streamline your configuration:

  1. Add resilience4j Dependencies: Ensure you have the necessary dependencies in your pom.xml:
@mike-seger
mike-seger / map-sort.sh
Last active June 21, 2024 16:50
data mapping
#!/usr/bin/env bash
input_file="$1"
declare -A data
declare -A items
declare -A dates
# Read the data and populate arrays
while IFS=$'\t' read -r date item count; do