This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
blog:spring2016:ddalton:journal [2016/01/21 13:20] – [January 19, 2016] ddalton | blog:spring2016:ddalton:journal [2016/04/14 13:46] (current) – [April 14, 2016] ddalton | ||
---|---|---|---|
Line 1: | Line 1: | ||
======C/C++ Programming Journal====== | ======C/C++ Programming Journal====== | ||
- | ====MONTH Day, YEAR==== | + | ====January 24, 2016==== |
- | This is a sample format for a dated entry. Please substitute the actual date for "Month Day, Year", and duplicate | + | I learned |
- | As an aid, feel free to use the following questions to help you generate content for your entries: | + | I have a lot to learn... |
- | * What action or concept of significance, as related to the course, did you experience on this date? | + | ====January 28, 2016==== |
- | * Why was this significant? | + | |
- | * What concepts are you dealing with that may not make perfect sense? | + | |
- | * What challenges are you facing with respect to the course? | + | |
+ | We did a C project where we made a program that used a trick to square two-digit numbers that ended in 5. In the trick, we left " | ||
+ | |||
+ | This trick might be able to work with any set amount of digits by changing what's appended and what the first digit is. My question is, we have powerful computers, and they would use a lot less power if they had simply multiplied out the numbers. They are machines, not humans. I'm not sure if it's optimized more for the computer to use the human trick of two-digit squaring with numbers ending in 5, but, it's there... | ||
+ | |||
+ | **Update to reflect reflection** | ||
+ | |||
+ | - The trick will work with 3 digits. For example, 105 ^ 2 = 11025. | ||
+ | |||
+ | '' | ||
+ | |||
+ | - The trick will also work with 4 digits. For example, 1005 ^ 2 = 1010025. | ||
+ | |||
+ | '' | ||
+ | ====February 7, 2016==== | ||
+ | |||
+ | I didn't even know the day of the week mental math procedure before this project. I think it's a really neat trick. I believe now it is a ton easier to figure out what day of the week that January 1st will be. The programming for a script to calculate it becomes much easier when a programmer not only uses '' | ||
+ | |||
+ | When dividing two '' | ||
+ | |||
+ | int a, b, c; | ||
+ | a = 2; b = 3; // set start values | ||
+ | c = b / a; | ||
+ | printf(" | ||
+ | |||
+ | Then we end up with '' | ||
+ | |||
+ | As a secondary example: For the step in the calculation where we have to get the biggest fitting multiple of 7 to subtract from the end of the year multiplied by 1.25, most would resort to this code: | ||
+ | |||
+ | multof7 = floor(eoy125 / 7) * 7; | ||
+ | | ||
+ | I switched my code to this and abused C's integer truncation: | ||
+ | |||
+ | multof7 = (eoy125 / 7) * 7; | ||
+ | | ||
+ | In addition: I also used the modulus operator ('' | ||
+ | |||
+ | ** UPDATE ** | ||
+ | |||
+ | This is not true. Days in the 20th century are consistently a day off. However, it is accurate for every 4th century after the 1st (0-99 AD, 400-499, 800-899, etc). | ||
+ | |||
+ | I'm honestly at a loss for how the algorithm works for years where the end two digits of the year are 0. | ||
+ | |||
+ | ====March 3, 2016==== | ||
+ | |||
+ | It took a long while, but my prime number script is about as optimized as I'm going to get it. Here's what I did: | ||
+ | |||
+ | - Found that all primes mod six are either 1 or 5. Any result that's even is either even or divisible by 3. | ||
+ | - Found that no even number (except 2) is prime, so it iterates by 2. | ||
+ | - Found that no number ending in 5 is prime, since it's divisible by 5. If the iterator is divisible by 5, it increments by 2 again. | ||
+ | - Since arrays allocate memory in order and array elements are faster to access than variables, I used those. | ||
+ | - I used prefix increments instead of postfix, because those are quicker | ||
+ | - I store primes in an array to use Sieve. | ||
+ | |||
+ | I've tried redefining square root and found that I can instead check if the number times itself is greater. If it's equal, it's not prime. | ||
+ | |||
+ | This sort of computational skill is not only fun to me, but it can be useful in the future in order to speed up currently implemented system implementations. I like puzzles like this. Give me more. | ||
+ | |||
+ | ==== March 22, 2016 ==== | ||
+ | |||
+ | Now we're exploring binary data in C as well as UNIX. In our current project, we're, to my understanding, | ||
+ | |||
+ | I've had an idea on how to do this one: just grab char values and print them in hex. Not too hard of a project, but, due to the terminal size restriction, | ||
+ | |||
+ | I wonder if we'll get into Makefiles, as the Unix project uses one to make its suite of binhaxx tools. | ||
+ | |||
+ | ==== March 29, 2016 ==== | ||
+ | |||
+ | The C project, a hex viewer, wasn't a very hard project. It was about reading files and formatting output in a really specific manner. It was great at showing me file manipulation, | ||
+ | |||
+ | My question is, what even is the FILE type? I get it's a pointer to a file, but what is it? Is it a type alias for something else? Just... what is it? | ||
+ | |||
+ | ==== April 14, 2016 ==== | ||
+ | |||
+ | Welp. I did get Joe with a meme, but it resulted in him pulling up the Bitmap standard... and this was the day after break. He's been talking about the Bitmap standard for a 24-bit Bitmap since the end of spring break. | ||
+ | |||
+ | Terminals plead for mercy. PNGs and JPEGs run off scared. The C standard is somewhere hiding off in a corner. Joe eagerly looks at the Bitmap standard. | ||
+ | |||
+ | Lol ok so I'm done describing that in any greater sort of detail. However, I got the grade figure-outer-er script done rather quickly and found a bug in it where it would just give me the days they logged in instead of the nice " | ||
======UNIX/ | ======UNIX/ | ||
====January 19, 2016==== | ====January 19, 2016==== | ||
Line 25: | Line 100: | ||
IRC helps, but, without documentation, | IRC helps, but, without documentation, | ||
+ | ====January 28, 2016==== | ||
+ | |||
+ | In our latest project, we explored how to make, add files to, and compress an archive using Gzip, Tar, and Zip on UNIX/Linux systems. Using that, we took out four files from an archive and re-arranged the text in them to form a forward-facing Mudkip, or the LAIR Image Calabration System Test Image (LAIRICSTI). In order to submit a compressed tar archive (tarball), we had to archive it using tar, and then compress it with gzip. | ||
+ | |||
+ | My assumption is, tar archive files can optionally be compressed into a file with the .tar.gz file extension using gzip, but, if corruption among the network is a worry, then they can upload the uncompressed file over a secure TCP connection. | ||
+ | |||
+ | At least, that is one benefit of sepearating archival and compression into two different formats. Now, the Internet is pretty reliable and not corrupted, so we don't have to worry about corrupted compressed file uploads. | ||
+ | |||
+ | ====February 2, 2016==== | ||
+ | |||
+ | So in UNIX, you can change the end of a file name so it doesn' | ||
+ | |||
+ | * Copying file.txt into my home directory resulted in a copy of file.txt in my home directory. | ||
+ | * file.txt appears to be ASCII text. | ||
+ | * Reading the file with cat reports that it is, in fact, ASCII text. The file reads, "This is a simple text file. It contains ASCII text." | ||
+ | * GZip' | ||
+ | * GZip' | ||
+ | |||
+ | In each respect, that lab was one of the most fun ones I've had yet, and I only hope to have more like it! | ||
+ | |||
+ | ====February 7, 2016==== | ||
+ | |||
+ | The second lab, Puzzlebox NEXT ('' | ||
+ | |||
+ | In class today, we got started with using vi as a text editor. It looks to be really useful with editing code in C, and, even though I already sorta use Vim on my Mac for some stuff, I can use it to write code in C in OpenBSD. Speaking of OpenBSD, I would partition a flash drive to be able to boot OpenBSD on it, but the computers here have, oddly enough, a password-locked BIOS on them. | ||
+ | |||
+ | Even I think that's weird that the Windows 7 computers have a locked BIOS and that you can't boot from a flash drive or an external hard drive, but, I guess it's so IT can have that amount of control over the computer, or, if someone decides to yank the USB drive while it's running, it's so they don't have to deal with the possibility of hardware failure. | ||
+ | |||
+ | My guess is that, in addition, it would interfere with the DeepFreeze software that goes and re-images Windows 7 every time the computer boots up. Either way, it's strange, but I guess it helps with security. | ||
+ | |||
+ | ====March 3, 2016==== | ||
+ | |||
+ | Web pages were actually how I got into programming. The web based adventure was easy to me for that reason. When I was around 10, I read books on HTML 4.01. I had a website coded and up when I was in 6th grade, and now I forget the credentials to access that domain. Coding HTML was always fun for me, and the web based adventure was a cinch in that matter. | ||
+ | |||
+ | I could' | ||
+ | |||
+ | Hopefully this month, I'll fix it. | ||
+ | |||
+ | ====March 10, 2016==== | ||
+ | |||
+ | I'm already on the right track again! This week, we're taking a look at a project involving UNIX data recovery, which should be referred to as the binary puzzlebox. Besides the ASCII table of contents, the rest of the file is a scrambled image. One part was encoded, another was compressed, and another was unmodified. After unscrambling the data and re-ordering it, it's an image saying " | ||
+ | |||
+ | Image formatting was my biggest problem during that. Converting from decimal system and using the dd command was really easy. It was the fact that I didn't initially know a lot about the image format the image was originally saved in, and, as a result, I stumbled around for a while trying to manipulate it when I didn't know how to convert it to something I could use, and it messed me up. | ||
+ | |||
+ | Besides that obstacle, it was a fun challenge. I enjoy challenges like these. They' | ||
+ | |||
+ | Another obstacle I somewhat disliked was that I was using a terminal to manipulate an image. If it's an image, I naturally would like to see it. But, for the nature of the project, the terminal was all I could use, and the only visual aspect of it was opening up a web browser to see the finished project. Sure, I could' | ||
+ | |||
+ | It was a beaut of a project. I enjoyed it, simply put. | ||
+ | |||
+ | ==== March 22, 2016 ==== | ||
+ | |||
+ | This week's project entails making sense out of digital sleeping brain wave data. So far, my challenge lies within automating this task, since there are tens of thousands of packets to look through and examine. | ||
+ | |||
+ | ==== April 5, 2016 ==== | ||
+ | |||
+ | I couldn' | ||
+ | |||
+ | I wish this was an April Fool's day prank. It isn't. Nobody knows how to do this project. And it's due in an hour. I don't even have a method to analyze individual data packets, let alone get data for the huge mass of them. | ||
+ | |||
+ | I know some of the bytes are simply going in sequential order as if they were part of a C script' | ||
+ | |||
+ | Technically speaking, I need help with this one. | ||
+ | |||
+ | ==== April 14, 2016 ==== | ||
+ | |||
+ | I never got udr2 all the way done to the point where I can pull up and analyse the data in a timely and efficient manner. I didn't quite know how to go about doing that sort of logic. I'm guessing calculus already fried that part of my brain into a nice toasty bacon. | ||
+ | |||
+ | The gfo script was extremely easy, though. It was simply modifying the output of a script. I may have broken the rule that says "each line should be less than 80 characters in width," | ||
+ | I think I did good, finally. |