feat: add development environment configuration and Docker setup

This commit is contained in:
2026-01-27 17:31:44 +07:00 Unverified
parent d765124706
commit f086b9aaff
16 changed files with 477 additions and 25 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import { isNotNull, lte, or, type SQL } from "drizzle-orm";
import { isNotNull, lte, or, type SQL, sql } from "drizzle-orm";
import {
type AnyPgColumn,
boolean,
@@ -134,7 +134,7 @@ export const endgameSubmissions = endgame.table("submissions", {
.generatedAlwaysAs(
(): SQL =>
or(
lte(endgameSubmissions.price, 0),
lte(endgameSubmissions.price, sql.raw("0")),
isNotNull(endgameSubmissions.slip),
)!,
),
+37 -1
View File
@@ -131,6 +131,42 @@ export const sse = new EventSourceManager();
export const b2s = (t: number) => {
let e = (Math.log2(t) / 10) | 0;
// biome-ignore lint/suspicious/noAssignInExpressions: copied
return `${(t / 1024 ** (e = e <= 0 ? 0 : e)).toFixed(1)}${" KMGP"[e]}B`;
};
type Node = { count: number; next: Map<string, Node> };
function node(): Node {
return { count: 0, next: new Map() };
}
// find unique shortest code for each string
export function shortestPrefixes(values: readonly string[]) {
const uniq = [...new Set(values)];
const root = node();
for (const v of uniq) {
let cur = root;
for (const ch of v) {
let n = cur.next.get(ch);
if (!n) cur.next.set(ch, (n = node()));
n.count++;
cur = n;
}
}
const res = new Map<string, string>();
for (const v of uniq) {
let cur = root;
let prefix = "";
for (const ch of v) {
const n = cur.next.get(ch)!;
prefix += ch;
if (n.count === 1) break;
cur = n;
}
res.set(v, prefix);
}
return res;
}