Skip to content

Instantly share code, notes, and snippets.

@mqzhang
mqzhang / askllm_for_google_apps_script.gs
Created February 27, 2025 01:21 — forked from lyricat/askllm_for_google_apps_script.gs
AskLLM for Google Sheet Apps Script
function AskLLM(base, token, model, systemPrompt, query) {
// support all openai compatible api: openai, deepseek, grok, etc
var apiUrl = base + "/chat/completions";
var payload = {
"messages": [
{
"role": "system",
"content": systemPrompt
},
{
@mqzhang
mqzhang / CONVENTIONS.md
Created February 12, 2025 01:32 — forked from peterc/CONVENTIONS.md
CONVENTIONS.md file for AI Rails 8 development
  • You MUST NOT try and generate a Rails app from scratch on your own by generating each file. For a NEW app you MUST use rails new first to generate all of the boilerplate files necessary.
  • Create an app in the current directory with rails new .
  • Use Tailwind CSS for styling. Use --css tailwind as an option on the rails new call to do this automatically.
  • Use Ruby 3.2+ and Rails 8.0+ practices.
  • Use the default Minitest approach for testing, do not use RSpec.
  • Default to using SQLite in development. rails new will do this automatically but take care if you write any custom SQL that it is SQLite compatible.
  • An app can be built with a devcontainer such as rails new myapp --devcontainer but only do this if requested directly.
  • Rails apps have a lot of directories to consider, such as app, config, db, etc.
  • Adhere to MVC conventions: singular model names (e.g., Product) map to plural tables (products); controllers are plural.
  • Guard against incapable browsers accessing controllers with `allo
@mqzhang
mqzhang / decent_request.py
Created December 21, 2023 12:22 — forked from laixintao/decent_request.py
Send HTTP requests using python-requests with timeout, tcp reuse(session) and retry.
from requests.adapters import HTTPAdapter, Retry
from requests import Session
retries = Retry(
total=5, backoff_factor=1, status_forcelist=[502, 503, 504]
)
session = Session() # reuse tcp connection
session.mount("http://", HTTPAdapter(max_retries=retries))
session.mount("https://", HTTPAdapter(max_retries=retries))
@mqzhang
mqzhang / weread.user.js
Created October 18, 2022 14:18 — forked from jianyun8023/weread.user.js
weread download,直接生成epub。仅用于技术研究。
// ==UserScript==
// @name 微信读书下载
// @namespace http://tampermonkey.net/
// @version 0.5
// @description 下载微信读书的书籍资源
// @author tang
// @match https://weread.qq.com/web/reader/*
// @grant unsafeWindow
// @grant GM_setValue
// @grant GM_getValue