Thursday, December 13, 2007

Updates

I've been pretty busy with life lately, haven't been able to pay as much attention to this kind of stuff as I would have liked.

Long story short, I took too many credits. Pretty sure I failed the math class I needed to get into the next class (no worries, there's a way around it that involves the exact same amount of work and will probably end up being easier on me).

I did give up on the long addition program after making a little more headway. Turns out that the end of line marker flipped out when the string was full, so I needed to call the skip_line function. That was all I got before giving up on it though, because the next project was much more difficult. The final project of the class was to read in an external file containing a partially completed Sudoku puzzle and solve it with algorithms.

Sounds fun, but I couldn't even read in the external file and so Me => Not turning it in. I skipped the study sessions because I wanted to get it by myself. A bad idea in retrospect and hopefully it doesn't drop my grade so low I can't move on. That would be discouraging enough to have to drop CS as a major (which doesn't leave me with a whole lot of options incidentally).

Oh well though. Somehow I don't think a 10-week course on a new (and basically first) programming language can cover enough about file i/o and multidimensional arrays (and the manipulation thereof) well enough to solve this problem. The study guides I skipped out on were provided by a student who probably wasn't new to programming (or Ada) so I am confident that without his help at least 50% of the class is with me. Still kicking myself for skipping, but oh well.

Next quarter will be much more focused for me: one math class and two CS classes (computer organization and programming II (with more Ada)). Basically this just means I won't have to write a paper all quarter. Fucking awesome.

In other news, I downloaded Visual Studio 2008 from the CS MSDN and I plan to finish my "Learn Visual C# in 24 Hours" book over Winter break. I'm only a chapter in but I can already tell that if I (God willing) stick with this, I'll learn a lot about the .NET framework and object-oriented programming. Plus it's a C derivative, which should be fun.

That's it for now, just keeping my fingers crossed for my final grades.

Sunday, November 18, 2007

Giving Up

Wow, I've really hit a wall on this one. Assignment's due tomorrow at 5 pm so unless I can get an answer from the professor or TA, I'm shit outta luck.

The assignment is called "Long Integer Addition" and the idea is to take two numbers (up to but not exceeding 30 digits) and add them together. Things to keep in mind:

-The "long integers" are not numeric data types (they are too long to be represented on 32 (or 64) bit machines). They are strings. What the fuck.
-Ada is very strongly typed, meaning casting (conversion) can't be done from integer to string. VB6's CInt and CStr will not work here.
-How do you add two values from a string literal and come up with their sum? You don't.

Well it would be nice if I could get far enough to do that, but I can't even get the basic input to go through. It'll take the first variable just fine, but freaks out when it comes to deux. Code:

Ada.Text_IO.Put(Item => "Enter a nonnegative long integer(30 digits maximum) >");
Ada.Text_IO.New_Line;
Ada.Text_IO.Get_Line(Item => X, Last => StrLenX);
Ada.Integer_Text_IO.Put(Item => StrLenX);
Ada.Text_IO.New_Line(2);
FOR Idx IN REVERSE 1 .. StrLenX LOOP
ArrayX(Idx) := X(Idx);
END LOOP;

That seems to work just fine. X is a 30-character length string and StrLenX is the length of the string. The For..Next loop at the bottom assigns the contents of the string to an array holding characters '0' through '9', the idea being that since each character will be stored as such in the string X, nothing outside that range will ever need to be represented.

A conditional would catch when the sum was over 9 and would carry the one, but I never got far enough to be concerned with that.

That first block works fine, but an identical block below it to correspond to Y variables (all declared as used obviously, the compiler would never let me get away with something stupid like that). It raises a data error when it goes to get string Y, which means that somewhere the data types are being misrepresented or mismatched through some bizarre and presently incomprehensible means.

That's all OK though, I don't know how to do this without casting the characters to integers and back.

Saturday, October 6, 2007

More Ada and Nerdery

So I had my first lab on Friday, and it turns out I'm the biggest nerd in my computer science class.

I don't have acne, I don't watch Battlestar Galactica, I don't play Halo, and I didn't know the name of the creepy laughing monster in Jabba's palace in Return of the Jedi (Salacious Crumb) until my sister told me.

But somehow it's true. I actually stayed in the lab after everyone had left, just so I could do my homework. I even came back after my next class to finish up. The TA had to remind me several times that I had finished the classwork and could leave whenever I wanted.

It was kind of an embarrassing revelation, but I had a problem I just had to figure out. And I still couldn't. Not to brag, but if I couldn't figure out how to screw around with the enumerated values and the TA didn't know how to help me, I think the rest of that class is fucked.

