This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""This is an example of how to use async langchain with fastapi and return a streaming response. | |
The latest version of Langchain has improved its compatibility with asynchronous FastAPI, | |
making it easier to implement streaming functionality in your applications. | |
""" | |
import asyncio | |
import os | |
from typing import AsyncIterable, Awaitable | |
import uvicorn | |
from dotenv import load_dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Extension } from "@tiptap/core"; | |
export interface LineHeightOptions { | |
types: string[]; | |
heights: string[]; | |
defaultHeight: string; | |
} | |
declare module "@tiptap/core" { | |
interface Commands<ReturnType> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Extension } from "@tiptap/core"; | |
import "@tiptap/extension-text-style"; | |
export type ColorOptions = { | |
types: string[]; | |
}; | |
declare module "@tiptap/core" { | |
interface Commands<ReturnType> { | |
backColor: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Extension } from "@tiptap/core"; | |
import "@tiptap/extension-text-style"; | |
export type FontSizeOptions = { | |
types: string[]; | |
}; | |
declare module "@tiptap/core" { | |
interface Commands<ReturnType> { | |
fontSize: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Using a JavaScript proxy for a super low code REST client */ | |
// via https://dev.to/dipsaus9/javascript-lets-create-aproxy-19hg | |
// also see https://towardsdatascience.com/why-to-use-javascript-proxy-5cdc69d943e3 | |
// also see https://github.com/fastify/manifetch | |
// also see https://github.com/flash-oss/allserver | |
// and https://gist.github.com/v1vendi/75d5e5dad7a2d1ef3fcb48234e4528cb | |
const createApi = (url) => { | |
return new Proxy({}, { | |
get(target, key) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path' | |
import vue from '@vitejs/plugin-vue' | |
import icons from 'vite-plugin-svg-icons' | |
import inspect from 'vite-plugin-inspect' | |
import tailwindcss from 'tailwindcss' | |
import autoprefixer from 'autoprefixer' | |
import createDebugger from 'debug' | |
import { defineConfig } from 'laravel-vite' | |
export default defineConfig() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// array buffer to JSON | |
const dataString JSON.stringify(Array.from(new Uint8Array(arrayBuffer))); | |
// send around | |
// JSON to ArrayBuffer | |
new Uint8Array(JSON.parse(dataString)).buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 检测浏览器的 User Agent 应该是非常简单的事情 | |
// 微信在 Android 下的 User Agent | |
mozilla/5.0 (linux; u; android 4.1.2; zh-cn; mi-one plus build/jzo54k) applewebkit/534.30 (khtml, like gecko) version/4.0 mobile safari/534.30 micromessenger/5.0.1.352 | |
// 微信在 iPhone 下的 User Agent | |
mozilla/5.0 (iphone; cpu iphone os 5_1_1 like mac os x) applewebkit/534.46 (khtml, like gecko) mobile/9b206 micromessenger/5.0 | |
// 通过javascript判断 | |
// 很容易看出来,微信的 User Agent 都有‘micromessenger’字符串标示,我们判断是否含有这些字符串就OK了 | |
function isWeixinBrowser(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Global : | |
- Only optimize when you need to! Pixi can handle a fair amount of content off the bat. | |
- Be mindful of the complexity of your scene. The more objects you add the slower things will end up. | |
- Order can help, for example sprite / graphic / sprite / graphic is slower than sprite / sprite / graphic / graphic | |
- Some older mobile devices run things a little slower. passing in the option 'legacy:true' to the renderer can help with performance | |
- Culling, is disabled by default as its often better to do this at an application level. If you are GPU it will improve performance, if you are CPU bound - it will degrade performance | |
Sprites: | |
- Use spritesheets where possible to minimize total textures | |
- Sprites can be batched with up to 16 different textures (dependent on hardware) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<textarea style="width:80%;" rows=40 id="text1" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea> | |
<textarea style="width:80%;" rows=40 id="text2" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea> | |
<script src="bower_components/yjs/y.js"></script> | |
<script src="bower_components/y-websockets-client/y-websockets-client.js"></script> | |
<script src="./index_1.js"></script> | |
</body> | |
</html> |
NewerOlder