This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="ja"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <title>note.com風記事モックジェネレータ</title> | |
| <style> | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif; | |
| margin: 0; | |
| padding: 20px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <reference lib="webworker" /> | |
| /** | |
| * Rails の CSRF トークンを取得し、それを使ってリクエストを送信する | |
| * | |
| * ワーカースクリプトで動作する | |
| * | |
| * ワーカースクリプトの場合、メインスクリプトからメッセージを送信して CSRF トークンを更新する | |
| * メインスクリプトからメッセージを送信して CSRF トークンを更新する | |
| * メインスクリプトからメッセージを送信して CSRF トークンを更新する |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export type UnionToIntersection<Union> = ( | |
| Union extends unknown ? (distributedUnion: Union) => void : never | |
| ) extends ( | |
| (mergedIntersection: infer Intersection) => void | |
| ) ? Intersection & Union : never; | |
| type TemplateString<Varname extends string> = UnionToIntersection<`${string}{{${Varname}}}${string}`> | |
| declare const phantom: unique symbol |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { resolve } from 'node:path' | |
| import { readFile } from 'node:fs/promises' | |
| import { exec } from 'node:child_process' | |
| import { promisify } from 'node:util' | |
| const execp = promisify(exec) | |
| /** | |
| * @see https://git-scm.com/docs/git-status#_porcelain_format_version_1 | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Vector2D < Vector | |
| class Pixel < Vector2D; end | |
| class Millimeter < Vector2D; end | |
| class Viewbox < Vector2D; end | |
| def initialize(*) | |
| super | |
| raise ArgumentError unless size == 2 | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { compile } from 'path-to-regexp' | |
| type UrlParams = Record<string, string | number> | |
| function normarizeUrlParams(input: UrlParams): Record<string, string> { | |
| return Object.fromEntries( | |
| Object.entries(input).map(([key, value]) => [key, value.toString()]) | |
| ) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module AttrReaderGuard | |
| extend ActiveSupport::Concern | |
| class InvalidError < ArgumentError | |
| PREFIX = '[attr_reader_guard!]:' | |
| def initialize(subject, predicate) | |
| super [PREFIX, subject, predicate].join(' ') | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class Unreachable extends TypeError { | |
| static assert(value: never): never { | |
| throw new this(value) | |
| } | |
| static silent(value: never): void { | |
| void value | |
| } | |
| constructor(value: never) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ClassNameValue = string | number | false | undefined | null | ClassNameValue[] | { [className: string]: boolean } | |
| function cx(...values: ClassNameValue[]) { | |
| const classNames: string[] = [] | |
| for (const value of values) { | |
| if (!value) { | |
| continue | |
| } | |
| if (Array.isArray(value)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Papa from 'papaparse' | |
| class Csv { | |
| constructor(readonly header: string[], readonly rows: string[][]) {} | |
| static parse(csv: string) { | |
| const [header, ...rows] = Papa.parse(csv.trim(), { header: false }) | |
| return new this(header, rows) | |
| } |
NewerOlder