眠気.jl

投稿=不定期

CypressがERR_FAILED (-2)になったときの対処:備忘録

エラー

ERR_FAILED (-2) loading 'http://todomvc.com/'
Error: ERR_FAILED (-2) loading 'http://todomvc.com/'
    at rejectAndCleanup (node:electron/js2c/browser_init:165:7500)
    at EventEmitter.stopLoadingListener (node:electron/js2c/browser_init:165:7875)
    at EventEmitter.emit (node:events:527:28)

対処方

--browser chromeオプションをつける

  "scripts": {
    "cypress:run": "cypress run --browser chrome"
  },

原因?

デフォルト(Electron)だとクラッシュする(ときもある)らしい

Cypress 10 component test crash after 100~ tests · Issue #22208 · cypress-io/cypress · GitHub

Yewで作ったアプリをAmplifyにデプロイした:備忘録

前回

www.mathwithjulia.com

作ったYewのアプリをAmplifyでホスティングできたのでamplify.ymlを公開しておきます

version: 1
frontend:
  phases:
    preBuild:
      commands:
        - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
        - source ~/.cargo/env
        - cargo install --locked trunk
        - rustup target add wasm32-unknown-unknown
    build:
      commands:
        - trunk build --release
  artifacts:
    baseDirectory: dist
    files:
      - "**/*"
  cache:
    paths:
      - target/**/*

YewでMaterialUIが使えるらしいmaterial-yew使ってみた:備忘録(Rust)

Yewプロジェクトの準備

cargo newで作る方法 Tutorial | Yew と、cargo new --libで作る方法 Getting Started | Yew がありますが、今回はcargo newで準備します

cargo install trunk
rustup target add wasm32-unknown-unknown
cargo new yew mui

Cargo.toml追記

yew = { version = "0.20", features = ["csr"] }
material-yew = { git = "https://github.com/ootoo1/material-yew.git", features = ["full"] }

src/main.rs編集
Click me!に対してMatButtonを充てる

use yew::prelude::*;
use yew::html;
use material_yew::MatButton;

#[function_component]
fn HelloWorld() -> Html {
    html! {<MatButton label="Click me!" />}
}

#[function_component(App)]
fn app() -> Html {
    html! {
        <>
        <h1>{ "Hello World" }</h1>
        <HelloWorld />
        </>
    }
}

fn main() {
    yew::Renderer::<App>::new().render();
}

index.html作成

<!DOCTYPE html>
<html lang="en">
    <head> </head>
    <body></body>
</html>

serve

trunk serve --open

MatButtonが反映されてる

YewでJSONをHTML表示: チュートリアルの備忘録

struct Video {
    id: usize,
    title: String,
    speaker: String,
    url: String,
}
let videos = vec![
    Video {
        id: 1,
        title: "Building and breaking things".to_string(),
        speaker: "John Doe".to_string(),
        url: "https://youtu.be/PsaFVLr8t4E".to_string(),
    },
    Video {
        id: 2,
        title: "The development process".to_string(),
        speaker: "Jane Smith".to_string(),
        url: "https://youtu.be/PsaFVLr8t4E".to_string(),
    },
    Video {
        id: 3,
        title: "The Web 7.0".to_string(),
        speaker: "Matt Miller".to_string(),
        url: "https://youtu.be/PsaFVLr8t4E".to_string(),
    },
    Video {
        id: 4,
        title: "Mouseless development".to_string(),
        speaker: "Tom Jerry".to_string(),
        url: "https://youtu.be/PsaFVLr8t4E".to_string(),
    },
];

to html

let videos = videos.iter().map(|video| html! {
    <p key={video.id}>{format!("{}: {}", video.speaker, video.title)}</p>
}).collect::<Html>();

render

html! {
  { videos }
}

Tutorial | Yew

日記

1 今日

焼肉行った、美味しかった。おごったので明日から雑草食べて暮らします。

2 畳と女と食洗機

ばじるさんとおそろいの食洗機買っちゃいました、すごいですか?
今までの食洗機大体1年で動作不良起こしていたので、今回は5年保証に加入して箱も保存しました、大事にします。

3 axumがなんかこける

axumを0.4.8から0.6.1にあげたら

use axum::extract::RequestParts

error[E0432]: unresolved import `axum::extract::RequestParts`

になりましたが代替記法がまだ見つかってません