Froxx
Froxx
TTCTheo's Typesafe Cult
Created by Froxx on 7/24/2024 in #questions
Handling ADHD while programming
@finite-field Thanks for the resources! I already knew about second brain. I also listened to the audio book from Tiago Forte a while ago. Really good input. This is actually the reason why I try to push using a note taking while working quite heavily – in my case Notion. I find the ADHD FTW website quite interesing, maybe even for myself. Thanks again for that! I'll show it to him
11 replies
TTCTheo's Typesafe Cult
Created by Froxx on 7/24/2024 in #questions
Handling ADHD while programming
Sorry for the late reply and thanks a ton for your feedback! @e of pi He got the diagnosis but no therapy or medication so far afaik. Regarding the body doubling: We both work from home since we live in different cities, but are constantly in Discord and basically have a "digital office" where we can talk to each other almost every minute of the day if we want. @EntranceJew I don't expect him to work every minute of every day like a clockwork (obviously). I never worked like that neither. But I fear a future where he will work on customers' projects, having a low level of reliability, resulting us moving into struggling sutations time-wise. But I am aware that he is he is still very fresh and things can change alot over time. To give a bit more background info: Since he is mainly learning all the basics for now, I let him work on an own project he chose. It's pretty much a Bulbapedia clone since we're both big Pokémon fans. He gets all data from PokeApi, and is free to design all UI and UX by himself (with me giving him ideas for improvements). He is enjoying the variety in his work doing design as well as coding. We have a daily meeting in the morning and I try having at least 1 or 2 milestones defined during the working day, so he has short term goals, which works mostly well. Some specific challenges I noticed are: 1. Him having quite some trouble as soon as things won't work immediately. He does not have a feeling (yet?) on how to debug problems and I'm not sure on how to teach him this better than reminding him of using console.logs to check his context and find out what exactly works as expected and what doesn't. But I can often see his head blocking in these situations, so he won't even make the connection to use console.logs and just being clueless on how to even start handling the problem. 2. Since he tends to forget quite a lot of things I try to encourage him to take more notes during the day, so when he faces the same problem again, he can just check Notion. But he doesn't really realize when he observes something that's worth writing down. So in both cases what I think might be the core issue is him not "clicking" in these situations and start thinking solution-oriented. And I don't know if that is something he just needs to learn on his own by running into these situations again and again until he gets it, or if I can do something different to make it easier for him. That said I also need to say it is the first time for me teaching someone how to code starting from 0. I worked as a leading dev a few times teaching juniors, but all of them had a few years of working experience covering the basics of soft and hard skills, while he still needs to learn how to think as a developer as well as even how to work in an office job. So all of this is just as new for me as it is for him, and I'm not exactly sure what things happen due to "him not getting it (yet?)" or "me not teaching it right".
11 replies
TTCTheo's Typesafe Cult
Created by Froxx on 7/19/2023 in #questions
Single source of truth for models using Zod and Prisma
What do you mean by that? What would chatgpt be good for here? Generating the zod schemas? That would not be my problem. I don't hesitate writing the schemas myself, I hesitate having to manually change pretty much the same info twice when e.g. my model gets a new prop
6 replies
TTCTheo's Typesafe Cult
Created by Froxx on 7/19/2023 in #questions
Single source of truth for models using Zod and Prisma
Thanks for the suggestion. I thought about that, but it would leave the possibility to devs to use the basic, unrefined schemas. Although I could still at least try to prevent that with some... ✨ documentation ✨ Anyway I don't know if you tried prisma-zod-generator yourself. It kind of does the job creating Zod schemas, but it has a huge amount of overhead for my purpose, and it offers little to no configuration. I wish zod-prisma was still maintained. It seems it did the job a lot better
6 replies
TTCTheo's Typesafe Cult
Created by Massukka on 7/19/2023 in #questions
Zod, mocking fake data that works with refine?
What I do is defining a generate function for each model using faker for data population like so:
import { z } from "zod";
import { faker } from "@faker-js/faker";

const Person = z.object({
firstName: z.string(),
lastName: z.string(),
});

export const generatePerson = (): z.infer<typeof Person> => {
return {
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
};
};
import { z } from "zod";
import { faker } from "@faker-js/faker";

const Person = z.object({
firstName: z.string(),
lastName: z.string(),
});

