User Tools

Site Tools


blog:spring2016:ddalton:start

Danny Dalton's spring2016 Opus

Tales of things.

Introduction

Hey, name's Danny. My interests involve gaming. It's a thing that allows people to have fun while I get to be productive. In this sense, productivity is non-productivity.

I joke around a lot, and, from what I've created in the past, it shows.

As far as programming experience, I've messed around with Swift and Objective-C (the thing Mac and iOS uses, and, with that, I've messed around with SpriteKit/SceneKit), VB, Java, and C#.

C/C++ Programming Journal

January 24, 2016

I learned a lot so far. Not just an intro of compiling C, but I also learned how to make a console program through C. I learned how to compile C into an executable on pretty much any OS. Although, I still do have a lot of questions, such as, how would I go about making an OpenGL program on Windows? How would I make an OpenGL program on other OSes such as Linux and Mac OS X? How do I even use OpenGL? With the Windows Objective-C compiler, what headers can I import in? Would these headers be the same as Apple's on Mac OS X? And to what version? Can I do some evil with pointers such as specify specific memory addresses and get the value of what's in said memory addresses?

I have a lot to learn…

January 28, 2016

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 “25” at the end, and, from the first digit of the number (n) that was input, we got the hundreds place like so: ((n / 10) * ((n / 10) + 1) * 100).

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.

((105 / 10) * ((105 / 10) + 1) * 100 = (10 * 11) * 100 = 110 * 100 = 11000. Add 25 and you will get 11025.

- The trick will also work with 4 digits. For example, 1005 ^ 2 = 1010025.

((1005 / 10) * ((1005 / 10) + 1) * 100 = (100 * 101) * 100 = 10100 * 100 = 1010000. Add 25 and you will get 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 if and switch statements, but also when a programmer is able to exploit the native C int type for their advantage.

When dividing two ints, C will truncate (cut off) the decimal. When people, for example, punch in 3 / 2 into a calculator, the calculator will output 1.5. However, 1.5 is a floating-point decimal number. In C, to get an integer from the number 1.5, the computer will cut off the decimal in order to get the number 1.5 into an integer that's able to represent it. In this case, if we decide to, say, run this code…

int a, b, c;
a = 2; b = 3; // set start values
c = b / a;
printf("%d", c); // print out c

Then we end up with 1 in stdout when most people would expect 1.5 to be rounded to 2. Please note: This is roughly equivalent to using floor() without importing any external libraries.

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 (%) to return the last two digits of the year, rather than simply subtracting 2000. Meaning mine might be accurate for years that aren't in the 21st century. Some of us might live in the past, and some of us might live in the future.

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, making a hexdump program that runs if the terminal is at least 80×20.

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, not the easiest project out there, either.

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, which I liked. Before that project, we just knew how to read and write files. It wasn't hard, but, to those new, it wasn't easy, either.

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 “1”s and “0”s from the example, so I guess that all works out :)

UNIX/Linux Fundamentals Journal

January 19, 2016

We got ourselves a little bit more acquainted with the machines. Although the class has an IRC chat, I have no idea where the server is located. It is probably in the next room. With that being said…

echo “Hello, world!”

January 21, 2016

The IRC chat is nothing if you don't know how to use it proficiently. It can be a help to those that know how to use it, but, if you don't know how to use the IRC, good luck. Luckily /help command is a thing on Irssi, and it's a very nice thing at that. What threw me off for a good couple moments was how to be able to connect to Lab46's IRC server, because that wasn't explained very well, in my honest opinion.

IRC helps, but, without documentation, it's useless. As with any piece of software. I'm talking about you here, Apple, with your out-dated non-ARC using Objective-C documentation for doing simple stuff that would be required in your new-fangled games… ugh. Your documentation sucks, Apple. To say the least.

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't fit convention. For example, you can neatly name your zip archive “mytextfile.mp4” and watch IT get more and more confused. It's fun to do, in all honesty. As far as the puzzlebox project went…

  • 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'ping and then using file reports that the file is now a gzip archive.
  • GZip'ping with the fastest compression method and then using file correctly reports that it is a gzip archive compressed at max speed.

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 (pbx1) wasn't as much of a challenge as the first Puzzlebox was. It was simply using uudecode, unzipping a file, and re-arranging four parts of a text file to get ASCII art of a bat out of it. I figured there would be more to the lab, but that was it.

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've tried to use more advanced CSS to make it fancier, but I didn't quite have the time to do that. I had other priorities at the time I worked on it, such as calculus, sociology, the optimized prime number calculator, and, of course, forgetting about the Opus, somehow, for a full month. I'm not even sure how that one even happened. I've been working on programming for a good while now. I know there was a break for a week in February, but I'm still unsure of how I forgot to do an Opus entry, yet I remembered to program a lot. Oops.

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 “TACOCAT IS A PALINDROME.”

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're fun to try to decipher.

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've converted it into color ASCII art, but where's the fun in that?

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't quite do an entry or finish my March 22 one as my PuTTY connection was super laggy and I may have forgotten. Either way, the UNIX project is super difficult for me, because bc is a pain in the butt to work with, considering every other thing it outputs is syntax error.

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's output, but not all of them are. A lot of it is simply wild guessing and hoping it works until it doesn't and then you sit for about five hours and accomplish nothing.

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,” but the thing not only satisfies the bonus requirements, but it even color-codes the results for an even quicker overview.

I think I did good, finally.

blog/spring2016/ddalton/start.txt · Last modified: 2016/01/18 16:05 by 127.0.0.1