I hereby claim:
- I am ncaq on github.
- I am ncaq (https://keybase.io/ncaq) on keybase.
- I have a public key ASCsmQ3khGkf2BIDprBc92-WDIvebtgSRTKcpnCbN_1_two
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| #!/usr/bin/env python3 | |
| # Pythonのメジャーな型チェッカーは`B`が`A`を継承していても、 | |
| # `list[A]`を受け取る関数に`list[B]`を渡すとエラーを出力します。 | |
| # 型システム的な面倒な話は置いておいて、実際にこれがエラーじゃないと問題になってしまう例を示します。 | |
| # 別にdataclassでなくても構わないのですが、printのやりやすさで使っています。 | |
| from dataclasses import dataclass |
| /** | |
| * Twitterの埋め込みスクリプトをボタンを押さずに取得します。 | |
| */ | |
| async function getTwitterEmbed(url) { | |
| // TwitterのURLやツイートのURLじゃない場合は`undefined`を返します。 | |
| if ( | |
| !( | |
| (url.hostname === "twitter.com" || url.hostname === "mobile.twitter.com") && | |
| /^\/\w+\/status\/\d+/.exec(url.pathname) | |
| ) |
| /** | |
| * 指定されたURLのタブが既に開かれていればそのタブをアクティブにします。 | |
| * 開かれていなければ新規に開きます。 | |
| */ | |
| function tabActivateOrCreate(url) { | |
| RUNTIME("getTabs", { queryInfo: { url, currentWindow: true } }, ({ tabs }) => { | |
| if (!Array.isArray(tabs)) { | |
| throw new Error(`tabs is not Array: ${JSON.stringify(tabs)}`); | |
| } | |
| const tabId = tabs?.[0]?.id; |
| import sys | |
| from collections.abc import Iterator | |
| def format_line_endings(line: str) -> str: | |
| """ | |
| 一行の文字列を受け取り、文字列の種類によって行末の書式を決定します。 | |
| 文字列が空行であるか、行自体に意味がありそうなことを示唆している場合は、行末に改行を追加します。 | |
| それ以外の場合は、文字列をそのまま返します。 | |
| """ |
| #!/bin/bash | |
| # tail使った方が良い。 | |
| # [unix - Concatenate multiple files but include filename as section headers - Stack Overflow](https://stackoverflow.com/questions/5917413/concatenate-multiple-files-but-include-filename-as-section-headers) | |
| for i in $1/* | |
| do | |
| echo $i | |
| cat "$i" | |
| done |
| import Control.Applicative | |
| import Control.Monad | |
| import qualified Data.List as L | |
| main = print (兄弟 sally erica :: [Bool]) | |
| 兄弟 x y = do | |
| xa <- 子の親 x | |
| ya <- 子の親 y | |
| guard $ xa == ya |
| #!/usr/bin/env nix-shell | |
| #!nix-shell -i runghc -p "haskellPackages.ghcWithPackages (p: with p; [ here time ])" | |
| {-# LANGUAGE QuasiQuotes #-} | |
| -- | テレワーク補助を計算しつつ途中式を見るためのプログラム。 | |
| -- 一回出力が証拠付きで出せれば良いだけなので、 | |
| -- 真面目に書いてない。 | |
| module Main (main) where | |
| import Data.Maybe (fromJust) |
| #use "topfind" | |
| #require "camomile" | |
| open CamomileLibrary | |
| let print_filter_word () = | |
| let rec print_filter_word_sub () = | |
| let line = read_line () in | |
| let yomi = List.hd (String.split_on_char '\t' line) in | |
| if 1 < UTF8.length yomi then print_endline line else (); | |
| print_filter_word_sub () in |
| const stateA = { foo: "bar" }; | |
| const stateB = stateA; | |
| stateB["hoge"] = "huga"; // stateAに対する破壊的変更 | |
| console.log("stateA: ", stateA); // stateAが更新されている | |
| // コピーしたいならこうする | |
| const correctStateA = { foo: "bar" }; | |
| const correctStateB = { ...correctStateA }; // 浅いコピー | |
| correctStateB["hoge"] = "huga"; // correctStateAには影響が出ない | |
| console.log("correctStateA: ", correctStateA); |