export const generatePerson = (): z.infer<typeof Person> => {
return {
firstName: faker.person.firstName(),
lastName: faker.person.lastName(),
};
};
6 replies
TTCTheo's Typesafe Cult
Created by slidebug on 5/10/2023 in #questions
Vitest Test can't load serverRuntimeConfig
Judging your file naming, it looks like you are testing behaviour in your user scope. Your error is occuring in .../router/distribution-report.ts which may not be related to your test suite. This code may only get executed because you load your whole appRouter in your user test. You could prevent that by just importing the regarding sub-router (userRouter?) there. This does not answer the actual question, but might help you with your current situation. Maybe it's a generally bad idea to access Next's config data there, but I have no hint on what to do instead. Maybe someone else might have another idea on that.
3 replies
TTCTheo's Typesafe Cult
Created by Revaycolizer on 4/26/2023 in #questions
How can I fetch data in my component
Also you're not rendering the "profiles" state in your component yet
126 replies
TTCTheo's Typesafe Cult
Created by Revaycolizer on 4/26/2023 in #questions
How can I fetch data in my component
Im not familiar with supabase, but the general way of calling your endpoint, wait for a response, and set the result to a state variable in your component looks right. You should probably add am empty dependency array to your useEffect though. Apart from that a bit more information on what's going wrong in your example would help solving the cause.
126 replies
TTCTheo's Typesafe Cult
Created by Noam Muallem on 4/26/2023 in #questions
optional authenticated tRPC function
Usually Auth is handled in a procedure. But if an endpoint shall be conditionally open, I would create a trpc endpoint based on a not authed procedure, check for a session in the endpoint and conditionally throw an unauthorized error. You could of course write a util function for that and implement it in all endpoints like that
4 replies
TTCTheo's Typesafe Cult
Created by Froxx on 4/19/2023 in #questions
Make NextAuth consider i18n
I'm not sure about how much this is in the NextAuth team's mind, but replacing the signIn() call with
router.push({
pathname: "/auth/login",
query: { callbackUrl: router.pathname },
});
router.push({
pathname: "/auth/login",
query: { callbackUrl: router.pathname },
});
does the job. Keep in mind this is just the signIn call without parameters in my route guard, so I get redirected to the login page – not the signIn call on my login page that actually signs me in (e.g. signIn("credentials", { username: "foo", password: "bar" }))
2 replies
TTCTheo's Typesafe Cult
Created by JessesBeetShoppe on 3/12/2023 in #questions
Disable Refetch on Focus in TRPC
This is most likely what you wanna do, and turn it on for specific ones again. Never understood that the refetchOn... options are turned on by default
12 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/9/2023 in #questions
Clean definition of models using Zod schemas
Alright, I searched a bit in the Zod discussions on GH and found this thread which 100% nailed my problem with refined schemas: https://github.com/colinhacks/zod/discussions/694 The contributors know it's now optimal, but explained very well there why they chose the way they did, so I actually go this way now: 1. Define base schema 2. Extend / omit the base schema wherever I need it 3. Create a central function to add my .refine to a minimally abstracted version of the schema I need for it, and add it on top of the transformed base schema It's not perfect in regards of DX, but it does what it's supposed to do. Hopefully my comment will gather some feedback though and maybe trigger an update in some future: https://github.com/colinhacks/zod/discussions/694#discussioncomment-4926037
6 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/9/2023 in #questions
Clean definition of models using Zod schemas
In that case I have to refine my base schema, but can't extend / omit / pick on it later on since refine changes its type to ZodEffect
6 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/9/2023 in #questions
Clean definition of models using Zod schemas
My case is something like this
const Schema = z.object({
amount: z.number(),
children: z.array(Schema),
const Schema = z.object({
amount: z.number(),
children: z.array(Schema),
And I want to add a refinement that checks that amount is >= the sum all of childrens' amounts
6 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/9/2023 in #questions
Clean definition of models using Zod schemas
Regarding the refinement: I need a refinement on the whole object since I want to add a validation regarding multiple (nested) props
6 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/1/2023 in #questions
react-hook-form with formatted numeric values
True. Hooks are nice. Thanks
26 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/1/2023 in #questions
react-hook-form with formatted numeric values
Well I guess I could go for the controlled number inputs for now. I'm not too happy since the simple "add register(name) to it, and everything works fine in the context"-way of RHF is really handy. Anyway, I get my formatted value this way, my validation works, and those are the main points. Taking care of a working reset functionality etc can be seen as "sugar" for the future. So thanks again to you, @Brendonovich , lord of the forms ✨
26 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/1/2023 in #questions
react-hook-form with formatted numeric values
Ah. That makes sense
26 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/1/2023 in #questions
react-hook-form with formatted numeric values
Also taking the 2nd parameter from forwardsRef instead of the one from Controller.render doesn't solve it
26 replies
TTCTheo's Typesafe Cult
Created by Froxx on 2/1/2023 in #questions
react-hook-form with formatted numeric values
Yeah, I read that in the error message as well, but I don't know how React wants to get that there. I tried this, but it doesn't like it:
<Controller
{...{
control: form.control,
name,
render: ({ field: { value, onChange, ref } }) =>
// eslint-disable-next-line react/display-name
React.forwardRef(() => (
<NumericFormat
{...{ value, ref }}
onValueChange={({ floatValue }) => {
onChange(floatValue);
}}
thousandSeparator=","
<Controller
{...{
control: form.control,
name,
render: ({ field: { value, onChange, ref } }) =>
// eslint-disable-next-line react/display-name
React.forwardRef(() => (
<NumericFormat
{...{ value, ref }}
onValueChange={({ floatValue }) => {
onChange(floatValue);
}}
thousandSeparator=","
I don't really know a lot about refs until this point poohheh
26 replies