Skip to content

Instantly share code, notes, and snippets.

@yano3nora
yano3nora / cuid.md
Last active April 4, 2024 02:01
[js: cuid] Collision-resistant ids optimized for horizontal scaling and performance. #js
@yano3nora
yano3nora / placeholder-com.md
Created September 8, 2022 12:06
[dev: placeholder.com] Placeholder.com – The Free Image Placeholder Service Favoured By Designers. #dev

https://placeholder.com/

  • ?text で文字指定可能
  • 何も指定しないとサイズを width x height で表示してくれる
# size 指定 (1920x1080)
https://via.placeholder.com/1920x1080/?text=background

# 色指定 (#333)
@yano3nora
yano3nora / npm-run-all.md
Last active May 14, 2023 00:17
[js: npm-run-all] A CLI tool to run multiple npm-scripts in parallel or sequential. #js

Overview

mysticatea/npm-run-all

npm scripts を複数、並列または直列実行するためのツール。

$ npm i -D npm-run-all

# npx での実行はちょっとイレギュラーな書き方する
#
@yano3nora
yano3nora / vite.md
Last active March 19, 2024 09:01
[js: vite] Vite - Next Generation Frontend Tooling. #js

Overview

ja.vitejs.dev
github.com/vitejs/vite

  • 開発時には esbuild を、本番ビルドには rollup を使うバンドルツール
  • react, vue など ui library や typescript への対応もばっちり
  • とにかく早くて使いやすいとのこと
  • 次世代 front ツールとして snowpack と比較されるが、今んとこシェアぶっちぎり

nextjs つかうなら内包されている webpack で十分だし、それ以外の node project で使うかはまだちょっとわからないけど、単純な SPA 作成なら parcel 代替で使えそうに見える。

@yano3nora
yano3nora / restrict-right-cliek-context-menu.jsx
Created September 2, 2022 17:02
[js: Restrict Right-Click Context Menu] Right-click Restriction by onContextMenu. #js
<div
// 右クリックメニュー表示の抑止
// ゲーム開発などではこれを利用して独自メニューとかを生やす
onContextMenu={e => e.preventDefault()}
></div>
@yano3nora
yano3nora / node-fetch.md
Last active March 13, 2025 07:10
[js: node-fetch] Fetch API for Node. #js
@yano3nora
yano3nora / cexceljs.md
Last active August 21, 2023 03:42
[js: exceljs] #js

Overview

github.com/exceljs/exceljs

js で excel / csv うにょるやつ。そのまんま。

$ npm i exceljs

Blob Download with URL.createObjectURL

@yano3nora
yano3nora / crypto.js
Created August 28, 2022 05:54
[js: crypto] Node.js encryption library. #js
import {
createCipheriv,
createDecipheriv,
} from 'crypto'
const PASSWORD = 'xxxxxxxxx'
const SALT = 'xxxxxxxxx'
const CIPHER_KEY = crypto.scryptSync(PASSWORD, SALT, 32).toString('hex')
const CIPHER_IV = crypto.randomBytes(16).toString('hex')
@yano3nora
yano3nora / luxon.md
Last active March 13, 2025 03:58
[js: luxon] ⏱ A library for working with dates and times in JS. #js

Overview

github.com/moment/luxon
moment.github.io/luxon

  • moment.js の後継っぽい日時うにょるやつ
  • 書き方は dayjs のほうが moment.js に近いし人気ある
  • immutable で API がきれいなのと、TZ の取り回しが直感的らしい
  • date-fns が JS Date オブジェクトの helper 的な拡張なのに対して、こっちは独自の DateTime オブジェクトを内部的に取り回すぽい

JS の日時操作ライブラリを比較する: date-fns のインターフェイスがイカす