Skip to content

Instantly share code, notes, and snippets.

View marttp's full-sized avatar
🙇‍♂️
Let's improve equality of developer and make the world better together

Thanaphoom Babparn marttp

🙇‍♂️
Let's improve equality of developer and make the world better together
View GitHub Profile
import dev.tpcoder.reactivedockercompose.book.Book;
import dev.tpcoder.reactivedockercompose.book.BookRepository;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import reactor.core.publisher.Flux;
import java.util.List;
@marttp
marttp / Book.java
Created April 27, 2023 03:39
Group of Java Code to represent the Cache-Aside Pattern in Book Service
public record Book(Long id, String title, String isbn) {
}
@marttp
marttp / docker-compose.yml
Created April 27, 2023 03:33
Docker compose with PostgreSQL and Redis Stack
version: '3.1'
services:
db:
image: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: p@ssw0rd
POSTGRES_DB: book
ports:
@marttp
marttp / Dockerfile
Created March 21, 2023 12:41
Dockerfile for Axum
FROM rust:1.68.0 as builder
WORKDIR /app
COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
COPY ./src ./src
RUN cargo build --release
RUN rm src/*.rs
@marttp
marttp / Dockerfile
Created March 21, 2023 09:52
Dockerfile for GraalVM
FROM ghcr.io/graalvm/graalvm-ce:22.3.1
WORKDIR /app
ADD . /app
RUN gu install native-image
RUN native-image --version
RUN ./gradlew nativeCompile
@marttp
marttp / Circle.kt
Last active January 2, 2023 07:55
Example of programming paradigm
data class Circle(val radius: Double) {
fun getArea(): Double {
return Math.PI * radius * radius
}
}
fun main(args: Array<String>) {
val c = Circle(5.0)
println("The area of the circle is ${c.getArea()}")
}
@marttp
marttp / statistic_example.py
Created January 1, 2023 11:04
Statistic with python
# define the data set
data = [1, 2, 2, 3, 3, 3, 4]
# calculate the mean
mean = sum(data) / len(data)
print("Mean:", mean) # Mean: 2.5714285714285716
# calculate the median
data.sort()
if len(data) % 2 == 0:
@marttp
marttp / matrix_ops.py
Created January 1, 2023 11:03
Matrix operation in python
A = [[1, 2],
[3, 4]] # 2 x 2
B = [[5, 6],
[7, 8]] # 2 x 2
D = [[5, 6],
[7, 8],
[9, 10]] # 2 x 3
def order_fried_chicken():
# Decide on type of chicken
chicken_type = input("Would you like to order chicken nuggets or a whole chicken? ")
# Order sides or not
order_sides = False
sides_choice = input("Would you like to order any sides with your chicken? ")
if sides_choice.lower() == "yes":
order_sides = True
package dev.tpcoder.bffjav;
import dev.tpcoder.bffjav.client.DriverClient;
import dev.tpcoder.bffjav.client.LocationClient;
import dev.tpcoder.bffjav.model.Driver;
import dev.tpcoder.bffjav.model.Location;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;