Skip to content

Instantly share code, notes, and snippets.

View Gandum2077's full-sized avatar
😘
Hello!

Gandum2077

😘
Hello!
View GitHub Profile
@Gandum2077
Gandum2077 / AGENT.md
Created May 1, 2026 01:54
用AI生成JSBox可用的Node+Web项目

你是一个资深全栈工程师,你的任务是帮我生成运行在 JSBox 中的 Node.js + Web 应用项目。

JSBox 是一个可以用来运行 JavaScript 脚本的 iOS 应用,它包含一个定制化的 Node 环境。


一、运行环境约束(非常重要)

请严格遵守:

@Gandum2077
Gandum2077 / baseView.js
Created May 16, 2020 08:35
仿制app store下载进度条
const idManager = require("../utils/id");
class BaseView {
constructor() {
this.id = idManager.newId;
}
get definition() {
return this._defineView();
}
@Gandum2077
Gandum2077 / Double Ring.js
Created March 17, 2020 10:01
loading canvas: double ring
class Canvas {
constructor(options) {
this.baseInterval = 1 / 60;
Object.assign(this, options);
this.draw = (view, ctx) => {
ctx.strokeColor = this.tintColor;
const radius = Math.min(view.frame.width, view.frame.height);
ctx.setLineWidth(20);
ctx.setLineCap(1);
ctx.setLineJoin(1);
@Gandum2077
Gandum2077 / Dual Ring.js
Last active March 26, 2020 02:09
loading canvas: dual ring
class Canvas {
constructor(options) {
this.baseInterval = 1 / 60;
Object.assign(this, options);
this.draw = (view, ctx) => {
ctx.strokeColor = this.tintColor;
const radius = Math.min(view.frame.width, view.frame.height);
ctx.setLineWidth(20);
ctx.setLineCap(1);
ctx.setLineJoin(1);
@Gandum2077
Gandum2077 / JSBox UI Colors.js
Last active April 1, 2020 06:33
查看JSBox全部的语义化颜色,适配dark mode
const TIPS =
"如果在请注意对于黑、白、灰、深灰、浅灰等单色,hexCode仅前两位有效,比如#80FF00其实是灰色,#00FF00其实是黑色。\n由于颜色可以动态变化比较复杂,不对此进行修改。";
$app.theme = "auto";
const semanticColors = [
{
name: "tintColor",
description: "主题色"
},
@Gandum2077
Gandum2077 / rectUtils.js
Created March 5, 2020 15:59
rect计算相关的基础函数
// When called without arguments, return the center of the rectangle. When a Point is passed as an argument, the rectangle’s x and y values are adjusted, so that the new center of the rectangle is p.
function center(rect, point) {
const { x, y, width: w, height: h } = rect;
if (!point) return $point(x + w / 2, y + h / 2);
const { x: px, y: py } = point;
rect.x = px - w / 2;
rect.y = py - h / 2;
return point;
}
class Canvas {
constructor(options) {
this.baseInterval = 1 / 60;
Object.assign(this, options);
this.draw = (view, ctx) => {
ctx.fillColor = this.tintColor;
const radius = Math.min(view.frame.width, view.frame.height);
ctx.setLineWidth(1);
ctx.setLineCap(0);
ctx.setLineJoin(1);
@Gandum2077
Gandum2077 / gbk-html.js
Created February 15, 2020 14:08
Download GBK encoding html
function download(params) {
params = params || {};
params.handlers = params.handlers || {};
const url = params.url;
const method = params.method || "GET";
const timeout = params.timeout || 60;
const header = params.header || {};
const body = params.body;
const callback = params.handler;
@Gandum2077
Gandum2077 / battery.js
Created February 7, 2020 14:24
获取所有连接上设备的电量和名字
$objc("NSBundle").$bundleWithPath("/System/Library/PrivateFrameworks/BatteryCenter.framework").$load();
let deviceController = $objc("BCBatteryDeviceController").$sharedInstance();
let devices = deviceController.$connectedDevices();
for (var idx=0; idx<devices.$count(); ++idx) {
let device = devices.$objectAtIndex(idx);
console.log(`name: ${device.$name().rawValue()}`);
console.log(`percentCharge: ${device.$percentCharge()}%`);
console.log(`charging: ${device.$isCharging()}`);
@Gandum2077
Gandum2077 / createImage.js
Created January 30, 2020 05:31
创建纯色image对象,可以指定大小和颜色,支持全部html颜色,部分系统颜色,并可以自行添加
const htmlColors = {
//Pink Colors
"Pink": "#FFC0CB",
"LightPink": "#FFB6C1",
"HotPink": "#FF69B4",
"DeepPink": "#FF1493",
"PaleVioletRed": "#DB7093",
"MediumVioletRed": "#C71585",
//Purple Colors
"Lavender": "#E6E6FA",