Programming/rust2023. 5. 9. 13:04

테터링 걸어서 하려니 1번 선택하니 데이터 용량의 압박으로  3번 으로 진행

 

 

 

다운로드 크기 1.37GB...?!

 

3번으로 하면 아래와 같은 메시지가 나오면서 진행된다.

 

다운로드 용량은 좀 줄어, 그나마 테터링으로 비빌용량(100MB)이 나온다.


Rust Visual C++ prerequisites

Rust requires a linker and Windows API libraries but they don't seem to be
available.

These components can be acquired through a Visual Studio installer.

1) Quick install via the Visual Studio Community installer
   (free for individuals, academic uses, and open source).

2) Manually install the prerequisites
   (for enterprise and advanced users).

3) Don't install the prerequisites
   (if you're targeting the GNU ABI).

>3


Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  C:\Users\free\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  C:\Users\free\.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  C:\Users\free\.cargo\bin

This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-pc-windows-msvc
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

info: profile set to 'default'
info: default host triple is x86_64-pc-windows-msvc
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: latest update on 2023-04-20, rust version 1.69.0 (84c898d65 2023-04-16)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 13.4 MiB /  13.4 MiB (100 %)   9.9 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
 25.1 MiB /  25.1 MiB (100 %)   8.7 MiB/s in  2s ETA:  0s
info: downloading component 'rustc'
 58.9 MiB /  58.9 MiB (100 %)   9.4 MiB/s in  6s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
  4.1 MiB /   4.1 MiB (100 %)   3.4 MiB/s in  1s ETA:  0s
info: installing component 'clippy'
info: installing component 'rust-docs'
 13.4 MiB /  13.4 MiB (100 %)   1.3 MiB/s in 20s ETA:  0s
info: installing component 'rust-std'
 25.1 MiB /  25.1 MiB (100 %)   4.0 MiB/s in  6s ETA:  0s
info: installing component 'rustc'
 58.9 MiB /  58.9 MiB (100 %)   4.5 MiB/s in 13s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'

  stable-x86_64-pc-windows-msvc installed - rustc 1.69.0 (84c898d65 2023-04-16)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload its PATH environment variable to include
Cargo's bin directory (%USERPROFILE%\.cargo\bin).

Press the Enter key to continue.

 

근데.. 어떻게 실행하지 -ㅁ-?

 

+

하라는대로 환경변수에 아래꺼를 추가해주고 리부팅 하면 끝

%USERPROFILE%\.cargo\bin

 

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

rust if문  (0) 2023.05.11
rust rustup doc  (0) 2023.05.10
rust cargo new를 통한 프로젝트 생성  (0) 2023.05.09
rust 와 main.rs  (0) 2023.05.09
rust 문서 다운로드하기(cargo)  (0) 2023.05.09
Posted by 구차니
Programming/golang2023. 5. 8. 10:30

e.Static은 아래와 같이 접근 경로, 디렉토리(상대경로)로 설정되며

index.html은 연결되어도 디렉토리에 대해서 리스팅을 해주지 않는데

e := echo.New()
e.Static("/static", "assets")

 

e.Use에 middleware를 사용하고 Browse:true를 넣어주면

apache에서 처럼 index.html이 없는 디렉토리에서 목록을 리스팅해준다.

Root 는 static과 같이 입력하면 실행으로 부터 상대경로로, /static과 같이 입력하면 절대경로로 작동한다.

 

e := echo.New()
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
  Root:   "static",
  Browse: true,
}))

