Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@akira-cn
akira-cn / proxy.js
Last active November 16, 2023 16:10
const fetch = require('node-fetch');
const endpoint = "api.openai.com";
async function handleRequest(params, context) {
const path = context.request.url.replace(/\/[^\/]+/, '');
const fetchAPI = `https://${endpoint}/v1${path}`;
console.log(fetchAPI);
const headers = {
...context.headers,
const compiler = require('@vue/compiler-sfc');
function generateID() {
return Math.random().toString(36).slice(2, 12);
}
module.exports = function transformVueSFC(source, filename) {
const {descriptor, errors} = compiler.parse(source, {filename});
if(errors.length) throw new Error(errors.toString());
const id = generateID();
export default 42;
console.log('hello');
{"storageType":"元|物|爻|術|言|列|數","constantNumeric":"負|·|又|零|〇|一|二|三|四|五|六|七|八|九|十|百|千|萬|億|兆|京|垓|秭|穰|溝|澗|正|載|極|分|釐|毫|絲|忽|微|纖|沙|塵|埃|渺|漠","constantLang":"陰|陽|其","keywordsModifier":"吾有|今有|有","keywordsType":"數|列|言|術|爻|物","keywordsControl":"乃行是術曰|若其不然者|乃止是遍|乃歸空無|欲行是術|若其然者|其物如是|乃得矣|恆為是|之術也|必先得|是術曰|之物也|云云|其餘|中之|為是|之長|乃止|若非|或若|乃得|是謂|蓋謂|或云|者|若|遍|充|銜|凡|也","keywordsOperator":"中有陽乎|所餘幾何|中無陰乎|不等於|不大於|不小於|等於|大於|小於|加|乘|除|變|以|於|減","keywordsOther":"不知何禍歟|不復存矣|如事不諧|姑妄行此|吾嘗觀|之禍歟|乃作罷|名之曰|書之|以施|之禍|嗚呼|之義|昔之|方悟|是矣|今有|吾有|之書|物之|夫|中|今|取|噫|曰|施|豈|有","tokenizer":{"root":[[{"type":"RegExp","source":"(注曰|疏曰|批曰)。「「","flags":""},"comment","@blockComment"],[{"type":"RegExp","source":"(注曰|疏曰|批曰).*$","flags":""},"comment"],[{"type":"RegExp","source":"#!.*$","flags":""},"comment"],[{"type":"RegExp","source":"「「","flags":""},"string","@string"],[{"type":"RegExp","source":"「","flags":""},"variable.name","@variableName"],[{"type":"RegExp","source":"。","flags":""},"delimiter"],[{"type":"RegExp","source":"@constantNumeric","flags":""},"constant.numeric"
#!/jcode/lang/glsl
export default {
// Set defaultToken to invalid to see what you do not tokenize yet
// defaultToken: 'invalid',
keywords: `break continue discard return
for while do if else struct
in out inout
for while do if else struct`.split(/\s+/),
typeKeywords: `float int bool void
class Complex {
#r = 0;
#i = 0;
get r() {
return this.#r;
}
set r(value) {
this.#r = value;
}
get i() {
const el = document.createElement('script');
el.textContent = 'console.log(123)';
document.getElementById('app').appendChild(el);
const a = 10;
function jump(arr) {
let cur = 0;
const target = arr.length - 1;
if(cur >= target) return true;
while(cur < target) {
const r = arr[cur];
if(r <= 0) return false;
if(cur + r >= target) return true;
let o = 0, s = cur;