Skip to content

Instantly share code, notes, and snippets.

View wonglok's full-sized avatar
🙏
Thank you Jesus for the new life

Wong Lok wonglok

🙏
Thank you Jesus for the new life
View GitHub Profile
/db
/plugins
/uploads
/logs
@wonglok
wonglok / VectorDB.ts
Created October 11, 2024 05:48 — forked from nico-martin/VectorDB.ts
An in-memory vectorDB for cosine similarity search in TypeScript that runs directly in the browser and uses TransformersJS for the embeddings.
// requires the experimental v3 of transformersJS:
// npm install xenova/transformers.js#v3
import { FeatureExtractionPipeline, pipeline } from "@xenova/transformers";
export interface Entry<T> {
str: string;
metadata: T;
}
export interface VectorizedEntry<T> extends Entry<T> {
/*------------------------
Libraries
------------------------*/
const axios = require("axios");
const fs = require("fs");
const FormData = require("form-data");
/*------------------------
Download the file.
Good article on how to download a file and send with form data - https://maximorlov.com/send-a-file-with-axios-in-nodejs/
@wonglok
wonglok / vat.py
Created August 9, 2023 03:29
avatar fake crowd vat
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@wonglok
wonglok / blender-socket.py
Last active March 28, 2023 09:15
websocket with blender
import asyncio
import websockets
async def echo(websocket):
async for message in websocket:
await websocket.send(message)
async def main():
async with websockets.serve(echo, "localhost", 8173):
await asyncio.Future() # run forever
@wonglok
wonglok / pattern xyy.glsl
Created March 1, 2023 10:11
pattern xyy.glsl
const float MY_PI = 3.14159265;
const float MY_SCALE = 1.0;
const mat3 m = mat3(
cos(MY_PI * MY_SCALE), -sin(MY_PI * MY_SCALE), 0.0,
sin(MY_PI * MY_SCALE), cos(MY_PI * MY_SCALE), 0.0,
0.0, 0.0, 1.0
);
float noise( in vec3 p ) {
return cos(p.x) * sin(p.y) * cos(p.z);
@wonglok
wonglok / index.html
Created June 14, 2022 08:56 — forked from BlueMagnificent/index.html
Javascript 3D Physics Snippet Four
<html>
<head>
<meta charset="utf-8">
<title>JS 3D Physics</title>
<style>
body { margin: 0; }
</style>
</head>
<body>
<script src="js/three.js"></script>
@wonglok
wonglok / tryme.js
Last active February 14, 2022 01:26
tryme.js
import { OrbitControls } from "@react-three/drei";
import { Canvas } from "@react-three/fiber";
import { Bloomer } from "../vfx-library/Bloomer";
import { ENLogicGraphAutoLoad } from "../vfx-runtime/ENLogicGraph";
export default function TryMe() {
let REPLACE_ME = `-MvpfxG3QZ37safQAPJS`;
return (
<Canvas dpr={3}>
{/* content-sphere */}
@wonglok
wonglok / effect node by you rules json.js
Last active February 14, 2022 00:59
effect node by you rules json
{
"rules": {
".read": true,
".write": false,
//
//
"profile": {
"$owner_user_id": {
".read": "true",
@wonglok
wonglok / AppExample.js
Last active February 12, 2022 03:42
Per-Pixel-Glow-Threejs with FXAA
<AppMiniAPI>
{({ api }) => {
return (
<Starter reducedDPI={2}>
<GLMiniAPI api={api}>
{({ gpi }) => {
return (
<LinkGLToDOMAPI
init={() => {
api.now.renderMode = "pixel"; // pixel, mesh, none