[링크 : https://stackoverflow.com/questions/45558773/serving-files-with-echo]

[링크 : https://echo.labstack.com/middleware/static/]

 

테스트 디렉토리에 아래와 같이 파일을 생성하고

# cd test
# ls -al
total 32
drwxr-xr-x    2 root     root         16384 May  8 10:52 .
drwxr-xr-x    6 root     root         16384 May  8 10:52 ..
-rwxr-xr-x    1 root     root             0 May  8 10:52 1.log
-rwxr-xr-x    1 root     root             0 May  8 10:52 2.log

 

localhost/test 로 접속하면 이쁘진 않은데 아래와 같이 목록이 출력된다.

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

golang mutex (sync)  (0) 2023.05.16
go 포맷터  (0) 2023.05.11
golang websocket binary  (0) 2023.03.28
golang 크로스 컴파일 GOARM GOARCH  (0) 2023.02.03
golang map 에 데이터 추가하기  (0) 2023.01.13
Posted by 구차니

내부적으로 이렇게 처리할 줄이야..

 

A number literal like 37 in JavaScript code is a floating-point value, not an integer. There is no separate integer type in common everyday use. (JavaScript also has a BigInt type, but it's not designed to replace Number for everyday uses. 37 is still a number, not a BigInt.)

[링크 : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number]

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

canvas 없는 getcontext  (0) 2023.07.12
html canvas와 시간 그래프 흘리기  (0) 2023.07.06
websocket binarytype  (0) 2023.04.04
자바스크립트 소수점 자르기  (0) 2023.03.13
Math.min.apply()  (0) 2023.02.07
Posted by 구차니

웹 브라우저에서 웹 소켓을 열면 기본값은 blob 으로 열리는데

Value
A string:

"blob"
Use Blob objects for binary data. This is the default value.

"arraybuffer"
Use ArrayBuffer objects for binary data.

 

binaryType을 지정하면 blob이 아닌 arraybuffer로 열 수 있다.

// Create WebSocket connection.
const socket = new WebSocket("ws://localhost:8080");

// Change binary type from "blob" to "arraybuffer"
socket.binaryType = "arraybuffer";

[링크 : https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType]

 

웹 소켓에서 blob이나 arraybuffer로 받는데

blob은 slice를 통해 자를수 있긴 한데 이래저래 행렬 처리가 아니다 보니 번거롭고

개인적인 취향으로는 blob을 받아서 arraybuffer로 변환하기 보다는 arraybuffer로 받아서 적당히 잘라쓰는 쪽 일 듯

blob은 contentType을 멀 지정해야 하나 조금 귀찮은 듯.. (타입이다 보니 int32, float64 이런게 아닐 것 같으니)

Syntax
slice()
slice(start)
slice(start, end)
slice(start, end, contentType)

[링크 : https://developer.mozilla.org/en-US/docs/Web/API/Blob/slice]

 

Convert an ArrayBuffer or typed array to a Blob
#
var array = new Uint8Array([0x04, 0x06, 0x07, 0x08]);
var blob = new Blob([array]);

[링크 : https://riptutorial.com/javascript/example/1390/converting-between-blobs-and-arraybuffers]

[링크 : https://velog.io/@chltjdrhd777/ArrayBuffer-와-Blob]

[링크 : https://heropy.blog/2019/02/28/blob/]

 

strToAB = str =>
  new Uint8Array(str.split('')
    .map(c => c.charCodeAt(0))).buffer;

ABToStr = ab => 
  new Uint8Array(ab).reduce((p, c) =>
  p + String.fromCharCode(c), '');

console.log(ABToStr(strToAB('hello world!')));

[링크 : https://stackoverflow.com/questions/39725716/]

[링크 : https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Int32Array]

 

[링크 : http://mohwa.github.io/blog/javascript/2015/08/31/binary-inJS/]

 

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

html canvas와 시간 그래프 흘리기  (0) 2023.07.06
javascript 정수는 정수가 아니다  (0) 2023.04.06
자바스크립트 소수점 자르기  (0) 2023.03.13
Math.min.apply()  (0) 2023.02.07
web 렌더러 벤치마크  (0) 2022.12.22
Posted by 구차니
Programming/web 관련2023. 3. 31. 12:15
Posted by 구차니
Programming/golang2023. 3. 28. 10:36

웹소켓을 통해 데이터를 JSON으로 변환해서 보내니 웹서버에 부하가 걸리는 것 같아서

binary 데이터 그대로~ 보내고 웹에서 binary를 처리하도록 하려고 찾아보는 중

 

서버 사이드(golang)

for {
    messageType, p, err := conn.ReadMessage()
    if err != nil {
        log.Println(err)
        return
    }
    if err := conn.WriteMessage(messageType, p); err != nil {
        log.Println(err)
        return
    }
}
In above snippet of code, p is a []byte and messageType is an int with value websocket.BinaryMessage or websocket.TextMessage.

[링크 : https://pkg.go.dev/github.com/gorilla/websocket#section-readme]

[링크 : https://kiwitrip.tistory.com/5]

 

클라이언트 사이드(웹 브라우저)

webSocket.onmessage = function (message) {
    var blob = message.data;
    var fileReader = new FileReader();
    fileReader.onload = function (event) {
        var arrayBuffer = event.target.result;
        var dataview = new DataView(arrayBuffer);
        var answer = dataview.getFloat64(0);
        alert("Server> : " + answer);
    };
    fileReader.readAsArrayBuffer(blob);
};

[링크 : http://www.gisdeveloper.co.kr/?p=5594]

 

+

23.04.04

var wsHost = "http://my-sites-url.com/path/to/echo-web-socket-handler";
var ws = new WebSocket(wsHost);
var buffer = new ArrayBuffer(5); // 5 byte buffer
var bufferView = new DataView(buffer);

bufferView.setFloat32(0, Math.PI);
bufferView.setUint8(4, 127);

ws.binaryType = 'arraybuffer';

ws.onmessage = function(message) {
    var view = new DataView(message.data);
    console.log('Uint8:', view.getUint8(4), 'Float32:', view.getFloat32(0))
};

ws.onopen = function() {
    ws.send(buffer);
};

[링크 : https://riptutorial.com/javascript/example/6661/working-with-binary-messages]

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

go 포맷터  (0) 2023.05.11
golang echo directory listing  (0) 2023.05.08
golang 크로스 컴파일 GOARM GOARCH  (0) 2023.02.03
golang map 에 데이터 추가하기  (0) 2023.01.13
golang reflect  (0) 2023.01.03
Posted by 구차니
Programming/web 관련2023. 3. 15. 11:25

chatGPT 님에게 server push 예제를 알려줘라고 했더니 아래와 같이 알려주신다.

Server push is a technique that allows a server to push data to a client without the client first making a request for the data. In JavaScript, this can be achieved using the Server-Sent Events (SSE) API.
Here's an example of how you can use SSE to implement server push in JavaScript:
On the server side, you need to create an endpoint that will send the SSE messages. In this example, we'll create a simple Node.js server:
const http = require('http');

const server = http.createServer((req, res) => {
  if (req.url === '/sse') {
    res.writeHead(200, {
      'Content-Type': 'text/event-stream',
      'Cache-Control': 'no-cache',
      'Connection': 'keep-alive'
    });

    setInterval(() => {
      res.write(`data: ${new Date().toISOString()}\n\n`);
    }, 1000);
  } else {
    res.writeHead(404);
    res.end();
  }
});

server.listen(3000);
const source = new EventSource('/sse');

source.onmessage = (event) => {
  console.log(event.data);
};

 

아무튼 SSE를 검색해보는데.. jquery 연관은 잘 안보이고

EventSource.onmessage() 로 처리 가능만 하다면야 머...

[링크 : https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events]

 

 

+

golang의 REST / websocket 제거하고 cgi로 돌리려는 어마어마한 음모가! ㅠㅠ

'Programming > web 관련' 카테고리의 다른 글

webGPU  (0) 2023.05.18
chart.js log 스케일  (0) 2023.03.31
chart.js 특정 항목 보이지 않게 하기(가로줄 치기)  (0) 2023.03.10
chart.js 수직 도움선  (0) 2023.01.27
JWT 로그인 예제  (0) 2022.08.24
Posted by 구차니

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

javascript 정수는 정수가 아니다  (0) 2023.04.06
websocket binarytype  (0) 2023.04.04
Math.min.apply()  (0) 2023.02.07
web 렌더러 벤치마크  (0) 2022.12.22
웹에서 f5 갱신 막기  (0) 2019.06.04
Posted by 구차니
Programming/web 관련2023. 3. 10. 16:23

클릭하면 당연히(?) 줄 그어져서 죽는데

코드로 처음부터 해당 항목을 hidden 상태로 표시하려니 먼가 묘하게 어렵다?

 

function(e, legendItem, legend) {
    const index = legendItem.datasetIndex;
    const ci = legend.chart;
    if (ci.isDatasetVisible(index)) {
        ci.hide(index);
        legendItem.hidden = true;
    } else {
        ci.show(index);
        legendItem.hidden = false;
    }
}

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

 

매우 귀찮으니(!)

chart 라는 변수에 chart.js 객체가 존재한다면

아래의 legned.chart.hide(index) 로 끄고 legned.chart.show(index) 로 표시할 수 있다.

index 이니 0부터 시작함에 주의!

//var chart = new chart()
chart.legend.chart.hide(1)
chart.legend.chart.show(1)

'Programming > web 관련' 카테고리의 다른 글

chart.js log 스케일  (0) 2023.03.31
chatGPT님 가라사대 Server-Sent Events (SSE)  (0) 2023.03.15
chart.js 수직 도움선  (0) 2023.01.27
JWT 로그인 예제  (0) 2022.08.24
quirks mode  (0) 2022.08.08
Posted by 구차니

matplotlib을 이용하여 python 에서 그래프를 그리려고 하는데 그려지지 않아서 고생 -_-

그냥 설치하면 이상한(?) 에러가 발생하면서 중단되는데

나의 경우에는 jpeg 라이브러리 없다고 배쨰는 중. 그래서 libjpeg 등을 설치하고 Pillow 라는 python 패키지를 설치후

matplotlib을 설치하니 해결되었다.

 

sudo apt install libjpeg-dev zlib1g-dev
pip install Pillow

[링크 : https://stackoverflow.com/questions/44043906/the-headers-or-library-files-could-not-be-found-for-jpeg-installing-pillow-on]

pip3 install matplotlib

[링크 : https://www.zinnunkebi.com/python-modulenotfounderror-matplotlib/]

'Programming > python(파이썬)' 카테고리의 다른 글

matplotlib  (0) 2023.10.04
pyplot  (0) 2023.10.04
python openCV / PIL 포맷 변경  (0) 2022.04.12
파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip  (0) 2022.04.12
python interactive mode  (0) 2022.03.15
Posted by 구차니