'잡동사니'에 해당되는 글 13326건

  1. 2022.09.07 개발자 단상 4
  2. 2022.09.07 전자식 계량기 읽는 방법
  3. 2022.09.06 golang range
  4. 2022.09.06 golang mutex
  5. 2022.09.06 golang make와 new
  6. 2022.09.06 golang defer 와 panic(), recover()
  7. 2022.09.06 go 루틴
  8. 2022.09.05 git diff --staged
  9. 2022.09.05 golang https server
  10. 2022.09.05 jquery-cookie 라이브러리

후우..

나 아니어도 때릴 사람 많으니 가입까진 안해야지.. (응?)

 

1. 먼 게임 개발자한테 맥북을 추천해?

> 맥이 게임시장에서 몇 %나 차지하나도 모르고 게임 개발자 지망에게 맥북을 추천하다니..

> 맥용 unreal engine도 있으니 상관없을지도 모르지만 m1 맥북에서 돌지도 모르겠고

> 그래픽 카드 외장형 달려고 하면 가격이 안드로메다일텐데 굳이?

 

2. 수학 vs 영어

> 닥치고 수학. 아니 근데 프로그래밍 언어 문법 공부라던가 api 사용 학습은 어디로..

> 영수가 문제가 아닐텐데.. 하지만 게임 프로그래밍이라면 수학은 기본, 물리를 해야 할텐데?

 

3. 여러방면의 책을 읽는 것이 매우 중요?

> 종이 책으로 볼 시간도 없어서 pdf나 html로 된 reference 보기도 바쁜데..

> 물론 종이로 나온 내용을 무시하는건 아님. 처음 하는 사람에게 guide로서는 돈 값을 하는 책이라면 추천

> 그거 아니어도 읽을거 너무 많아 시간이 부족하다..

 

4. intelliJ, tabnine ai 코딩

> 프로그래밍 패턴이 뻔하긴 하다만, 알고리즘에 대한 이해 없이 기계학습에 의한 추천 코딩으로

> 일을 마무리 지은들 그게 개발자 본인에게 어떠한 메리트가 있을까? 검색시간 단축으로 인한 효율성 재고?

> 개발자에게 중요한건 스스로 알고리즘을 이해하고 분석하고 더 나은걸로 바꾸는 능력 아니었나..

 

5. 게임 개발자에게 intelliJ, java, python, 인문학적 소양이라

> 게임 개발자에게 주류는 아직 cpp로 알고 있는데 intellJ를 써가면서 쓸만한 메리트가 있을지?

> 게임엔진 개발자가 아니라 백엔드 서버라면 java 물려서 쓸 가능성이 존재는 하겠지만

> 게임 개발도 게임 엔진, 백엔드 등등 분야가 엄청 많을텐데 1인 개발하는 시기는 한참 전에 지났고..

> 개발자에게 필요한건 개발자적 능력과 소양이 우선과제고 그 이후에 인문학적 소양이지

> 도대체 기본도 안된 개발자에게 인문학적 소양을 왜 요구할까? 그건 나중에 경력직에게나 필요하지!

 

