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
// @ts-check | |
/** | |
* | 課税所得 | 税率 | 控除額 | | |
* | ---------------------------------- | ---- | ----------- | | |
* | 1,000円 から 1,949,000円まで | 5% | 0円 | | |
* | 1,950,000円 から 3,299,000円まで | 10% | 97,500円 | | |
* | 3,300,000円 から 6,949,000円まで | 20% | 427,500円 | | |
* | 6,950,000円 から 8,999,000円まで | 23% | 636,000円 | | |
* | 9,000,000円 から 17,999,000円まで | 33% | 1,536,000円 | |
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
function arrayBufferToHex(arrayBuffer) { | |
const view = new Uint8Array(arrayBuffer); | |
let result = ""; | |
for (let i = 0; i < view.length; i++) { | |
const value = view[i].toString(16); | |
result += value.length === 1 ? "0" + value : value; | |
} | |
return result; |
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
$ = window.OpenSeadragon; | |
$.TileSource = class extends $.TileSource { | |
downloadTileStart(context) { | |
// 👼 Keep original code as is | |
var dataStore = context.userData, | |
image = new Image(); | |
dataStore.image = image; | |
dataStore.request = null; |
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
const ID_BYTES = 8; // 64 bits | |
const HEADER_BYTE_LENGTH = 2 * Uint16Array.BYTES_PER_ELEMENT; | |
// OpenAI embeddings are [-1, 1), so we can | |
// quantize to Int16 by multiplying by 2^15 | |
const QUANTIZE_MAX = Math.pow(2, 15); | |
export class VectorCollection { | |
static VERSION = 1; |
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 const promiseAllWithConcurrency = async <T>( | |
queue: (() => Promise<T>)[], | |
concurrency: number = 1 | |
) => { | |
let index = 0; | |
const results: T[] = []; | |
const execThread = async () => { | |
while (index < queue.length) { | |
const curIndex = index++; |
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
local wezterm = require "wezterm"; | |
local act = wezterm.action; | |
return { | |
font = wezterm.font("Cica"), | |
font_size = 22, | |
adjust_window_size_when_changing_font_size = false, | |
initial_cols = 120, | |
initial_rows = 40, |
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
// @ts-check | |
import fs from "node:fs/promises"; | |
import path from "node:path"; | |
// This script is temporary work-around for issue, | |
// https://github.com/withastro/astro/issues/2146 | |
// TL;DR, we need to replace all url() in CSS manually... | |
// e.g. url(__VITE_ASSET__********__) => url(/assets/asset.********.webp) | |
// Some url() work fine if they are updated to data-url. | |
(async () => { |
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
#!/usr/bin/env bash | |
set -e | |
bytesToHuman() { | |
b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}iB) | |
while ((b > 1024)); do | |
d="$(printf ".%02d" $((b % 1024 * 100 / 1024)))" | |
b=$((b / 1024)) | |
let s++ | |
done |
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
fn powerset<T>(s: &[T]) -> Vec<Vec<&T>> { | |
(0..2usize.pow(s.len() as u32)) | |
.map(|i| { | |
s.iter() | |
.enumerate() | |
.filter(|&(t, _)| (i >> t) % 2 == 1) | |
.map(|(_, e)| e) | |
.collect() | |
}) | |
.collect() |
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
class Game { | |
constructor({ $buttons, $result, $reset }) { | |
this.answer = null; | |
this.$buttons = $buttons; | |
this.$result = $result; | |
this.$reset = $reset; | |
} | |
start() { | |
this.answer = Math.floor((Math.random() * 5) + 1); |
NewerOlder