Right now I am working on two problems, one of which takes the colors of resistor bands (which, sadly, I have almost committed to memory) and converts them into ohms. The problem is taking three separate variables and concatenating them to become one number (e.g. 4,3, and 6 needs to become 436). This may not sound very hard, but it's kind of a daunting task*. The second needs to take a date and calculate what day of the week it will fall on, which is really just a formatting problem since we were given the linear algorithm (no loops, conditions, or arrays) to solve the problem.

God damned Ada, so picky and typesafe.

*As I typed this, I realized that if I could cast (convert) a string type to type integer/natural, I might have more luck. It won't work, but it's reassuring to know that I can come up with creative solutions that had not occurred to me.

Friday, September 28, 2007

Ada

All right, while I was sitting in class today I wrote my first Ada program on paper and compiled it when I got back to my dorm. Pretty simple (and obnoxious), but I think I've got the formatting/syntax down, at least for text I/O.

WITH Ada.Text_IO;

PROCEDURE Hello IS

Name : String(1..4);

BEGIN --Hello
Ada.Text_IO.Put(Item => "Enter your name:");
Ada.Text_IO.Get(Item => Name);
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item => "Hello, ");
Ada.Text_IO.Put(Item => Name);
Ada.Text_IO.Put(Item => "!");

END Hello;

This program, of course, takes a name and greets them. At least, only if the user has a four-letter name. This of course means that I'll need to dynamically allocate the contents of the array in memory.

Edit: I like how that last sentence really makes it obvious that English is not my first language. Which it is.

Wednesday, September 19, 2007

CSCI 141

I really thought I'd update this more often, but I really haven't done anything lately.

At all.

Anyway, I'm finally on my way to becoming a CSCI major since I emailed the professor and pleaded with him to drop the math prereq for the class I wanted (which is bullshit anyway, I've taken enough math to get in a calc class). The condition is that I have to go to every lecture and lab, but I kinda had my heart set on that anyway.

The class uses Ada95 to teach the basic concepts of OOP programming. I'm not too thrilled about having a new language crammed down my throat in a ten-week course, but I do feel ready for it. Apparently they used to use C++ for the class, but I think it was probably too sink or swim for the majority of students.

I'm just hoping I don't get a bunch of people in my class who think CSCI is for them because they're good at the Internet. I hear stories about people failing CSCI classes all the time, and I'm hoping that's the reason why.

I don't really know what I would do if I couldn't make it through, so let's hope this works out.

Tuesday, August 28, 2007

Commissioning a Symphony in C

...Kinda.

This whole week I've been trying to get into C and, surprisingly, the only problem I don't have is a lack of motivation.

First off, I can't find a compiler that will work. Fortunately I finally got a C/C++ compiler that has the I/O header I need. Unfortunately, I can't seem to get it to a) display anything for more than a fraction of a second when I use the printf() function or b) accept any kind of input with scanf() because hitting Enter exits out of the console. I could go to my dad (as I usually do when I need help with programming), but he always wants something in return, be it a nature hike, family function, or some other lame bonding experience.

The second problem I have is the textbook I'm using to learn C (which might explain the problems with compiling...) which was published right around my second birthday. It refers to ANSI C (the official C standard) as "the new way". As far as I can tell, this is the equivalent to my elementary school history texts that referred to landing on the moon as "an almost realized dream". But hey, basics are basics.

I am pretty excited to learn C though, since it would be my first "real" language (since I don't consider VB6 a real language). Hopefully this will set up the foundation for learning other languages, especially the OOP languages I'll need to learn for a CSCI degree (Ada95, C++, etc.).

I'm also hoping to do some Linux developing, particularly working on porting and recompiling applications to the Nintendo DS. My ultimate goal (unless it ends up being too hard or too much of a clusterfuck) is to get VLC running on it and stream video from a computer to the DS. Whether or not this is possible with a CLI is up in the air for the time being. It would also have to support UDP (the protocol VLC uses to stream video) which is also up in the air, but I digress.

Anyway, I'll post some source code when I finally get a functioning program (which I know you're dying to read).

Monday, August 20, 2007

Case 1

Skipping the introduction, as this should be pretty self-explanatory. Template may change over time.

Situation
Coworker was talking about her fried computer that won't even start up. Thinking this will make a good challenge and indicator of my abilities, I offer to get the pictures off her hard drive. Fortunately for me, she tells me that the computer has gathered dust for a while and all data was assumed lost long ago. Nothing to lose.

