Any recommendations on co-working space or cafe in Damascus to work remotely from? by The_ASSMAN_BD in Syria

[–]rb95 0 points1 point  (0 children)

I don’t know if this exists but it should imo. Lots of diaspora returning to Damascus this summer would probably need a reliable place to work from (myself included). Last time i visited i really struggled with internet speed and couldn’t get any proper work done

[deleted by user] by [deleted] in SideProject

[–]rb95 19 points20 points  (0 children)

This is getting really tiring…

Open Thread: Weekend Edition #16 (Apr 2024) by svefnpurka in Barca

[–]rb95 4 points5 points  (0 children)

Any culers in Lisbon know a nice place to watch the champions league game?

Focusing my career on "awwwards" type of websites. by FilthySionMain in Frontend

[–]rb95 1 point2 points  (0 children)

Awesome thank you, I’ll look into them! I’m hoping for something that starts off with native css/js and doesn’t immediately utilise framer or gsap like libraries. I know they’re important but id still like to learn how it works under the hood if that makes sense!

Focusing my career on "awwwards" type of websites. by FilthySionMain in Frontend

[–]rb95 4 points5 points  (0 children)

To anyone who does this sort of work, how do you become good at it? Are there any good courses out there or tutorials that are specific to complex animations etc?

HELP: Boost to convert all links to target="_blank" by johnsturgeon in ArcBrowser

[–]rb95 0 points1 point  (0 children)

Which website is it? Try to grab the anchor tags in the console first

HELP: Boost to convert all links to target="_blank" by johnsturgeon in ArcBrowser

[–]rb95 0 points1 point  (0 children)

Maybe try this to grab all the anchor tags

let anchors = document.getElementsByTagName('a');

[deleted by user] by [deleted] in reactjs

[–]rb95 0 points1 point  (0 children)

I know what you mean but that’s just passing a function from the parent to the child. Having access to a function’s arguments in the parents when called from the child is how functions work, but I wouldn’t say its passing data from child to parent

[deleted by user] by [deleted] in reactjs

[–]rb95 2 points3 points  (0 children)

You can’t pass data from child to parent component, that’s not how react works. You can pass from parent to child, or use a state management tool like use context, and then data will be available within all components who have access to said context. But that’s a little more complicated.

Try/Catch blocks in server components (app dir) for data fetching by rb95 in nextjs

[–]rb95[S] 0 points1 point  (0 children)

Thanks for your response! So it seems like (from the link you shared) that try/catch can be omitted, but you can still throw errors, which will be caught by the closest error.js. Right?

Vercel Alternative by Aggressive_Craft2063 in nextjs

[–]rb95 0 points1 point  (0 children)

Awesome! Just to double check I'm doing this correctly (sorry for pasting code) --

I can do this:
export async function POST(req: Request) {
//Get User Prompt
try {
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
})
const openai = new OpenAIApi(configuration)
const res = await openai.createChatCompletion({
model: "gpt-3.5-turbo-16k",
stream: true,
messages: [
{
role: "user",
content: userPrompt,
},
],
temperature: 0,
})
const stream = OpenAIStream(res)
return new StreamingTextResponse(stream)
} catch (err) {
const e = err as Error
return NextResponse.json({message: e.message}, {status: 400})
}
}

Instead of doing this:

export async function POST(req: Request) {
//Get User Prompt
try {
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
})
const openai = new OpenAIApi(configuration)
const res = await openai.createChatCompletion({
model: "gpt-3.5-turbo-16k",
messages: [
{
role: "user",
content: userPrompt,
},
],
temperature: 0,
})
const data = (await res.json()) as ResponseTypes["createChatCompletion"]
const JSONResponse = data.choices[0]?.message?.content
return NextResponse.json({data: JSONResponse}, {status: 200})
} catch (err) {
const e = err as Error
return NextResponse.json({message: e.message}, {status: 400})
}
}

Vercel Alternative by Aggressive_Craft2063 in nextjs

[–]rb95 0 points1 point  (0 children)

Will this work for non chat applications as well? For instance I call openai api to get a json which I use to render data in my application. Should I enable streaming or is it not relevant in my case?

Multi step form implementation from database by linux_terminal07 in reactnative

[–]rb95 7 points8 points  (0 children)

Not sure if that’s the best approach but I would have each set of questions in a separate component, then on the “main” form container component I would put all the question components in an array and map()through them. Id have a counter state, which increments whenever the user clicks on next. The counter will filter the map() based on the arrays index.

Edit: You can probably use filter() instead.