'Programming'에 해당되는 글 1854건

  1. 2023.01.27 chart.js 수직 도움선
  2. 2023.01.13 golang map 에 데이터 추가하기
  3. 2023.01.04 c에서 cpp 함수 불러오기
  4. 2023.01.03 golang reflect
  5. 2023.01.03 golang unsafe
  6. 2023.01.03 golang 웹 pprof
  7. 2022.12.22 web 렌더러 벤치마크
  8. 2022.11.22 golang shared memory 모듈
  9. 2022.11.17 glReadPixels() 와 glUseProgram()
  10. 2022.10.07 golang net.TCPConn
Programming/chart.js2023. 1. 27. 14:28

chart.js의 interaction 항목을 intersect = false로 해주면

 

var chart_obj = new Chart(chart, {
plugins: [{
afterDraw: chart => {
  if (chart.tooltip?._active?.length)
  {               
 let x = chart.tooltip._active[0].element.x;             
 let yAxis = chart.scales.y;
 let ctx = chart.ctx;
 ctx.save();
 ctx.beginPath();
 ctx.moveTo(x, yAxis.top);
 ctx.lineTo(x, yAxis.bottom);
 ctx.lineWidth = 1;
 ctx.strokeStyle = 'rgba(0, 0, 255, 0.4)';
 ctx.stroke();
 ctx.restore();
  }
}
  }],

// ...

options: {
animation : false,
interaction: {
            intersect: false,
            mode: 'index',
          },
spanGaps: true
}

[링크 : https://stackoverflow.com/questions/68058199/chartjs-need-help-on-drawing-a-vertical-line-when-hovering-cursor]

 

options.interaction.mode
nearest - 근접한 위치의 포인트를 툴팁으로 표시 (기본값)
index - 여러개의 데이터가 있을 경우 모아서 툴팁으로 표시

optiones.interaction.intersect
true - 선에 겹쳐야만 툴팁 표시
false - 해당되는 x 축에 대해서 툴팁 표시

[링크 : https://www.chartjs.org/docs/latest/configuration/interactions.html]

Posted by 구차니
Programming/golang2023. 1. 13. 21:00

동적 길이를 지니는 map은 없나?

 

package main

import (
    "fmt"

    "github.com/mitchellh/mapstructure"
)

type MyStruct struct {
    Name string `mapstructure:"name"`
    Age  int64  `mapstructure:"age"`
}

func main() {
    myData := make(map[string]interface{})
    myData["Name"] = "Wookiist"
    myData["Age"] = int64(27)

    result := &MyStruct{}
    if err := mapstructure.Decode(myData, &result); err != nil {
        fmt.Println(err)
    }
    fmt.Println(result)
}

[링크 : https://wookiist.dev/107]

 

걍 추가하면 되는 듯?

package main

import "fmt"

func main() {
// employee 라는 map 타입의 자료가 있습니다.
var employee = map[string]int{
"Mark":  10,
"Sandy": 20,
"Rocky": 30,
"Rajiv": 40,
"Kate":  50,
}

// employee map 타입의 자료를 iterate하는 방법은
// for range 문구를 사용하는 겁니다.
// key, element 를 지정하면 해당 key와 value를
// 각각 key, element라는 변수로 액세스할 수 있습니다.
for key, element := range employee {
fmt.Println("Key:", key, "=>", "Element:", element)
}

// employee map 타입에 자료를 추가해 봅시다.
employee["Lunar"] = 60
employee["Mars"] = 70

// employee map 타입의 자료중 기존 자료 업데이트하기
employee["Mark"] = 15

// 수정 된 후 출력하기
fmt.Println("after modified")
for key, element := range employee {
fmt.Println("Key:", key, "=>", "Element:", element)
}

// Map data 삭제하기 - delete 함수 이용
delete(employee,"Mark")

// 수정 된 후 출력하기
fmt.Println("after modified")
for key, element := range employee {
fmt.Println("Key:", key, "=>", "Element:", element)
}

// 빈 Map 타입 생성
employeeList := make(map[string]int)

// Map 자료의 갯수는 len함수로 쉽게 구할 수 있습니다.
fmt.Println(len(employee))     // 2
fmt.Println(len(employeeList)) // 0
}

[링크 : https://cpro95.tistory.com/155]

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

golang websocket binary  (0) 2023.03.28
golang 크로스 컴파일 GOARM GOARCH  (0) 2023.02.03
golang reflect  (0) 2023.01.03
golang unsafe  (0) 2023.01.03
golang 웹 pprof  (0) 2023.01.03
Posted by 구차니
Programming/C Win32 MFC2023. 1. 4. 18:58

수정없이 사용하려면

so로 빌드하고 해당 cpp so를 호출하는 class에 속하지 않은 함수로 만들고

그걸 extern c로 불러와야 할 듯

 

[링크 : https://stackoverflow.com/questions/2744181/how-to-call-c-function-from-c]

[링크 : http://www.parashift.com/c++-faq-lite/c-calls-cpp.html]

 

[링크 : https://stackoverflow.com/questions/7281441/elegantly-call-c-from-c]

[링크 : https://5kyc1ad.tistory.com/343]

'Programming > C Win32 MFC' 카테고리의 다른 글

float 자릿수 제한  (0) 2025.10.11
free(): invalid next size (normal)  (0) 2023.12.18
MSB / LSB 변환  (0) 2022.08.29
kore - c restful api server  (1) 2022.07.07
fopen exclusivly  (0) 2021.07.09
Posted by 구차니
Programming/golang2023. 1. 3. 19:05

먼가 여기저기서 나오는데 정체를 모르겠다.

 

[링크 : https://pkg.go.dev/reflect]

 

copy 말고 Copy인데.. copy는 그럼 누구꺼지?

[링크 : https://pkg.go.dev/reflect#Copy]

 

빌트인 패키지라는데 primitive로 봐도 되려나?

[링크 : https://golangbyexample.com/copy-function-in-golang/]

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

golang 크로스 컴파일 GOARM GOARCH  (0) 2023.02.03
golang map 에 데이터 추가하기  (0) 2023.01.13
golang unsafe  (0) 2023.01.03
golang 웹 pprof  (0) 2023.01.03
golang shared memory 모듈  (0) 2022.11.22
Posted by 구차니
Programming/golang2023. 1. 3. 19:03

멀 하던 성능을 위해서는 unsafe를 쓸 수 밖에 없나?

shared memory의 내용을 Binary Reader를 통해 읽으니 이상하리 만치 너~~~무 느리다.

 

[링크 : https://hackernoon.com/golang-unsafe-type-conversions-and-memory-access-odz3yrl]

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

golang map 에 데이터 추가하기  (0) 2023.01.13
golang reflect  (0) 2023.01.03
golang 웹 pprof  (0) 2023.01.03
golang shared memory 모듈  (0) 2022.11.22
golang net.TCPConn  (0) 2022.10.07
Posted by 구차니
Programming/golang2023. 1. 3. 15:21

0.0.0.0:6060 으로 하면 외부에서도 접근 가능하게 설정이 가능하다.

근데 멀 눌러야 사용율이 잘 나올까...

 

import _ "net/http/pprof"

go func() {
    log.Println(http.ListenAndServe("localhost:6060", nil))
}()

[링크 : https://coralogix.com/blog/optimizing-a-golang-service-to-reduce-over-40-cpu/]

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

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

golang reflect  (0) 2023.01.03
golang unsafe  (0) 2023.01.03
golang shared memory 모듈  (0) 2022.11.22
golang net.TCPConn  (0) 2022.10.07
golang 변수 타입 알아내기  (0) 2022.10.05
Posted by 구차니

현재 사용중인 컴퓨터(i5-10210U) 에서 해보니

2000개(기본값 기준)

27~32 fps svg

42~48 fps canvas

60~61 fps webgl(아마도.. 측정불가?)

 

10000개

6~7 fps svg

11~12 fps canvas

60~61 fps webgl(아마도.. 측정불가?)

 

[링크 : https://ahoak.github.io/renderer-benchmark/]

   [링크 : https://github.com/ahoak/renderer-benchmark]

 

최적화 방법에 따라 달라지지만

SVG < canvas < webGL 순서로 성능이 올라가는 듯.

 

[링크 : https://www.yworks.com/blog/svg-canvas-webgl]

[링크 : https://blog.scottlogic.com/2020/05/01/rendering-one-million-points-with-d3.html]

'Programming > javascript & HTML' 카테고리의 다른 글

자바스크립트 소수점 자르기  (0) 2023.03.13
Math.min.apply()  (0) 2023.02.07
웹에서 f5 갱신 막기  (0) 2019.06.04
cose network graph  (0) 2019.06.03
HTTP 302 redirect  (0) 2019.04.26
Posted by 구차니
Programming/golang2022. 11. 22. 18:11

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

golang unsafe  (0) 2023.01.03
golang 웹 pprof  (0) 2023.01.03
golang net.TCPConn  (0) 2022.10.07
golang 변수 타입 알아내기  (0) 2022.10.05
cgo  (0) 2022.10.04
Posted by 구차니
Programming/openGL2022. 11. 17. 17:49

wayland / weston 에서 glReadPixels를 통해 읽어 오는게 실패해서 찾아보니

glUserProgram()을 하면 된다는데.. 문제는 어떤 컨텍스트의 정보를 어떻게 받아오냐 일 듯..

 

glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, output->width, output->height, GL_RGBA, GL_UNSIGNED_BYTE, data);

[링크 : https://github.com/ereslibre/wayland/blob/master/compositor/screenshooter.c]

 

It's an error to call anything but a very limited set of functions between glBegin and glEnd. That list is mostly composed of functions related to specifying attributes of a vertex (e.g., glVertex, glNormal, glColor, glTexCoord, etc.).

So, if your OpenGL implementation is following the OpenGL specification, glReadPixels should return immediately without executing because of being called within a glBegin/glEnd group. Remove those from around your calls, and glReadPixels should work as expected.

[링크 : https://stackoverflow.com/questions/19351568/glreadpixels-doesnt-work]

 

I figured it out. All I had to do was add glUseProgram(0) at the very end of the draw cylinder function. After more than 3 weeks of looking into this.

[링크 : https://computergraphics.stackexchange.com/questions/8354/why-is-glreadpixels-only-working-in-certain-cases]

 

glUseProgram — Installs a program object as part of current rendering state

[링크 : https://registry.khronos.org/OpenGL-Refpages/gl4/html/glUseProgram.xhtml]

[링크 : https://stackoverflow.com/questions/13546461/what-does-gluseprogram0-do]

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

blender in openGL  (0) 2025.04.28
opengl glortho gluperspective  (0) 2023.08.28
openCV + openGL  (0) 2022.02.08
glMatrixMode()  (0) 2020.04.14
opengl superbible 3rd 리눅스 빌드 패키지  (0) 2020.04.08
Posted by 구차니
Programming/golang2022. 10. 7. 18:00

net.Listen() 으로 받은것을

sock.Accept()로 받아 어떤 FD에 저장이 되어서 처리되고 있나를 보고 싶은데

(왜 굳이 이게 필요한 진 묻지 말자. 걍 보고 싶었음)

 

아래와 같이 8000번 열고 nc localhost 8000 하면 접속이 가능하다.

그나저나 conn.File()은 없는 메소드라 나오고

conn.(*net.TCPConn).File()은 되는데 타입 캐스팅인가? 도대체 무슨 문법이지?

tcp_sock, err := net.Listen("tcp", ":8000")
if err != nil {
        fmt.Println(err)
}

for {
        conn, err := tcp_sock.Accept()
        if err != nil {
                fmt.Println(err)
                continue
        }
        fmt.Println(conn)
        fd, err := conn.(*net.TCPConn).File()
        if err != nil {
                fmt.Println(fd.Fd())
        }
        fmt.Println(reflect.TypeOf(conn))
        fmt.Println(conn.LocalAddr())
        fmt.Println(conn.RemoteAddr())
}
fmt.Println("done")
&{{0xc0000a0180}}
*net.TCPConn
127.0.0.1:8000
127.0.0.1:37690

위와 같이 출력된다. 왜 그러나 했더니 포인터 형태로 리턴되는건데, 이걸 출력하려면 unsafe를 써야 하는건가..

 

[링크 : https://pkg.go.dev/net#TCPConn.File]

[링크 : https://pkg.go.dev/os#File.Fd]

[링크 : https://pkg.go.dev/builtin#uintptr]

 

+

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

 

Type assertions

[링크 : https://go.dev/tour/methods/15]

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

golang 웹 pprof  (0) 2023.01.03
golang shared memory 모듈  (0) 2022.11.22
golang 변수 타입 알아내기  (0) 2022.10.05
cgo  (0) 2022.10.04
golang unsafe package  (0) 2022.10.01
Posted by 구차니