Skip to content

Instantly share code, notes, and snippets.

View fsubal's full-sized avatar

fsubal fsubal

View GitHub Profile
@fsubal
fsubal / note.html
Last active August 10, 2025 06:39
漫画用に、架空のツイートや架空の記事のスクショが作れるジェネレーター( Generated by ChatGPT + GPT-5。利用自由 ) https://fsubal.github.io/fake-sns-screen/
<!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;
@fsubal
fsubal / sw.ts
Last active June 17, 2025 00:57
/// <reference lib="webworker" />
/**
* Rails の CSRF トークンを取得し、それを使ってリクエストを送信する
*
* ワーカースクリプトで動作する
*
* ワーカースクリプトの場合、メインスクリプトからメッセージを送信して CSRF トークンを更新する
* メインスクリプトからメッセージを送信して CSRF トークンを更新する
* メインスクリプトからメッセージを送信して CSRF トークンを更新する
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
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
*/
class Vector2D < Vector
class Pixel < Vector2D; end
class Millimeter < Vector2D; end
class Viewbox < Vector2D; end
def initialize(*)
super
raise ArgumentError unless size == 2
end
@fsubal
fsubal / AppUrl.ts
Last active February 2, 2025 09:44
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()])
)
}
module AttrReaderGuard
extend ActiveSupport::Concern
class InvalidError < ArgumentError
PREFIX = '[attr_reader_guard!]:'
def initialize(subject, predicate)
super [PREFIX, subject, predicate].join(' ')
end
end
export class Unreachable extends TypeError {
static assert(value: never): never {
throw new this(value)
}
static silent(value: never): void {
void value
}
constructor(value: never) {
@fsubal
fsubal / cx.ts
Last active December 14, 2024 04:03
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)) {
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)
}