JavaScript:クレジットカード番号からカードブランドを取得する関数
December 4, 2021
かつて自分が使うために作ったものですが、誰かの役にたてばと公開しておきます。 関数(TypeScript / JavaScript) # TypeScript で記載して ...
かつて自分が使うために作ったものですが、誰かの役にたてばと公開しておきます。 関数(TypeScript / JavaScript) # TypeScript で記載して ...
ケバブケースのデメリットとして、ダブルクリックなどで文字列全体を選択できないという点がよく挙げられますが、VSCode ならば設定を一つ変える ...
S3 でホスティングしてきた静的サイトを別の場所に移したので、再び実施する時のために手順を残しておく。 詳細な実施方法は調べればいくらでも出てくる ...
既出にも程がある情報ですが、自分が必要になった時にすぐ取り出せるように記事にしておきます。なお、自分の環境が Mac & Android なのでその前提で記載します ...
Google 公式の説明を引用しつつ適宜補足します。 基本的に Firebase の権限を管理するには Firebase IAM を利用します。Firebase IAM で可能な粒度よりもさらに細かく設定 ...
Google 公式の手引きに従って実施ください、の一言で終わってしまいそうですが、備忘録もかねて記載します。 公式ドキュメント データのエクスポートをスケジ ...
以下を参考に package.json 及びワークフロー定義を作成してください。 package.json # package.json { "scripts": { "lint:tsc": "tsc --noEmit", "lint:eslint": "eslint src --ext .js,.jsx,.ts,.tsx", "lint:prettier": "prettier --check src" } } 上記は src ディレクトリ下に検査対象のファイルが配 ...
Next.js の Static HTML Export で生成した資産を Amazon S3 にデプロイする方法について。 昔初めて作った上記ワークフローが見つかったので、削除する前に思い出として残しておき ...
引数に応じて戻り値の型は変化しない # 例えば以下の関数と実行結果があるとして、age の型は何になるでしょうか? const getAge = (shouldString: boolean) => { return shouldString ? '20' : 20; }; const age ...
かつて自分が使うために作ったものですが、もし誰かの役にたてばと公開しておきます。 説明 # 経度緯度で指定された中心地点 A から、引数で指定された距 ...
かつて自分が使うために作ったものですが、もし誰かの役にたてばと公開しておきます。 説明 # 経度緯度で指定された中心地点 A から、引数で指定された距 ...
たまにこのコードが欲しくて過去のコードを漁るときがあるためここに載せておきます。 関数 # 指定された年月日が実在する日付なのかを判別する関数です ...
ダミーデータを作る際、基本的には何らかのライブラリを使うことが多いのではないでしょうか。 私はよく Faker.js を利用しています。 Marak/faker.js: generate massive amounts of realistic fake data in Node.js and the ...
Android と iOS のそれぞれの環境を考慮して、画面の高さいっぱいに要素を表示させる方法です。 実行環境で高さの解釈が異なる # 100% や 100vh の解釈がそれぞれの環境で ...
自分用にメモ。どう書くのだっけと都度微妙にググり作業が発生しているので。 TypeScript # 次の1行を無視: @ts-ignore # let x = 1; // @ts-ignore x = 'a'; FYI: TypeScript: Documentation - TypeScript 2.6 - @ts-ignore ファイル内 ...
もう一度同じ作業をすることになった時のために。自分用の備忘録です。 環境準備 # (Firebase CLI でプロジェクト作成は済んでいるものとしてスタ ...
自分用の備忘録です。頻繁に実施するものでもなく、記憶が薄れがちなので。 パッケージをインストール # ESLint をインストール # eslint npm install --save-dev eslint ESLint の Parser をインスト ...
ローカルから SSH などで Lightsail に接続する時に使用するキーペアをインスタンス作成後に変更する時の手順です。 また、手元の秘密鍵を紛失してしまった時も同様 ...
先日、スタイリングした HTML メールを送る場面があったのですが、その時初めて Gmail アプリでは HTML タグがエスケープされることを知りました。 HTML タグを使用した ...
最近は HOW TO 記事を多く投稿していましたので、たまにはどうでも良い感想記事でも投稿。(この記事に Lightsail に WordPress を構築する手順の説明はありません。) そうい ...
This article is a translation of a Japanese article I posted earlier. Original article firestore.rules in the Firebase project generated by the Firebase CLI is the file that defines the security rules. The initial contents are as follows. rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if false; } } } All the security rules will be written in this file, but it’s not hard to imagine that the content of this file will become so large that you will get tired of it one day. ...
This article is a translation of a Japanese article I posted earlier. Original article After init of the Firebase CLI, the files related to Cloud Functions will be as follows (In the case of TypeScript). └ functions/ ├ (ohter files) ├ lib/ └ src/ └ index.ts All you have to do is write the trigger function in index.ts However, if you create a lot of triggers, you will definitely be tempted to split the files, right? ...
This article is a translation of a Japanese article I posted earlier. Original article One of the Firestore data types is the Timestamp type. This is a proprietary type of Firestore. Timestamp has a toDate() method that can be called to convert data to Date type of JavaScript. After getting data on the client side, it is a common practice to call toDate() first when using the data. If all Timestamps in a document can be treated as Date type on the client side, it is useful to make a function that execute toDate() on all Timestamp fields of the getting document. ...
Firebase CLI で生成された Firebase プロジェクト内の firestore.rules がセキュリティルールを定義するファイルです。 初期状態の内容は以下です。 rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if false; ...
Firebase CLI の init 後の初期状態では Cloud Functions 関連のファイルは以下となっているはずです。(TypeScript の場合) └ functions/ ├ その他ファイルたち ├ lib/ └ src/ └ index.ts あと ...
Firestore のデータ型の1つに Timestamp 型があります。これは Firestore 独自の型です。 Timestamp が持っている toDate() メソッドを呼び出すと、JavaScript の Date 型に変換することがで ...
例えばローカルのエミュレータ環境の Firestore へシードデータを流す際、シーディングの初期化処理としてデータを全削除したいというシチュエーションはよくあ ...
「何について調べますか?」 → 「お前を消す方法」 Running in emulator mode. Do not use with production credentials. # Firebase のローカルエミュレータ環境で開発中、Authentication により ...
Firestore の苦手とする部分として複雑な検索条件をもとにデータを取得するのが困難です。 そのような要件のあるサービスに対してそもそも Firestore を選定するべきでは ...
関数の引数から型を取得 # Parameters<typeof (function name)> const greet = (name: string, word: 'Hello' | 'Good Bye') => { return `${word}, ${name}!`; }; type Args = Parameters<typeof greet>; // [name: string, word: "Hello" | "Good Bye"] type firstArg = Args['0']; // string type secondArg = Args['1']; // "Hello" | "Good Bye" 関数の戻り値から型を取 ...