ゆずめも

メモ的なブログです。主に勉強した事について書いてます。

サードパーティ製のipad用のペンシル買ってみたのでレビューする

数年使ってるipad mini 5だとpdfの資料が見づらい時があったので、ちょっと前にipad airを購入した。

イラスト描かないし第二世代ペンシルいらないと思ってたがリモートで絵を書いて伝えるときにairでやりたい時が出てきて、公式のペン買うほどではないので筆圧検知が無い変わりに価格が約1/10だったのでサードパーティ製のものを買ってみた。

比較レビュー

第一世代 + ipad mini5と上記のペン + ipad airの比較なのでどこまでに当てになるのかわからないけど

若干線画が遅い気がする

試しにiosのノートアプリで適当に文字を書いてみた。不自由することは無いがちょっと線画が遅い気がする

電源のオン・オフを上部タップで行う

apple pencilの第二世代はどうなのかわからないけど、第一世代は任意のタイミングでオフにできなくていざ使おうと思うと充電切れの時がちょこちょこあった。これで充電切れ起こしにくくなるなら結構良いのかもしれない。amazonのレビューではオン・オフしづらいとあったが個人的には特に気にならなかった。

第二世代のapple pencilのようにipadにマグネット?でくっつけれる

買ったばかりでどこまでメリットかわからないけど、くっつけておけば置き場所に困ることはないので便利そう

usb-cで充電できる

usb-aだけかと思ったらusb-a to usb-cのアダプタもついていたのでusb-cからも充電できる。 公式ペンシル2だとマグネットで充電できる?のでケーブルとか持ち歩く必要性がないのはいいなと思うけど、それのためにお金出すかといわれるとうーん…

2023/03/21 追記

現在のバッテリー状態がわからない

今どのくらいバッテリー残量あるのかがわからないので全然充電してない。でもなんか使えてるのでよくわからない。

まとめ

自分と同じようにイラストを書くわけではなく四角とか丸とか線を引いて、たまに文字書くくらいの用途だと全然これで良さそう。あとはすぐ壊れたみたいなレビューがあったのでどうかな〜

aws-cdkでapigatewayに独自ドメインを設定する

自分のメモ用

前提

紐付けたいドメイン(例: example.com)をroute53に登録し、NSレコードのdns設定が済んでいる。

独自ドメインを設定するための定義

api gatewayapi.example.comを設定する

import * as apigw from "aws-cdk-lib/aws-apigateway";
import * as acm from "aws-cdk-lib/aws-certificatemanager";
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
import * as route53 from "aws-cdk-lib/aws-route53";
import * as route53Tg from "aws-cdk-lib/aws-route53-targets";

const hostedZone = route53.HostedZone.fromHostedZoneAttributes(
  this,
  "HostedZone",
  {
    hostedZoneId: "hostedZoneId", // route53のコンソールから確認できるID
    zoneName: "example.com", // 紐付けたいドメイン
  },
);

// httpsにしたいのでacmを使用する
const certificate = new acm.Certificate(this, "APIDomainCertificate", {
  domainName: "api.example.com",
  validation: acm.CertificateValidation.fromDns(hostedZone),
});

const lambda = new NodejsFunction({/* 省略 */});

// apigwの用意
const httpEndpoint = new apigw.RestApi(this, "HttpEndpoint", {
  restApiName: "hello",
  endpointTypes: [apigw.EndpointType.REGIONAL],
});

httpEndpoint.root.addMethod("GET", new apigw.LambdaIntegration(lambda));

// apigwとドメインを紐付ける
const customDomain = httpEndpoint.addDomainName("CustomDomain", {
  domainName: "api.example.com",
  certificate,
  endpointType: apigw.EndpointType.REGIONAL,
});

const aRecord = new route53.ARecord(this, "WebApiARecord", {
  recordName: "api.example.com.",
  zone: hostedZone,
  target: route53.RecordTarget.fromAlias(
    new route53Tg.ApiGatewayDomain(customDomain),
  ),
});