Initial Thoughts
No big deal. I'll plug it in, see if it POSTs (or turns on at all, as the case may be). Bad hard drive is likely the culprit, but hardware failure is never out of the question. If it is the hard drive, I'll stick it in my case, change the jumpers to Slave, and recover the data.

Process
When I booted the computer, it flashed the HP screen and went straight to an error message that said a file in the System32 folder needed to be reinstalled. Somebody fucked it up good, but far from hope being lost. So I yank the HDD out of the case, change jumper settings, and put it in my Antec case (which is awesome, review to follow).

First mistake (and I'm not entirely sure it was a mistake) was letting Windows scan the new disk for consistency. I was paranoid at first, since I have read that you have to be careful what you do with a corrupt disk, lest you write to it and fuck something up. Windows reports that the disk is unusable, which I find a little hard to believe.

Sure enough, when I pull it up in Explorer, most everything's there. WINDOWS, Program Files, and Documents and Settings. It's a cakewalk from here, I might as well pop in a blank CD now. But there's no data. All I can find are files that were bundled with the computer. Default pictures, songs, etc. None of the coworker's pictures. But...

There's something strange going on. Every directory has a common file. AXEL.DAV (a 24 byte file that reads "A" when pulled up in a text editor). A little bewildered, I turn to the God Almighty, Senor Google. Results aren't promising, but piecing together bits and pieces of forum discussion leads me to find that the drive was infected with the vbs_redlof.A virus. This doesn't explain the missing files (or the remaining ones for that matter), but I'm guessing that was on the user's end when she tried to use XP's restore.

Well, whatever. I run compmgmt.msc and delete both partitions (surprisingly, the backup partition was unaffected, despite the fact that most of the files had been removed). Clean drive goes back into the old computer and I start the XP setup. Formatting goes fine, but this machine will be God damned if it's going to install Windows. Every other component it tried to install was unable to be installed.

So fuck it, I'll start over. Except now the computer won't start up. Trying to enter the BIOS locks up the computer. A hard shut down and five minutes later, it reports that NTLDR is missing. Oops. Restart, enter BIOS, change boot priority, we're going to try this again. "Press any key to boot from CD..." is followed by the NTLDR error. Super cool. A half hour job is now at three hours and counting. Restart. Press any key before the fucker realizes that NTLDR ain't coming home.

Overwrite the partition I just created with a quick NTFS format. Before, Setup was at 0% when it found an error. This time I get all the way to 6% before it tells me a *.ttf (true type font) file is missing. Guess they're going to have to do without Courier for a while. But now we have a success.

Ladies and gentlemen, we are through the Looking Glass. Windows is installing. I'm going to install some third-party software and hopefully return an over-sized paperweight as a functioning machine. Fuck the pictures, at this point a revived hard drive is all that really counts for anything. I rename the computer MOTHER, and the rest of the install goes smoothly.

And of course, I forgot about drivers. Fortunately, HP has my back on this one. And with my Passport Drive, I can easily download and transfer files. Now, to you this might not seem like a big deal, but I've had to find drivers for entire systems on a 56k connection. 20 MB is a huge deal, especially if you end up with the wrong drivers... repeatedly. Thank God for 802.11b.

Drivers are good, so what about third-party software? I picked up a disc in a Maximum PC magazine a while back that came with some decent freeware that had been scavenged off the Internet. It's a good list, even though it's missing VLC and IZArc, two of my favorite programs (VLC supports streaming video over a network using UDP, which is just fucking awesome). Anyway, I went with AVG (virus scanning), Firefox (running IE on a fresh XP install is out of the question, I remember Blaster), HDDlife Pro (gave me an idea of how long the drive has before it dies), and of course, SpyBot (for spyware, most likely cause of all of these problems). Now to see how the coworker likes it.

Aftermath
Well, no recovered files. I don't know if I wrote over them when it checked the disk, if the virus got them somehow (shouldn't have targeted anything outside of .vbs, .html, and some other system files), or they got caught in some XP Recovery limbo, never to be seen again. (my money's on this one). I gave it back to my coworker this afternoon and explained what had happened and she didn't seem to be too surprised.

Post-ordeal Thoughts
First of all, I'm going to be more careful about quarantining the disk. I ran AVG on it when I got it/after I took it out and I have no idea if anything could have gotten onto my system anyway, but I should figure out a safer way to go about it next time.
Second of all, it might be worth it to invest in some recovery software if I end up doing anymore of this. I have a few freeware utilities in mind, but shelling out some cash might not be a terrible idea.

So that's it. Riddled with confusing problems and anticlimactic. This is one of the weirder things I've seen, and I have no reason to think it will stay that way.