Skip to content

Instantly share code, notes, and snippets.

View mindon's full-sized avatar
🙃
zig, deno and hx, sometimes go & qt

mindon mindon

🙃
zig, deno and hx, sometimes go & qt
View GitHub Profile
@mindon
mindon / shot_video_with_duration.scpt
Created March 27, 2026 02:04
AppleScript to shot a video with Photo Booth
-- 录10秒视频
tell application "Photo Booth" to activate
delay 1
tell application "System Events" to tell process "Photo Booth"
click radio button 3 of radio group 1 of group 1 of window "Photo Booth"
end tell
tell application "System Events"
set frontmost of process "Photo Booth" to true
keystroke return using {option down} -- option + enter
end tell
@mindon
mindon / photo_booth_shot.scpt
Created March 27, 2026 02:03
AppleScript to take a photo with Photo Booth
-- 拍照片
tell application "Photo Booth" to activate
delay 1
tell application "System Events"
-- click radio button 2 of radio group 1 of group 1 of window 1
set frontmost of process "Photo Booth" to true
keystroke return using {option down} -- option + enter
end tell
tell application "Photo Booth" to quit
@mindon
mindon / markers.svg
Created August 11, 2025 10:12
marker arrow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mindon
mindon / seamless.js
Created December 7, 2024 23:56
Keep and restore css animation timepoint
// restore animation timepoint from first animation of an element
export function restore(anis, key) {
if (anis.length === 0) return;
const s = sessionStorage.getItem(key);
if (!s) return;
const t = s.split(",").map((v) => parseFloat(v));
Array.from(anis).some((ani, i) => {
ani.pause();
ani.startTime = t[0] || 0;
ani.currentTime = t[1] || 0;
@mindon
mindon / tencent_cloud_postgres_auto_filter.js
Last active October 18, 2024 03:33
腾讯云PG设置某字段多个OR值过滤数据(包含React的input事件激发)
(function(raw, key) {
const d = raw.split('\n').map(line => line.trim()).filter(line => !!line);
console.log(key, d.length);
if (d.length == 0) return;
const tab = document.querySelector('.dmc-mysql-operating-filter .tea-table__body table.tea-table__box');
const nb = tab.querySelector('tr:last-child > td > div > div');
let n = d.length - [].slice.apply(tab.querySelectorAll('tr')).length + 1;
while (n > 0) { nb.click();n--;}
const trs = [].slice.apply(tab.querySelectorAll('tr')).slice(0, d.length);
trs.forEach((tr,i) => [].slice.apply(tr.querySelectorAll('div.tea-segment > button')).forEach(btn => {
@mindon
mindon / MyCompleter.cpp
Created September 12, 2024 08:59
How to make QCompleter supports search/filter multiple keywords?
// Make a QCompleter to match all keywords seperated by space
// MyCompleter is a customize splitPath QCompleter
class MyCompleter : public QCompleter {
public:
MyCompleter(QAbstractItemModel* model, QObject* parent = nullptr)
: QCompleter(model, parent)
{
}
@mindon
mindon / schedule.go
Last active September 4, 2024 06:10
Schedule daily tasks with golang, without any third-party dependence
// Schedule daily tasks at moment or every dur from at to another time point of the day
// schedule.go
package main
import (
"fmt"
"log"
"strings"
"time"
)
@mindon
mindon / draggable.js
Last active August 19, 2024 10:12
Make a HTML dom or element with id or id-header (if exists, only header) draggable
// Make a HTML dom or element with id or id-header (if exists, only header) draggable
// auto init .draggable elements, <div class="draggable">Drag Here</div><script src="draggable.js"></script>
// usage: draggable(elm)
// orgin from https://gist.github.com/mindon/84a8906a2d9e7ad078ae07692b52c460
globalThis.draggable = ((auto = true, stylize = true, globalized = false) => {
// ---------->>>
const win = globalThis || window;
console.assert(win);
const doc = win.document;
console.assert(doc);
@mindon
mindon / inside_points.js
Created August 2, 2024 04:13
Fill a geometry with points in THREE.js
// generate points inside a geometry, with THREE.js
// Mindon<mindon@live.com> https://mindon.dev, 2024.08.01
// Example code:
// const inside = Inside(THREE);
// const material = new THREE.PointsMaterial({color: 0xffffff, size: 0.25});
// scene.add(inside.points(num, geometry, material));
// // scene.add(new THREE.Points(inside.geometry(num, geometry), material));
export function Inside(THREE) {
const ray = new THREE.Ray();
@mindon
mindon / txcloud_pgrecovery.zig
Last active May 11, 2024 04:09
helper in zig to get data from auto full backups of Tencent Cloud Postgres 腾讯云POSTGRES备份数据提取小工具
/// tencent cloud postgres data recovery helper
/// required:
/// [zig](https://ziglang.org/download/)
/// [docker](https://docker.com/) or [podman](https://podman.io/) required
/// usage:
/// 1) update recovery for zst path and tables to export
/// 2) `zig run txcloud_pgrecovery.zig`
const std = @import("std");
const print = std.debug.print;
const path = std.fs.path;