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
#include <iostream>
#define ISSUE
int main(){
#ifdef ISSUE
std::ios_base::sync_with_stdio(true);
#else
std::ios_base::sync_with_stdio(false);
#endif
@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
@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
func (s *Serv) Init() error
func (s *Serv) Init(config MyConfig)
func (s *Serv) Init(config MyConfig) error
func (s *Serv) Init()
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"))
}
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 {
type DimService interface {
Init(conf ServiceConfig) error // ์ดˆ๊ธฐํ™” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. dim.Initํ•จ์ˆ˜์—์„œ ์ด๊ฑธ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
DefaultConfig() ServiceConfig // ์ดˆ๊ธฐ ์„œ๋น„์Šค yaml ์„ค์ • ๊ตฌ์กฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
ConfigName() string // ์„œ๋น„์Šค yaml ์„ค์ • ํŒŒ์ผ์˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค.
}
@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)
}
fetch("http://localhost:5353/10", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({"game": {"hello":"hi"}})
});
fetch("http://localhost:5353/10").then(x => x.json()).then(x => {
@sunho
sunho / asdf
Created February 5, 2019 06:50
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using Game.Events;
using Models;
using Newtonsoft.Json;
using UnityEngine;
namespace Network