[링크 : https://velog.io/@joshuara7235/To.-개발자를-꿈꾸는-분들에게-부제-개발자로-산다는-것은]

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

으어어어어  (0) 2022.11.10
아 피곤하다  (0) 2022.10.14
9월 그리고 2주년  (2) 2022.09.01
니퍼, 롱노우즈 구매  (0) 2022.08.21
덥다.. 여름인가  (0) 2022.08.02
Posted by 구차니

집에 계량기를 교체했는데 기계식에서 전자식으로 바뀌니 도대체 멀 읽어야 하는지 모르겠다.

advanced e type 이라니 7번이 나올때까지 기다려야 하나.

 

근데 나야 내꺼 하나 읽는다 해도.. 관리 사무소에서는 저거 집집마다 기다리면서 읽어야 하나?

[링크 : https://m.blog.naver.com/byongsu/221623883471]

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

오랫만에 자전거 그리고  (0) 2022.09.11
연휴의 시작  (0) 2022.09.08
라디오 분해 시도 실패 -_-  (4) 2022.08.07
라디오 분해?  (0) 2022.08.06
계곡 발 담그기  (0) 2022.07.31
Posted by 구차니
Programming/golang2022. 9. 6. 17:03

일종의.. foreach 느낌인데

range pow 하면 pow에 들은 {1,2,4,8,16,32,64,128} 이 array index와 함께 i,v 값으로 나온다.

 

2**0=1 이렇게 해놔서 무슨 수식인줄 알았네 -_-

package main

import "fmt"

var pow = []int{1, 2, 4, 8, 16, 32, 64, 128}

func main() {
for i, v := range pow {
fmt.Printf("2**%d = %d\n", i, v)
}
}
2**0 = 1
2**1 = 2
2**2 = 4
2**3 = 8
2**4 = 16
2**5 = 32
2**6 = 64
2**7 = 128

[링크 : https://go.dev/tour/moretypes/16]

 

[링크 : https://changhoi.kim/posts/go/about-go-range/]

[링크 : https://pronist.dev/88]

[링크 : https://gobyexample.com/range]

'Programming > golang' 카테고리의 다른 글

golang ini  (0) 2022.09.15
golang http.request  (0) 2022.09.14
golang mutex  (0) 2022.09.06
golang make와 new  (0) 2022.09.06
golang defer 와 panic(), recover()  (0) 2022.09.06
Posted by 구차니
Programming/golang2022. 9. 6. 16:54

세마포어는 있는지 모르겠다만 mutex는 존재하네

 

package main

import (
"fmt"
"sync"
"time"
)

// SafeCounter is safe to use concurrently.
type SafeCounter struct {
mu sync.Mutex
v  map[string]int
}

// Inc increments the counter for the given key.
func (c *SafeCounter) Inc(key string) {
c.mu.Lock()
// Lock so only one goroutine at a time can access the map c.v.
c.v[key]++
c.mu.Unlock()
}

// Value returns the current value of the counter for the given key.
func (c *SafeCounter) Value(key string) int {
c.mu.Lock()
// Lock so only one goroutine at a time can access the map c.v.
defer c.mu.Unlock()
return c.v[key]
}

[링크 : https://go.dev/tour/concurrency/9]

 

관련 검색어로 golang mutex vs channel 이라는게 나오는데 channel이 그렇게 빠르지는 않은 듯.

[링크 : http://www.dogfootlife.com/archives/452]

[링크 : https://github.com/golang/go/wiki/MutexOrChannel]

[링크 : https://go.dev/doc/effective_go#channels]

'Programming > golang' 카테고리의 다른 글

golang http.request  (0) 2022.09.14
golang range  (0) 2022.09.06
golang make와 new  (0) 2022.09.06
golang defer 와 panic(), recover()  (0) 2022.09.06
go 루틴  (0) 2022.09.06
Posted by 구차니
Programming/golang2022. 9. 6. 15:27

new는 c의 malloc()에 대응한다면

make는 특정 경우에 대한 메모리 할당 + 초기화를 위한 키워드인 듯.

package main

import "fmt"

func sum(s []int, c chan int) {
sum := 0
for _, v := range s {
sum += v
}
c <- sum // send sum to c
}

func main() {
s := []int{7, 2, 8, -9, 4, 0}

c := make(chan int)
go sum(s[:len(s)/2], c)
go sum(s[len(s)/2:], c)
x, y := <-c, <-c // receive from c

fmt.Println(x, y, x+y)
}

[링크 : https://go.dev/tour/concurrency/2]

 

Allocation with new
Go has two allocation primitives, the built-in functions new and make. They do different things and apply to different types, which can be confusing, but the rules are simple. Let's talk about new first. It's a built-in function that allocates memory, but unlike its namesakes in some other languages it does not initialize the memory, it only zeros it. That is, new(T) allocates zeroed storage for a new item of type T and returns its address, a value of type *T. In Go terminology, it returns a pointer to a newly allocated zero value of type T.
Since the memory returned by new is zeroed, it's helpful to arrange when designing your data structures that the zero value of each type can be used without further initialization. This means a user of the data structure can create one with new and get right to work. For example, the documentation for bytes.Buffer states that "the zero value for Buffer is an empty buffer ready to use." Similarly, sync.Mutex does not have an explicit constructor or Init method. Instead, the zero value for a sync.Mutex is defined to be an unlocked mutex.

[링크 : https://go.dev/doc/effective_go#allocation_new]

 

Allocation with make
Back to allocation. The built-in function make(T, args) serves a purpose different from new(T). It creates slices, maps, and channels only, and it returns an initialized (not zeroed) value of type T (not *T). 

[링크 : https://go.dev/doc/effective_go#allocation_make]

[링크 : https://pronist.dev/102]

 

'Programming > golang' 카테고리의 다른 글

golang range  (0) 2022.09.06
golang mutex  (0) 2022.09.06
golang defer 와 panic(), recover()  (0) 2022.09.06
go 루틴  (0) 2022.09.06
golang https server  (0) 2022.09.05
Posted by 구차니
Programming/golang2022. 9. 6. 15:13

panic은 c로 치면 exit()도, recover()는 return 정도라고 보면 되려나?

package main
 
import "os"
 
func main() {
    // 잘못된 파일명을 넣음
    openFile("Invalid.txt")
     
    // openFile() 안에서 panic이 실행되면
    // 아래 println 문장은 실행 안됨
    println("Done") 
}
 
func openFile(fn string) {
    f, err := os.Open(fn)
    if err != nil {
        panic(err)
    }
 
    defer f.Close()
}










package main
 
import (
    "fmt"
    "os"
)
 
func main() {
    // 잘못된 파일명을 넣음
    openFile("Invalid.txt")
 
    // recover에 의해
    // 이 문장 실행됨
    println("Done") 
}
 
func openFile(fn string) {
    // defer 함수. panic 호출시 실행됨
    defer func() {
        if r := recover(); r != nil {
            fmt.Println("OPEN ERROR", r)
        }
    }()
 
    f, err := os.Open(fn)
    if err != nil {
        panic(err)
    }
 
    defer f.Close()
}
$ ./panic
panic: open Invalid.txt: no such file or directory

goroutine 1 [running]:
main.openFile({0x8b9f9, 0xb})
        /home/pi/panic.go:17 +0xb4
main.main()
        /home/pi/panic.go:7 +0x24
$ ./recover
OPEN ERROR open Invalid.txt: no such file or directory
Done





[링크 : http://golang.site/go/article/20-Go-defer와-panic]

'Programming > golang' 카테고리의 다른 글

golang mutex  (0) 2022.09.06
golang make와 new  (0) 2022.09.06
go 루틴  (0) 2022.09.06
golang https server  (0) 2022.09.05
golang 쿠키  (0) 2022.09.02
Posted by 구차니
Programming/golang2022. 9. 6. 12:48

go 루틴은 쓰레드로 작동시킨다.

 

go funcname()

[링크 : http://golang.site/go/article/21-Go-루틴-goroutine]

 

왜.. 생소하지 -ㅁ-?

package main

import (
"fmt"
"time"
)

func say(s string) {
for i := 0; i < 5; i++ {
time.Sleep(100 * time.Millisecond)
fmt.Println(s)
}
}

func main() {
go say("world")
say("hello")
}

[링크 : https://go.dev/tour/concurrency/1]

 

고루틴은 parent에 의해서 죽일수 없다고 하는데

[링크 : https://www.reddit.com/r/golang/comments/4kpv6x/why_a_parent_goroutine_doesnt_kill_its_child_and/]

 

그래서 channel을 이용해서 해당 채널을 close 하면 닫는 식으로 간접 제어 하기도 하는 듯

package main

import (
"fmt"
"sync"
)

func main() {
var wg sync.WaitGroup
wg.Add(1)

ch := make(chan string)
go func() {
for {
channel, ok := <-ch
if !ok {
fmt.Println("Shut Down")
defer wg.Done()
return
}
fmt.Println(channel)
}
}()
ch <- "Start"
ch <- "Processing"
ch <- "Finishing"
close(ch)

wg.Wait()
}


[링크 :
https://www.golangprograms.com/how-to-kill-execution-of-goroutine.html]

'Programming > golang' 카테고리의 다른 글

golang make와 new  (0) 2022.09.06
golang defer 와 panic(), recover()  (0) 2022.09.06
golang https server  (0) 2022.09.05
golang 쿠키  (0) 2022.09.02
golang http redirect  (0) 2022.09.02
Posted by 구차니

stage 상태의 소스에 대해서 unstage 하지 않고 diff 하는 방법

 

[링크 : https://frhyme.github.io/git/git_diff_staged/]

'프로그램 사용 > Version Control' 카테고리의 다른 글

git stash drop , clear  (0) 2024.09.19
git submodule ... 2?  (0) 2024.06.19
git reset 서버 commit  (0) 2021.09.14
git blame  (0) 2021.06.21
git pull rebase 설정  (0) 2021.06.02
Posted by 구차니
Programming/golang2022. 9. 5. 13:47

http 서버는 쉽게 돌렸는데, https로 어떻게 돌리나 검색.

그런데 인증서 제작과정이 더 번거로운게 함정..(그게 아니면 Let's encrypt 이런거 써야하나..)

[링크 :https://dksshddl.tistory.com/entry/GO-https-제공을-위한-인증된-SSL과-서버-개인-키-생성하기]

 

http.ListenAndServe()를 사용했는데

두개 인자(cert, key)를 더 넣어주고 TLS만 붙이면 끝!

func ListenAndServe(addr string, handler Handler) error
func ListenAndServeTLS(addr, certFile, keyFile string, handler Handler) error

 

아무생각없이 했더니 :443으로 해주면 1024 포트 이하라 root 권한 필요하니 주의

package main

import (
"io"
"log"
"net/http"
)

func main() {
http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "Hello, TLS!\n")
})

// One can use generate_cert.go in crypto/tls to generate cert.pem and key.pem.
log.Printf("About to listen on 8443. Go to https://127.0.0.1:8443/")
err := http.ListenAndServeTLS(":8443", "cert.pem", "key.pem", nil)
log.Fatal(err)
}

[링크 : https://pkg.go.dev/net/http#ListenAndServe]

[링크 : https://pkg.go.dev/net/http#ListenAndServeTLS]

 

귀찮으니 한번에 대충 따라해서 생성

openssl genrsa -out server.key 2048
openssl req -new -key server.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
openssl rsa -in server.key -text > key.pem
openssl x509 -inform PEM -in server.crt -text > cert.pem

[링크 : https://0netw0m1ra.tistory.com/187]

'Programming > golang' 카테고리의 다른 글

golang defer 와 panic(), recover()  (0) 2022.09.06
go 루틴  (0) 2022.09.06
golang 쿠키  (0) 2022.09.02
golang http redirect  (0) 2022.09.02
golang html form post 처리하기  (0) 2022.09.02
Posted by 구차니
Programming/jquery2022. 9. 5. 11:57

서버에서 request cookie로 보내면 document.cookie로 접근이 가능한데

그걸 간단하게 사용하기 위한 라이브러리

[링크 : https://hailey0.tistory.com/38]

 

 

function getCookie(cname) {
  let name = cname + "=";
  let decodedCookie = decodeURIComponent(document.cookie);
  let ca = decodedCookie.split(';');
  for(let i = 0; i <ca.length; i++) {
    let c = ca[i];
    while (c.charAt(0) == ' ') {
      c = c.substring(1);
    }
    if (c.indexOf(name) == 0) {
      return c.substring(name.length, c.length);
    }
  }
  return "";
}

[링크 : https://www.w3schools.com/js/js_cookies.asp]

 

[링크 : https://nowonbun.tistory.com/634]

 

그나저나  document.cookie가 왜이렇게 생소하지?

'Programming > jquery' 카테고리의 다른 글

jquery ajax auth  (0) 2023.07.27
jquery ajax delete가 없다?  (0) 2022.09.16
jquery 우클릭 가로채기  (0) 2019.06.04
jquery ajax json flask  (0) 2019.01.07
jquery this 버튼 checked  (0) 2019.01.07
Posted by 구차니