Skip to content

Instantly share code, notes, and snippets.

@espring
espring / GEMINI.md
Created July 5, 2025 13:10
PlanMode的GEMINI.md

You are Gemini CLI, an expert AI assistant operating in a special 'Plan Mode'. Your sole purpose is to research, analyze, and create detailed implementation plans. You must operate in a strict read-only capacity.

Gemini CLI's primary goal is to act like a senior engineer: understand the request, investigate the codebase and relevant resources, formulate a robust strategy, and then present a clear, step-by-step plan for approval. You are forbidden from making any modifications. You are also forbidden from implementing the plan.

Core Principles of Plan Mode

  • Strictly Read-Only: You can inspect files, navigate code repositories, evaluate project structure, search the web, and examine documentation.
  • Absolutely No Modifications: You are prohibited from performing any action that alters the state of the system. This includes:
    • Editing, creating, or deleting files.
  • Running shell commands that make changes (e.g., git commit, npm install, mkdir).
@espring
espring / gist:e0aaf3d0bb3de16d9b6b42174d79abf2
Created July 17, 2024 06:46
node-schedule 支持更多cron定义
每5秒执行一次。 cron的格式:*/5 * * * * *, node-schedule支持比标准cron多一个秒的设置, */5 表示每5秒。
```
import * as schedule from 'node-schedule'
const job = schedule.scheduleJob('*/5 * * * * *', function(){
console.log(`${new Date().toISOString()}`);
});
```
@espring
espring / MQTT.js v5 enhanced authentication.md
Last active August 10, 2023 01:07
MQTT.js v5 enhanced authentication

与Server无交互, 使用固定的 authenticationData

  • authenticationMethod 在各处必须是相同.
  • 覆盖client.handleAuth方法, 在cb函数中将原有的packet返回, 不这样做, 会报undefined错误. 不明白为什么是这样.
const mqtt = require('mqtt')

  const opt = {
    protocolVersion: 5, // MQTT5
@espring
espring / protobuf.js.md
Last active August 1, 2023 05:45
protobuf.js

https://github.com/protobufjs/protobuf.js

保持proto文件中变量名的定义格式

> const protobuf = require('protobufjs');
> const root = new protobuf.Root();
> root.loadSync('./test.proto', {keepCase: true});
@espring
espring / gist:906bc6dc63db9295717be0109c6d3b0a
Last active March 24, 2023 10:17
ethers.js cheatsheet
## 生成bytes32
ethers.utils.formatBytes32String("")
空字符串时生成 0x00...00
## 私钥 -> 公钥 -> 地址
@espring
espring / golang: dotenv
Created January 5, 2023 02:05
golang 环境变量配置库
//https://github.com/joho/godotenv
import (
"log"
"os"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load()
```js
'use strict';
const Boom = require('boom')
module.exports = {
lifecycles: {
beforeCreate: async (data) => {
# basic usgae.
const { describe, expect, test, it } = require('@jest/globals')
beforeAll( async () => { });
afterAll( async () => { });
beforeEach(() => { });
afterEach(() => { });
@espring
espring / Joi cheatsheet
Last active August 12, 2021 06:56
Joi cheatsheet
# basic usage.
```js
const Joi = require('joi')
const Schema = Joi.object({
username: Joi.string().required().description('user name)
})
// 如果失败, 抛出异常.
const value = await Schema.validateAsync(config)
// 同步返回value, 如果出错, error不为null
const fs = require('fs')
const path = require('path')
const withLess = require('@zeit/next-less')
const lessToJS = require('less-vars-to-js')
require('dotenv').config()
// Where your antd-custom.less file lives
const themeVariables = lessToJS(
fs.readFileSync(path.resolve(__dirname, './assets/custom-less/antd-custom.less'), 'utf8')