これをcdk deployするとhttps://api.example.comにアクセスするとlambdaを呼び出す事ができる

デフォルトで設定されるドメインをオフにする

カスタムドメインを設定してもApi Gatewayがデフォルトで生成するエンドポイントにはアクセスできたのでこれを無効にする。
disableExecuteApiEndpoint: trueを設定するとログにはエンドポイントが表示されるがリクエストをすると403が返ってきてアクセスができないようになっている。

const httpEndpoint = new apigw.RestApi(this, 'HttpEndpoint', {
  restApiName: 'hello',
  endpointTypes: [EndpointType.REGIONAL],
  disableExecuteApiEndpoint: true, // 追加
})

flutterインストールして起動してみた

flutterのmacosへのインストールをnotionにメモしてたのでそれを公開 *1

インストール

直接入れるよりも nodebrew 的な fvm を利用して入れるのが良さそう

fvm.app

macへのインストール

install

brew tap leoafarias/fvm
brew install fvm

uninstall

brew uninstall fvm
brew untap leoafarias/fvm

fvm入れたら dart が入ってきた

プロジェクトの作成

fvm install stableしたあとにfvm flutter create してもダメで、先に fvm use <version> --force で無理やり初期化してやる必要がある(fvmのドキュメントでflutterの公式のインストール方法に従ってflutterをグローバルにインストールすることを推奨してるので、 flutter コマンドプロキシしてcreateとかが楽にできたりするのか…?)

iosでのrun

デフォルトのアプリが起動できるかやってみる

fvm flutter doctor を実行すると以下のように設定できているものの一覧が出る。下記の例だとAndroidiosもできてなくてchrome(web)だけ使える。直前にxcodeのインストールだけApp Storeからやってしまったので入れてない場合の表記はわからない。

[✓] Flutter (Channel stable, 3.3.9, on macOS 12.6.1 21G217 darwin-arm, locale ja-JP)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.

[!] Xcode - develop for iOS and macOS (Xcode 14.1)
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web

(cocoapodsがrubyに依存してたりでめんどくさくなってきた)

ちなみにxcodeというかiosのセットアップはflutterのios setupの部分を参考にした

docs.flutter.dev

cocoapodsインストール

自分はhomebrewでcocoapodsインストールするだけでdoctorが大丈夫になった

brew install cocoapods

インストールが終わったらios simulatorが立ち上がる事を確認する

open -a Simulator

画面サイズ等変えれるがなんとなくiphone se第3世代にした

設定後の確認

emulatorsdevices というコマンドがあるらしいが違いはよくわかってない。いろんな記事でemulatorsコマンドで apple_ios_simulator • iOS Simulator • Apple • ios というのが表示されると書いてたが表示されなかった

> fvm flutter emulators
Unable to find any emulator sources. Please ensure you have some
Android AVD images or an iOS Simulator available.

> fvm flutter devices
3 connected devices:

iPhone SE (3rd generation) (mobile) • <UUID>                               • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-1 (simulator)
macOS (desktop)                     • macos                                • darwin-arm64   • macOS 12.6.1 xxxxxx darwin-arm
Chrome (web)                        • chrome                               • web-javascript • Google Chrome xxxxxxx

実行

ios simulatorを立ち上げてる状態でflutter run コマンドを使うと自動的にシミュレーター上でアプリが立ち上がってきた

flutter run

# 端末を指定したい時
flutter run -d chrome

(devicesコマンドで取れたmacosとかchromeと書かれた部分でios立ち上げたかったらuuid指定するのか?)

editorの設定

まだプラグイン入れただけで特に何もしてないがこの辺参考にすると良さそう

dev.classmethod.jp

まとめ

しょうがないけど初期セットアップがめんどくさいな。。主にxcodeのインストールだけど。。

とりあえずバージョンマネージャー入れて動かすところまでを忘れる前にメモ的に書いてるので、本当はこうやったほうがいいと言ったようなことがあれば知りたい。

*1:notionのものをexportしてはてなブログに貼ったらどうなるのかも実験したかった