This file contains 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 { Element, Root } from 'hast' | |
import { fromHtml } from 'hast-util-from-html'; | |
import { selectAll } from 'hast-util-select'; | |
interface Option { | |
excludes?: string[]; | |
icon?: boolean; | |
iconClass?: string; | |
rel?: 'alternate' | 'author' | 'bookmark' | 'canonical' | 'dns-prefetch' | 'external' | 'help' | 'icon' | 'license' | 'manifest' | 'me' | 'modulepreload' | 'next' | 'nofollow' | 'noopener' | 'noreferrer' | 'opener' | 'pingback' | 'preconnect' | 'prefetch' | 'preload' | 'prerender' | 'prev' | 'privacy-policy' | 'search' | 'stylesheet' | 'tag' | 'terms-of-service'; | |
} |
This file contains 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
// For timer mocks, see https://jestjs.io/docs/timer-mocks | |
// For setSystemTime, see https://jestjs.io/docs/jest-object#jestsetsystemtimenow-number--date | |
jest.useFakeTimers().setSystemTime(new Date('2023-01-02 12:34:56')); |
This file contains 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
# Run this scripts like the following: | |
# python list_unused_sg.py | |
# | |
# CLI Options | |
# --include-inbound: include inbound setting information | |
# --no-include-inbound: Do not include inbound setting information | |
# --include-outbound: include outbound setting information | |
# --no-include-outbound: Do not include outbound setting information | |
# --output: json or list |
This file contains 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
# Run this scripts like the following: | |
# python inactive_deployments_deleter.py --target-arn "arn:aws:iot:<AWS_REGION>:<AWS_ACCOUNT_ID>:thing/<YOUR_THING_NAME>" | |
import argparse | |
from time import sleep | |
import boto3 | |
client = boto3.client('greengrassv2') |
This file contains 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
<div class="animate-fade-in"> | |
Fadein! | |
</div> |
This file contains 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 fs from 'fs'; | |
export async function download(url: string, file: string): Promise<void> { | |
// See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch | |
const response = await fetch(url); | |
if (!response.ok) { | |
return; | |
} | |
const data = Buffer.from(await response.arrayBuffer()); | |
fs.writeFileSync(file, data); |
This file contains 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 hiragana_to_katakana(src: str) -> str: | |
result = '' | |
for char in src: | |
code = ord(char) | |
result += chr(code + 96) if 12352 < code < 12439 else char | |
return result | |
print(hiragana_to_katakana('てすと')) | |
# It outputs 'テスト'. |
This file contains 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
from datetime import datetime | |
from pytest_mock import MockerFixture | |
def test_your_function(mocker: MockerFixture): | |
now = datetime.strptime('2024-01-02 12:34:56', '%Y-%m-%d %H:%M:%S') | |
mock = mocker.MagicMock(wraps=datetime) | |
mock.now.return_value = now | |
mocker.patch('src.your_module.datetime', new=mock) |
This file contains 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 async function getHashByUrl(url: string): Promise<string> { | |
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest | |
const uint8 = new TextEncoder().encode(url); | |
const digest = await crypto.subtle.digest('SHA-256', uint8); | |
return Array.from(new Uint8Array(digest)).map(b => b.toString(16).padStart(2,'0')).join(''); | |
} |
This file contains 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
<input type="checkbox" style="pointer-events: none" checked/>Click me! | |
<input type="checkbox" checked/>Toggle me! |