ibrahimyaacob
ibrahimyaacob
Explore posts from servers
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 7/13/2024 in #questions
How do you achieve this with T3 stack SEO
No description
3 replies
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 12/25/2023 in #questions
I need to validate the uploaded file on clientside before perform upload
I encounter this error on the onBeforeUploadBegin callback function. any other suggestion on how can i achieve the objective ?
2 replies
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 11/2/2023 in #questions
How did Vercel Implement this ??
No description
12 replies
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 11/2/2023 in #questions
How to simulate Open AI's word by word stream works in the backend?
I have a completed string and i want to deliver it word by word instead of dumping the whole string. Apparently the example from chatgpt doesnt works
import { type NextApiRequest, type NextApiResponse } from "next";
import stream from "stream";

export default function Handler(req: NextApiRequest, res: NextApiResponse) {
// Set the response headers to indicate it's a text stream
res.setHeader("Content-Type", "text/event-stream");

// Create a readable stream from your string
const wordsToStream =
"This is the string you want to s as daslfalfj kldfklsad nhkgl skgskdg njkhdgnkjdnj njknjksjgnsjd gsdng ds sndgk dskl stream\n";

const words = wordsToStream.split(" ");
let currentIndex = 0;

const readableStream = new stream.Readable({
read(size) {
if (currentIndex < words.length) {
this.push(words[currentIndex] + " "); // Push a word with a space
currentIndex++;
setTimeout(() => {
this._read();
}, 1000); // Delay for 500 milliseconds
} else {
this.push(null); // Signal the end of the stream
}
},
});

// Pipe the readable stream to the response
readableStream.pipe(res);
}
import { type NextApiRequest, type NextApiResponse } from "next";
import stream from "stream";

export default function Handler(req: NextApiRequest, res: NextApiResponse) {
// Set the response headers to indicate it's a text stream
res.setHeader("Content-Type", "text/event-stream");

// Create a readable stream from your string
const wordsToStream =
"This is the string you want to s as daslfalfj kldfklsad nhkgl skgskdg njkhdgnkjdnj njknjksjgnsjd gsdng ds sndgk dskl stream\n";

const words = wordsToStream.split(" ");
let currentIndex = 0;

const readableStream = new stream.Readable({
read(size) {
if (currentIndex < words.length) {
this.push(words[currentIndex] + " "); // Push a word with a space
currentIndex++;
setTimeout(() => {
this._read();
}, 1000); // Delay for 500 milliseconds
} else {
this.push(null); // Signal the end of the stream
}
},
});

// Pipe the readable stream to the response
readableStream.pipe(res);
}
2 replies
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 10/19/2023 in #questions
with trpc, how to invalidate query only when there's the query cached exist?
it seems like utils.myRouter.myQuery.invalidate(), triggers the query, even though api.myRouter.myQuery.useQuery() is not called from the page. how do i prevent this
3 replies
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 10/16/2023 in #questions
npx create/npm create just freeze forever
No description
2 replies
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 9/8/2023 in #questions
vercel webhook for hobby plan
Is there such thing ? I cannot find it in the menu? what i'm trying to do is to perform request upon successful deployment production branch
2 replies
TTCTheo's Typesafe Cult
Created by ibrahimyaacob on 4/13/2023 in #questions
clerk typesafe metadata
Just how exactly do I do it ?
2 replies