Skip to content

Instantly share code, notes, and snippets.

View BrandonStudio's full-sized avatar

BrandonStudio

View GitHub Profile
@BrandonStudio
BrandonStudio / BatchCallback.py
Created April 9, 2024 05:49
LangChain batch job progress bar callback
from typing import Any, Dict
from uuid import UUID
from tqdm.auto import tqdm
from langchain_core.callbacks import BaseCallbackHandler
class BatchCallback(BaseCallbackHandler):
def __init__(self, total: int):
super().__init__()
self.count = 0
self.progress_bar = tqdm(total=total) # define a progress bar
@BrandonStudio
BrandonStudio / StringsExtension.cs
Last active December 26, 2022 12:45
.NET MAUI Globalized String Markup Extension.
/// <summary>
/// Xaml extension providing globalized strings.
/// </summary>
/// <remarks>
/// Providing key itself if specified string is not found,
/// </remarks>
public class StringsExtension : IMarkupExtension<string>
{
/// <summary>
/// Key of globalized strings.
@BrandonStudio
BrandonStudio / register.cmd
Last active November 11, 2023 20:35
VLC URL protocol handler for "vlc://" links on Windows
@echo off
echo Waiting for UAC...
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c ""%~0"" ::","","runas",1)(window.close)&&exit
set /p vbspath=Please enter the path of vlc-protocol.vbs with double quotation mark (e.g. "C:\Program Files\VideoLAN\VLC\vlc-protocol.vbs"):
set command=wscript \"%vbspath:~1,-1%\" %%1
reg.exe add HKCR\vlc /ve /d "URL:VLC"
reg.exe add HKCR\vlc /v "URL Protocol"
reg.exe add HKCR\vlc\shell\open\command /ve /d "%command%"
echo Done!
pause
@BrandonStudio
BrandonStudio / onevercel-cf-raw.js
Last active May 27, 2022 07:00
Getting raw files for onedrive-vercel-index via Cloudflare Workers
addEventListener("fetch", (event) => {
event.respondWith(
handleRequest(event.request).catch(
(err) => new Response(err.stack, { status: 500 })
)
);
});
async function handleRequest(request) {
let requestURL = new URL(request.url)