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 / 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
@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)
}
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 설정 파일의 이름입니다.
}
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
func LoadParsers(customParsers map[reflect.Type]Parser) (map[reflect.Type]Parser, error) {
parsers := map[reflect.Type]Parser{}
var boolParser BoolValue
parsers[reflect.TypeOf(true)] = &boolParser
var intParser IntValue
parsers[reflect.TypeOf(1)] = &intParser
var int64Parser Int64Value