Skip to content

Instantly share code, notes, and snippets.

View marttp's full-sized avatar
🙇‍♂️
Make the better world with tech and non-tech

Thanaphoom Babparn marttp

🙇‍♂️
Make the better world with tech and non-tech
View GitHub Profile
@marttp
marttp / example.js
Created August 31, 2023 11:45
Random target & obstacle for Group 5
const TARGET = 3;
const OBSTACLE = 2;
/**
*
* @param {Number} height : ความสูงของตาราง;
* @param {Number} width : ความกว้างของตาราง;
* @param {Number} ob : สิ่งกีดขวาง;
*/
function generateMap(height, width, ob) {
@marttp
marttp / CourseProgressReceiverWorker.kt
Created July 30, 2023 19:11
Interaction Service - Consumer example
package dev.tpcoder.interaction.domain.progression
import com.fasterxml.jackson.databind.ObjectMapper
import jakarta.annotation.PostConstruct
import jakarta.annotation.PreDestroy
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.stereotype.Service
import reactor.core.Disposable
import reactor.core.Disposables
@marttp
marttp / CourseController.kt
Created July 30, 2023 18:53
Content Delivery Service - Example
package dev.tpcoder.contentdelivery.domain.course
import com.fasterxml.jackson.databind.ObjectMapper
import dev.tpcoder.contentdelivery.configuration.properties.KafkaChannelProperties
import dev.tpcoder.contentdelivery.domain.course.model.Course
import dev.tpcoder.contentdelivery.domain.course.model.KafkaPayload
import dev.tpcoder.contentdelivery.domain.course.model.ProgressEvent
import dev.tpcoder.contentdelivery.domain.course.model.Section
import org.apache.kafka.clients.producer.ProducerRecord
import org.slf4j.LoggerFactory
package dev.tpcoder.medicalcheckup.appointment
import dev.tpcoder.medicalcheckup.appointment.dto.CheckupResultCreation
import dev.tpcoder.medicalcheckup.appointment.entity.CheckupResult
import org.springframework.web.bind.annotation.*
@RestController
@RequestMapping("/checkups")
class CheckupController(private val checkupResultService: CheckupResultService, private val appointmentService: AppointmentService) {
@marttp
marttp / AppointmentController.kt
Created June 3, 2023 11:25
Healthcare Appointment Example
@RestController
@RequestMapping("/appointments")
class AppointmentController(private val appointmentService: AppointmentService) {
private val logger = LoggerFactory.getLogger(AppointmentController::class.java)
// Appointment - For Patient
@PostMapping
fun createAppointment(@RequestBody payload: CreateAppointmentRequest): CreateAppointmentResponse {
val createdAppointment = appointmentService.createAppointment(payload)
@marttp
marttp / Subscription.kt
Created June 3, 2023 11:21
Newsletter subscription with JobRunr
package dev.tpcoder.medicalcheckup.newsletter
import dev.tpcoder.medicalcheckup.common.entity.Patient
import org.springframework.data.annotation.Id
import org.springframework.data.jdbc.core.mapping.AggregateReference
import org.springframework.data.relational.core.mapping.Table
@Table("subscriptions")
data class Subscription(
@Id val id: Long? = null,
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