Skip to content

Instantly share code, notes, and snippets.

View civilizeddev's full-sized avatar

Hyeonsoo David Lee civilizeddev

View GitHub Profile
@civilizeddev
civilizeddev / Dockerfile
Created October 31, 2022 18:03
Minimal Size Golang Docker Image
FROM golang:alpine as builder
COPY . .
RUN apk update && \
apk upgrade && \
apk add --no-cache ca-certificates && \
apk add --update-cache tzdata && \
update-ca-certificates
RUN echo "nobody:x:65534:65534:nobody:/:" > /etc_passwd
ENV GO111MODULE=on
ENV CGO_ENABLED=0
@civilizeddev
civilizeddev / ApplyMapN.scala
Created September 24, 2019 13:40
독립적으로 실행가능한 계산을 모으기: Apply 타입 클래스 사용
case class Pack(orders: Seq[Order], orderItems: Seq[OrderItem], products: Seq[Product])
// 1. for-comprehension에서 flatMap 체이닝: 순서대로 실행된다.
for {
orders <- orderRepository.findAll()
orderItems <- orderItemRepository.findAll()
products <- productRepository.findAll()
} yield Pack(orders, orderItems, products)
// 2. future를 먼저 받아놓고 flatMap 체이닝: 동시에 여러 개의 Future를 진행할 수 있지만, 코드가 많아진다.
@civilizeddev
civilizeddev / combination.ts
Created September 4, 2019 12:37
배열 조합
export function combination<T>(xs: T[]): Array<Array<T>> {
return Array.from({ length: 2 ** xs.length }).map((_, i) =>
xs.filter((_, j) => (i >>> j) & 1)
)
}