Skip to content

Instantly share code, notes, and snippets.

View tecsoc's full-sized avatar

TecSoc tecsoc

  • Tokyo
  • 09:29 (UTC +09:00)
View GitHub Profile
@tecsoc
tecsoc / copy-canonical-url.js
Last active October 14, 2023 19:23
正規URLをコピーするブックマークレット
javascript:(() => {
const canonicalLink = document.querySelector('link[rel="canonical"]');
if (!canonicalLink) {
alert("Canonical URLが見つかりませんでした");
return;
}
const textToCopy = canonicalLink.href;
const hiddenInput = document.createElement("input");
hiddenInput.value = textToCopy;
type StringKeyToAnyValue = Record<string, any>;
// 「.」より前の文字列を取り出す型
type HeadProperty<T extends string> = T extends `${infer First}.${string}` ? First : T;
// 「.」より後の文字列を取り出す型
type TailProperty<T extends string> = T extends `${string}.${infer Rest}` ? Rest : never;
// ネストしているオブジェクトを再起的にPickする型
type DeepPick<T extends StringKeyToAnyValue, U extends string> = {
[K in HeadProperty<U> & keyof T]: K extends readonly unknown[] // Union Typesかどうか
@tecsoc
tecsoc / introduction-profile.ts
Created October 6, 2023 14:06
自己紹介.ts
// ----------------------------------------------------
// 基底となる型を定義
// ----------------------------------------------------
enum SkillLevel {
Junior = 1,
Middle,
Senior,
SemiExport,
Export,
}