Skip to content

Instantly share code, notes, and snippets.

View AClon314's full-sized avatar
📖
Learning

AClon AClon314

📖
Learning
View GitHub Profile
@AClon314
AClon314 / copyq-paste-photo.js
Last active February 21, 2026 05:48
From the latest N records of copyq, output the binary buffer of the latest image to stdout (convenient for satty to accept pipeline input) 从copyq最近N条记录中,输出最新图片的二进制buffer到stdout(方便satty接受管道输入)
const recent = 10;
const maxMB = 10;
for (i = 0; i < Math.min(recent, size()); ++i) {
const mimes = str(read("?", i))
.split("\n")
.filter((v) => v.startsWith("image/"));
// .filter((v) => v.startsWith("image/") || v == "text/plain");
for (const m of mimes) {
const bin = read(m, i);
if (m == "text/plain") {
@AClon314
AClon314 / isLeaf.py
Created February 15, 2026 02:00
isBasicType/isLeaf
def isBasicType(o):
return isinstance(o, str) or not isinstance(o, (Mapping, Sequence))
def isLeaf(obj):
if isinstance(obj, Mapping):
return all(isBasicType(v) for v in obj.values())
if isinstance(obj, Sequence):
return all(isBasicType(v) for v in obj)
return False