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
package dev.tpcoder.bffjav.config;
import dev.tpcoder.bffjav.client.DriverClient;
import dev.tpcoder.bffjav.client.LocationClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.rsocket.RSocketRequester;
import org.springframework.messaging.rsocket.service.RSocketServiceProxyFactory;
import org.springframework.web.service.invoker.HttpClientAdapter;
import org.springframework.web.service.invoker.HttpServiceProxyFactory;
package dev.tpcoder.bffjav.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.codec.cbor.Jackson2CborDecoder;
import org.springframework.http.codec.cbor.Jackson2CborEncoder;
import org.springframework.messaging.rsocket.RSocketRequester;
@marttp
marttp / LocationController.kt
Created November 6, 2022 15:36
Backend Service for RSocket base
package dev.tpcoder.location
import org.slf4j.LoggerFactory
import org.springframework.messaging.handler.annotation.*
import org.springframework.stereotype.Controller
import reactor.core.publisher.Flux
import java.time.Duration
@Controller
class LocationController {
@marttp
marttp / DriverController.kt
Last active November 6, 2022 18:19
Backend Service with RESTful base
package dev.tpcoder.driver
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.asFlow
import org.slf4j.LoggerFactory
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.codec.multipart.FilePart
import org.springframework.stereotype.Controller
import org.springframework.util.MultiValueMap
@marttp
marttp / Pdf2JpegConverter.java
Created November 26, 2021 01:43 — forked from dyllanwli/Pdf2JpegConverter.java
convert PDF to JPEG/multi-page tiff/image-pdf files
package org.doc2pdf.lambda;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.imageio.ImageIO;
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.5.0;
contract Bank {
// Dictionary that maps address to balances
mapping (address => uint256) private balances;
// Users in the system
address[] accounts;
@marttp
marttp / MongoConfig.java
Last active June 2, 2021 13:55
[Spring WebFlux]: ReadingConverter & WritingConverter for ZonedDateTime inside MongoDB
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.convert.ReadingConverter;
@Component
public class CronScheduler {
private final Logger logger = LoggerFactory.getLogger(CronScheduler.class);
@Scheduled(cron = "${cron.expression}")
public void cronScheduleTask() {
logger.info("schedule tasks using cronScheduleTask - {}", ZonedDateTime.now());
}
}
@Component
public class FixedDelayScheduler {
private final Logger logger = LoggerFactory.getLogger(FixedDelayScheduler.class);
@Scheduled(fixedDelay = 10000)
public void fixedDelayScheduleTask() {
logger.info("schedule tasks using fixedDelayScheduleTask - {}", ZonedDateTime.now());
}