jsconf2024 で発表したスライドのソースコードだが、テキスト版のが読みやすい気がしたので公開する。 画像のデッドリンクは面倒なので、気が向いたら…
// Types for the result object with discriminated union | |
type Success<T> = { | |
data: T; | |
error: null; | |
}; | |
type Failure<E> = { | |
data: null; | |
error: E; | |
}; |
Someone asked me about the spacing scale in Braid and I thought I'd share my thoughts here. For reference this is what they were referring to: https://github.com/seek-oss/braid-design-system/blob/ecdd7f3060cab2a6675cde7dd45bcd510caa268b/packages/braid-design-system/src/lib/themes/baseTokens/apac.ts#L166-L175
I could maybe have turned this into a blog post, but I'm just dropping my rough thoughts here instead.
In practice, the T-shirt size scale felt like indirection because our designers didn't think in those terms so it actually got in the way of developers and designers communicating.
The names also weren't really semantic in the sense that we couldn't confidently change them later without breaking a lot of layouts.
It also made it difficult to name new values to the scale, e.g. if we needed to add a value between "small" and "medium", what would we call it? I've seen things like "xmedium" in other systems before which shows how awkward this can get.
import gzip | |
def gzip_search(query: str, candidate_chunks: list[str], top_k: int=1): | |
""" | |
文字列ベースで類似したテキストチャンクを推定するアルゴリズム. | |
`query`, `chunk`, および`query + " " + chunk`をそれぞれgzipで圧縮し、編集距離のようなものをベースに評価する. | |
Parameters: | |
query (str): 検索クエリとして使用する文字列. | |
top_k (int, optional): 返される類似チャンクの上位k個を指定する (default: 1). |
// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary! | |
// Example using the Next.js App Router. | |
import { useRouter } from 'next/navigation'; | |
import { useEffect } from 'react'; | |
function useLinkHandler() { | |
let router = useRouter(); | |
useEffect(() => { | |
let onClick = e => { |
/** | |
* @type {import('prettier').Options} | |
*/ | |
module.exports = { | |
plugins: [require.resolve('prettier-plugin-astro')], | |
overrides: [ | |
{ | |
files: '**/*.astro', | |
options: { parser: 'astro' } |
#! /bin/bash | |
# Author: Birgit Olzem aka @CoachBirgit | |
# Version: 1.0 | |
# Created on: January 19th 2022 | |
# Requires WP-CLI, cURL, wget | |
# credits for the origin idea to Jeremy Herve: https://jeremy.hu/dev-environment-laravel-valet-wp-cli/ | |
### How to use |
tsconfig.json
の設定についてのメモ書きです。
- TypeScript: TSConfig Reference - Docs on every TSConfig option
- TypeScript: Documentation - What is a tsconfig.json
target は 変換後のコードのECMAScriptバージョンを指定する
たとえば、Node.js 14はES2020をサポートしている。そのため、Node.js 14向けのコード(サーバなど)ならtarget: "ES2020"
を指定することで、余計なTranspileが省かれててコードサイズや実行時間が最適化される。
/** | |
* BASE SIZE | |
* All calculations are based on this. It’s recommended that | |
* you keep it at 1rem because that is the root font size. You | |
* can set it to whatever you like and whatever unit you like. | |
*/ | |
$gorko-base-size: 1rem; | |
/** | |
* SIZE SCALE |