2022
Navigation
Jan - Feb - Mar - Apr
May - Jun - Jul - Aug
Sep - Oct - Nov - Dec
Resources
MIT Bootcamp 1/31
Coding Bootcamps Won't Make You A Developer 1/31
Pointer Programming Exercises 2/2
C Programming Issues with scanf() 5/4
How to Install and Use Make in Windows 6/7
Boot Linux from a USB on Windows 10 6/20
Hash Table Explanation 7/1
How to Use Global Variables 7/1
Applications of a Hash Table 7/5
Data Structures & Algorithms 7/5
Merge Sort in C 7/15
mergeSort(): A Graphical, Recursive, C++ Explanation 7/16
Most Tech Interview Prep is GARBAGE. (From a Principal Engineer at Amazon) 7/21
Reading CSV Files in Python 7/27
The 1 Coding Project Idea Guaranteed To Get You A Software Development Job 8/12
Memory Management in C: The Heap and the Stack 8/15
A const int is not a constant. 8/15
Wikipedia 8/31
Programming Security and Why Rust 8/31
BMP Output 9/12
What is Embedded Development? 9/19
Git Rename Master to Main 10/5
Setup Relationship Django Models 10/24
Django Send Email 11/3
RST 11/7
Mount Virtual Hard Disk VHD File - Ubuntu 11/7
Applications of C 11/9
How Do I Remove Windows but Keep Ubuntu 11/12
How Do I Remove Windows From the UEFI Boot Menu After Custom Installing Ubuntu 11/12
Django Check Constraints 11/29
Web Development Tools 11/29
WebAssembly 11/30
How to Fix Domain - GitHub Pages 12/4
How to Upload and Process the CSV File in Django 12/7
Screen Recording 12/15
Regular Expressions 12/18
Regular Expressions Cheatsheet 12/19
C Documentation 12/19
C: Loops & feof() 12/22
Open A Terminal Window 12/26
1/1/2022
CS50x
(Wk2) Finished substitution.c and consequently week 2!
1/2/2022
CS50x
(Wk3) watched half of Lecture 3.
1/3/2021
CS50x
(Wk3) finished Lecture 3. Watched all the shorts. Completed Lab 3 "Sort." Completed first of Problem Set 3, "Plurality."
1/4/2021
CS50x
(Wk3) working on runoff.c. I really think I'm in the deep end here. I'm finding myself frustrated! But I will persist a little bit at a time.
1/5/2022
CS50x
(wk3) finished runoff.c! What a relief. I was misunderstanding the usage of a couple key variables. Consulting the discord forum, I figured it out.
1/6/2022
Bankless Podcast: 2021 Rollup Episode
1/7/2022
CS50x
(wk3) working on tideman.c. Since I found runoff.c such a challenge, I decided I'd better complete the other project from this pset as well. Feeling pretty good about it so far!
Bankless Podcast: Episode 99 - Endgame
1/10/2022
CS50x
(wk3) I'm not going to finish the Tideman problem. I already completed runoff and I am only required to solve one of the problems.
Udemy
More lectures on the MetaMask faucets. Will start Solidity tutorials soon. Successfully received Ropsten ETH from moonborrow.com
Watched some videos about recursion by the YouTube channel Computerphile.
1/11/2022
CS50x
(wk4) watched most of Lecture 4.
1/14/2022
CS50x
Wk4 shorts, Pointers
Bankless Podcast
Sololearn
C language
1/15/2022
Sololearn
C language (writing my own program, Pythagorean)
1/16/2022
Sololearn
A couple lessons. Tried out code coach.
CS50x
Wk4, finished watching shorts. Completed Lab 4 volume.c (I have to say I’m currently frustrated with this course - it's progressing too fast for me. I stopped keeping up around week 3. Maybe this is just a part of the process. I had to use the “not sure how to solve” option on volume.c)
Sololearn
I’m trying out a two-week free trial. I like this course so far!
1/17/2022
Sololearn
This app is really helping me solidify what I’ve learned in CS50 and teaching me new material along the way. Finished Code Coach exercise to change decimal to hexadecimal.
1/18/2022
Sololearn
Completed several lessons and code coach projects. Decided to take a pause on CS50 this week while I use Sololearn to refresh what I’ve learned.
1/19/2022
Khan Academy
Taking a course called “Computers and the Internet.” Reviewing the binary system.
1/20/2022
Sololearn
Clarified my understanding of pointers. I think I’m finally beginning to understand them! I’m still struggling with how to use pointers in relation to strings.
Khan Academy
Reviewing Binary.
1/22/2022
Sololearn
Trying to figure out how to take string inputs and parse them is annoying. Tried working on a code coach where you turn standard time into military time.
CS50x
Wk4 after a hiatus, I return! And with a vengeance. I ripped through several of the problems in the “filter” problem set, and I feel fantastic about it.
Khan Academy
Learned about number limits, overflow, and roundoff errors in computing.
1/23/2022
CS50x
Wk4 worked on the filter problem set some more!
1/24/2022
Sololearn
Wrote a simple program that reverses an array, so I could see what I’m doing wrong with the “blur” filter in #### CS50x.
CS50x
Finished the filter problem set! The problem was I had been conflating the number of elements of an array with its indices. Since arrays are zero-indexed, the last index of an array will always be the number of elements minus one:
/*
23, the 1st element is at array[0], and 5, the fifth element is at array[4]
*/
Int array[] = {23, 12, 76, 20, 42};
Khan Academy
Storing text in Binary - learned more about ASCII, Unicode (not an encoding), UTF-8, and others.
1/25/2022
Khan Academy
Converting Analog Data to Binary.
Sololearn
Struggle and anger! Tried two code coaches that kicked my ass! I didn’t solve them. Man, programming has been nothing but a struggle today!!
YouTube
Jacob Sorber channel Beginner C Playlist
TAKEAWAY: get comfortable with everything involving strings and pointers.
1/26/2022
YouTube
Jacob Sorber Beginner C Playlist // this is really helpful! Just implemented an elegant solution for string reversal. This review is paying off.
CS50x
Succeeded in compiling my code for the Recover pset, but when I run it, I get “Segmentation Fault (core dumped)”. However, I’m happy with my progress. Time to debug!
1/27/2022
CS50x
Wk4 finished recover.c!! Definitely perused Discord for some help, but I did do nearly all the heavy lifting myself. On to week 5!
Sololearn
Void pointers and part of module quiz
1/28/2022
Sololearn
Trying to solve Military Time code coach. I satisfied more test cases, but case 5 still eludes me.
1/29/2022
Sololearn
Tried to solve Text Decompressor. Hitting some walls!
Khan Academy
A couple lessons about Lossless and Lossy Compression.
1/30/2022
Sololearn
Solved Text Decompressor! Using Data type “long” seems to work better than “int”. Also, I used “malloc()” and “free()” from the stdlib.h, and this is what solved the last problem.
1/31/2022
Sololearn
Lesson on structs and typedef. Solved Flowing Words code coach on first try!
Khan Academy
Learned about Run-Length Encoding (RLE), a primitive form of compression that works mainly with black and white text documents, bitmaps, etc. Completed quiz on compression.
Bootcamp Research: MIT Bootcamp
THIS article was a slap in the face: Coding Bootcamps Won't Make You A Developer
2/1/2022
Sololearn
Solved Credit Card Validator. Learned that a char can easily be converted to int by the following: int num = c - ‘0’; // subtracting the zero character
INSIGHT: need to really focus on pointers
2/2/2022
Research: MIT Back End Development course
Help with pointers: Pointer Programming Exercises
Sololearn
Easy Kaleidoscopes Code Coach. I used a pointer to solve this one just for the practice.
2/3/2022
Sololearn
New Driver’s License Code Coach solved! It was labeled hard too!
2/4/2022
Khan Academy
More on lossless and lossy compression.
Sololearn
Working on code coach No Numerals. I want to use an array of strings, and I’m finding it’s a little harder than I thought to sort out. Solved No Numerals, but I don’t like the aesthetic of my code. I want my solutions to be more elegant.
2/5/2022
Sololearn
Trying out Hofstadter Q Sequence code coach, and it’s kicking my butt! I tried recursion, which satisfied two of the success cases, but any numbers bigger than around 44 take far too long to calculate, if they calculate at all. The solution is Dynamic Programming (or memoization), which I barely understand at this point!
2/6/2022
Sololearn
A few lessons
2/7/2022
Sololearn
Trying to solve the day of the week code coach.
2/8/2022
Sololearn
Day of the week code coach -> learned about the Doomsday rule and an algorithm devised by John Conway to calculate the day for a given date mentally.
CS50x
45 minutes of Lecture 5 (I’m noticing that I understand the nomenclature much better! Sololearn has really helped.)
Used Valgrind on my wday.c program and found that I had a memory leak! I fixed it by freeing memory I’d forgotten about. I bet this was what caused my computer to freeze up!
2/9/2022
Sololearn
Finished a couple lessons
CS50x
Finished Week 5 Lecture
YouTube
Computerphile - Pointer Power!
Khan Academy
Digital Information Unit Test passed!
2/10/2022
Sololearn
Finished three lessons and in the process, a section. I have plenty of practice to do!
Khan Academy
Logic gates
2/11/2022
Khan Academy
Logic gates.
Sololearn
YouTube Link Finder code coach
2/12/2022
Sololearn
Solved Camel to Snake code coach!
2/13/2022
Sololearn
Worked on the Day of the Week code coach in VSCode.
2/14/2022
Sololearn
Made a lot of progress on my Day of the Week code!
I’ve solved the Day of the Week challenge! Strangely, one date gives me problems: every time I enter March 13, 1887 or 3/13/1887 I get a Segmentation Fault (signal 11).
2/15/2022
Sololearn
I’ve continued to edit my Day of the Week code and I found more bugs to squash. I improved the code and it’s time for another few rounds of testing!
Downloaded MingW gcc compiler and successfully compiled and ran my wday.c program in Windows Command Prompt!
2/16/2022
Moved my personal programs from VSCode to Atom. I’m using the gcc compiler in Atom. Decided to improve the hexchange.c program; I added error handling, the fgets() function for better input handling, and I streamlined some of the code.
Learned more about bitwise operations and began to see how useful they can be!
2/17/2022
General research. I didn’t get to do much since it’s my busiest day at work.
2/18/2022
CS50x
Watched short on Singly-Linked Lists.
My Projects: tried to gain deeper understanding of File Handling with some success. I need to dig deeper here for a bit. I want to make a cryptographic program that open a txt file and scrambles it according to an algorithm. Played around with file handling some more and I am having more success! I was able to open a file and duplicate it with my program. What’s more, I dynamically allocated memory with the following:
Buffer = malloc(sizeof(inFile));
WOW: this is an event! I thought of making this program (texthash.c) a while back and I finally did it! It works perfectly. You open a .txt file with the program and give it a 26 character cipher and it produces a new, encrypted .txt file!
BREAK: I’ve continued to practice here and there, but the moving process has taken up a lot of my time!
2/23/2022
YouTube
Jacob Sorber’s video on Linked Lists. I watched half of the video and am simply playing around with the logic or linked lists.
Got clearer on the arrow operator ( -> ).
Found that I cannot use the assignment operator to assign a string to an array that was declared separately. Must use strcpy().
2/24/2022
Sololearn
Took a shortcut in the C++ curriculum.
2/25/2022
CS50x
Finished up Week 5 Shorts.
2/26/2022
Sololearn
Solved a hard code coach - 2D Grid
2/27/2022
Sololearn
Nearly solved the Password Validator code coach.
2/28/2022
CS50x
Finished Week 5 Lab - Inheritance.
Sololearn
Solved Password Validator!
3/1/2022
CS50x
Read through the pset5 Speller guide carefully. I still need to watch the walkthrough videos.
YouTube
Jacob Sorber video on Linked Lists. I’m feeling a little overwhelmed with this one, yet I also felt that way with file handling and pointers at first: the answer is steady application!
Sololearn
More C++ lessons
Practiced with pointers: codeforwin.org
3/2/2022
Codeforwin.org practicing with pointers
3/3/2022
Codeforwin.org practicing with pointers: array search
Codeforwin.org input and print 2D array with pointers: eureka! Solving this felt like a triumph!!
3/4/2022
Codeforwin.org Pointer Practice - getting the length of a string without strlen(). Learned more about prefix and postfix increment operators. My program is called “slength.c”.
3/5/2022
Codeforwin.org - puzzling over prefix and postfix usage of decrement and increment operators.
3/6/2022
Codeforwin.org - wrote a program to concatenate two strings without using strcat().
Improved the syntax and functioning of some of my old programs; organized everything into folders.
3/7/2022
Jacob Sorber: hash tables video 🤯😵💫
Feeling quite frustrated, but I think I see a path ahead. Stay project-oriented.
3/8/2022
Jacob Sorber: hash tables
Linked List practice
3/9/2022
More hash table practice; worked on really understanding the difference between prefix and postfix with increment and decrement operators.
3/10/2022
Sololearn
Practicing with array sorting.
—Guess I needed a break—
3/15/2022
CS50x
Problem Set 5 Speller
4/5/2022
Am I back in the saddle? It feels better to code!
CS50x
Pset5 Speller - worked a little on the hash function!
Udemy
Download & install Code Blocks, watched a few intro videos. This course will be good for reviewing fundamentals and filling in gaps.
4/18/2022 🙂
Found myself experimenting with xenharmonic tunings again, so I built a simple C program to help me easily calculate the ratios and frequencies needed for any subdivision of the octave. Moreover, I got the program to play the frequencies back to me using the beep functions in the windows.h library! I feel inspired to code again!
4/19/2022
Udemy
Going over fundamentals!
4/25/2022
Udemy
Watched a couple videos. Trying to get even more grounded in fundamentals.
4/26/2022
Udemy
Going over fundamentals.
5/3/2022
Udemy
Exercises on the Basics - 15, 16. I’m learning to use infinite loops - what a useful thing.
5/4/2022
Trying to work on my octave division program, which I renamed xencalc.c because I want it also calculate the harmonic series. I got hung up on trying to take chat input with scanf. It wasn’t working at all; even though it successfully read the input, the while loop (used for error checking) kept iterating even when the input wasn’t errant! Ugh. Stupid scanf. Moreover, getchar and getc didn’t work either.
LOL I figured out the problem: it was my logic!! I wrote:
While (prog != ‘T’ || prog != ‘H’)
When I should have written:
While (prog != ‘T’ && prog != ‘H’)
😂😂
Nearly finished updating this program and I learned a lot in the process! Rewarding experience. This video was helpful: C Programming Issues with scanf()
5/5/2022
Updated my xencalc.c program: Octave Division (TET) now has no limit on the melody that can be described. The program uses a linked list and creates as many nodes needed to accommodate every note entered by the user. To signal that they are done inputting values, the user enters -1 and the program plays the melody. However, it plays it backwards! I need to fix this bug.
5/8/2022
Xencalc program - fixed the playing backwards problem!! I searched online for how to iterate through a linked lists in reverse, and someone mentioned a doubly linked list. Without learning how to implement it, I set about trying to figure it out myself, and I did!! This is a great personal triumph.
5/9/2022
Xencalc program
Played with it some more. Debugging: the program didn’t let you continue more than once, and the problem was that my delete_list function looked like this:
Delete_list(node *h, node *t);
Instead, it needed a double pointer (I’m still working out why):
Delete_list(node **href, node *t);
I used “href” to help distinguish from the actual head.
Messed around with header files to no avail, but I did learn a little bit!
5/10/2022
Tried to work out how to use ffmpeg to create audio files with my xencalc3.c program. Decided to put it on hold until I have more fundamentals under my belt.
5/11/2022
Udemy
Section 2: 18, 19 (mostly mathematical programs)
Sololearn
Doing a little to understand C++ better.
5/12/2022
Sololearn
A little more with the C++ course - still in the early parts of this course, so it’s easy stuff.
5/13/2022
Udemy
A couple exercises! Just trying to stay relatively consistent!
5/16/2022
Udemy
Completed section 2-11
5/17/2022
Udemy
Section 2-12 & 2-13 (calculating GCD and LCM, I ran into what might be called a short-circuit evaluation with my logical operator &&. Moreover, I had to really puzzle this problem out - it may be a good problem to return to and find other solutions, i.e using dynamic programming).
5/18/2022
Udemy
Section 2-14 Fibonacci Number calculation; section 2-15 Lucky Number - I fussed over this one a while trying to make the modulo operations as succinct as possible. I overused them, not knowing I could simply use the truncating feature of the int data type to reduce the number as I went along.
5/20/2022
Sololearn
Two simple C++ lessons about functions.
5/23/2022
Udemy
02-17 learned that you cannot pass an array by value into a function unless you composite the size and array inside a struct and pass the struct into the function.
02-18 Get the min and max and occurrences of each from an array.
02-19 Really easy one. Get the multiples of 7 from array.
02-20 Filling an array while error checking for values above 150.
02-21, 02-22
5/24/2022
Udemy
Section 02-23 - a simple program that calculates total cost and tax based on how many small and large rooms the user wants cleaned.
02-24 - wrote a program that determines how to denominate an input cents value. Got myself turned around trying to use a struct - I was trying to initialize the struct in its definition, which you cannot do!
5/25/2022
Udemy
Section 02-25 Tic Tac Toe game (finally this course is getting into more complex territory. I don’t believe I’ve ever made a game in C, so this is giving me good experience.
5/26/2022
Sololearn
A bit of C++ study. I know it will be a transition going from C to C++.
Solved a Code Coach using C++ to convert CMYK to RGB.
Code coach that adds even numbers together C++.
5/27/2022
Udemy
Finished section 02-25 Tic Tac Toe Game - I created a lot of my own functionality in this program, trying my own solutions before watching the videos. Among other enhancements, I spruced up the display by coloring the victory conditions green!
Quick video on header files: Tic Tac toe game updated to include a custom header file
5/30/2022
Udemy
Section 02-26 menu program (solved this one without consulting the video) 😈😈
I really tinkered with this one and made some changes I’m proud of. I used a pointer to keep track of the latest element in the array, which should reduce the operation time as the array gets larger.
5/31/2022
Udemy
Section02-26 Fought with the Remove Number function for a while. I found I was overthinking it and the solution was MUCH more simple than I was making it - I imagined several steps every time the number in question was found; instead, I figured out how to do only one step for each iteration.
6/1/2022
Udemy
Section02-26 for fun, I decided to write my own “export to file” function! It currently can only write single digits to file. When I learn more about File handling, I’ll come back to this program and improve the export function!
IDEA: figure out how to run my menu program in Atom - it will probably require building a Makefile of some sort (if that’s what it’s called). I believe Jacob Sorber has a good video on how to do this.
6/2/2022
Started working on my own program, Student Log, which will hopefully become sophisticated enough to actually aid me in my current job! I want a more streamlined way to store and look up information.
6/3/2022
Student Log
Was banging my head against a wall trying to figure out why my delete node function was not working. Turns out I needed to pass not the head pointer to the function, but a pointer to the head pointer (pointer to pointer, double reference). This boggled my mind at first, but reading online, I found the reason: if we want to make a permanent change (one that endures when the function call is finished) to a pointer being passed into a function, we must instead pass a reference to the pointer! This is the exact same rule as when passing a variable; in other words, it’s the classic “pass by value vs. pass by address” situation.
6/4/2022
Student Log
Worked on this one more during my breaks at work. It’s difficult to keep track of all the features I’ve added; I’ve got so much momentum in this project. 😅 Generally, I found myself debugging, improving the code I’d already written, and adding the select student feature, which allows me to zoom in on one student and view their information. I also added a time stamp feature to the addStudent function: now I will easily know the exact date that the student started lessons. This evening, I added a file handling feature: now when I exit the program all the information I entered into the linked list is exported to individual files for each student. If the file already exists, the programs merely appends the information.
6/5/2022
Student Log
debugging, creating a text wrapping feature for the assign item in the student struct. Success! To do: add a function that reads from student files based on which weekday I select. Do I need to add a “weekday” item to the student struct, or should I create a separate “roster” file that keeps track of what days I have certain students?
6/6/2022
Student Log
created insertStudent function to add students at different parts of the list.
6/7/2022
Installed Chocolatey using an elevated/admin command prompt in Powershell. I need to learn what Chocolatey is capable of! I used it to install make (choco install make). Now, I can write Makefiles in my atom text editor to make compiling my programs more streamlined! How to Install and Use Make in Windows
Jacob Sorber: how to use make in 60 seconds; compiling c programs with multiple files A COMPILER IS A TOOLCHAIN Successfully implemented a Makefile for my studentlog program. I have a lot to learn about build systems! After jumping through countless hoops, I turned on the Linux subsystem (Ubuntu) for Windows. It’s hard to remember what I did!
Student Log
did some debugging (still more to do - having trouble with scanf in selectStudent function), wrote a new function, exportRoster, which sends all students in the list to a txt file named after the day on which their lessons are scheduled. LoadRoster needs to be written next, so I don’t have to re-input students every day with addStudent function. I can tell I need to rethink several aspects of my file handling: I need the exported info to retain its structure - I think I need to export to binary instead of text. I also need to read the article about how to write structs to file. Phew! Lots to do.
6/8/2022 🤩🤩🤩
BIG NEWS: I finished my program today!!! I can now use my student log at work. I was able to make a function that exports the linked list to a file and another function that retrieves the list from file and reloads it into a linked list! I was pretty shocked when this worked! Now I simply need to debug the program as I use it.
6/9/2022
Some debugging of my student log. I needed to clear the ASSIGN array in my NODE struct whenever I want to assign new homework so that the new assignment will completely overwrite the old assignment.
Made the menu easier to interface with: using numbers to select the day desired rather than typing in the day. I need to find a way to do that with selecting students.
I’m mostly working on debugging now, implementing some error handling to make sure that inputs don’t make the program crash. I looked up ways to flush standard input and found that you can create a simple function to flush the input buffer after every scanf statement.
6/10/2022
Student Log
Improved the selectStudent function; now I simply enter the number associated with the student to select them! I also updated the exportStudents function; now all the student files are saved neatly in a students folder.
6/13/2022
Udemy
Section02-28 - created my own solution to the copyString function using pointers. I took advantage of the fact that I can manipulate a pointer inside a function and it will not alter what the pointer points to outside the function; however, it can still change the value at the memory address held by the pointer. Ergo, I didn’t need to create any more variable inside my function.
6/14/2022
Udemy
Section02-29 thru 02-32. I got a lot done! Implemented a lot of my own solutions in these exercises, but they were still incredibly helpful. Mostly string manipulation exercises: creating our own strlen, strcat, and strcmp functions (and other things). I misunderstood strcmp at first, thinking it took the sum total ascii values to determine whether to return -1 or 1. Instead, it looks for the first instance of divergent elements and returns -1 or 1 on that basis alone.
Student Log
made some simple updates - now when a student is selected, a submenu pops up which allows the user to Assign Homework, Set Attendance, Open Student File (I’ve yet to write this feature), and Return to Main Menu. I wrote a function specifically to display this menu. It might not be the most elegant implementation! Later, I possibly want to make the text wrapping feature into a function.
6/15/2022
studentlog
Commented more of my functions; for new students, the program writes date start at top of file if it is empty; when I remove a student, an end date is appended to their file; added the open student file functionality (not portable - relies on powershell commands - in the future, I’ll need a cleaner option); created the textWrap function to clean up my selectStudent function; finally, I used the pre-processor directive #define to create a PATH constant and a WRAP constant - the path allows a user to specify the path at which student files will be stored and retrieved, and the wrap allows a user to specify the formatting for the assign member of each struct node.
6/17/2022
studentlog
Been trying to find GUI building tools for my student log. I don’t want to be confined to the shell to interact with my program! So far I’ve gotten dizzy trying to figure out how to build the following tools: IUP, GTK, QT, and WxWidgets. I think I may have settling on WxWidgets since I found a great build tutorial video on YouTube (channel: javidx9). WHY IS IT SO HARD TO INSTALL THIS STUFF.
6/18/2022
studentlog
I want to run Valgrind on my program, but I have to be in a Linux environment to do it, so I learned how to make Bash the default shell for Atom, then I had to install gcc for Linux to compile my program, and then I thought I had to change the path and in my environment variables window, but I didn’t. Success! However, compiling and running the program with bash, I notice that when I read the roster from the .bin file created by the studentlog.exe (compiled in powershell), the data is corrupted.
Read up on linked list serialization. I noticed I’m writing the node pointers to file in my writeRoster function - perhaps that adds to the issue. I know I could improve my program by making every string format exactly alike - then I could use the same criterion to write each to file.
6/20/2022
Checked out local shop Computer Supply. Turns out they no longer stock inventory (i.e. SSDs), nor do they do custom builds anymore. I’m glad I went and checked the place out - took me out of my comfort zone. The guy told me I should check out Green PC.
Had an awkward yet fruitful experience at Green PC. Got what I needed to start using the old tower that my dad didn’t need anymore!
Learned how to boot Linux from a flash drive. Boot Linux from a USB on Windows 10 — now I’m successfully running Linux (distributor: Ubuntu) on this computer!
studentlog
Worked on my writeRoster and readRoster functions on my Linux PC.
6/21/2022
studentlog
With all the changes I’ve made while compiling in bash, I wanted to compare the new and old versions of studentlog. I wrote a program called filecomp.c and it didn’t work. Then I wrote pretty much the exact same program, calling it test.c, and it worked. So I went through the filecomp.c program line by line until it was identical to test.c, and it still didn’t work! Only once I deleted filecomp.c, created a new file with the same name, and copied test.c contents into it did it work. 🤯 Anyhow, I think I’m going to leave my student log be for now - it works as I need it to - it makes sense that it doesn’t work when I run the program in bash and it was compiled in powershell. I don’t need to fix that.
Udemy
Section02-33 string squeeze (pretty simple exercise); section02-35 writing a function that checks if one shorter string is equal to the start of a longer string.
6/22/2022
Udemy
Section02-35 thru 02-41. Projects centered mostly around searching thru strings and counting the occurrences of some smaller string. Almost done with section 2!
6/23/2022
studentlog
Added a Display Expanded feature, so the user can now expand the list to show all the information contained in each student node for the current roster.
Watched the first episode of The Triumph of the Nerds documentary - generally very informative! I’m anxious to learn all I can about the history and hardware of computers.
Learned that Program Files (x86) is a folder in a 64bit system where 32bit programs are stored. x86 refers to a particular kind of processor- 386, 486, 586, etc.
6/25/2022
studentlog
Tried to work out a method to increase the struct node size without messing up the data. I have a potential solution, a function that can transfer the data from one node to another node with the changed formatting. I implemented this, but it doesn’t work perfectly yet. As I type this, I’m thinking of another way to do this that involves fewer steps: I could modify the readRoster function to pull the data into the original node then copy it into the new node, thereby making two linked lists at the same time, one with the updated formatting. Of course! I need to rewrite the whole program to accommodate the new struct size, and then create a back door for the old format to be loaded in, reformatting it in the process!
6/28/2022
Linux: had to reinstall the drivers for Cudy WC1300 wifi adapter using terminal commands since it wasn’t detecting Wi-Fi. This time, I saved the installation guide pdf in the cudy_driver folder so that I’ll be ready to troubleshoot in the future. Installed net-tools. We’ll see if that comes in handy.
Udemy
Finished section 2 (section02-42 thru 45)!
studentlog
Made progress with the linked list transfer concept - I’m able to take the old roster, load it into a linked list of old nodes, and then transfer the data from each node into a modified node in a new linked list. From there, I’ll be able to update the roster with the new nodes, and then I won’t have to load old nodes anymore. I’m still having a bug: the last student in the roster never makes it into the linked list, and I need to find out why.
Watched the second episode of Triumph of the Nerds.
6/29/2022
studentlog
Woohoo! Fixed the issue with the last student not printing! Like a chump, I was freeing the last node in the linked list in my transfer function, so the penultimate node wound up pointing to a random address that held garbage values! I fixed that, and then I changed the function so it would load the nodes in the correct order. Everything is now running smoothly, and I think I’m ready to implement the update in my official studentlog!
6/30/2022
YouTube
Watched “How I got good at Algorithms and Data Structures.” Learned about Leetcode. Learned about Pramp. Book: Cracking the Coding Interview.
General thoughts: 1) try not to be a slave to the completionist mindset. Yes, I want to be thorough and complete things as much as possible, but I must know when I’ve extracted all I need from a resource and let myself move on. 2) Keep working on your own projects (i.e. studentlog)! 3) As with any learning, resist the temptation to rush on to the next thing! Of course, this of tricky to do because sometimes moving on is the right move.
Udemy
Section03-01 thru 03. I’m not always following along in codeblocks because some of this material is purely review for me. The beginning of this section is mainly about structs.
7/1/2022
YouTube
Finally found a simple explanation of a hash table! Hash Table Explanation
I’ll need to practice creating hash tables - first I’ll start by creating one just to create it (I’ll probably use chaining to deal with collisions), and then I’ll come up with a useful project in which to create one.
Hashprac.c: I began experimenting with hash tables once again, and I found that all my prior study of linked lists has really helped! I was able to intuit much more of the process, and I built my hash table pretty much from scratch. A couple times when I got stuck, I was able to refer to a previous hash table I created (one I got considerable help with from a video). I noticed that in this other implementation, the hash table array was declared globally — hence, it didn’t need to be passed as a parameter to each function. Instead, the functions that needed it already had access to it by default. I used this in hashprac.c, and it really cleaned up the code. How to Use Global Variables
7/2/2022
Hashprac.c: trying to sort out how use file handling with my hash table. Successfully implemented a function for saving the hash table data & a function for reloading the data into the table - serializeTable() and batch_insert(). I must say, the fread function is harder to grasp than fwrite. I’m becoming familiar very slowly.
7/3/2022
Hashtext.c: suddenly found myself improving this program I wrote several months ago. It now takes two files as arguments: the first one is the file to be encrypted, and the second one is the key with which to do the encrypting. The program then spits out the encrypted file & a new key that can be used for decryption.
Udemy
I decided to start skimming through any videos that don’t present me with new material, so I mostly skimmed from section03-03 through section03-06 (this last one went over structures within structures, which was helpful).
Hashprac.c: I’ve noticed that when I load the serialized data items back into the hash table, they end up in different buckets than when they were first entered. Suppose Alex ends up at index 74 when I first enter him in; each time I reload him into the table, he consistently appears at index 0. I’d like to fix this soon.
7/5/2022
Hashprac.c: I solved the problem described in the previous entry by storing the initial hash result from the key in the structure. Then, when I need to reload the table, the batchInsert function grabs those values from the serialized structures.
Did some reading on hash tables. I’m trying to find a project I can work on that needs a hash table. I keep reading that they are perhaps the most useful data structure out there! I found one article that had some great examples of their uses.
7/6/2022
Udemy
Section 03-07 thru 03-15. When declaring pointers, we put the star next to the variable name and not the data type to make things clear: if you declare pointers in a row (i.e. int *p1, *p2;) you have to place a star next to each variable name; otherwise, only the first declaration will be a pointer. Also, when doing pointer arithmetic, i.e. &num + 1, the address will be increased according to the amount of memory the data type takes up, so +1 will move an int pointer address by 4 since an integer takes 4 bytes in memory. Also, using the inc/dec operator on an array will throw an error since it will ruin the array (the array variable name will always point to the first element - it is a constant pointer).
Hashlprobe.c: my first try at creating a hash table that solves collisions with linear probing. It all works, yet I can’t help but feel that my implementation is not as tight as it could be. Moreover, I wonder if my method for linear probing is actually O(n).
CodeSnack IDE: explored the data structure examples (queues, stacks, linked lists, dynamic arrays) and wrote my own dynamic array (dynarray.c).
7/7/2022
Jacob Sorber: “Fixed and Variable Length Arrays in C and C++”, “How Different are C and C++? Can I Still Say C/C++?”
Udemy
Section03-15 thru 03-18. Learning about the const keyword, how it prevents a variable or pointer from being changed (03-15). Swap pointers in a function by using pointers to pointers. Heading on to the exercises 04-01 thru 04-02.
CS50x
Wk 5 Speller - Wow. I came to this problem with much more confidence. It still took some work, but I got it to run! I can finally proceed to week 6!
7/9/2022
Udemy
Section 04-03 thru 04-06. Good review here. There’s nothing that I’ve not encountered before, but I’m glad to enhance the skills I already have!
Did some general research on bootcamps; the differences b/t web devs and software engineers; and the differences b/t function, procedural, and object oriented programming.
Sololearn
A few lessons in C++ (default parameters, function overloading, recursion)
7/10/2022
Sololearn
A few more lessons & code coaches in C++. Finished module 4 & completed the project, which was rather tricky only because the maths were wonky - the code itself (syntax, operations) made sense. I had to check if a given int was a palindrome, so it had to be reversed. I rightly deduced that the modulo operator would be handy, but I failed to consider how the truncation feature of int division could be useful. Next section is about Classes and Objects! This will be good.
7/11/2022
Sololearn
A little bit about Classes and Objects; I know this topic will fascinate me greatly!
Udemy
Section04-06 worked more on this project - it was about storing coordinates for a rectangle in a struct. We used a struct within a struct to make the “rectangle type.”
Decided to learn how to use GitHub more.
7/12/2022
Udemy
Section04-06 (this section is a multi-video project) - the video is #97: I got some good insight from this one. Specifically, I’m finding how helpful it is to nest functions within other functions to reduce complexity and increase legibility. I’m general, section04-06 has helped me see how a program can interact with a coordinate system.
Watched a video on using GitHub. It gave me a basic idea of how to use it! www.youtube.com/watch?v=v_1iqtOnUMg
Leetcode: (I think I’ll like this resource) started solving an Add Two Numbers problem, which I thought would be easy, but it used a linked list with each digit of a large integer stored in its own node. I can see the merit of storing large numbers in this way. I had to write a function that took two linked lists and adding their digits together - of course, I had to account for carrying values. I succeeded today, but I didn’t like the runtime of my function.
7/13/2022
Leetcode: Add Two Numbers - was able to shave off 1 ms of runtime and 0.3 MB of memory usage: see image above. Strange - I submitted the problem a few more times with pretty much the same code and my runtime got worse and worse!
Remove Duplicates problem: this was much easier!
Two Sum problem: easy brute force solution, but I can’t yet figure out a solution with better time complexity.
7/14/2022
Leetcode: Running Sum of 1d Array - easy beginner problem (helps boost my confidence) 😂
Leetcode: Richest Customer Wealth problem - working with a 2d array (I’m completing the Leetcode Beginner’s Guide)
Leetcode: Fizz Buzz - the dreaded pointer to a pointer (specifically in this case char **). Ugh, I need some clarity on this one - this is a sobering reminder that I’m still a beginner. SWEET MERCY this was such a struggle - I kept getting a heap buffer overflow and a block of text with the header “Address Sanitizer”. I tried so many different things to fix it that I don’t really know what I did that made it work, but it works now.
Leetcode: Number of Steps - easy one, but I learned the merit of using the bitwise shift operators! They can cut an integer in half or double it just by shifting all the bits one place to the left (half) or to the right (double)! It was quite an aha moment.
Sololearn
Working on sorting algorithms and a little bit of C++ classes and objects.
7/15/2022
Udemy
(C Programming: Become A Pro! Think Like a Programmer!) worked on section04-07 and decided to follow the instructor exactly: he likes to use a lot of functions. On one hand, I can see how it organizes the code. On the other, it also seems to make the code more labyrinthine. I’m not the expert here, but I can’t help feeling that using the number of functions we’re using for this project is overkill. I found myself losing track of what goes where!
Sololearn
Using the code playground to mess around with sorting algorithms. I made a bubble sort algo pretty quickly, but I’ve had a hard time making a merge sort algo - the recursive aspect desiccates my brain. Hyperbole aside, I’m gaining understanding of how merge sort works - I got my algo to work (of course I based it off of help I found online) and the execution time is drastically better than that of bubble sort! Merge Sort in C
7/16/2022
Implemented a merge sort algorithm from scratch. This time I didn’t follow along with any tutorial; I tried to write it using logic and my memory! I intend to watch a video on the merge sort algorithm because though I understand recursion for the most part, I want a strong conceptual sense of the exact flow of a recursive function.
mergeSort(): A Graphical, Recursive, C++ Explanation (this video helped me understand recursion better).
7/19/2022
CS50x
Watched the first half of Lecture 6, which takes us into Python. I have an idea to make another iteration of my Student Log program but with Python as a way to learn the language.
7/20/2022
studentlog
I forgot to export the students from yesterday, so I did it when I opened my computer this morning. As I suspected, the wrong date was written to the student files. To make sure this issue didn’t happen again, I edited my program so that the current date is retrieved at the beginning of runtime and is passed to functions as needed.
CS50x
Finished Lecture 6! I know the feeling will pass, but I’m less excited about Python than I was about C and C++. There seems to be something about the low-level, fine-tuning capabilities of C that I really enjoy. Python seems like it relies much more on the intelligence of others. I think that’s it! So far I’ve enjoyed the challenge that C has offered. I’m kinda talking out of my ass here: I bet in a few weeks I’ll find appreciation for Python. Having said all this, I’m intrigued by how much easier file handling and saving data appears to be in Python! My studentlog program could probably be implemented much more cleanly in Python.
7/21/2022
YouTube
Watched a video about prepping for interviews. Most Tech Interview Prep is GARBAGE. (From a Principal Engineer at Amazon)
Udemy
Section04-07 I skimmed the last video for this project since I believe it covers topics I mostly understand. If I need to brush up on them, I can do so in the context of my own projects. section04-08 making our own strlen & strcpy functions with pointers.
Sololearn
Solved a hard level code coach with C++ (however, it didn’t need any OOP functionality). Started trying to build a merge sort algo from scratch - ran into some bugs.
7/22/2022
Sololearn
By consulting my previous merge sort build, I discovered what I did wrong: I failed to set the for loop iterator equal to the left bound of the sub-array. I set it to 0, which was causing the loop to retrieve the wrong values & overflow.
Stackoverflow.com: searched for definition of stack overflow, integer overflow, buffer overflow. The last of these simply “refers to any case in which a program writes beyond the end of the memory allocated for any buffer.” The first two are specific instances of buffer overflow! Very helpful.
Udemy
Section04-08 writing the strEqual function with pointers (I did it myself without needing the video). A lot of stuff is review at this point, but I’m glad to go through it b/c I don’t want to forget! Also, completed strPrefix function.
7/23/2022
Leetcode: reverse integer problem. I knew how to solve this one, but I missed the part where I needed to return 0 if the reversed number were to exceed the bounds of a signed int type {-2,147,483,647, 2,147,483,647}. Unsigned can go from {0x0, 0xFFFFFFFF}. The difference is that the signed int needs the leftmost (I think?) binary digit for storing + or - sign.
Sololearn
Completed a few lessons to get a better handle on classes & objects in C++.
Reading the coding-interview-university study checklist on GitHub. I think I want to follow this study plan.
Cleaned up my PC today - I need a new laptop soon, I think.
7/24/2022
Sololearn
Solved a code coach with C++.
Leetcode: struggled with the String to Int function - I thought I had solved it several times, but extremely subtle edge cases kept cropping up that my function didn’t satisfy. I haven’t solved it yet.
7/25/2022
CS50x
Watched week6 short & completed lab6. I’m reminded how much ambiguity #### CS50x leaves in its problem sets - there’s always a sink or swim feeling that I don’t appreciate. I wish they would give just a little more guidance. I was able to think through a lot of the logic for the lab, but the new syntax had my head swimming. I had to consult the “not sure how to solve” section. I’m a little demoralized, but I know I’ll pull through. Completed several of the problems for pset6! The wind is back in my sails! Python is making a little more sense.
Thinking I should figure out a book to use for study!
7/26/2022
CS50x
Feeing A LOT better about Python. I must have been having a bad day yesterday. I now know that I can figure out anything I need to know for Python since I’ve really started to speaking the language of programming in general! I think I’m actually going to like this language.
Started working on the dna.py problem and it involves csv files and dictionaries again. I need to watch a few extracurricular videos to get a handle on this!
Sololearn
Decided to work on the Python for Beginners course to help me understand the new syntax.
7/27/2022
YouTube
Watching a video on reading CSV files in Python, I quickly noticed why my csv was not being read: I had spaces after the commas! That was the only thing I did wrong. Furthermore, I was confused by the iterating process in the for loop (for name in reader) because I didn’t realize that “name” could be any arbitrary name - it is just an iterator for each line of the CSV file (like ‘i’). Reading CSV Files in Python
CS50x
After much suffering trying to make sense of the new syntax, I solved dna.py. I’m proud to say that I was able to think my way through most of it on my own. That concludes Week 6!
Leetcode: solved Linked List Cycle problem. I had the correct intuition in using two pointers to iterate through the linked list. I called one “scout” and the other “nexus.” Scout would charge ahead while nexus waited until scout came back around. If scout didn’t come back around and also didn’t reach NULL, then I would increment nexus. The trouble was I didn’t know after how long to increment it! I read from the discussion section and found the brilliant and simple answer to my question: nexus move 1 at a time while scout move two at a time. If there is a loop, scout will eclipse nexus: if they are both moving at different rates along a circuit, they have to intersect at some point! This was called Floyd’s Cycle-Finding Algorithm.
studentlog.py
Experimented with Python more on my own. Decided to chip away at a new studentlog program!
7/28/2022
Udemy
😩🤬😁 Wow, what a ride. I struggled so much on section04-08 occSubStr(). Finally, right when I ran out of time, I was able to solve it!! I was making it too complicated. I checked for equality between the string and substring when it would’ve been simpler to check for inequality! I know I was making other errors, but they are hard to suss out. 😅
Studentlog.py
Played with Python some more. I’m finding it is way too easy to create a student log program. 😅 Maybe my C student log is more complex than necessary as well.
Received my book “Code” by INSERT HERE. I’m already hooked! It’s an easy reader that takes you from the earliest computer-like technologies to today.
Browsed tech job listings. I need to do more of this!
7/29/2022
studentlog.py
I’m getting the hang of this language! Of course, there’s a lot to learn, but I feel less lost in general. Wrote writeRoster and readRoster functions; I’m working on exportStudents.
Code by Charles Petzold: read Chapter 4, which is about electricity, a topic that is almost always nebulous to some degree.
7/30/2022
Sololearn
Finished the C++ section on Class and Objects. I was briefly confused about Constructors, but now I understand! For the final project of the section, I had to create an add function for a queue data structure. Now I want to create my own queue from scratch!
C++ Practice: built my own queue! I got it to work much quicker than I expected! Created a class Queue with a constructor, attributes, and methods. Feeling very accomplished. I looked it up and found that I can compile with gcc if I link in the C++ library <-lstdc++>. For the pop() function, I tried to simply move the int pointer to the next element and delete the first element, but it didn’t work: I got a garbage value (not to mention my array would slowly shrink with this method!). Instead, I need the equivalent of realloc() in C++. Evidently, I need to use a library called vector for this. A vector is essentially a dynamic array.
Udemy
Section04-09 working on pointers. I have a little bit of a hard time with these: ++*p, *++p, *p++ (they are resolved from right to left except the one with post-increment: in that case, the dereference operator engages before the increment).
7/31/2022
CS50x
Watched over half of Lecture 7, which Is on SQL and Relational Databases. I’m excited for the possibilities here: I bet I could improve my studentlog dramatically using SQL.
8/1/2022
Udemy
Section04-10 practicing finding the output of pointer arithmetic. In total, I completed 04-10 thru 04-17! I finished section 4. Now, I have to revisit section 3 and finish the few videos that I was required to save until after section 4.
8/2/2022
CS50x
Finished Week 7 lecture. Watched week 7 short. Completed Lab 7.
Created an Oracle account and downloaded and installed MySQL. We’ll see if I can use this thing 😅
Read chapters 6 and 7 of my book, “Code”.
8/3/2022
Figured out how to run MySQL in the terminal with the help of a YouTube video, but I’ve yet to figure out how to use it!
CS50x
Completed Movies of pset7! I rather proud of this one because I felt a strong sense of understanding throughout the project.
Code - Book
Read chapter 8.
8/4/2022
CS50x
I’m euphoric! I solved Fiftyville and had a blast doing it. Thinking through the logic and seeing my queries access the appropriate data was a thrill - no joke. Some of the most fun I’ve had in this course so far! Done with Week 7; on to Week 8!
Sololearn
Completed a simple code coach in C++.
8/5/2022
Resist the negative feelings! I’m feeling a little adrift in my studies, but it may be that I just need a small break.
C++: messed around in VS Code building classes. I’d like to understand this better! I’d also like to learn how to integrate C++ and MySQL. For now, I’m practicing the merge sort algorithm again, this time using OOP, and it’s loads of fun! Ran into some problems trying to create a merge sort algo in a class - I’ll come back to it when I’ve got more OOP understanding! For now, I’ll just read about C++ on W3 Schools.
PROJECT IDEA: for my next project, I’d like to create an inventory & ordering system for Woodland Espresso (just for the sake of practice - I would only offer the finished program to them if it worked flawlessly).
W3 Schools: this is proving a useful resource - the string data type is actually an object with methods such as .append(). Reread: Strings, cout as object, not using namespace.
8/6/2022
W3schools: reading up on C++ some more, I’m happy to find that much of the basic syntax is the same as in C! There’s new type called a reference, which as far as I can tell, is like a pointer that doesn’t need to be dereferenced and which doesn’t actually store the address (it simply has the same address as the variable it references). Now I’m reading about functions.
C++ Practice: successfully built a class with a merge sort method! Evidently, I needed to make my size attribute a “static const int” in order to pass it as a default argument to the method. I also found that since the array and the method are a part of the same class, I can pass the array to the function as though it were a global variable - this was important because I didn’t want the method to demand an argument when called in main().
8/7/2022
Code - Book
Read chapter 9 - I found the bit about UPC codes quite interesting!
8/8/2022
Code - Book
Read chapter 10 - wow, I love this book. Several elucidating moments in this chapter! My first thought was to try building simple logic gates in Minecraft using redstone. 😂
C++practice: worked in vain (it seems so far) to get C++ and SQLite to play nice. It baffles me that everyone says “it’s easy.” Clearly, I’m still a novice, but it irks me how difficult it ALWAYS is to get software to work on windows. I did FINALLY get my program to compile with sqlite3 as a header file, and this website provided the key: www.devdungeon.com/content/compiling-sqlite3-c
Udemy
Section 03-19 - difference between pointer string and declared string: pointer strings are constants - they cannot be changed (at least in the same way that declared strings can be). Now the video is saying this, “only use char * in function parameters; do not use it to make strings.” Also section03-20.
DEBRIEF: I’ve been feeling aimless and overwhelmed with my coding efforts lately, so I decided go back to the roots: I found some fun project ideas online and decided to implement a madlibs program with C. I found myself back in the flow, the problem-solving cogs turning steadily. I mustn’t rush myself!
8/9/2022
Madlibs.c: as usual, when I’m deep in a project that I understand well enough, the obsession kicks in! I feel the desire to optimize every line of code, and little tweaks come rapidly to mind. I find myself increasing the functionality beyond what I initially planned for - I get in the flow! This is why I like coding. Finished this project - there’s definitely more I could do, but I got it to work nicely as it is.
8/10/2022 🤩🤩🤩
CS50x
Cybersecurity Lecture (no Problem Set included).
Udemy
Section03-21 thru 03-22.
Parse_file.c: started working on a much cleaner way to parse a file into discrete words. Figured out how to use strtok(), which create tokens (or substrings) from a larger string based on some set of delimiters (a period, a comma, etc.). Evidently, it is potentially unsafe - not fully “thread safe,” as it was said. I need to learn more! I’m excited by the possibilities here.
Decided to use a hash table to store the tokens created in my parsefile app (now called parse_app). I find myself rusty at making hash tables and linked lists.
8/11/2022
Parse_app: by reviewing code I wrote previously, I found my errors - they were small and pretty dumb 😅 I used strcat where I need strcpy; I failed to malloc the space needed for my nodes. ETC. Now it works how I want it to!
Udemy
Section03-23 (array of char pointers) useful little section! Stuff I mostly already knew, but it’s good to refresh. Officially done with sections 3 and 4 now!
I think I’m going to write a program to convert docx to txt for my parse_app! I’ll probably use Python.
Learned a bit about docx and how it is mainly just a zipped package of OOXML files; then I learned about XML files (Extensible Markup Language); then I learned about an application called Pandoc, which can easily convert docx to txt, among many other things! Also, I used 7-zip to extract a docx file myself - then I was able to open the document as a plain text with the xml formatting. I noticed the text that I care about was always enclosed in a specific statement:
<w:t xml:space=“preserve”>
8/12/2022 ***
Emscripten: my first tango with this compiler to web-assembly was a disaster. Why is this so often the case when trying to install sdks? I’ll try again later.(Need to learn the real sense of SDK — and API for that matter). develop.mozilla.org/en-US/docs/WebAssembly/C_to_wasm
Udemy
Section05-01 (Dynamic Memory Allocation) a nice review of Stack and Heap in memory and how the Heap requires manual allocation and deallocation.
VIDEO The 1 Coding Project Idea Guaranteed To Get You A Software Development Job. A lot of excellent tips here. I’ll rewatch this video for sure. Highlights: projects should have 1) design pattern (MVC), 2) professional UI (bootstrap), 3) database (SQlite), 4) handle security, 5) solve a complex business problem. Best project to build: bug tracker. SRS - Software Requirement Specification: write down all the features of the project, track progress. Recommends building with .NET, C#, nbc (why?).
8/13/2022
Udemy
Section05-02 -> a great illustration of the malloc, calloc, and realloc functions!
allocation.c
Working on using a dynamic array with the strtok function to parse out a file! Didn’t quite get this to work; I’m trying to use realloc (thought I don’t really have to in this circumstance), but it’s not working as I expect. I’ll keep trying!
8/14/2022
allocation.c
Decided to remove realloc after all since I didn’t really need it (the program gets the file size and therefore the dynamically allocated string array can be sized exactly to meet the required storage - no need to call realloc) and then I found that my free function wasn’t working (I knew already that simply freeing char ** wouldn’t work since I allocated memory to each string in the array, so my function had to iterate through the array and free each element). I found I needed to have a temp variable that held onto the char pointer to be freed while I moved the char * pointer to the next element (just like in freeing a linked list, really). Phew, that was a lot to explain 😅
Code - Book
Read Chapter 11. It was all about logic gates and how relays can be used to construct them.
8/15/2022
Udemy
Section05-03 thru 05-06. 05 and 06 were especially useful! 06 discussed the different types of allocation (static, automatic, and dynamic) and what makes them different. With automatic and dynamic, it’s simply stack and heap respectively, but with static, it’s something else - on Stack Overflow, I read something about BSS in memory, but I don’t know what it is; I’ve been led to an article, and here’s the link: Memory Management in C: The Heap and the Stack
Jacob Sorber: A const int is not a constant. (I’ve definitely run into these problems using the “const” expression. “const” doesn’t really make a constant!
Udemy
Completed section06-01 - making a dynamically allocated array.
8/16/2022
Udemy
Section06-02 (create array function), 06-03 (create array of int pointers), 06-04 (array of arrays using pointers).
c_sqlite.c
Worked on integrating C and sqlite3 again, the problem that rotted my brain on August 8th. I noticed I made several syntactic errors in my previous attempt, so I fixed those. I got the program to work, but it doesn’t work consistently. It’s still annoying, but at least I’ve got a better foothold now. [Later] Ok, it works! I can begin developing it further!!
RESET GOALS:
- Finish CS50x
- Finish Udemy Course & Start new course
- Finish my book, Code
- Get comfortable with SQLite using C/C++, Python
- Data Structures and Algos: learn more!
- Project: learn how to brainstorm (whiteboard)
- Find several viable bootcamps
8/17/2022
studentlog4.0
For better or worse, I decided to rebuild this program with SQLite3. I got the SQLite3 API to integrate with my C file, and I adapted the Makefile from studentlog3.0 to include it. I’m currently in the process of designing my student_base table. A question I have: can I use SQLite3 to store the assignment log, or do I still need separate txt files for that? [LATER] Things are coming together! My program can now load a student into my students array (although I need to alter the callback function because it fails when I try to store multiple students in the array), and it can add new students to the database.
8/18/2022
studentlog4.0
I had several moments of wanting to give up on this project, but I pushed through and discovered some of my errors! Using the sqlite3 API for C/C++ is proving challenging; I’m slowly figuring it out. I know have a better understanding of what an API is, and I have a good idea of how function pointers and callback functions work!
Udemy
Section06-05 (no wasted memory) we used dynamic allocation to receive the initial input and then transferred the data to an automatically-allocated array at the exact right size; then, we freed the initial input. This is a good way to make efficient use of memory. While working on this, I thought of my own functions I could write for getting text from stdin without \n. I created a few functions and then stored them in a header file using VS Code.
studentlog4.0
Was able to put all my header files in a subdirectory - I had to alter my includes and my Makefile to follow the new path; I included my new in_out.h file in this. Lastly, I cleaned up main.c by outsourcing more of the code to the tools.c source file.
8/19/2022
studentlog4.0
Really cleaned up the main.c file by moving the code into neatly organized functions for each menu. Added a delete_student function, which modifies the day to -1 so that the student doesn’t show up in the line up. I need to add end_date appending and an option for permanent deletion, which would completely destroy all records of the student. I need to improve the way date and time are stored in the database. Also, I think I’ve decided to store student assignment logs in the database itself; I think I’ll have to create another table that links to the student_base table. Question: do I need to allocate all 20 elements for the student array each time or can I allocate just what’s needed?
8/20/2022
studentlog4.0
Added end_date appending to my delete_student function. Added permanent deletion option by prepending ‘-d’ to the name of student to be deleted. Designing another table:
CREATE TABLE assignments (
assignment_id INTEGER PRIMARY KEY
student_id INTEGER,
date TEXT,
name TEXT,
assignment TEXT);
I got caught up with my date function, which I ultimately decided to scrap! I’ll get back to the new table next time.
8/21/2022
studentlog4.0
Improved add_student function; now it displays a menu of choices for time and instrument, greatly simplifying the input process. Added system(“clear”) so that the program executes more cleanly in the console. Tried to get the callback function to read in the student_id (even made my own str to int function), but I kept getting errors - I think it’s due to conflicting data types. Just realized that my new time format might not display properly with SQLite ORDER BY statement.
Code - Book
Read Chapter 12.
8/23/2022
studentlog4.0
Made everything regarding the “time” column work smoothly; decided not to use the student_id to communicate between menus and tables - only student “name” is really needed (If in the future I had two students with the exact same name, the “student_id” would be more significant); added the student menu complete with “assign” and “view assignments” operations (deployed my own input function, get_var_text, here!); implemented a second callback function to handle assignments info (could maybe use a 3rd for fetching student_id, but not a priority); UP NEXT: update textwrap() and add to in_out.h for use in formatting assignment output; write a program to automatically transfer student and assignment info from individual student files in the students folder; add error handling for faulty input, etc; and possibly design callback function to fetch student_id like I initially wanted.
Follow up: fixed textWrap(); tried to get the transfer program to work, but no success yet - I’m close though!
8/24/2022
studentlog4.0
After much toil and lucubration, I got my transfer program to work; now I’ll be able to load all the assignment data from each student file into a sql file quite rapidly. I still have to enter the filenames manually, which is cumbersome, but I’ve saved a tremendous amount of time by not having to write each INSERT statement over and over!
Follow up: added a feature that lets me iterate through each student file automatically! Now, I just have to troubleshoot a few things.
8/25/2022
Udemy
Section06-05 (array of strings) and 06-06. I noticed the lecturer didn’t free the individual string elements of the array - is this a mistake or a feature? Section06-07 (using realloc) - a simple demonstration of realloc().
Still can’t figure out how to get VS Code to see the GTK libraries I installed. I updated the include path, but I’m not sure I did it right. I’d really like to implement a primitive GUI for my studentlog4.0 app.
studentlog4.0
TO-DO add error checking; replace student array with linked list (to help with insertion and deletion) - this will be a significant task, but I think it will improve the program overall!
8/26/2022
studentlog4.0
Decided not to implement a linked list; instead, I created a hash function that takes the student lesson time and convert it into an index for the student array - do it’s a quasi hash table. Now I can easily insert and remove from the array, and I reduced how many times I have to deallocated the array (the cost is that I have to search through the array more). I still can’t figure out why my delete_student function won’t remove the student from the student array.
8/27/2022
studentlog4.0
I figured out what was going wrong with my delete_student function: in the strcmp() function, I was comparing the wrong string. 🤬 It took me so long to catch it because I was following a red herring with the extern keyword and with variable scope, thinking the problem resided with the student array being somehow invisible to the delete_student function. Of course, the problem was much simpler.
Made use of the return codes from SQLITE3_EXEC, so now I can print “empty” when the function doesn’t find any data.
Wrote a simple program to transfer student data to the student_base table in the database. Not all the dates reformat properly yet - I might just manually correct the faulty ones. UPDATE: corrected the dates and inserted the data into the database.
TODO add error handling for user errors; and general debugging!
8/28/2022
Code - Book
Read chapter 13, which was on how to make the adding machine also subtract. The trick was to do it without borrowing.
8/29/2022
studentlog4.0
Improved the way the initial menu and main menu functions take the user’s selection and added error handling. TODO: more debugging; add more error handling; and spruce up the display of each menu, i.e. adding labels to each menu (WEDNESDAY).
8/30/2022
CS50x
Week 8 Lecture - I watched the first hour and a half, which was on HTML (Hypertext Markup Language). The last hour is on CSS (Cascading Style Sheet) and I think I’ll complete it tomorrow. 1:25:43
studentlog4.0
Added an option to cancel when assigning, adding, and deleting; added weekday labels to main menu; and finally, I decided to implement the program at work today! I think it’s debugged enough that it will work for all general purposes - I will add things like assignment deletion later. TODO make the most recent assignment display by default and rename the view assignments to view all assignments.
8/31/2022
studentlog4.0
Improved the look of the code by wrapping the long sprintf query statements.
CS50x
Finished lecture 8! After week 8, I have two more weeks and then the final project. From here on, I need to focus on this course and make sure I complete everything before the end of the year. I also watched two of the short videos, internet primer, IP, and TCP.
Terms to learn: statically-typed, kernels, type-safe, thread-safe. I found a fantastic YouTube channel called Fireship that has short videos overviewing key terms and programming languages etc. They’re rather amusing to boot. Statically-typed means you must specify the data types of your variables (C is statically typed).
“The kernel is a computer program at the core of a computer's operating system and generally has complete control over everything in the system. It is the portion of the operating system code that is always resident in memory and facilitates interactions between hardware and software components.” Retrieved from Wikipedia
Programming Security and Why Rust
9/1/2022
CS50x
Watched week 8 shorts HTTP, HTML, CSS. I played around with my own html and css files, and I’ll probably do more of this! I found it pretty easy and fun.
9/2/2022
Learn more about design patterns. Also, I’m reminded that I want to get a handle on Object Oriented Programming with C++ (I have a course on Udemy I plan to take).
CS50x
Watched the week 8 short on JavaScript. It’s taking a while to get through these shorts!
9/3/2022
CS50x
Finished all the short videos; completed Lab 8; and now I’m planning for the main week 8 project, homepage. Update: made great progress on my web page. I planned out my four pages, made a functioning navigation bar, and took the first steps of adding pictures in!
Sololearn
Started the JavaScript course just to get a better handle on the basics; I figure I ought to get comfortable with the basics of web dev even if I don’t find it as interesting as back-end development so far.
9/4/2022
CS50x
It took way too much effort just to figure out how to align my links on my navigation bar. I am, however, enjoying this process for the most part. Update: discovered flexbox, a CSS organization feature that is making my life easier. I also implemented a carousel for my homepage using Bootstrap, and I quite like it! I will have to go back through this project and make it responsive to different screen sizes - that will be another challenge.
9/5/2022
CS50x
I’m thinking of changing my layout from flexbox to grid. I JUST want something that will allow me to create a simple webpage - it doesn’t need to be fancy.
9/6/2022
Code - Book
Read chapter 14, Feedback and Flip-Flops. This chapter introduced the concept of a clock, and the idea of storing the last received state of a circuit (this plays at the idea of memory, and later in the book we will see more fully how something like RAM can be constructed).
CS50x
Finally feeling like I’m making progress; I don’t have to undo everything I’ve done! I need to make my page responsive and add some JavaScript code to satisfy the project requirements.
9/7/2022
CS50x
Made several improvements to my page. I was able to make it responsive using @media (I did something that might be unconventional - I nested an @media in another @media statement in order to make incremental changes to the page as a browser window size is reduced. TODO: fill interests page with content (use JavaScript to make a tabs menu for my various interests: hiking/camping, programming, reading, traveling).
studentlog4.0
Found a bug - date(‘now’) sets the date according to UTC time, so my lesson times after 5pm were registering as the next day. I had to change the function to date(‘now’, ‘localtime’).
9/8/2022
CS50x
Worked on the interests page; mainly, I added some blurbs to my accordion tabs.
9/9/2022
CS50x
Got the JavaScript to work for my interests page - I’m so close to being done with this project! I just have to polish everything up, and then verify that I’ve satisfied all the project requirements. TODO: write the blurb for the travel tab on my interests page; play with the responsiveness of the interests tab; verify that I have satisfied all the requirements of the project.
9/10/2022
CS50x
Got my interests page to be fully responsive! Changed the webpage background-color to off white - I like it much better. I wrote the travel blurb, gave everything a once over, and found that everything is ready to go! I submitted the homepage assignment! On to week 9.
Played around with HTML, CSS, and JavaScript in my own project folder, and I found that I have a much better understanding now. I can use flexbox pretty well by nesting flex columns within flex rows: ultimately, a grid of responsive flexboxes is created and I have a high degree of control over quantity, placement, color, et cetera. I’m starting to like this stuff more!
Downloaded and tried the Windows equivalent of Valgrind, Very Sleepy, on my studentlog4.0, checking for potential memory leaks.
Bought a breadboard circuit starter kit! I want to play around with hardware and learn how software integrates.
TODO: Review how to process a JPEG image within C - consult the CS50x lab from week3, I believe.
9/11/2022
NEW PROJECT: since completing the CS50x problem set for week 4, I’ve determined to revisit the concept of image manipulation in a C program. I downloaded the content for pset4 and read through the source and header files. Initially, I thought I’d practice with CS50x’s material, but I’ve decided to do it all myself instead. —> On docs.fileformat.com, I read up on the bitmap format. I’ll need to do much more research. —> Decided to finally get a handle on C’s error codes and messages. —> I’m also committed to using <stdint.h> and getting a better understanding of data types such as uint32_t (_t stands for typedef). —> I also want to get a good grasp of Makefiles
9/12/2022
Bmp_processing:
- use library <inttypes.h> for fixed-width integer types (uint64_t) since this library contains the macros that function as format specifiers (i.e. “%” PRIu64 “\n”).
- learned about the “xxd” command (hex dump) in Linux that “displays a file as it’s hexadecimal values and ASCII representation and allows edits to that.” This brought up the subject of Endianness as well, of which I now have a better grasp.
- I made notes in the program of all my sources. One website was particularly helpful: BMP Output
- I haven’t quite gotten this program to work, but I’ll keep trying!
- received my breadboard and jumper cables kit! I’m excited to get familiar with hardware too!
9/13/2022
YouTube
Ben Eater channel - I watched several videos on breadboards, how they work, how to organize components on them, and more.
Bmp_processing: with the help of IBM docs, I found my error! I specified “r” and “w” for my fopen() modes when I should have specified binary, “rb” and “wb”. Now it works! I’ll have more fun with this program later.
Udemy
“C Programming” section06-08 — writing an insert function that inserts a char at a specified index in a string. I decided to add improved error handling to my function and I used the <errno.h> library. Also solved section06-09.
My Website: I decided to build a website FOR REAL. I have an NFT domain name that I’ll use, and I can have my programming blog, a link to my GitHub page, and perhaps videos of my projects!
9/14/2022
CS50x
Week 9 Lecture (Flask). This week is about Flask, a framework for developing websites and web apps. I watched half of the lecture today (1:16:00). I’m intrigued by the possibilities Flask offers! As usual, #### CS50x lectures inundate you with information, but they are good primers. The short videos and the lab really help to let the information sink in. My Website: made some changes to the layout: now I have flex rows contained in a flex column wrapper - this seems to work better for sizing of elements such as the footer, which needs to adhere to the bottom of the page. I also added a photo that can be clicked like a button and which fades to 50% opacity when hovered over.
9/15/2022
My Website: registered for 000webhost to host the website I’m building because they host for free! After wrestling with my seanreed.nft domain from Unstoppable Domains, I decided to purchase a traditional domain name - seandavidreed.com; I’m still in the process of connecting it to my site. I made some improvement to my html and css. I’m quite happy with the direction I’m headed!
9/16/2022
Breadboard: received my 9-volt battery connectors this morning and promptly connected up a circuit on my breadboard to power an led, which immediately burned out - I passed far too much current through it! Later today, I learned more about Voltage, Resistance, and Current and the formula V = I x R. I needed to connect a resistor between the power source and the anode (positive) or the led; it worked!
My Website: added the meta viewport tag so that my page would display better on mobile. In projects.html, I added a button that links to my GitHub page TODO: find out how to make the blog post process more efficient. I can use the browsers inspector to see how the text is encapsulated on other websites.
CS50x
Watched a little more of Lecture 9. This one is taking me longer to get through. I’m certainly interested in the Flask framework, but I feel a little overwhelmed with all the different learning processes I have going on at once! The lecture is also very fast-paced. I know the short videos will help clarify things further.
9/17/2022
My Website: added a footer to all HTML pages; this prompted me to change the structure of layout, effectively simplifying it. It seems that with all my revisions, I had accumulated some vestigial organs in my markup, so to speak! This site was a great help for the footer format: dev.to/nehalahmadkhan/how-to-make-footer-stick-to-bottom-of-web-page-3i14
- I wrote a simple function in JavaScript that shows and hides a gallery of photos on the homepage when the initial image is clicked! I’m rather proud of how it turned out.
TODO: use something like Flask with my Website so that I can extend the layout to all pages and not write lots of duplicate HTML. Streamline the blog post structure. Write my about blurb.
Breadboard: read a little bit about NPN transistors and how to connect them into a circuit properly. I built some simple circuits, calculating the resistance I needed to avoid burning out the led (I think I still burned one out - lol). Also, I tried my hand at making an OR gate, but finding it more complex than I thought, I decided to postpone the endeavor.
9/18/2022
My Website: fixed the problem of the gallery not displaying on mobile in portrait - it was my use of the .nextElementSibling method in my JavaScript that was inhibiting the gallery from displaying. Wrote my About page blurb today! I added it to the HTML and uploaded it. I’ll probably make further revisions, but I’m quite happy with my first draft.
9/19/2022
CS50x
Finished Lecture 9. Watched both of the shorts for week 9 as well!
My Website: added a link to my music on Bandcamp on the links page. Corrected an issue on mobile where the image gallery was not properly formatted in landscape orientation; I used the following CSS to fix it:
@media only screen
And (orientation: landscape)
And (max-width: 1000px) {
.gallery {
flex-direction: column;
width: 70%;
}
}
Now I have a new code problem: my image gallery doesn’t respond properly in Edge or Chrome browsers! Ugh!! Tried in vain to solve it tonight, but to no avail.
I read a helpful article on embedded systems engineering, and I’d like to learn more! What is Embedded Development?
9/20/2022
Bare Metal C
I finally got started in this book! I read the intro and got started in chapter 1, downloading the STM32 System Workbench IDE Installer (I’ve yet to install it) and writing a hello world program. Of course a lot of this is review, but I appreciate reading a bit more about Makefiles, compiler flags, and bash commands. The next section covers how the compiler works.
- Tried to install the STM32 System Workbench IDE to no avail. I eventually found that I needed the latest version of Java SE Runtime Environment, so I downloaded it and still had no success.
9/21/2022
Bare Metal C
After searching forums online, I found that most likely the installation failed because I had two versions of Java installed on my machine. I uninstalled both versions and then installed Java afresh. Finally I was able to install and open System Workbench!
- I finished reading through Chapter 1. There were some excellent bits about the inner workings of the compiler, the importance of reading SOME assembly code to make sure the compiler isn’t taking too many liberties with our code, and how Makefiles and flags work. Very helpful!
CS50x
Woohoo! Finished Lab 9. Now I’m on to Problem Set 9, which I think will certainly present me with a challenge.
studentlog4.0
Quickly debugged the program - when a new student is created, the date will display correctly according to local time.
Code - Book
Read chapter 15, Bytes and Hex. It was mainly a primer on how the term byte came to be and how hexadecimal is useful for referring to bytes.
9/22/2022
YouTube
I watched three videos from Ben Eater’s Digital Electronics Tutorial; he starts out showing what happens when you pass too much current through an LED (which I did on my own when I connected a 9-volt battery directly), and he discusses Ohm’s Law, showing how we want to ensure that the voltage drops to zero across the whole circuit, and how resistors allow us to do that.
CS50x
Watched the walkthrough video of Finance to the time stamp 11:52. I created the register.html template according to the pattern of login.html, and I wrote the function in app.py for register. Returning to this function a few hours later, I was able to get it fully working! Woohoo! Later this evening, I completed the quote function, and I had to debug the register function. Now both are working smoothly.
9/23/2022
YouTube
Watched Ben Eater’s video “Why Build An Entire Computer on Breadboards?” and I think I’ve decided to do it! I’m not sure when I’ll set about buying the kit and the extra parts; I might wait until I’ve completed my numerous other projects.
CS50x
Worked on problem set 9 during my breaks at work. I made some progress on the buy function.
9/24/2022
CS50x
Did my best to work on the buy function in problem set 9 during my breaks at work. I didn’t have much more time to code today!
9/25/2022
CS50x
Worked on the index and buy functions. It took some troubleshooting, but I got them to work! Initially, I wasn’t indexing into the lists and dictionaries correctly, but that just comes from my lack of experience with Python syntax. After some research, I solved the problem. Also, I learned how to enforce a relationship between tables in SQLite using a foreign key. I can’t say I fully understand it at this point, but it works.
- Worked a bunch more on this problem set tonight. Went through and commented everything thoroughly; streamlined the orders table in SQLite and found that #### CS50x disabled the foreign key feature, so I need not bother with it; decided to create an additional table, portfolios, that will keep all the holdings organized by user and when stocks are bought and sold, this table will be operated on only with UPDATE statements.
- TODO: I need to format my html so that the data displayed actually looks nice.
9/26/2022
CS50x
Really trying to tackle this problem set! I finished sell() and history(). My portfolios table solution worked well. I had to debug sell() a bunch after completing it; history() was rather easy by contrast! Now I’m on the final feature, which is adding a personal touch. I decided to add buying and selling functionality to the index page so users can more easily place orders. I’m having a rough go of it, but I know I’ll get a breakthrough soon. For now, I need a break! After this, the final step is to make everything look nice.
9/27/2022
CS50x
I caved and decided to copy/paste the code from the buy and sell functions into the index function: I’m done trying to route from one function to another while preserving the variables (a task I think Flask should make easier). I’m so close to getting everything to work; there’s one thing in the buy function I have to fix, and I don’t expect it to be difficult once I’ve read up on the return value of SQLite’s .execute() method. LATER: wow this was SUCH a struggle. I found a stupid error in a couple of my execute statements, specifically for placing buy orders. In my query, the search conditions included “id = ?” when they needed to include “user_id = ?”! I kept missing this tiny detail! All the logic is now complete for this project: I need only beautify it by manipulating the HTML and CSS now.
9/28/2022
YouTube
My VS Code code space was taking eons to connect this morning, so I decided to watch a video on circuits by Ben Eater. The video brought me back to the study of electricity, so I headed over to Khan Academy to get yet another primer on Ohm’s Law (V = I x R). Of course, most of these concepts are very mysterious, but currently the one I understand the least is Power. I plan to learn more about all this through Khan Academy. LATER: returned to Ben Eater’s videos and learned more about NPN transistors! IDEA: try to replicate a circuit based on the diagrams in my Code book! Perhaps I can build a blinking LED circuit.
CS50x
I’m busting! I just completed the final Problem Set (Week 9) for this course!! Now I have to complete the final project, which I expect will be quite a challenge indeed. I’ve worked so hard at this: what a release it will be when I finish the course!
9/29/2022
I need to better organize my studies: perhaps I’ll create a list of common daily executables. For example, here’s my first attempt at such a list:
Current Personal Project: this could be an extensive or simple project where I solve a problem of my own or a problem someone else has (i.e. my Student Log Application fits here; Spencer wants a bot to scrape Facebook Marketplace for clothing listings)
Programming Language Study: my Udemy C Programming class fits in this category, as does my Bare Metal C book. Here I study the syntax, logic, and best practices of a given language (i.e. I’d like to do C++ after I’m done with the C Course; also, I’d like to look at Python more)
Hardware: working with my breadboard to better understand electricity, circuits, logic gates, and all the components therein. Bare Metal C also fits here.
Conceptual: reading my Code book; building a data structure just to understand it better; learning about various Computer Science topics like Graph Theory, Big O Notation (time and space complexity), and design patterns.
Bare Metal C
Worked through a bit of chapter 2, learning how to use STM32 Eclipse IDE. I created and compiled a hello world program as part of the exploration - the takeaway is the basic difference between Debug and Release configurations. Debug is not optimized, but easy to debug while Release is highly-optimized and difficult to debug.
9/30/2022
Bare Metal C: tried to use the GNU debugger (GDB) as the book instructed, but I kept getting an error message since GDB is often not auto-installed on Windows. At this URL — rpg.hamsterrepublic.com/ohrrpgce/GDB_on_Windows — I was able to find the answer. I went into the MinGW (Minimalist GNU for Windows) Installation Manager, and scheduled the GDB packages for installation. Voila! LATER: I tested out the debugger, stepping over a line of code, and where the book said I should see “!!! Hello World !!!” output, I saw nothing. I wondered if the GDB I installed was the wrong version, and I eventually found myself trying to reinstall a GCC package I downloaded directly from GNU’s site (I couldn’t figure out how to install it!). I’ll probably stick with MinGW. Still gotta figure out why I’m not getting output from GDB!
10/1/2022
Bare Metal C: puzzled over the lack of console output from the debugger. I saw some things online that suggested this issue is common when running the Eclipse IDE on a Windows machine, so I decided to just move on in the book.
10/2/2022
Bare Metal C
Worked on answering all the questions at the end of chapter two. Chapter three finally let’s me use the Nucleo microcontroller!
I bought a multimeter for my breadboard circuit exploits!
10/3/2022
CS50x
Watched the FINAL lecture, Week 10 Emoji! I felt some nostalgia while watching this lecture. I’ve been at this course for 8 months or so; I took the long route because I wanted to more thoroughly study the material presented in each week, so I treated each problem set as a stepping off point for deeper study. I owe a lot to this course, and I would certainly take another course offered by EdX in the future!
YouTube
Watched more videos on Electricity, specifically more about Ohm’s Law and Power, measured in Watts.
10/4/2022
CS50x
Watched the seminar on Git. I will definitely benefit from using this command-line tool; already, I have gotten into the habit of copying the directory of a project so that I can make experimental changes, but this is cumbersome and inefficient. While watching this seminar, I put the tool into practice, initializing my studentlog4.0 directory as a repository. Then, I used remote add to connect is to my studentLog repo on GitHub. Finally, I committed and pushed the files to the main branch (after renaming the old studentlog3.0 branch to “deprecated”).
I set about moving more of my programming project files into their own repos on GitHub using Git. I’m only moving those projects that are more sophisticated and stand-alone, not those that were built solely for practicing a technique.
Hardware: learned a little bit about my new multimeter - which terminals to connect the test leads to for which testing purposes, how to do a continuity test, etc. With the multimeter on current mode, I accidentally burned out another led: I connected the test leads to the resistor in parallel, which caused all the current to divert through the multimeter and bypass the resistor. The led is not rated for anything above 30mA I’m guessing, and when I connected my multimeter in parallel, I allowed something like 9A of current to pass through it! I learned online that I instead need to break the circuit and connect the test leads in series.
10/5/2022
CS50x
Continuing to practice with Git by working on my personal projects, committing, and pushing them. I improved my parsefile program, and I changed the default branch from master to main for each repo using this tutorial: Git Rename Master to Main
Watched the VS Code Local Environment setup video. It was very informative! Several things he implements I had already done on my own; however, he showed how to run VS Code using Windows Subsystem for Linux, which I already installed but wasn’t using in my IDE: I was simply using bash to interface with my Windows directories. Now, that I’m trying WSL, I’m finding issues with my studentlog program - the compiler can’t find some of the necessary header files, and I’ve yet to figure it out!
WTF is this error: “undefined reference to ‘dlopen’”, which is thrown on account of SQLite. That’s not even all the errors.
After almost pulling my hair out, I found the solution: I just needed to link in the dynamic linker -ldl, pthread -lpthread, and math library -lm at the end of the studentlog rule in my Makefile. Ugh, I don’t really get it, but I now know the issue was with the linker, and everything works.
10/6/2022
studentlog
Added create database feature that creates a database with the requisite tables if none exists in the program directory. I used sqlite3_open_v2 to check for the existence of a database. It works because this function takes two extra parameters: one that more precisely specifies what to do with the database once opened (I passed in SQLITE_OPEN_READONLY, which throws an error if no database exists, voila!) and one that I don’t really understand - it dictates what VFS module to use based on what operating system you’re running. I pushed all the changes to my repository!
10/7/2022
studentlog
Tried to implement a function that allows the user to restore archived students, a feature that I do need. However, I found that the changes would be more complex than I thought, and I wasn’t up for the task today. Plus I find that there is probably an easier way to implement such a feature. I executed two git commands, git reset —hard AND git clean -fxd, which reverted my local project folder back to the previous commit, effectively “undoing” my uncommitted changes.
10/8/2022
No time to code today! I worked a full day and then promptly drove down to Central Oregon with Rachel. While trying to sleep tonight, I find myself brainstorming about my #### CS50x final project; I think the inventory manager Flask Application is the way to go. My main question at the moment regards how to package the application: if I make it a web app, I have to concern myself with security since a user can’t have just anyone updating their inventory list. Is there a way to make a web app that can’t be accessed by just anyone on the internet? Possible tools to use: Python, Flask, and SQLite.
10/9/2022
Inventory Manager Web App: Alright! I decided that this is the project to do, and I think I’m going to use the Django framework.
Visited this URL to learn about Django: docs.djangoproject.com/en/4.1/intro/tutorial01/
Installed Django via “python3 -m pip install Django”
Created Django project via “django-admin startproject mysite”
Manage.py allows me to interact with the project from the command-line.
Read about packages in the Python docs: “A.B designates a submodule named B in a package named A.” A package helps to structure Python’s module namespace. A package is a collection of modules. Followed this link to learn more about packages and read up to 6.4.1: docs.python.org/3/tutorial/modules.html#tut-packages
10/10/2022
Read a little on Python’s built-in data types. I was mainly seeking to understand lists, dictionaries, and tuples better.
10/11/2022
Inventory Manager
Read through “Writing Your First Django App Part 2” up to “Playing With The API”. I learned about models, which are basically classes stored in models.py that define how data will be stored in the database (SQLite is default). Models create a database schema (CREATE TABLE statements, a Python database-access API for accessing objects. After creating or modifying models, use the command-line tool, manage.py, to “makemigrations” for those changes, and then “migrate” to apply the changes to the database. This feels a lot like Git (e.g. git add
10/12/2022
Inventory Manager
Following Django App Part 2. The tutorial showed how to display, manipulate, and save objects via the database API in the shell (python3 manage.py shell). “Question.objects.all()” returns unhelpful information, so I need to add the __str__() method to each model - this will get the database API to return useful information about the objects when requested in the API.
“It’s important to add __str__() methods to your models, not only for your own convenience when dealing with the interactive prompt, but also because objects’ representations are used throughout Django’s automatically-generated admin.”
Adding a custom method to the Question model, “was_published_recently()”.
Purchased another book published by No Starch Press, The Art of Clean Code. I’m excited about this one because it won’t be another intensive how-to but more of an overview helping me to think more clearly about how I design and build my projects.
10/13/2022
Inventory Manager
Still following Django App Part 2. I learned about the Django Admin page and how the models I created are automatically formatted and displayed there. Django really does a lot of heavy lifting for me here. I also changed the timezone value to Pacific Standard Time.
Practiced the concepts presented in Part 1 & 2 of the tutorial by creating an Inventory app in my project. My knowledge of Django is slowly coming together. Django automates many of the web app features, a fact which helps the build process but often hinders deeper into understanding. I’ll get there!
10/14/2022
Inventory Manager
Moved on to part 3 of the tutorial. Now I’m focused on creating templates and rendering them within views.py. This is how the interface of the web application can really begin to take shape! Here are some features I want to implement in my own app: login page (this is separate from admin login); UPC barcode scanner to both add new inventory items and search for items already in the system; order form generator that allows for different formats and methods of submission to suppliers; a simple data sheet that shows inventory stocking & consumption year over year.
Began a cursory design of the index.html page for my Inventory Manager app.
Reminder: use Django’s built-in authentication system for logging users into the app.
10/15/2022
Inventory Manager
Took a break from the polls app tutorial to try making templates for my inventory app. I encountered familiar headaches, trying to vertically align an element and finding that nothing works! I found myself mired in HTML, CSS, and Bootstrap jargon with little understanding. I was able to make an index.html page that displays a table of inventory items, and a login.html page with email and password inputs and login and register buttons, but I couldn’t get any of it to align where I wanted it! I’m really irked about it.
Returned to this project later after cooling off and made a little progress. Little victories.
10/16/2022
Inventory Manager
Initially, I roamed through the various tasks required for this project, trying for a few minutes to tackle one and, seeing little success, moving on to the next. This was a bad choice; I only got more and more agitated! Finally, I settled on the front-end task, building my login page using Bootstrap 5. After much toil, I was able to make the login page look and behave how I want - the main challenge was getting the login form horizontally and vertically centered. At first, resizing the browser caused the login form to narrow too much, but I was able to solve that as well. To finish my work for the day, I initialized the directory as a repo (git init); added all the files (git init add —all); changed the default branch (git branch -m main); made the commit (git commit -m “Initial Commit”); and after creating the repo on GitHub, I pushed the commit to the repo (git push -u inventory_manager main).
Later: began working on the model Item for my inventory app, and with the help of mdn web docs Django tutorial, I was able to iterate through the inventory items in the index.html template with a Jinja for loop.
10/17/2022
Inventory Manager
Improved index.html, centering the table, resizing cells, and changing the color scheme.
Following mdn web docs Django tutorial, I added user authentication. After consulting stackoverflow.com, I successfully connected my login.html template with Djangos built-in username and password fields. When valid credentials are provided, I am redirected to a page not found message since I’ve not created the profile page yet.
Installed the Better Jinja Extension on VS Code to stop the editor from deleting my curly braces when I hit enter. Had to go to file associations in VS Code and add the following key-value pair -> *.html: “jinja-html”
The Art of Clean Code - Book
Learning about algorithmic complexity - the book presented three sorting algos: Bubblesort, Quicksort, and Timsort (the default sorting algo for Python). With graphs generated by a Python program, the book demonstrated the significant differences in efficiency between the algorithms: Bubblesort is O(n^2); Quicksort is O(n * logn); and Timsort is O(n * logn). Timsort is named after Tim Peters, who implemented it in 2002. Anyhow, this chapter is about Complexity in general and this was one example.
10/18/2022
Met with Brett today, and he offered encouragement and insight. I took notes on some of the especially helpful stuff he said in my notebook. I’m feeling a lot more confident about my endeavors now: perhaps I’ll be able to get a new job sooner than I think! He presented a problem he uses in his interviews: it involves sorting a matrix and analyzing the time and space complexity it would take to do it. I couldn’t solve it completely in the moment, but I decided to write a simple c program to solve it in my own time - sort_matrix.c
Inventory Manager
Chipped away some more at the user authentication system. I mainly generated templates for the password reset case, but I haven’t gotten the reset email to send.
10/19/2022
Inventory Manager
Added a static folder to the project directory and allowed Django to “see” it by entering the following into settings.py:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, ‘static’)
]
Then, I included this in the index.html template:
\{\% load static \%\}
<img src=“\{\% static ‘images/image.jpg’ \%\}
Solved the NoReverseMatch error with the help of stackoverflow: since I added “app-name = ‘inventory’” to url.py in the app directory, I needed to write the template tag in layout.html thus: {% url ‘inventory:index’ %}
For fun, I got started on the logo, which index.html displays only when the user is not logged in. I bought a vector image of a clipboard for the logo!
Sort_matrix.c: Everything works, except I’m confused about whether I’m satisfying the sorting criteria!
10/20/2022
The Art of Clean Code - Book
Finished reading the “Complexity in Software and Algorithmic Theory” section, learning about Cyclomatic complexity, which quantifies complexity based on the number of branches in a codebase (i.e. if else statement, switch statement, etc.). I also read the “Complexity in Learning” section; I absolutely loved the author’s treatment of preparedness on page 15, how a knowledgeable person can fail to start a project because they are daunted by all the complex components therein.
Inventory Manager
Tackled the -/+ buttons on the index template; using JavaScript, I got them to adjust the values in the text fields! I had to link my jive.js file into layout.html using {% load static %} and
<script src=“{% static ‘js/jive.js’ %}”>
I learned how to add an attribute to a Python object using setattr(); I wanted to autopopulate the text fields in index.html with the difference between item.par and item.current_qty, but there didn’t seem to be an easy way to do it in template, so I did it with a new attribute appended to each object in the context. I now find that this feature may be unnecessary.
10/21/2022
Inventory Manager
Explored Django’s built-in form handling - I’m not sure whether I need to use it.
Added an option to login as admin on the login screen. On Stackoverflow, I found I could link to the admin login page via {% url ‘admin:index’ %}
Fixed vertical alignment of index.html table cells via class=“align-middle”
I realized I do need to make use of Django’s form handing, so I made a forms.py file and I created a TakeInventory class. The trouble is that I need a variable amount of fields in my form since inventory items may be added or removed - the solution is Django’s formset. I’m still in the process of implementing this using Geeksforgeeks documentation as a guide.
10/22/2022
Inventory Manager
I gave up on the Geeksforgeeks tutorial because I need to simply understand Django forms at their most basic before I work with formsets, which is what the tutorial covered.
I watched “How to Add Database Forms To A Web Page - Django Wednesdays #7” on YouTube and made a dummy form just to see if it could successfully populate the database, and it did.
10/23/2022
Inventory Manager
Spent way too much time trying to figure out how to connect my custom shed.html form to the Django SQLite database. I kept running up against the MultiValueDictKeyError and I thought it was because my Python code was incorrectly written. After scouring the internet, I found one helpful suggestion - print(request.POST). This would let me see exactly what is being returned from the form: when I did it, everything was made clear. I failed to realize that request.POST returns a dict where the key:value pair is defined by the name and value attributes in the input tag. Now, my form successfully populates the database. I’ve got a long way to go, but this little victory helped me keep the spark alive.
Sololearn
For fun, I completed a lesson in Python for Beginners. It was ridiculously easy.
10/24/2022
Inventory Manager
After examining the current inventory ordering system used by Woodland Espresso, I decided to edit models.py. I’m renaming and removing a couple fields in my item model and creating a new model called order, which will be a running list of all order history.
Created new model Supplier, which will be used to generate order form PDFs.
I found this resource helpful when trying to use ForeignKey fields in my new models: Setup Relationship Django Models
Modified the shed view to display shed inventory items only and the shop view the same. I had to add a “storage” field to the Item model: it offers two choices: shed or shop. Then I simply ran Item.objects.filter in the view to get only shed items and only shop items.
TODO: add user authentication to views. Create order history page.
10/25/2022
Inventory Manager
In views.py, I imported login_required from django.control.auth.decorators and applied the decorator to the shed and shop views; that way I don’t have redundant if-else code in each template.
Added order history functionality. The user can now visit a list of dates in order history; from there, the user can select one and see all the items ordered that day. Using the polls tutorial app as a reference, I got the url path to show the date selected from the order history page.
Now that I’m understanding both Django and Python better, I’m able to come up with new ideas and implement them in the spot. I successfully got the form in shed.html to submit all the values with unique dict keys - I simply used: name=“ and value=“0” (which is adjusted by user input). This was able to beat the MultiDictKeyValueError.
Dramatically simplified my shed and shop views. I used Django’s get_or_create method to make sure that there isn’t more than one entry per day for a given item.
TODO: Create an option for the user to download a given days orders as a PDF using the Python ReportLab module.
10/26/2022
Inventory Manager
Corrected the timezone in settings.py - ‘America/Los_Angeles’.
Eliminated the need for two separate views for shed and shop by adding this to one of them:
If request.path == ‘/inventory/shed/‘:
item_list = Item.objects.filter(storage__contains=‘A’)
Else:
item_list = Item.objects.filter(storage__contains=‘B’)
Learned how to pass order information to the orderfile view, which will generate a pdf with the data. I kept trying to pass the date from order to orderfile via the queryset list. I realized the easy solution was to simply add the order_date string to the context in the order view render function.
Added email and phone fields to Supplier model.
TODO: login to woodlandespresso email and get contact info for suppliers; work on PDF layout (read ReportLab docs); consider design elements - coffee with steam rising image.
The Art of Clean Code
Finished chapter 1 (complexity). The biggest takeaway from the last section was the importance of deep work, letting myself focus intensely on the task at hand, ruthlessly eliminating distractions and multi-tasking. Instead of working on three big projects simultaneously, work in one big project deeply, which is what I’m doing now with Inventory Manager!
10/27/2022
The Art of Clean Code
Began reading chapter 2, the 80/20 Rule, or Pareto Principle. 20% of causes account for 80% of effects and 80% of causes account for 20% of effects. The recipe for success is to focus on those 20% of causes; find out what they are, practice them. How to do this in programming? Well the book aims to tell me in the pages ahead.
Lagging indicators: they measure success, but they come on the heels of the causes that effected that success to begin with.
Inventory Manager
I attempted to connect my phone to the Django server running on my computer, and though I followed steps outlined on stackoverflow and Reddit, nothing seemed to work. I did learn a little about IP addresses though, that 0.0.0.0 specifies any IPv4 address when used as a host address. I suspect my troubles come from WSL. Tomorrow, I’ll try this process on my Linux desktop.
Codesnack: I created a linked list with C. Why not? I look forward to working more with C again in the future.
10/28/20222
Inventory Manager
Woohoo! Got on my Linux desktop and was able to access the Django server from my phone! Here’s the steps I took:
git init
git remote add inventory_manager https://codeberg.org/seandavidreed/inventory_manager.git
git stash
git fetch inventory_manager main
git merge inventory_manager/main
ifconfig // to get IPv4 address 10.0.0.162
Add IP to ALLOWED_HOSTS in settings.py
Python3 manage.py runserver 0.0.0.0:8000
On mobile, enter http://10.0.0.162:8000 into browser and voila!
Phone call with client: interested in value entered being the actual number of inventory items present: then, the app can get the difference from quota and append that to the order form.
TODO: using the site on mobile made me privy to the double-tap zoom feature on phones - how to disable it so users can rapidly click the +/- button without zooming; learn about the _pycache_ folders in the Django project - may not need to push them to repo.
Later, I worked on the aesthetics of the web app, adding a CSS folder to static and linking it into layout.html. I added a background image in the css file. I played around with using cards on the dashboard: I’d like to use them if I can get them to look nice. Corrected the navbar so it stretches the entire width of the viewport.
TODO: stack background image in a photo editor to make sure background is fully covered in mobile.
10/29/2022
In the hope of writing a C program that tiles a jpeg for me, I set off reading about the file format. I found several good resources, and I began to write my C code for the project, titling it jpegStitcher.c. I used Linux’s hexdump command line tool to view the byte stream of a sample image, and I was able to see the various markers, as the documentation said. For the most part, I could see all the components of the so-called header (JPEG does not have a formal header like PNG or BMP). However, I couldn’t find the pixel array, where the actual “atoms” of the image would be. I suspect I didn’t look hard enough, but moreover, I think the lossy compression makes the array much less straightforward than a BMP, for example. To conclude, I found an article on how to build a JPEG encoder using Python; I think I will eventually follow it.
Inventory Manager
I played with the aesthetics of the web app, finding a new gradient background that’s large enough to cover everything no matter the viewport, redesigning the logo using Inkscape, changing the opacity and colors of the login form.
I found an easy solution to the double tap problem on mobile, but I haven’t implemented it. I’ll do it tomorrow.
10/30/2022
Inventory Manager
Added .gitignore to ignore __pycache__ and .pyc files.
Changed the background to a purple gradient.
Adjusted the navbar to fit full width of viewport.
Deleted all .pyc files and pushed changed to repo.
Made more aesthetic changes: used my styles.css to make universal changes. Added “touch-action: manipulation;” to fix the double-tap zoom issue on mobile.
The Art of Clean Code
Finished up chapter 2, on the Pareto distribution. The most important takeaway is that I must become an 80/20 thinker - too much in my life have I allowed myself to become focused on tasks that belong to the trivial many! When I have become an expert at anything, it has always been in spite of these fixations. I must become knowledgeable in the things that help me succeed the most rapidly and effectively. I can set aside the notion of becoming knowledgeable for knowledge’s sake (even though I think this posture has its virtue). I intend to read several of the articles that the author recommends in this chapter.
10/31/2022
Inventory Manager
Watched a video on how to use the pdfgen in ReportLab and I was able to get the formatting much better for the Download as PDF feature.
Tried to work on the CSS a little, but I couldn’t get a:hover to work. Ideally, I’d just use bootstrap’s nav-link class, but the way I have it configured, the text is to difficult to read. I’ll have to explore this further.
Scraped the idea of using hover. I simply read up on bootstrap colors, backgrounds, etc to achieve the look and feel I wanted. I’m still unsure how I want the final product to look.
11/1/2022
Inventory Manager
Read up on Report Lab’s documentation for the pdfgen library. I found myself enjoying the process! I now have a workable document that displays all the orders placed for a given date.
TODO: Solve the problem of page breaks in the PDF file.
Woohoo! Solved the problem of page breaks by expanding the for loop. Now the Download as PDF function dynamically creates the necessary number of pages to accommodate any size order list.
11/2/2022
Inventory Manager
Wrote finalize.html which will handle the order forms generated from the user-added data on previous take inventory pages.
Redesigned the take inventory process: now it is a chain of redirects.
Wrote the view for finalize, adding the send_mail class from django.core.mail module.
Wrote success.html with option to return to dashboard using HttpResponseRedirect and reverse.
Committed changes using
Git commit -a -m "<message>”
Thinking it would add untracked files, but it didn’t. Amended the commit by running
Git add —all
Git commit —amend —no-edit
And then pushed.
TODO: find out if I can generate a PDF without having to call a separate view or display it.
11/3/2022
Inventory Manager
Wrote createPDF() function, which can be called within the finalize view.
Replaced the send_mail class with EmailMessage class since it can attach files to an email.
Followed instructions at Django Send Email to configure Django’s SMTP connection with Google. Got an app password from my Google account, added a .env file, and added the app password and other data to it. I linked the .env file into settings.py.
Moved my orderfile code into the createPDF function and modified the database query. Now, an email sends with an attached order form!
TODO: rethink the orderfile view - I may be able to call it as a function within the order view.
11/4/2022
Inventory Manager
Converted the orderfile view into a function, which I named downloadHistory, that can be called inside the order view, just like the createPDF function, which I renamed to createOrder.
I realized my views.py was getting rather cluttered and it didn’t seem right to have both views and functions in views.py, so I created a new file, functions.py in the inventory directory, moved the createOrder and downloadHistory functions to it, and from there imported them into views.py. It helps to make everything more legible.
TODO: see if I can merge my downloadHistory and createOrder functions since they are nearly identical.
C Programming: Become A Pro! Think Like A Programmer!
Worked on section06-10: extracting all odd elements in an array and storing them in a new array using realloc. Even though I followed the video exactly, my program would only sometimes print the values to the console, and then it would always hang before returning an error code. I rewrote the program in CodeSnack and it worked perfectly.
11/5/2022
C Programming: Become A Pro! Think Like A Programmer!
I rewrote the section06-10 program in VS Code and ran valgrind on it. Valgrind returned several errors. Finally, I rewrote the program in the way I would write it myself and I got it to work with no errors.
Finished section06-11, which was on return structures from a function - stuff I’ve done before countless times, but it was good to get a refresher. I found that I had to recollect some of the nuances of allocating memory. Sololearn
Completed a Python lesson on while loops. Wondered what are the myriad ways to take input in Python.
11/6/2022
Inventory Manager
Combined the downloadHistory and createOrder functions into one and named it createPDF. It has two default parameters which are None if no arguments are supplied. This was to accommodate both uses, downloading history and emailing an order.
Linux Installation
Decided to partition the hard drive on my Windows laptop: half of it will be used for Ubuntu. I’m following instructions I found on tomshardware.com. I’ve installed Rufus, downloaded Ubuntu, and loaded the disk image onto my USB drive. I’ve also backed up any files on my hard drive that I wanted to make certain are safe. Tomorrow, I’ll set about partitioning the disk.
11/7/2022
Linux Installation
Continued with Tom’s Hardware tutorial, and when I switched the SATA Controller mode from RST to AHCI in BIOS, the computer would not reboot in Windows. I followed the troubleshooting steps laid out here - RST - but nothing worked. I decided to give up on Windows for now and install Ubuntu on a partition half the size of the SSD. Now I’m using Ubuntu, and it works great! Eventually, I might address the Windows booting issues and get them to work again.
Had to configure VS Code with git again, and since Linux does not support simply entering username and password in the terminal for git, I had to download and install Git Credential Manager GCM, which works wonderfully.
I realized that the studentlog.db that I backed up was not the latest one from the WSL2 directory, so I started trying to get windows to boot again, to no avail. Then I remembered that I can see the Windows-SSD from my Linux partition. I began searching through it for the WSL file system (with help online, I found it). The file system was contained in a Virtual Hard Disk file (.vhdx). With more research, I found I needed to install libguestfs to get the guestmount tool, which could mount the .vhdx in an empty directory. After much suffering with root authority and permission issues, I FINALLY retrieved my files from the WSL file system and retrieved the up-to-date studentlog.db! Mount Virtual Hard Disk VHD File - Ubuntu
11/8/2022
Inventory Manager
I need to make a list of objectives: what are the next few essential things to do in this project?
TODO: Add inventory analytics; Make user info more dynamic, i.e. don’t hard code woodlandespresso@gmail.com into the source code.
Added a confirm submission checkbox to inventory form.
Used exclude() method in createPDF() to omit any items that have an order_qty of zero.
Reinstalled Better Jinja extensions and updated file associations in VS Code settings with this key-value pair: *.html: “jinja-html”.
Created analytics template and view and added them to the urls.py list.
Improved the table layout in the take-inventory template. Now the input fields and +/- buttons will stay a consistent size.
11/9/2022
Inventory Manager
Found an error: the exclude() method I added yesterday presented a problem — if the user does not enter any values into the take inventory form, the createPDF() function fails since the queryset it fetches is empty. In the createPDF() function, I added an if statement to check for an empty queryset, returning None if it is empty. Then, in the finalize view, an empty-order template is rendered if the pdf variable is None.
In the finalize view, I was able to access the admin email via the following: get_user_model() from django.contrib.auth
Email = get_user_model().objects.filter(is_superuser=True).values_list(‘email’, flat=True)
Then, the str is accessed via “email[0]”.
Watched some YouTube videos about Linux and it’s various distributions. I learned that Linus Torvalds also created Git!
I searched “C Language use cases” on Google to see what people are using it for these days and I found a fascinating article: Applications of C
Purchased the app Working Copy, which essentially lets me use git on my phone! Now I can pull from my remote and edit code on the fly. I think this app will be immensely useful.
11/10/2022
Inventory Manager
Got the finalize view to generate multiple email message fields, one for each supplier with items of non-zero order_qty. The view also successfully handles each email and sends them to email supplier’s email address.
Altered first query in finalize view to only display a textarea for suppliers who have orders to fill. I used the Python shell to test out several ideas for the query; I found this process very helpful!
TODO: consider merging the take-inventory and finalize views so that orders are only added to the order table right before submission.
The Art of Clean Code
Read part of chapter 3, on the Minimum Viable Product. A key takeaway: the dangers of working in stealth mode (working on a project entirely without giving demos and getting feedback).
11/11/2022
Inventory Manager
TODO: adjust take-inventory view so that orders are not appended to order table unless at least one of them non-zero. There must be a way to create a querylist that will only append to the database if certain conditions are met.
Tried my hand at adjusting the take_inventory code so that if all the values in the form are zero, nothing gets added to the database and the user doesn’t make it to the finalize view. I did succeed at a few changes, where only non-zero values are added to the database and zero values are stored in an object list called empty_orders. I don’t think I’ll keep this structure, however.
Read on Reddit that I can save the form data to the session and then save to the database from there if the data is valid.
11/12/2022
Linux Installation
I made the move and destroyed the Windows partition, resizing the Linux partition to the full size of the hard drive. I followed this tutorial: How Do I Remove Windows but Keep Ubuntu
Next, I needed to remove Windows Boot Manager from the GRUB menu - ideally, I don’t want the grub menu to appear at all. I followed this tutorial: How Do I Remove Windows From the UEFI Boot Menu After Custom Installing Ubuntu
Success! My laptop is now fully a Linux PC!!
Sickness and Misery intervene
11/16/2022
Student Log
Made some simple changes to the directory.
Git rm —cached studentlog.db // to remove the db from tracked files
I ran the same command for a few other files. Finally, I added a .gitignore file to make sure that the database file and any object files are never tracked.
Inventory Manager
My aim: to have an order written to order history only when the take inventory process is fully completed.
Currently, an order is appended to order history as soon as the form is submitted, but before the information is actually emailed to the suppliers. That means a user could start an order, decide to abandon it before emailing, and still find it in order history as though it were actually placed.
To solve this, I tried to use Django’s sessions framework. Nothing I tried succeeded, but I suspect there may yet be a way. Tomorrow I’ll try again.
11/17/2022
Inventory Manager
I successfully got the sessions idea to work! The issue lay in my attempt to pass datetime.datetime.now() through the session, which I didn’t even need to do since I could perform that operation on the other side, so to speak. That’s what I did, and now it works exactly as I wanted it to! Now I just need to get order history to display orders with the same date in case the user sends two orders in one day.
Added order_number field to the Order class in models.py - this way I can associate a group of entries more easily, and I can use that number to query that specific group of entries from the database.
Modified the order-history template to pass order_number instead of order_date to order view.
Modified order view to receive order_number parameter instead of order_date.
Modified createPDF() to take two default parameters, suppliers and orders.
Modified path to order view in urls.py — ‘order-history/<\str:order_number>/‘
Added this to the finalize view:
Order_number = Order.objects.values_list(‘order_number’, flat=True).latest(‘order_number’) + 1
Added a column for order number to the order-history template.
Fixed error in finalize where a textarea was created for each item ordered.
Used Pythons raise keyword to protect against improper usage of my createPDF() function.
Bare Metal C
I went ahead and installed STM32 System Workbench for Linux. I really would like to get more into this book - once I finish my inventory manager, I think I’ll do that.
11/18/2022
Inventory Manager
Messed with the cosmetics of the app, changing the dashboard buttons to images, etc.
11/19/2022
Bare Metal C
Refreshed on some of the content in chapter 1.
Read and followed along in Chapter 3 until page 44. I learned about the Hardware Abstraction Layer (HAL), general purpose input/output (GPIO), and the various other components on the Nucleo development board.
Wrote the led blinking program, and I tweaked it a little to get the led to blink twice rapidly before going off for a longer interval.
11/20/2022
Inventory Manager
Modified the take-inventory template and corresponding view by separating the shed and shop inventory items. Now they appear in the same template in different tables. The way they are processed remains the same as before.
Worked on the history process. There is now an archive for any order history entries beyond the latest 20 entries. When the user selects archive, they are taken to a page where entries are organized by year.
11/21/2022Browsing Jobs
Looking at developer listings on indeed.com, I found a company called Emonics hiring for a Web Developer developer position. I was excited to see that the job qualifications include several things with which I now have experience, e.g. HTML, CSS, Bootstrap, and Git. Moreover, the company is highly-rated on Glassdoor and other sites. I went ahead and saved the listing on indeed. I plan to start making a list of employers that intrigue me.
Read an article written by a guy who made a career change like I am planning to do. His writing was encouraging; I found that it largely validated the path I have been on so far.
Inventory Manager
Removed UPC code field from Item model and added latest_qty field, which is used to auto-populate the take inventory form with the average of the last two orders. This should make the process of taking inventory even more streamlined since the user may only need to adjust the order number by one or two each time.
Began messing with the matplotlib module to create a graph for my analytics view and template.
11/22/2022
C Programming: Become A Pro! Think Like A Programmer!
Watched the What is the Output video. I understood all of it, which I suppose is not surprising given how much time I spent with C earlier this year!
Watched an interview of Linus Torvalds on TEDX.
Inventory Manager
Decided to use the plotly module instead of matplotlib.
11/23/2022
Inventory Manager
Changed color of auto-populated values in the take-inventory template. They change from gray to black when the user modifies them.
Working on the query for the analytics view, I kept running into these errors:
TypeError: unsupported operant type(s) for +: ‘int’ and ‘str’
ValueError: invalid literal for int() with base 10: ‘order_qty’
I found that the error really came from my failure to import the Sum method from django.db.models!
Worked on designing queries for the analytics view. This is proving rather difficult.
Added select fields to the analytics template so the user can change the scope of the bar graph.
The Art of Clean Code (book)
Finished the chapter on the Minimum Viable Product. I’ve found myself thinking about this design method a lot as I work on my Inventory Manager. It has helped me to pare down the number of features I want to deliver. I’m at three: taking inventory, viewing and downloading history, and viewing and downloading analysis of inventory ordering.
11/24/2022
C Programming: Become A Pro! Think Like A Programmer!
Completed section07-01 through 07-03. This was all on the subject of streams - stdin, stdout, files, etc. The FILE type was introduced as well as the fopen() and freopen() functions. Further, the different opening modes were introduced. We also went over how to add the path to a file into the fopen() function. This is all review to me, but I find it quite useful since I’ve not used C much lately.
11/25/2022
Inventory Manager
The analytics feature is proving rather challenging. I think I need to better define my objectives.
Question to answer: what is the overall trend in the inventory (where the data is aggregated by day and presented as a line graph).
Hot take: I much prefer working directly with SQL than with Django’s database-abstraction API.
From agiliq.com (Django Aggregation Tutorial), I learned that each queryset object has a query attribute, which shows how the query was converted to SQL. I found this very helpful for troubleshooting.
On geeks for geeks, I learned how to make a simple line chart. I really appreciated how they stripped it down to the bare bones - from there, I can really start to get a grasp on plotly. Other sites, started out way too complex.
I finally wrote a query that gets the exact data I want:
Total_daily_orders = Order.objects.values(‘date__day’).annotate(sum=Sum(‘order_qty’))
Added the range method to my query so that only the data in a given timeframe is fetched.
11/26/2022
Inventory Manager
Modified the layout of the line graph using the method update_layout().
Improved the UI in the analytics template, allowing the user to select the scope displayed in the graph: YTD, Month, and All Time.
User can now select a specific item and see it’s trends within the above scopes.
Worked on the UI, changing some colors, i.e. navbar switched to black.
I’m having difficulty vertically centering the logo and login fields on the page. When I set the view height to 100, the navbar is not included, so I modified the body tag selector in my css file, setting display to flex, flex-direction to column, and height to 100vh. I’m able to get them to center, but then other formatting is thrown off. I’ll have to mess with it some more.
Success! Initially, I tried to solve the vertical centering problem by setting the body tag selector to display flex column and height 100vh, but this kept messing up the formatting for everything besides logo and login. Finally, I found a css function, calc(), that allowed me to target only the divs I wanted and simply subtract away the presence of the navbar from the total view height.
11/28/2022
Code - Book
I read chapter 16, An Assemblage of Memory. I was able to comprehend it for the most part, but considering I hadn’t read this book in a while, I had to refresh myself with content from previous chapters several times.
Minecraft
I know, I know - what’s up with this category? Well, to better understand logic gates and the D-type Flip-flop circuit, I built them using redstone in Minecraft. I found this exercise helpful! The redstone comparator in particular resembles a transistor in its function.
Inventory Manager
I modified the colors of the web app, i.e. navbar switched to light.
Added some JavaScript to control the navbar links visibility based on which page the user is visiting.
Eliminated dead code in urls.py (path to shop), and renamed the path to shed as take-inventory.
Changed the margins and sizing of buttons in the dashboard template.
Eliminated the unnecessary plotly modebar features using the modebar_remove method in update_layout.
Removed the plotly display logo with this:
Fig.to_html(config={‘displaylogo’: False})
TODO: main hurdle now is finding a clever way to keep track of cases and case sizes for inventory items (I need to add it to the logic in the codebase). Then, I need to spruce up the pdfs.
11/29/2022
Inventory Manager
Added ItemAdmin class to admin.py. It allows me to modify the layout of the Item class fields. I combined the new fields, package and package_qty, in a triple so they display on the same line. Further, I added the ‘collapse’ class so that they will only display if the user selects “show.”
With plenty of trial and error, I successfully implemented a constraint in the Item model. The user can only select a value for both package and package_qty, or for neither. I used several resources to help me figure this out, including the Django docs, but this one was by far the most helpful because it explained field lookups in Django and how to create our own: Django Check Constraints
TODO: modify admin page more, modify Supplier model to allow for selection (emailed order or no), modify order-history to accommodate package and package_qty
Reading Articles
I found this excellent resource regarding web developer tools: Web Development Tools
11/30/2022
Inventory Manager
Add packaging to order template and createPDF() function.
Fixed date format in createPDF() function.
Improved process of fetching date in analytics view using the strftime method in datetime.
Add packaging info to analytics view.
TODO: add preview order functionality to finalize; suppliers - select whether to email order; finalize - universal message (with individual message override); download as csv (upload too?).
I watched a video about WebAssembly, and now my interest is piqued. I have very limited understanding at the most, but I know I can use it to compile my C code for the web browser. One main tool for this is Emscripten, which I run into before when I was searching for ways to create a gui for my studentlog app. Just for fun, I tried compiling my studentlog3.0 app with Emscripten. After some finagling, I was able to get it to compile without any errors, but the program still wouldn’t run properly in the browser. Oh well, I’ll try again soon! Here’s the video: WebAssembly
12/1/2022
Side note: I’ve been using Vim in the terminal a lot lately and I’m finding it very helpful for when I need to make little tweaks and I don’t want the hassle of opening the IDE.
TODO: add preview order functionality to finalize; suppliers - select whether to email order; finalize - universal message (with individual message override); download as csv (upload too?).
GitHub Pages
I migrated my personal website directory from 000webhost to GitHub Pages! I intend to learn how to use Pages thoroughly, and I’ll likely make radical changes to the layout of my site (it’s pretty ugly as is!).
I moved my old website directory to a deprecated branch and now I’m installing Jekyll on my machine.
Whew, that was actually rather tough to sort out, but it works. I created a GitHub Pages site with Jekyll and Ruby. Now I simply need to populate it with my own information and code. I believe it comes with templates that I can try out! I’m excited to play around with it.
Inventory Manager
Improved the createPDF() function. Now it only returns one possible object. At first it returned buffer or buffer.getvalue(), but now the getvalue() method is in the EmailMessage object.
I played around with the preview orders button, but I couldn’t think of how to configure it at the moment. I’ll try again later!
12/2/2022
Inventory Manager
Lately, nothing that I implement seems to work! Oh well, I’m sure things with turn around. I decided not to fuss about the preview feature, so I turned my attention to the problem of whether to send order emails: supplier profiles now have a checkbox that selects whether orders will go to their email address or to the users email address.
12/3/2022
Inventory Manager
Fixed the email problem with this:
From django.contrib.auth.models import User
User = User.objects.get(pk=1)
Recipient = user.email
// latest_qty field now stores the average of the last five orders
Last_five_avg = Order.objects.filter(item_id=order[0]).order_by(‘-id’)[:5].aggregate(avg=Avg(‘order_qty’))
-Implemented Download as CSV for history and individual orders.
Removed groups from admin.
Added Delete Everything functionality to the Django Admin page.
Eliminated several views and used TemplateView.as_view in urls.py instead.
Vertically-aligned the results html pages (success, empty-order, etc.)
TODO: download everything as CSV
12/4/2022
GitHub Pages
I’ve been working on getting my custom domain properly configured with GitHub pages; I bought seandavidreed.com from hostinger.com in September. I added the following to the DNS records in hostinger:
A, @, 185.199.108.153, 21460
A, @, 185.199.109.153, 21460
A, @, 185.199.110.153, 21460
A, @, 185.199.111.153, 21460
CNAME, www, seandavidreed.github.io, 14400
This resource was helpful in straightening all this out: How to Fix Domain - GitHub Pages
Currently, when you type my custom domain in the address bar, it does lead to my page, but the browser throws a security risk warning. I believe my HTTPS certificate is still processing — it takes 24 hours sometimes.
12/5/2022
GitHub Pages
Went to hostinger.com and noticed a DNS record of A type that pointed to a different IP than the ones GitHub provided me. Sensing that this record was inhibiting my domain from getting HTTPS certified, I deleted it. Lo and behold, things started working properly!
Inventory Manager
Updated createCSV() function to handle “download all as CSV” case.
Connected the dataIO template to a view that returns the output of createCSV().
Worked on creating upload csv functionality, but I can’t get it to work so far. I found a resource online that may help me get it to work, but I’ll try it tomorrow.
12/6/2022
Inventory Manager
I’ve been working on the readCSV() function today and I’ve run into several issues: when I read the csv in from an html form, it enters Django as an InMemoryUploadedFile object, which is evidently one of Django’s wrapper. This object is seen by Django as binary data, so I can’t just toss it into csv.reader(), which needs a text stream, so I have to convert it to a string. Then, the problem is that the formatting of the csv is not recognized, so the csv.reader still does not parse it correctly, delimiting it at the commas and recognizing each row as distinct. I’ve been banging my head against the wall on this one, but luckily I think I found a tutorial that will clarify all this for me. I’ll try it tomorrow.
12/7/2022
Inventory Manager
After much suffering, I have completed the readCSV() function. Because of the issues described yesterday, I threw out the csv.reader method altogether. The following link helped me tremendously:
How to Upload and Process the CSV File in Django
Following the guidance, I used the string type’s method split() with a ‘\r\n’ delimiter to make the lines discrete, and then with a comma delimiter to separate each element in the line. This solved the problems I was having with simply reading the file in with the correct format.
Then, I was able to troubleshoot how the parsed data was handled. Here, I must lay some of the blame on fatigue. On two occasions, I failed to read the error message properly and spent considerable time troubleshooting the wrong code. One of these instances involves using the datetime module. I was trying to parse the csv file date with step time, and it kept returning “time data ‘Date’ does not match format ‘%Y-%m-%d’”. The trouble was, I knew that my date DID match the format, so my first instinct was to debug with a print statement. The print statement never executed, so I kept moving it around in the code with no luck. If it had printed, I would have solved the problem then and there. I still feel dumb because the solution was plainly in the error message: ‘Date’ was the value being read in, not the actual date! Ugh.
I added a lot of Cash and Carry and Dillanos items to the database, and I’ve got quite a few more to do. I plan to get the database entirely populated so I can begin testing it properly.
SOME THOUGHTS: I need to add more capability to the admin page, users should be able to organize items according to supplier and they should be able to insert new items wherever they want in the list. Also, I want to reorder how items are displayed in admin and add more information in each row (e.g. name, quota, etc.).
The Art of Clean Code - Book
In chapter 4, I read Principles 1, 2, and 3. I liked the bit about writing code with humans in mind first, not machines. Of course, Code must be written for machines by definition, but the point of this catchphrase is to reorient one’s thinking.
12/8/2022
C Programming: Become A Pro! Think Like A Programmer!
Completed section07-04 and 07-05. I started on 07-06. The first section is about freopen(), which essentially closes the file associated with a given stream and reassigns the stream to another file given as the filename parameter. The next section is about closing files (this was very straightforward since I already have plenty of experience). Section07-06 is about fseek() and ftell(); I’m eager to learn a little more about these ones.
Inventory Manager
Continued to add inventory items into the database in preparation for testing.
The Art of Clean Code
Read a few more of the principles. I especially liked the bit about the programming language style guides; Python has one called PEP-8. I browsed through it a little and found it very informative!
12/9/2022
Inventory Manager
Finished adding all the inventory items into the database!
Add more info to admin list so the user can see it at a glance.
Restrict non-superusers from altering the User table or using the Delete Everything feature.
Make style changes to templates.
Make brand field not required for Item model.
Add packs to packaging options.
Debug analytics view by adding exclude(order_qty=0) - then the queryset will be empty when there are only zero-quantity orders and the nodata TemplateView will be triggered.
12/10/2022
Inventory Manager
In the course of making changes to my program, I found that I got carried away, so I had to run
Git reset —hard
To return my local repo to the state of my last commit.
My main goal today was to change the way Suppliers with send_email=False are handled. Previously, I had them sent to the administrators email address, but this doesn’t seem particularly helpful. I have configured them to be rendered as csv files, appended to the session, and then accessed via a download button on the success page. However, I’ve run into some trouble: I get the error that HttpResponse objects aren’t JSON serializable. I did not figure out what to do with this error yet. I’ll do that tomorrow.
12/11/2022
Inventory Manager
Finally was able to push my changes: “Allow Suppliers with send_email=False to be downloaded from the success template as csv files”. Things will need to be commented and reformatted, but for now I’ll just revel in the fact that it works.
After reading the #### CS50x Final Project criteria again, I realized I needed to write a readme file. I wrote three hefty paragraphs, and I have plans to add about three more!
The Art of Clean Code - Book
Read Principle 6: Use Comments. I like the tips here. It can be too easy to skip over commenting the code, but this always comes back to bite me. It isn’t good for anyone, but it’s especially not good for me if I come back to the codebase after some time and struggle to understand everything for lack of comments!
C Programming: Become A Pro!
Section07-06: this is about fseek() and ftell().
12/12/2022
Inventory Manager
I added more to the README.md file. I’m finding that it’s actually rather fun to write. I’m able to take a tour through my app and rediscover, so to speak, how it all works. I’m also putting The Art of Clean Code to use: I’ve deleted redundant comments and rewritten others to be more clear. I also implemented the DRY principle (Don’t Repeat Yourself). In the take_inventory view, I initially had two for loops that were exactly alike yet that operated on two different lists, item_list_shop and item_list_shed. Using Python’s star operator, which unpacks a list, I was able to condense the two loops into one:
For item in [*item_list_shop, *item_list_shed]:
12/13/2022
Inventory Manager
Finished the first draft of my README.md! I’ll comb through it again and make edits.
Added the SECRET_KEY to the .env file, which will be in .gitignore when I’m done developing. I’m thinking I’ll need to get a new secret key when I actually deploy the app since I plan to submit the project for #### CS50x with the current secret key AND the current secret key is in my commit history, which I definitely shouldn’t have done to begin with! Added alternating blue striping to the pdfs generated by createPDF().
TODO: Test the entire app again; go through and make everything snake case to comply with Python standards; make sure readCSV() works; add instructions for testing app in README.md; explore tests.py.
12/14/2022
The Art of Clean Code - Book
Read about the DRY Principle (Don’t Repeat Yourself) and the Single Responsibility Principle. The SRP says that each class and function should have a single responsibility; for example, one function to retrieve data from the database and another to print the data rather than both these features combined.
Inventory Manager
Fixed readCSV()! I remember feeling a little lost when I was first writing it, and I think it’s because I had been coding for too long—I was crusty. When I looked it over today, the errors were as clear as day. This is a good reminder to take breaks!
Improved the layout of the success template using Bootstrap’s card component.
Added Table of Contents, Dependencies, and Testing the App sections to README.md.
Tested out various screen recording programs in preparation for recording my video! I haven’t found the right one yet.
12/15/2022
Inventory Manager
Woohoo! This video: Screen Recording showed me how to get full screen recording to work! I’m all set up to record the 3-minute video tonight!
Alright, so I recorded the video and it was way too long! I had to be ruthless in clipping out the fluff, and I don’t love how the video stutters a little at moments, but I think it’s workable. I’ll watch it again tomorrow and see what I think!
12/16/2022
C Programming: Become A Pro!
Section07-07: reading a char with fgetc(). More about the FPI (File Pointer Indicator) and how fgetc() advances it after reading a char.
#### CS50x
This is the class for which I’ve been doing all this work on Inventory Manager. I submitted the Django app today, and it hasn’t quite hit me yet that I’ve completed the course! I added my free certificate to LinkedIn, but once I get my verified certificate in 30 days, I’ll add that. This was such a great course; by stretching it out over a year, I was able to get more out of each topic. Each module acted as a springboard for further study and application! I will definitely take another one of Harvard’s edX classes in the future.
12/17/2022
GitHub Pages
I deleted my GitHub Pages repo, then forked “beautiful-Jekyll”, and renamed it seandavidreed.github.io, just like the old one. This template will make it much easier to build my personal website.
12/18/2022
Programming Log
I decided to create a new repository on GitHub for my programming log. I'll use markdown to help organize and format everything!
I copied everything from the programming journal and pasted it into 2022.md, removing entries not from this year. Then, I needed to add #### in front of every date. After exploring the world of regular expressions, I was able to input the following in VS Code to make the replacement!
// find
(\n)([0-9]+/)
// replace
$1 #### $2
Went through this whole document and reformated it to conform to markdown syntax. I cleaned up all the links to make them look like this.
This resource was extremely helpful for learning a bit about Regular Expressions.
12/19/2022
Programming Log
I added 2021.md, which is a rather small file! I omitted entries from September through November since they were primarily about blockchain technology, which was my gateway drug to programming and Computer Science.
Using regular expressions, I made sweeping format changes to this document! I'm quite taken in with regex. With it, one can wield unfathomable powers, and devise untold machinations. I'm using backreferences a lot and I learned how to change the case of a selection to upper or lowercase.
Regular Expressions Cheatsheet
C Programming: Become A Pro! Think Like A Programmer!
It's my goal to finish this course before the year it is. Most of the remaining content will be review, but I want to complete it since I'm so close. Plus, it will be good to review it! I have 30 sections left and 13 days. If I complete three sections a day, I will overshoot my goal, so I'll do three sections today!
Section07-08 fgets(). There are many subtleties to this function, and I’ve encountered them firsthand. Videos like this are a good reminder!
Section07-09 fputc(). I don’t believe I’ve used this function before. Through my own experimentation, I found I can pass hexadecimal numbers to the function and, just like decimals, they will be converted to characters according to ASCII code in the file.
Section07-10 Writing a string, fputs(). Pretty straightforward stuff here. I played around with the system() function from <stdlib.h>, executing the following code snippet to open the file in vim after writing to it with fputs():
system(“vim /home/seandavidreed/my_programs/CodeBlocks/section07-10/data.txt”);
Visiting devdocs, I was reminded that the system() function is in the standard library.
12/20/2022
C Programming: Become A Pro! Think Like A Programmer!
Section07-11 int fscanf(FILE *stream, const char *format, ...); Having taken a break from writing C code, it's refreshing to come back to it! I have a much mor intuitive understanding of functions like fscanf(), which is simply a way to have scanf() read from an input other than stdin, although fscanf() can also read from stdin. fprintf() is similar: it behaves like printf, but it prints the string to a file. In both cases, formatted strings can be produced, which is not possible with fputs() and fgets(). fscanf() can make file reading much simpler. I think I have overcomplicated it in the past with my studentlog program.
Section07-12 int fprintf(FILE *stream, const char *format, ...); As I described above, this function is the antipode of fscanf(). I can see how it would be quite easy to build a csv file using this!
Section07-13 size_t fwrite(const void *source, size_t size, size_t n, FILE *stream); When working with strings, I think I've often used fwrite() when I could have used fprintf() or fputs(). Now I see that fwrite is much better for a wider scope of data since it can work with binary.
Section07-14 size_t fread(const void *destination, size_t size, size_t n, FILE *stream); I took it upon myself to practice with both fread() and fwrite() for this section and get them to work with data.bin. It didn't work at first because I was trying to read from the file stream that I had opened with fopen() in "w" mode. Once I discovered this, I got it to work.
studentlog5.0
My Udemy Course has me into C all over again. I started writing another iteration of the studentlog, though I’m not fully committed to it. If I stick with it, I hope to make it extremely lightweight with minimal time and space complexity. I won’t use a relational database. Instead, I’ll use the good old text file. As I was experimenting with fscanf() for reading the cache csv file, I learned about scanners, which work with the scanf functions and allow us to tell scanf how far to read and when to stop.
/* What will be read:
* Sean Reed,time,12-12-1212,0,guitar */
fscanf(cache, “%[^,],%[^,],%[^,],%[^,],%[^,]”, s->name, s->time, s->start, s->end, s->instrument);
The ^ character says read everything until some character: in this case a comma.
12/21/2022
student-log
I was reminded how much I love working with C, so I started working on student-log again. This time around, I decided to push my work to a public repository! I'm trying to make this one as efficient and simple as possible. I can really feel the influence of The Art of Clean Code: I feel a strong desire to write tight, elegant code. I can give a rough idea of my progress by displaying my student.h file:
#ifndef __STUDENT_H_
#define __STUDENT_H_
typedef struct student {
char name[25];
int day;
char time[8];
char start[11];
char end[11];
char instrument[10];
int hash_offset; // going for the linear probing approach this time
char *assignment;
struct student *next;
} student;
extern const int TABLE_SIZE; // excited to get more understanding of "extern"
int hasher(char *str);
void initialize_table(student *table[]);
int file_to_table(FILE *cache, student *table[]);
void display_table(student *table[]);
void display_menu(student *table[]);
void consume(FILE *stream);
void destroy_table(student *table[]);
#endif
C Programming: Become A Pro! Think Like A Programmer!
Section08-01 Count the number of characters in a file. I solved this simply using fseek() and ftell(). In the video, he solved it with a function that iterates through each character in the file and increments a counter variable.
Section08-02 Printing Contents from a File using fgetc().
Section08-03 Printing Contents from a File using fscanf().
while (fscanf(f, "%s %s %lf %lf", fname, lname, &age, &grade) == 4) {
printf("%s %s %.2lf %.2lf\n", fname, lname, age, grade);
}
12/22/2022
C Programming: Become A Pro! Think Like A Programmer!
Section08-04 Make a printReverse() function to reverse a string from file. Solved this one before watching the video. Here is my solution:
void printReverse(char \*path) {
FILE *f = fopen(path, "r");
if (f) {
printf("opened\n");
}
else {
printf("error opening file\n");
return -1;
}
fseek(f, 0, SEEK_END);
long int file_size = ftell(f);
rewind(f);
char buffer[255] = {};
for (int i = file_size - 1; i >= 0; i--) {
buffer[i] = fgetc(f);
}
fclose(f);
printf("%s", buffer);
}
Section08-05 printContent function.
Section08-05 copyFile function. I found a good use for the strncopy() function: I needed to add "-copy" after a filename and before its extension (".txt"). So I counted the characters of the filename and used strncopy() to copy only that number from the source string before using strcat() to concatenate "-copy.txt".
student-log
I worked on this more than I should have today. I need to let myself take more breaks. Several of my edits to the code were successful: I implemented a matrix of pointers-to-struct (I also intuited how I might create a pointer to a matrix of pointers), and I added linked list functionality to each bucket in the matrix. However, I struggled to get the while loop in file_to_matrix (formerly file_to_table) to work right. A big reason for that was my erroneous use of feof():
// incorrect code
while (!feof(file)) {
// do stuff
}
This answer on stackoverflow explains why it is incorrect to use feof() to control a loop.
12/23/2022
student-log
I wanted to shriek last night: I couldn't for the life of me figure out how to make this program work. Here were the steps I took to fix it:
- Replace
while(!feof(file))withwhile((c = fgetc) != EOF) - Load file one character at a time into buffer.
- Parse buffer using sscanf() and scansets, terminating the read at newline character
- Add iterator pointer to any function that manipulated the matrix since it is passed by reference. The iterator moves through the linked list while the matrix pointer is preserved.
- Add newline character to the end of the file.
All these things together fixed my program. Now I need a good break.
Linux
I bought O'reilly Linux Pocket Guide book today at Half Price Books. I'm eager to become adept at using bash, which I learned stands for "Bourne-Again Shell". I spent a little time this evening practicing with the following commands: ln, type, and xxd.
12/24/2022
C Programming: Become A Pro! Think Like A Programmer!
Section08-07 saveWords() function. Pretty simple exercise here. We just practiced saving user input to file and printing it from file.
Section08-08 swapChar(). I tried solving this without watching the video, but it was too late in the day. I took a break for now!
12/25/2022
C Programming: Become A Pro!
Section08-08 I solved the problems from last night (my solution is below). Then, I watched the video.
void swapChar(char \*path, int find, int replace) {
FILE \*f = fopen(path, "r+");
if (f) printf("replacing...\n");
else {
printf("file does not exist\n");
return;
}
int c;
while((c = fgetc(f)) != EOF) {
if (c == find || c + 32 == find) {
fseek(f, -1, SEEK_CUR);
if (c > 64 && c < 91) {
fputc(replace - 32, f);
}
else {
fputc(replace, f);
}
}
}
fclose(f);
}
12/26/2022
C Programming: Become A Pro!
Section08-09 Another method for swapChar() using remove() and rename(). These <stdio.h> functions will be incredibly useful. Here are their declarations:
int remove(const char\* \_\_filename);
int rename(const char\* \_\_old, const char\* \_\_new);
[say what these functions do]
Since I’m trying to learn Linux more deeply, I consulted my pocket guide to learn how to make a new file with some text quickly. I ran this command: echo Hello, how are you, you hound? > data.txt which took the output from the echo command and redirected (>) it to a txt file.
This resource showed me how to open a shell window with the keyboard (CTRL + ALT + T).
Section08-10 Counting lines in a file using fgetc() and looking for newline characters.
Section08-11 Building a Currency Converter. For this project, we needed to write a function that reads space-separated strings from a file and prints them, and we needed the final string from each line to be ignored. I came up with this before watching the video:
while (fscanf(f, “%s %s %lf”, curr\_one, curr\_two, amount) != EOF) {
printf(“%s %s\n”, curr_one, curr_two);
}
I changed it to while(fscanf(…) == 3) after watching the video.
Linux Pocket Guide
Reading about directories and the file system of Linux. Commands I’d like to make more use of:
// switch to another directory in the parent
cd ../mydir
pwd // print working directory
I also learned that sudo is used when you want to exit a super user command without entirely switching from current user to super user.
12/27/2022
C Programming: Become A Pro!
Section08-11 Currency Converter. Finished this little project!
Section08-12 Comparing two files for equality. This was a fun project. I solved it myself before watching the video. Moreover, I kept my implementation even after watching it. This sort of program would be quite useful: occasionally, I have found myself with two files and I'm not sure if they are identical. I also used the errno variable from <errno.h> and perror() for error handling with opening files.
12/28/2022
C Programming: Become A Pro!
Section08-13 Write an array of integers to binary file and print from file.
Section08-14 Write a struct to binary file. I recall using this in one of my studentlog iterations. I ought to consider using it again in 5.0 if I continue to build it. It is much more convenient than the method I'm using now, which is to serialize everything in each struct into a text file formatted as a CSV. However, the advantage of my current implementation is that the output file is human-readable and can be easily moved wherever it needs to go.
Section08-15 Employee Manager. I started going off in my own direction on this one! Since it is so similar to my studentlog efforts, I disregarded what the instructor was doing and wrote several additional functions. While I'm happy with what I did, I think I'll go back and follow what he is doing just in case there is something new to learn.
12/29/2022
C Programming: Become A Pro!
Section08-15 Employee Manager. Alright, I went back through the previous videos for this project and got my code back in shape. I did keep some of the nuances of my own implementation, but now my program should behave pretty much the same way as in the videos. Later today, I have finished this section and I just received an email with my course completion certificate! There is one more video to watch, but it is classified as extra content: it’s 30 minutes on migrating one's C programming skills to Java. This course helped me tremendously, especially in its early sections. I started taking it when I had much less experience with C, but in these last few weeks, I already knew most of the content presented in these later sections. It was still helpful to review it all. Onward!
12/30/2022
C Programming: Become A Pro!
If I didn't finish this course yesterday, I definitely did today! I watched the 30-minute "Migrate to Java" video in the extra content. Now the course shows up as 100% completed! On to "Bare Metal C" and "Mastering Data Structures and Algorithms Using C and C++"!
student-log
I altered the file_to_matrix() function so that the student structs are now read from a binary file. That way storing them is much simpler! I also added file_to_matrix(), which writes them to a binary file in the first place, and add_student(), which adds a student to the matrix.
12/31/2022
Mastering Data Structures and Algorithms (Udemy)
I watched through the Section 1 videos and the first two videos of Section 2. It's all basic material at this point, but I was able to learn a little of C++ syntax, the "for each" loop. I'm still testing this course out; I'm not yet committed to it. I'm sure I'll know whether I want to complete it in a few weeks.
Code - Book
Read the first part of Chapter 17, Automation. I leafed through the rest of this book and I’m reminded why I need to finish it; it has some important material that will further increase my understanding of computers.
Linux Pocket Guide
Following the guide, I poked around in the operating system files. I was especially fascinated by the contents of /proc/ioports, which lists the hardware input/output devices present in the computer.
YouTube
I enjoyed browsing and watching videos from Computerphile and Ben Eater, two of my favorite computer channels. Jacob Sorber is another favorite.
Final Words on 2022
I proved to myself that I could become a programmer this year, and indeed I became one. I still have a tremendous amount to learn, but I think I have definitely established the discipline and reasoning that I need to succeed. I feel comfortable with C, Python, HTML and CSS, SQL, git, Django, a few data structures and algorithms, and more; I am able to conceptualize the innerworkings of a computer, how bytes are manipulated in memory, processed, and stored; I can solve problems programmatically; and I love programming. I'm leaving a lot out of that list for brevity. My next steps are to become adept with data structures and algorithms, understand time and space complexity deeply, learn C++ well, work through Bare Metal C, possibly take CS50's Web Development course, and keep reading my books. Perhaps most importantly, I need to keep hacking away at my own projects because that is the best way to learn! I might continue with my student-log 5.0, but at the moment, I don't feel it is essential. We'll see. I'm grateful for the progress of this year, and I'm excited for the opportunities ahead.





