Days 41-45: Code with Benny
If you're curious what this is all about, check out the Introduction to Code with Benny
Check out my last two posts: Days 31-35, Days 36-40
Follow me on twitter! All of these logs are posted there daily in short-form ๐
What I've done so far:
- Completed all 100 days of Replit's 100 Days of Python course. Wrote about what I've learned in Day 30 "Thoughts"
- Harvard's CS50, weeks 0-4.5!
- Daily log posts and several fun threads (follow me on twitter!)
This week, I'm back in ๐Bali!! Excited to return to routine (for the week). This is my 2nd time flying into Bali, and this time, it really felt like home, which I didn't expect. Lovely to be back ๐
Day 41 (April 23rd, 2023)
What I covered/did
Second half of Week 4 lecture of Harvard's CS50!
- Comparing & copying strings
- Malloc and free (related to memory allocation)
- Valgrind
- Garbage Values
- Swapping values & nuances around memory while doing this in C
- The true meanings of heap and stack overflow!!
- scanf built-in function and using it to recreate CS50 functions
Resources I used
Thoughts
Back in Bali today! Took a rest day to get situated again to being back here. Squeezed in a bit of coding while I was at it.
I'm cruising through CS50. Plan is to go quickly through it this week - I'm excited back to be in routine :)
Also love that I just learned the true meaning of stack overflow (when too many functions are called, overflowing the amount of memory available) in context of how memory is stored in the computer (see below - copied from CS50). Pretty funny that one of the most popular Q&A sites for programmers is called stackoverflow.com, basically saying "too many functions here".
Day 42
What I covered/did
Big day today! I covered the Week4 problem sets/labs/practice problems, and all of Week 5 lecture of CS50.
- Image filtering - what is actually happening to the pixels when a filter is applied in the following scenarios: grayscale, reflection, blur, and edge detection (this last one was super interesting!! and comes from research done in the late 60s)
- Code for turning certain pixels in an image to a different color
- Abstract data structures: queues & stacks
- Resizing arrays & realloc
- Linked Lists and -> operator
- Trees
- Dictionaries
- Hashing & Hash Tables
- Tries
Resources I used
Thoughts
I'm a bit doubtful that all this memory stuff (realloc, malloc, etc) will be relevant to my goal of shipping web apps quickly. It's useful for a comprehensive computer science degree, but a comprehensive CS degree and my indie hacker goals likely don't align 1:1. I'll keep going through it to be better safe than sorry, but I am mindful of using this learning as a distraction/avoidance tactic from building my own stuff. If anything though, I can document how helpful this has been for others to follow my learning roadmap more effectively.
Implementing linked lists is a test in logic - definitely a bit of a mind melter of a concept, but I think I fully understood this after ~45 min of study.
I am finding that as the content gets more complex, I'm spending more and more time watching the lecture (because, for all intents and purposes, the lectures do a great job of robustly explaining the material). I watch the lectures at 2x speed and can keep up okay, albeit with pauses here and there to fully digest and input material into my learning database.
Day 43
What I covered/did
CS50! Skimmed through Problem Sets/Labs from Week 5, and decided I didn't want to do them (to avoid spending a lot of time writing code in C). Breezed through Week 6 Lecture (Python!) given a lot of it was review.
- Everything from Types to Object Oriented Programming to Command Line Arguments (which was new!)
- Learned some nuances around different ways of importing functions, and swapping values in Python
- Learned about some fun libraries for import (qrcode, text-to-speech, etc)
Resources I used
Thoughts
Was nice to have a python review after filling my brain with a bunch of C syntax. I also learned a few new ways to use python, and found that the review was helpful for cementing some python syntax that was loosely jostling about in my cranium ๐ง
Tomorrow is project day for me :) and a review of SQL is coming up!
Day 44
What I covered/did
I started my own project: shouldireadthenewstoday?
- Pseudocoded the structure of the project which included doing the thinking behind the formula for advising the user to read the news or not. Can see the pseudocode here: Pseudocode for shouldireadthenewstoday
- Next steps: code it, and then deploy it! Might use an open-source AI model, rather than OpenAI's offerings
Resources I used
- N/A
Thoughts
Loved thinking through what would be required to build this app. Had to go into my notes from the Replit 100 Days of Python course that I completed by Day 30.
The biggest challenge in building the pseudocode was figuring out how to calculate an output "tolerance score" based on two inputs: the user's inputted general tolerance of bad news, and the % of headlines that are classified as "negative" by the AI model. The difficulty was to test and build the formula - the fact is, that I'm not methodically designing boundary conditions, and its possible that the conditions I'm defining don't allow for an easy polynomial-esque formula that covers all the conditions. I tried to account for this with some if/else statements further up the pseudocode that would exit the code if certain conditions are met. For example, if the user says that they can tolerate any bad news, then there is no reason to calculate the tolerance score, because the output should just be "read the news!". Same goes for headlines being all positive - then the user's tolerance doesn't matter.
But the difficulty is then capturing something like the edge case where all the headlines are negative. In this case, if the user's tolerance of bad news is 10 out of 10, where 10 is "can tolerate any and all bad news", then even if all headlines are negative, the tolerance score should be non-zero (meaning the user should consider reading the news). This should be captured by the if/else statement around the tolerance score being 10. Now while writing this - I think I need to make some pseudocode adjustments ๐ I actually think I may be able to remove or adjust the second if/else statements around the percentage of negative headlines:
Clearly, some more thinking to be done!
Nevertheless, it was fun also improving my prompting with ChatGPT and working with it to create formulas and test them based on a set of input/output conditions I defined myself. Looking forward to cranking away at this some more tomorrow :)
Day 45
What I covered/did
Worked on my project today! Was challenging but a lot of fun.
- Finalized the pseudocode & tolerance score formula. I wrote about how I did that here: ShouldIReadTheNewsToday Notion planning page
- Began to code the thing!
Resources I used
- ChatGPT
- Google Sheets
Thoughts
Good day of deep thinking today. Manage to transform my pseudocode into something that gives logical recommendations that take into account all edge cases I could think of. You can see the most up-to-date pseudocode here.
For the formula for recommending the user whether they should read the news or not, I settled on the following:
- If statements to capture the edge cases for when all headlines are bad or good
- A separate formula to capture the edge cases where all headlines are bad, but tolerance is high
- A formula that captures all other cases. This one I ended up writing myself. It just looks at how many headlines are bad, and then multiplies the tolerance as a percentage by that negative-headlines number (and then scales the whole thing to a 0-100 scale for ease of testing). The idea here is that someone with a given tolerance can go through a certain number of bad articles, and based on how tolerant they are, theyโll interpret it positively or negatively a certain percentage of the time.
tS = 10 * (10-negativeHeadlinesRatio) * (generalTolerance/10)
The pseudocode is still missing a few things - namely HTML/CSS that I still need to write, as well as the flask code to deploy the app. But I think that stuff is, for the most part, just copy-pasting from my notes. The real challenges that remain are debugging this code and setting up the AI model (if not openAI, some open-source one). I think I got bogged down too long in the formula crafting today and yesterday, but I'm happy with my ability to think through this - turns out it's a bit of a complex problem.
Regardless, I'm excited to keep building this thing!!
Wrapping up these 5 days: I really enjoyed starting my project :) I also am glad to be back in Bali. Marathon training is also going smoothly, and I have had a great time seeing my friends here again.
That being said, I definitely am quick to overplan/overschedule my weeks, and this week back in Bali was no exception. I'm looking forward to next week being more open (despite the fact that I will be traveling).
A few content pieces I have on my docket that I want to see if I can get to in the next week:
- A 50-days-in check-in article and overview of what I've done so far
- A marathon training log/summary
- A Bali lifestyle overview and cost of living article
Keep a look out for these ๐
Member discussion