11:40PM Dec 6, 2024:
For too long I keep asking myself what is holding me back from getting to the other side of where I want to be. Fear. It is a strong signal I must learn to lean into and follow. Money, time, focus theses are the biggest ex use I come up with that only equate to setbacks. Now I have all the ingredients I need, so let’s build me a got darn product prototype and but all the demons in my mind to rest.
12:27AM Dec 7, 2024:
CLI to Remember:
As I code I learn. Right now I am working with Next.js learning Typescript and working in Python learning to write Lambda Functions and fine-tuning models for deployment. Every year, every project there is something tremendously new to learn. I am tired of feeling like this hasn’t been my life’s work for over 15 years. This is it, learning a language, breezing my way through lines of code then fighting my way through the errors, bugs and road bumps. The more I do it the more patience I gain for the process knowing full well when the next shiny language or industry shift or new project requirements comes out, I will have to learn that all over and do the same work. There is no perfection in my field just constant learning.
npm run dev: start localhost to display current work with errors and all only local
npm run build: build a production deployment checking first for errors
ctrl+C: to exit run dev in terminal
nextjs-dashboard-postgres
.env is where secrets are kept for database keys.
2:03PM First Debug Completed:
It only took 2.5 hours to figure out why I couldn’t get from point A to B for the purpose of auto seeding my database. The frustrating part is I am following a tutorial and it is built in such a way that forces you to seek answers, debug issues and learn how to navigate on your own. Sure they can give you the step by step and I use to create step by step guides when I was younger. However, I see now the work and the fun isn’t follow the leader to the answer, instead it is the round about path we as engineers take to solve the problem. Like solving a math problem of long division by hand. How you arrive at the answer is more important than the answer. This is where testing programmers gives me anxiety if the work is in deriving the answer, how can one be tested with a limited time or even verbally with the expectation that they can solve the problem as if it were a copy /paste /memorize solution. Was I discriminated from jobs when verbally tested or was everyone treated the same in their career I wonder. Well back to coding, these problems won’t solve themselves.
2:23AM:
Mental break. time to walk away and around for a bit.
2:29AM:
Yes a 6 minute break… and I am back.
Because it always comes up, I want to keep this fix in hand. CORS | Access Control Fix. Or I can use a solution Middleware
3:56AM: Been stuck on a DB error that many have been stuck on. It’s good to know I am not alone, but sucks I have not found a fix for it as yet. One issue is that we were given the illusion of a choice to pick the DB when in fact we might have been limited to Neon Postgres. I may have to go back an hour and redo my DB setup just to move along. The funny thing about this is I can choose to follow the path laid out or learn a new path more in line with the direction I want to head which requires HIPAA Compliance. Hmm to follow the leader or get creative?
4:49AM
Walking away for my own sanity!
4:59AM
I am back, lets try try try again. Turns out the issue couldn’t be tackled because vercel deployment was holding on to an old cache commit. I needed to rest and let it catch up to me. See it turns out no matter how much higher up types like my CEO self want things done, many times it’s just not possible not because the team is slow, lazy or slacking but because WE like my Engineer self have to wait for the tech to catch up to where we are.
While computers are fast very fast, they still don’t process data as fast as we think it up, communicate the idea to another person and then are magically ready to see it live. That’s not life. I have to keep reminding myself of this as a CEO I need to give my Engineer self time and space to work out the details of the problem then wait for the technology to catch up. It already sucks that my computer is 2 years out of date and my internet is business but slow at rural business fiber speed.
I think every CEO should participate in a hackathon to get an understanding of what their engineers got through.
Alright back to hacking away.
7:30AM OMG Time:
So yes, I really just spent 2.5 hours solving DNS, CName, SSL redirect loop errors. For some reason my co-founder and I were seeing the site fine on our end but everyone else was not. So I took the time to update the main domain to point to our production server only to find myself in a cluster fudge. Lost two hours to necessary debugging of a 2 line copy paste task. The drama is so real! And I have decided I am going to give it some time. After all, dnschecker.org came back with all checks, a CLI dig resolved the IP address, and I cleared local cache via CLI but the browser is still not loading. So I will wait a bit then see if time was all it needed otherwise clear local cache via CLI.
Now back to the Postgres issue. At this point I want to roll back my changes and just work with Neon but in all truth what will I learn if I take the route? I think I will give it 30 minutes more then move on and figure out Supabase later.
8:01AM
Words of hard learned wisdom
Work Slow: https://github.com/vercel/next-learn/issues/630#issuecomment-2525165948
Use the
client.release()
method! It is essential for properly releasing the database connection back to the pool after each use. Without releasing the connection, the pool can run out of available connections, leading to performance bottlenecks or errors.Best Practices
Always Use
finally
: Ensureclient.release()
is always called, even if an error occurs.Encapsulate Connection Logic: Creating and releasing the client within the scope of the function ensures better resource management.
Error Handling: Ensure proper error handling to provide meaningful feedback when database issues occur.
8:30AM
Brain Feeding Time: aka Breakfast & Learn (Did you really think I would take a hard break during a hackathon? HA!)
https://youtu.be/4ysK3bCUVhc?si=y2qassddtMezc50s
AWS NOVA: Another consideration they say it’s cheaper.
9:30AM
Back to Work. No time reduction because I was learning other parts of my prototype while munching and looking at my family.
How data id fetched matters. You can stagger to sequence fetchCalls(); for times when you need a condition to be true or batch for parallel fetchAll(); for times when you want to save time and don’t need precursor data.
Example: of waterfall or sequence fetchCalls(); is when you need to load a user by id and their profile settings before loading data specific to them. But if the data is global and not tied to the user you can load in all at once.
In Action: When I was at Market Reader we didn’t need to wait to load in ETF data or Unusual Moves this was what the platform offered to everyone no matter their preferences. However we couldn’t load watch lists and layout preferences until we loaded in the user.id then settings data to fetchWatchList(); If we attempted to load watchlist before user.id we’d either get an error or blank depending on if error catching was setup.
10:30AM Hour Ten Completed!
Gonna take a quick nap. I have to I am fading. If I had gotten a full night’s rest I would push through but the reality is I only got a nap in thinking about starting this hackathon. So 20-40 minutes max for a nice brain and body refresher. Honestly the computer can use a hard shutdown also.
14 Hours to go.
11:20AM
Back in action. I have to say the silence of reading and going at this alone is slowing me down. A video tutorial would be nice as I am all about speed and energy plus I am a visual learner not a literary learner.
12:43PM
Made it through another chapter. I think I need another nap, however I am start 6 hours away from my starting line. Can I push through to actually get something build that is useful for my team not just to my knowledge base?
1:50PM
Break for Drink O Clock and Rubix Cube Solving!
https://www.tiktok.com/@unschoolpagesofourlives/video/7445760839279185182
2:30
Back at it, but with Dinner in the mix. Nope I can’t stop I am on a delirious high!
Found what I need to users who don’t login and are allowed X amount of time to use the app without having to login before the system is triggered to require login or sign up: https://www.npmjs.com/package/use-debounce
Now suck in another “I didn’t do it” roadblock. This time I need to install and us useDebounce but I am getting hella errors from my npm install attempts. and no pnpm does not work. Basically all installs need to be sudo -g global or override project and root permission issues. 1 Hour LOST!
4:39PM
Form validation that saves time and effort.
'use server';
import { z } from 'zod';
const FormSchema = z.object({
id: z.string(),
customerId: z.string(),
amount: z.coerce.number(),
status: z.enum(['pending', 'paid']),
date: z.string(),
});
const CreateInvoice = FormSchema.omit({ id: true, date: true });
Supabase NextJS sql fix
Instead of …
import { sql } from "@vercel/postgres";
Rather, Import at the top
import { db } from "@vercel/postgres";
Then:
const client = await db.connect();
try {
await client.sql`
//YOUR SQL QUERY HERE
`;
} catch (error) {
console.error("Database Error:", error);
throw new Error("Failed to fetch revenue data.");
} finally {
// Release the client back to the pool
client.release();
}
6:50PM
That’s a wrap for now. Need to Rest then crack back at these last 3 chapters of NextJS then on to model APIs for and basic prototype coding.
19 hours, 10 minutes, and 0 second
I think this 24 Hour Hackathon is going to be 48 hours in reality. I haven’t even started on the prototype!
Note not all tutorials a error free either the errors are there on purpose to teach you to debug or someone wasn’t paid enough to care. But getting a guide to listen to through the second half of my day was not only helpful to not feel alone in this journey but they had more trip ups than I did and I too was jumping ahead like then pre-solving before the tutorial because after a while you just know what you’re doing. But then we hit snags in the guide that just slowed us down and forced hours of debugging. I thing the take again is Software Engineering is just all about debugging… that’s the “work” in the midst of all the fun of programing!
For Learning Later:
https://www.youtube.com/watch?v=gCZCTor2Xco