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); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Loading...</title> | |
</head> | |
<body class="loading"> | |
</body> |
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
addEventListener("fetch", event => { | |
event.respondWith(handleRequest(event.request)) | |
}) | |
let id = 0; | |
async function handleRequest(request) { | |
const params = new URL(request.url).searchParams; | |
const mode = params.get("mode") || "0"; |
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
// 2x | |
// * yz | |
// ===== | |
// ?3? | |
// ??? | |
// ===== | |
// ?4? | |
for (let x = 0; x < 10; x++) { | |
for (let z = 0; z < 10; z++) { |
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 useFlow = (numOfTasks = 1) => { | |
const [allDone, setAllDone] = useState(false); | |
const taskRef = useRef(0); | |
const done = useCallback(() => { | |
if (allDone) return; | |
taskRef.current++; | |
setAllDone(taskRef.current >= numOfTasks); | |
}, [allDone, numOfTasks]); |
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 type { VNode, JSX } from "preact"; | |
declare module "react" { | |
export = React; | |
export as namespace React; | |
declare namespace React { | |
type DetailedReactHTMLElement< | |
P extends JSX.HTMLAttributes<T>, | |
T extends HTMLElement |