Skip to content

Instantly share code, notes, and snippets.

@zongwei007
zongwei007 / export-pg-table-schema-to-markdon.js
Created December 7, 2020 14:45
将 Postgresql 的表结构输出为 Markdown
const { SchemaConverter } = require("pg-tables-to-jsonschema");
(async () => {
const converter = new SchemaConverter({
pg: {
host: "::1",
port: 5432,
user: "user",
password: "pass",
database: "db",
@zongwei007
zongwei007 / react-table.d.ts
Created March 30, 2021 23:16
尝试使用动态类型实现 react-table 的插件化描述,但性能太差导致部分类型推断不可用
// Type definitions for react-table 7.0
// Project: https://github.com/tannerlinsley/react-table
// Definitions by: Guy Gascoigne-Piggford <https://github.com/ggascoigne>,
// Michael Stramel <https://github.com/stramel>
// Rohit Garg <https://github.com/gargroh>
// Jason Clark <https://github.com/riceboyler>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.5
// reflects react-table@7.0.4
@zongwei007
zongwei007 / extract-epub-comic-image.ts
Created May 24, 2021 19:24
提取 EPUB 漫画中的图片文件。基于 Deno 。
import * as path from "https://deno.land/std@0.97.0/path/mod.ts";
import { readZip } from "https://deno.land/x/jszip@0.9.0/mod.ts";
const dirPath = Deno.args[0] || ".";
for await (const entry of Deno.readDir(dirPath)) {
if (entry.isFile && entry.name.endsWith(".epub")) {
const epubPath = path.resolve(dirPath, entry.name);
const folderName = entry.name.substring(0, entry.name.lastIndexOf("."));
@zongwei007
zongwei007 / upload-to-mirror.sh
Last active May 26, 2021 17:38
手动将 k8s.gcr.io 的镜像同步到个人镜像库
#!/bin/bash
# 使用方式:./upload-to-mirror.sh k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
sudo docker pull $1
name=$1
name=${name////-}
tag="registry.cn-beijing.aliyuncs.com/${REGISTRY_NAME}/${name#*-}"
echo "tag image as ${tag}"
sudo docker tag $1 $tag
sudo docker login --username=${USER_NAME} --password=${PASSWORD} registry.cn-beijing.aliyuncs.com
@zongwei007
zongwei007 / FlatGeobufReader.java
Created November 16, 2024 14:17
基于 flatgeobuf 官方库实现的 Java 客户端,实现了搜索和数据遍历功能
package com.flatgeobuf;
import com.google.common.io.ByteStreams;
import com.google.common.io.LittleEndianDataInputStream;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.GeometryFactory;
import org.wololo.flatgeobuf.ColumnMeta;
import org.wololo.flatgeobuf.GeometryConversions;
import org.wololo.flatgeobuf.HeaderMeta;
@zongwei007
zongwei007 / koreader-sync-service.js
Last active December 21, 2024 03:05
Koreader sync server worker on cloudflare workers. Require bind D1 Database as DATABASE environment variable.
/**
* @typedef Env
* @property {D1Database} DATABASE
*/
/**
* @typedef User
* @property {string} username
* @property {string} password
*/
@zongwei007
zongwei007 / cloudflare-docker-proxy.js
Created December 21, 2024 05:54
Use cloudflare worker as docker proxy, code base https://github.com/ciiiii/cloudflare-docker-proxy
/**
* @typedef AuthenticateRealm
* @property {string} realm
* @property {string} service
*/
/**
* @typedef Env
* @property {string} API_DOMAIN
*/