Skip to content

Instantly share code, notes, and snippets.

View ducva's full-sized avatar

Vu Anh Duc ducva

  • Resola.ai
  • Viet Nam
View GitHub Profile
@ducva
ducva / CursorTools.json
Created April 15, 2025 07:25 — forked from ScriptedAlchemy/CursorTools.json
Reverse Engineering cursor prompts
{
"tools": [
{
"type": "function",
"function": {
"name": "codebase_search",
"description": "Find snippets of code from the codebase most relevant to the search query.\nThis is a semantic search tool, so the query should ask for something semantically matching what is needed.\nIf it makes sense to only search in particular directories, please specify them in the target_directories field.\nUnless there is a clear reason to use your own search query, please just reuse the user's exact query with their wording.\nTheir exact wording/phrasing can often be helpful for the semantic search query. Keeping the same exact question format can also be helpful.",
"parameters": {
"type": "object",
"properties": {
@ducva
ducva / .env
Created March 14, 2024 11:32
Simple Assitant Script
OPENAI_API_KEY=
@ducva
ducva / zod.final.ts
Created January 8, 2024 13:54
zod final
export const validateChannelConfig = z.discriminatedUnion('type', [
z.object({
type: z.literal(ChannelType.LINE),
config: LineChannelConfigSchema
}),
z.object({
type: z.literal(ChannelType.MAIL),
config: MailChannelConfigSchema
})
])
@ducva
ducva / zod.second.ts
Created January 8, 2024 13:51
zod second
export const ChannelSchema = z.discriminatedUnion('type', [
z.object({
id: z.string(),
name: z.string(),
type: z.literal(ChannelType.LINE),
config: LineChannelConfigSchema
}),
z.object({
id: z.string(),
name: z.string(),
@ducva
ducva / zod.first.ts
Created January 8, 2024 13:46
zod first try
const ChannelConfigSchema = z.union([
LineChannelConfigSchema,
MailChannelConfigSchema
])
export const ChannelSchema = z.object({
id: z.string(),
name: z.string(),
type: z.nativeEnum(ChannelType),
config: ChannelConfigSchema
@ducva
ducva / liff-app-prod.js
Last active April 11, 2023 02:55
liff-app-prod.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAADcYNABPANwCg5q4A7PvsAAPEAwBKz2YA9/33ANX11QCI35oAkeWRAPL88gAFvCsAI8RFAL/uyQAzyFIAHsNAAPj9+AAszSwA8/zzAJLiowCq66oA6frpAADDAACl6qUAP9I/ACjGSQCg6aAAOtE6AGzcbAAozCgABsQGABG/NQCs6bkAGsI9APn9+gBX0nEA4PjgAL7wvgD9//0AFMgUAM7zzgCe5a0Add91AALDAgDm+eYA9Pz2ACXFRgDh+OEAv/C/AP7//gBy2YcAa9iCAPn++QAyzzIAxfHFAPb89wA90T0A4vjiAJ7ongBFzWEA////AD7MXAAWyBYAXdR2AFXXVQD6/voALs4uAAzGDACx7bEAF8E7ADbJVQDB8MEAArwpABHANgC87scAF8gXAN733gB433gA6/ruADTPNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@ducva
ducva / liff-app.js
Last active January 19, 2023 04:48
Liff app for I want it campaign
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAEAAAAAAAAAAAAAAAEAAAAAAAAAAAAADcYNABPANwCg5q4A7PvsAAPEAwBKz2YA9/33ANX11QCI35oAkeWRAPL88gAFvCsAI8RFAL/uyQAzyFIAHsNAAPj9+AAszSwA8/zzAJLiowCq66oA6frpAADDAACl6qUAP9I/ACjGSQCg6aAAOtE6AGzcbAAozCgABsQGABG/NQCs6bkAGsI9APn9+gBX0nEA4PjgAL7wvgD9//0AFMgUAM7zzgCe5a0Add91AALDAgDm+eYA9Pz2ACXFRgDh+OEAv/C/AP7//gBy2YcAa9iCAPn++QAyzzIAxfHFAPb89wA90T0A4vjiAJ7ongBFzWEA////AD7MXAAWyBYAXdR2AFXXVQD6/voALs4uAAzGDACx7bEAF8E7ADbJVQDB8MEAArwpABHANgC87scAF8gXAN733gB433gA6/ruADTPNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
class Authed:
def __init__(self, func: typing.Callable[[str], None]):
self.func = func
self.checked_times = 0
def __call__(self, arg: str):
print('checking auth....OK')
self.checked_times += 1
def filter_message(prefix: str):
def inner_check(func: typing.Callable[[str], None]):
def inner_deeper_check(arg: str):
if arg.startswith(prefix):
print('Checking prefix....OK')
func(arg)
print('post process...OK')
else:
print('Checking prefix....Failed')
print('access denied')
@ducva
ducva / decorator.py
Last active May 28, 2020 01:45
how to declare a decorator
def authed(func):
def auth_check(*args, **kwargs):
print("checking authentication")
func(*args, **kwargs)
print("post-process")
return auth_check