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 / 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;
@marttp
marttp / DriverClient.java
Created November 6, 2022 18:26
ClientInterfaces
package dev.tpcoder.bffjav.client;
import dev.tpcoder.bffjav.model.Driver;
import org.springframework.http.MediaType;
import org.springframework.http.codec.multipart.FilePart;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.service.annotation.GetExchange;
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 {