Programming/rust2023. 5. 9. 13:17

설치할때 msvc가 안깔려서 그런가 무슨 link 없다고 배짼다.

인터넷이 되는 천국에 가면 다시 해봐야겠네

 

The HTML format is available online at https://doc.rust-lang.org/stable/book/ and offline with installations of Rust made with rustup; run rustup docs --book to open.

[링크 : https://doc.rust-lang.org/book/]

 

Requirements
Building the book requires mdBook, ideally the same version that rust-lang/rust uses in this file. To get it:
$ cargo install mdbook --version <version_num>

Building
To build the book, type:
$ mdbook build

[링크 : https://github.com/rust-lang/book]

 

+

msvc 깔고 재시도

C:\Users\user\Desktop\study\rust\hello_cargo\target\debug>cargo install mdbook
    Updating crates.io index
  Installing mdbook v0.4.28
   Compiling proc-macro2 v1.0.56
   Compiling quote v1.0.27
   Compiling unicode-ident v1.0.8
   Compiling cfg-if v1.0.0
   Compiling autocfg v1.1.0
   Compiling windows_x86_64_msvc v0.48.0
   Compiling windows_x86_64_msvc v0.42.2
   Compiling windows-targets v0.48.0
   Compiling version_check v0.9.4
   Compiling windows-sys v0.48.0
   Compiling winapi v0.3.9
   Compiling syn v2.0.15
   Compiling log v0.4.17
   Compiling windows-targets v0.42.2
   Compiling windows-sys v0.45.0
   Compiling itoa v1.0.6
   Compiling serde_derive v1.0.162
   Compiling thiserror v1.0.40
   Compiling once_cell v1.17.1
   Compiling serde v1.0.162
   Compiling bytes v1.4.0
   Compiling getrandom v0.2.9
   Compiling typenum v1.16.0
   Compiling rand_core v0.6.4
   Compiling generic-array v0.14.7
   Compiling ppv-lite86 v0.2.17
   Compiling pin-project-lite v0.2.9
   Compiling futures-core v0.3.28
   Compiling rand_chacha v0.3.1
   Compiling unicase v2.6.0
   Compiling fnv v1.0.7
   Compiling thiserror-impl v1.0.40
   Compiling siphasher v0.3.10
   Compiling syn v1.0.109
   Compiling phf_shared v0.10.0
   Compiling rand v0.8.5
   Compiling http v0.2.9
   Compiling tokio v1.28.0
   Compiling tinyvec_macros v0.1.1
   Compiling io-lifetimes v1.0.10
   Compiling bitflags v1.3.2
   Compiling tinyvec v1.6.0
   Compiling phf_generator v0.10.0
   Compiling tokio-macros v2.1.0
   Compiling socket2 v0.4.9
   Compiling mio v0.8.6
   Compiling lock_api v0.4.9
   Compiling slab v0.4.8
   Compiling futures-sink v0.3.28
   Compiling memchr v2.5.0
   Compiling parking_lot_core v0.9.7
   Compiling percent-encoding v2.2.0
   Compiling num_cpus v1.15.0
   Compiling utf-8 v0.7.6
   Compiling futures-task v0.3.28
   Compiling form_urlencoded v1.1.0
   Compiling unicode-normalization v0.1.22
   Compiling crypto-common v0.1.6
   Compiling block-buffer v0.10.4
   Compiling winapi-util v0.1.5
   Compiling scopeguard v1.1.0
   Compiling new_debug_unreachable v1.0.4
   Compiling httparse v1.8.0
   Compiling futures-util v0.3.28
   Compiling smallvec v1.10.0
   Compiling unicode-bidi v0.3.13
   Compiling idna v0.3.0
   Compiling digest v0.10.6
   Compiling is-terminal v0.4.7
   Compiling phf_codegen v0.10.0
   Compiling string_cache_codegen v0.5.2
   Compiling futures-macro v0.3.28
   Compiling tracing-core v0.1.30
   Compiling indexmap v1.9.3
   Compiling crossbeam-utils v0.8.15
   Compiling cpufeatures v0.2.7
   Compiling mac v0.1.1
   Compiling pin-utils v0.1.0
   Compiling anstyle v1.0.0
   Compiling ucd-trie v0.1.5
   Compiling ryu v1.0.13
   Compiling serde_json v1.0.96
   Compiling utf8parse v0.2.1
   Compiling anstyle-parse v0.2.0
   Compiling pest v2.6.0
   Compiling anstyle-wincon v1.0.1
   Compiling futf v0.1.5
   Compiling sha1 v0.10.5
   Compiling tracing v0.1.37
   Compiling markup5ever v0.11.0
   Compiling parking_lot v0.12.1
   Compiling url v2.3.1
   Compiling anstyle-query v1.0.0
   Compiling num-traits v0.2.15
   Compiling base64 v0.13.1
   Compiling futures-channel v0.3.28
   Compiling hashbrown v0.12.3
   Compiling colorchoice v1.0.0
   Compiling libc v0.2.144
   Compiling precomputed-hash v0.1.1
   Compiling string_cache v0.8.7
   Compiling anstream v0.3.2
   Compiling pest_meta v2.6.0
   Compiling mime_guess v2.0.4
   Compiling tokio-util v0.7.8
   Compiling tendril v0.4.3
   Compiling aho-corasick v1.0.1
   Compiling phf v0.10.1
   Compiling html5ever v0.26.0
   Compiling same-file v1.0.6
   Compiling terminal_size v0.2.6
   Compiling num-integer v0.1.45
   Compiling clap_lex v0.4.1
   Compiling regex-syntax v0.7.1
   Compiling mime v0.3.17
   Compiling strsim v0.10.0
   Compiling httpdate v1.0.2
   Compiling try-lock v0.2.4
   Compiling byteorder v1.4.3
   Compiling want v0.3.0
   Compiling tungstenite v0.18.0
   Compiling regex v1.8.1
   Compiling clap_builder v4.2.7
   Compiling walkdir v2.3.3
   Compiling crossbeam-channel v0.5.8
   Compiling h2 v0.3.18
   Compiling pest_generator v2.6.0
   Compiling pin-project-internal v1.0.12
   Compiling headers-core v0.2.0
   Compiling http-body v0.4.5
   Compiling filetime v0.2.21
   Compiling windows-sys v0.42.0
   Compiling anyhow v1.0.71
   Compiling tower-service v0.3.2
   Compiling base64 v0.21.0
   Compiling pulldown-cmark v0.9.2
   Compiling notify v5.1.0
   Compiling rustls-pemfile v1.0.2
   Compiling hyper v0.14.26
   Compiling headers v0.3.8
   Compiling pin-project v1.0.12
   Compiling pest_derive v2.6.0
   Compiling clap v4.2.7
   Compiling tokio-tungstenite v0.18.0
   Compiling serde_urlencoded v0.7.1
   Compiling tokio-stream v0.1.14
   Compiling termcolor v1.2.0
   Compiling fastrand v1.9.0
   Compiling maplit v1.0.2
   Compiling humantime v2.1.0
   Compiling scoped-tls v1.0.1
   Compiling glob v0.3.1
   Compiling warp v0.3.5
   Compiling env_logger v0.10.0
   Compiling gitignore v1.0.8
   Compiling tempfile v3.5.0
   Compiling ammonia v3.3.0
   Compiling clap_complete v4.2.1
   Compiling handlebars v4.3.6
   Compiling chrono v0.4.24
   Compiling notify-debouncer-mini v0.2.1
   Compiling elasticlunr-rs v3.0.2
   Compiling toml v0.5.11
   Compiling opener v0.5.2
   Compiling shlex v1.1.0
   Compiling topological-sort v0.2.2
   Compiling mdbook v0.4.28
    Finished release [optimized] target(s) in 5m 26s
  Installing C:\Users\user\.cargo\bin\mdbook.exe
   Installed package `mdbook v0.4.28` (executable `mdbook.exe`)

'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 in windows  (0) 2023.05.09
Posted by 구차니
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 구차니