This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PicService struct { | |
S3Service *S3Service `dim:"on"` // 여기로 서비스 인스턴스가 주입됩니다. | |
bucket string | |
} | |
// 서비스 메소드 | |
func (p *PicService) SavePic(buf []byte) { | |
p.S3Service.Store(p.bucket, buf) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type DimService interface { | |
Init(conf ServiceConfig) error // 초기화 함수입니다. dim.Init함수에서 이걸 실행합니다. | |
DefaultConfig() ServiceConfig // 초기 서비스 yaml 설정 구조체를 반환합니다. | |
ConfigName() string // 서비스 yaml 설정 파일의 이름입니다. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *Serv) Init() error | |
func (s *Serv) Init(config MyConfig) | |
func (s *Serv) Init(config MyConfig) error | |
func (s *Serv) Init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************** | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*************************************************** | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#define ISSUE | |
int main(){ | |
#ifdef ISSUE | |
std::ios_base::sync_with_stdio(true); | |
#else | |
std::ios_base::sync_with_stdio(false); | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |