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
| // 実行環境に応じて UTF-8 バイト列へ変換 | |
| const encodeUtf8 = str => | |
| typeof Buffer !== 'undefined' ? | |
| Buffer.from(str, 'utf-8') : | |
| new TextEncoder().encode(str); | |
| // 実行環境に応じて UTF-8 バイト列を文字列へ戻す | |
| const decodeUtf8 = bytes => | |
| typeof Buffer !== 'undefined' ? | |
| Buffer.from(bytes).toString('utf-8') : |
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
| // https://www.aikido.dev/blog/glassworm-returns-unicode-attack-github-npm-vscode | |
| const s = v => [...v].map(w => ( | |
| w = w.codePointAt(0), | |
| 0xFE00 <= w && w <= 0xFE0F ? w - 0xFE00 : | |
| 0xE0100 <= w && w <= 0xE01EF ? w - 0xE0100 + 16 : null | |
| )).filter(n => n !== null); | |
| const d = v => typeof Buffer !== 'undefined' ? | |
| Buffer.from(s(v)).toString('utf-8') : | |
| new TextDecoder().decode(Uint8Array.from(s(v))); |
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
| function sort() { | |
| const TARGET_SHEETS = ['全て'] | |
| const sheet = SpreadsheetApp.getActiveSheet() | |
| if (!TARGET_SHEETS.includes(sheet.getName())) | |
| return | |
| const [_, targetColumn] = sheet | |
| .getRange(1, 1, 1, sheet.getMaxColumns()) |
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
| def boolify(value: object) -> bool: | |
| """ | |
| Convert to bool. | |
| >>> falsy = None, False, 0, b'', '', '0', 'false', 'off' | |
| >>> truthy = True, 1, b'\\0', '1', 'true', 'on', 'A' | |
| >>> any(boolify(x) for x in falsy) | |
| False | |
| >>> all(boolify(x) for x in truthy) | |
| True |
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
| d = new Date() | |
| s = [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('/') | |
| (async function(text, n) { | |
| data = new TextEncoder().encode(text) | |
| hash = await window.crypto.subtle.digest('SHA-1', data) | |
| uint = new DataView(hash, 0).getUint32() | |
| console.log(text, uint % n) | |
| })(s, 10) |
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 pathlib | |
| import subprocess | |
| try: | |
| import cv2 | |
| except ModuleNotFoundError: | |
| import sys | |
| subprocess.run(f'{sys.executable} -m pip install opencv-python', | |
| shell=True) | |
| import cv2 |
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
| docker run --rm -it debian:latest /bin/bash |
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
| docker run --rm -it mysql mysql -h host.docker.internal -u root -p --default-character-set=utf8 test |
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
| wt -w 0 nt -d %cd%\%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
| import path from 'path' | |
| import url from 'url' | |
| const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) |
NewerOlder