Skip to content

Instantly share code, notes, and snippets.

View sunho's full-sized avatar
🐈
math is beutiful

Sunho Kim sunho

🐈
math is beutiful
View GitHub Profile
@sunho
sunho / dim1.go
Last active January 10, 2021 15:54
type PicService struct {
S3Service *S3Service `dim:"on"` // 여기로 서비스 인스턴스가 주입됩니다.
bucket string
}
// 서비스 메소드
func (p *PicService) SavePic(buf []byte) {
p.S3Service.Store(p.bucket, buf)
}
type DimService interface {
Init(conf ServiceConfig) error // 초기화 함수입니다. dim.Init함수에서 이걸 실행합니다.
DefaultConfig() ServiceConfig // 초기 서비스 yaml 설정 구조체를 반환합니다.
ConfigName() string // 서비스 yaml 설정 파일의 이름입니다.
}
type PicServiceConfig struct {
BucketName string `yaml:"bucket_name"`
}
type PicService struct {
S3Service *S3Service `dim:"on"` // 여기로 서비스 인스턴스가 주입됩니다.
bucket string
}
func (p *PicService) Init(conf dim.ServiceConfig) error {
func TestSavePic(t testing.Testing) {
pic := &PicService {
S3Service: setupDevS3Service(),
bucket: "test",
}
pic.SavePic([]byte{1,3,2,3})
asserts.Equal(t, true, pic.S3Service.Exists("test"))
}
func (s *Serv) Init() error
func (s *Serv) Init(config MyConfig)
func (s *Serv) Init(config MyConfig) error
func (s *Serv) Init()
@sunho
sunho / q3.c
Created January 14, 2022 02:23
q3
/***************************************************
Exercise 1.3
Rewrite the following program using optimal C coding style.
Pay attention to:
- white spaces and indentation
- short-cut boolean expressions in if or loop statements
- use the conditional operator
- code redundancy
- proper use of the relational expression in a return statement
- use of the comma operator in a loop
@sunho
sunho / q4.c
Created January 14, 2022 02:24
q4
/***************************************************
Exercise 1.4
Rewrite the following program using optimal C coding style.
Pay attention to:
- white spaces and indentation
- short-cut boolean expressions in if or loop statements
- use the conditional operator
- code redundancy
- proper use of the relational expression in a return statement
- use of the comma operator in a loop
#include <iostream>
#define ISSUE
int main(){
#ifdef ISSUE
std::ios_base::sync_with_stdio(true);
#else
std::ios_base::sync_with_stdio(false);
#endif
# receive input
N, X = input().split()
N = int(N)
X = int(X)
A = []
B = []
for i in range(N):
a, b = input().split()
A.append(int(a))
B.append(int(b))
#include <bits/stdc++.h>
using namespace std;
void solve() {
int N,X;
cin >> N >> X;
vector<int> A(N), B(N);
for(int i=0;i<N;i++) cin >> A[i], cin >> B[i];
vector<bool> prev(X+1);