Josh Cavaluzzi's Super awesome fall2012 Opus that is gonna BLOW YOUR FREAKIN' MIND
LIKE I SAID, IS GONNA BLOW YO MIND
Hello! I began my journey as a Computer Science major about 9 months ago, and it has been a journey of great sacrifice and success! Having taken C/C++ Programming, I have found that I am ready to partake in the quest to become a great programmer!
Mercurial/hg/Repository
Truth Table
passing by address (function parameter passing)
Passing by address is just one of the ways that you pass a variable into a function. This is done not by passing the variable itself, but by passing the variable address. The only uses for this type of variable passing that I have encountered are arrays.
pointer assignment
The pointer assignment statement causes a pointer to become associated with a target or causes the pointer's association status to become disassociated or undefined. this means that a pointer or (*) can force a pointer or word or number to be paired with another or not depending on how it is used.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Demonstration of the indicated keyword.
The following is the demonstration of pointer assignment by using the code and the resulting output:
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 char *array1, *array2; 7 int i = 0; 8 9 array1 = (char *)malloc( sizeof(char) * 4 ); 10 array2 = (char *)malloc( sizeof(char) * 4 ); 11 12 printf("Please input four values for the first array\n"); 13 14 for( i; i < 4; i++ ) 15 { 16 scanf("%hhu", &*(array1 + i)); 17 *(array2 + i) = 0; 18 } 19 20 printf("Here are the values in both arrays:\nArray1: "); 21 22 for( i = 0; i < 4; i++) 23 { 24 printf("%hhu ", *(array1 + i)); 25 } 26 printf("\nArray2: "); 27 28 for( i = 0; i < 4; i++) 29 { 30 printf("%hhu ", *(array2 + i)); 31 } 32 33 array2 = array1; // Example of Pointer Assignment 34 35 printf("\nHere are the results after setting 'array2' = to 'array1':\nArray1: "); 36 37 for( i = 0; i < 4; i++) 38 { 39 printf("%hhu ", *(array1 + i)); 40 } 41 printf("\nArray2: "); 42 43 for( i = 0; i < 4; i++) 44 { 45 printf("%hhu ", *(array2 + i)); 46 } 47 48 printf("\n\nThank you for your time.\n\n"); 49 return(0); 50 }
The code makes two arrays, sets one equal to whatever input the user decides to go with, and the other being equal to 0. The program will then print the arrays, then set the second array equal to the first, which is the example of pointer assignment. The program is assigning the second array to the data in the first array. The result is then this:
lab46:~/src/opus/opus1$ ./pa Please input four values for the first array 1 2 3 4 Here are the values in both arrays: Array1: 1 2 3 4 Array2: 0 0 0 0 Here are the results after setting 'array2' = to 'array1': Array1: 1 2 3 4 Array2: 1 2 3 4 Thank you for your time. lab46:~/src/opus/opus1$
Right Complementation
When given a Truth Table, you see two columns of two different values that are related to each other and show opposite relationships, most of the time they are represented by F for false and T for true. Right Complementation is the opposite of the second column, or the right one. When representing each of the results for a 4 by 2 table, there are 16 possible results, one of them being the right complementation, which is actually represented by negation q.
equivalence/if and only if
The opposite of an XOR, if something is T and T, then it would be T when applied.
Demonstration of the indicated keyword.
The following is the code used to demonstrate if and only if/equivalence and the resulting output when the program is run:
1 #include <stdio.h> 2 3 char logicor( char, char ); 4 5 char logiciff( char a, char b ) 6 { 7 char x; 8 if(a == b) 9 x = 1; 10 else 11 x = 0; 12 return(x); 13 } 14 15 int main() 16 { 17 char p = 1; 18 char q = 1; 19 20 // Printing the OR Truth Table 21 22 printf("\nTreat 0 as false, and 1 as true.\n\tXOR Truth Table:\n\n"); 23 printf("\t P | Q | X \n"); 24 printf("\t___________\n"); 25 26 // Printing the first set of values (values for p, q, and the result of p|q) 27 28 printf("\t %d | %d | %d \n", p, q, logiciff( p, q )); 29 q = 0; 30 printf("\t %d | %d | %d \n", p, q, logiciff( p, q )); 31 p = 0; 32 q = 1; 33 printf("\t %d | %d | %d \n", p, q, logiciff( p, q )); 34 q = 0; 35 printf("\t %d | %d | %d \n\n", p, q, logiciff( p, q )); 36 37 // Printing PART 3 38 39 /* printf("\tOR Truth Table comparing X and Q:\n\n"); 40 printf("\t P | Q | X | ( X|Q )\n"); 41 printf("\t____________________\n"); 42 43 p = 1; 44 q = 1; 45 46 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q )); 47 q = 0; 48 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q )); 49 p = 0; 50 q = 1; 51 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q )); 52 q = 0; 53 printf("\t %d | %d | %d | %d \n", p, q, logicor( p, q ), logicor( logicor( p, q ), q ));*/ 54 return(0); 55 }
Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:
lab46:~/src/opus/opus1$ ./iff Treat 0 as false, and 1 as true. XOR Truth Table: P | Q | X ___________ 1 | 1 | 1 1 | 0 | 0 0 | 1 | 0 0 | 0 | 1 lab46:~/src/opus/opus1$
Home Directory
The Home Directory is basically the place that all of a user's files and folders are stored. From the home directory, one may be able to access all of their files, or just access specifically places files. The user is able to completely customize their home directory. When files and folders are in a home directory (including readable, writable, and executable files), they are only able to be accessed by the user or any other administrator on the system. That can be changed at any point, however.
file ownership(access control)
Allowing others to view or change a files
Demonstration of the indicated keyword.
File ownership (access control), like previously stated, determines who can either read, write, or execute a file or directory.
First, by entering 'ls' into the terminal, you can see what files are in that directory, but if you add a '-l', you can see who has access to the files. The order displayed is Owner, Group, World. For Example
lab46:~/src/unix$ ls -l total 16 -rwxrwxrwx 1 jcavalu3 lab46 115 Sep 19 16:44 logincnt.sh _O__G__W_ O - Owner/G - Group/W - World drwxr-xr-x 6 jcavalu3 lab46 66 Sep 27 23:59 projects -rwx------ 1 jcavalu3 lab46 147 Sep 28 15:36 script2.sh -rwx------ 1 jcavalu3 lab46 574 Sep 28 16:52 script3.sh drwxr-xr-x 3 jcavalu3 lab46 16 Sep 26 11:39 submit -rw-r--r-- 1 jcavalu3 lab46 195 Sep 7 15:45 unixstuffs lab46:~/src/unix$
To edit a file and who can access it, simply input the command 'chmod 744* script2.sh'.
chmod stands for change mode, which is the program that allows you to modify who can access the file Followed by the change in access Lastly, the file should follow behind the change in access
* Each number represents one of the three types of access (OGW). The number for each type or access is 4(read - r), 2(write - w), 1(execute - x). The size of the number input depends on what type of access the modifier would like each “group” to access. 744 means that the Owner can read, write and execute, the Group can read and execute, and the World can read and execute.
Example:
lab46:~/src/unix$ ls -l total 16 -rwxrwxrwx 1 jcavalu3 lab46 115 Sep 19 16:44 logincnt.sh drwxr-xr-x 6 jcavalu3 lab46 66 Sep 27 23:59 projects -rwx------ 1 jcavalu3 lab46 147 Sep 28 15:36 script2.sh ^ ^ ^ -rwx------ 1 jcavalu3 lab46 574 Sep 28 16:52 script3.sh drwxr-xr-x 3 jcavalu3 lab46 16 Sep 26 11:39 submit -rw-r--r-- 1 jcavalu3 lab46 195 Sep 7 15:45 unixstuffs lab46:~/src/unix$ chmod 744 script2.sh lab46:~/src/unix$ ls -l total 16 -rwxrwxrwx 1 jcavalu3 lab46 115 Sep 19 16:44 logincnt.sh drwxr-xr-x 6 jcavalu3 lab46 66 Sep 27 23:59 projects -rwxr--r-- 1 jcavalu3 lab46 147 Sep 28 15:36 script2.sh ^ ^ ^ -rwx------ 1 jcavalu3 lab46 574 Sep 28 16:52 script3.sh drwxr-xr-x 3 jcavalu3 lab46 16 Sep 26 11:39 submit -rw-r--r-- 1 jcavalu3 lab46 195 Sep 7 15:45 unixstuffs lab46:~/src/unix$
Arrays in Shell Script: Fact or Fiction? (Are they different from arrays in C/C++?)
From the information I have collected, arrays are possible and very similar to arrays in C/C++.
I will create a shell script that will basically perform the same process as the Pointer Assignment Demonstration (http://lab46.corning-cc.edu/opus/fall2012/jcavalu3/part1?#phase_2), and compare the two. This will, hopefully, confirm my hypothesis and allow me to know and understand how arrays work in shell script as well as C/C++ (Nothing wrong with more refreshers!).
The following is the shell script program I created and the results:
1 #!/bin/bash 2 # 3 # You know, just a shell script file for my experiment in opus1 4 # 5 # I will create an identical file as the one I used in the pointer 6 # assignment and check to see if I get the same result. 7 # 8 # ONWARD! 9 10 for((i=0;i<4;i++)); do 11 echo -n "Enter a value (0-9): " 12 read array1[i] 13 echo -n "Enter a zero: " 14 read array2[i] 15 done 16 echo "Array1:" 17 for((i=0;i<4;i++)); do 18 echo "${array1[i]}" 19 done 20 echo "Array2: " 21 for((i=0;i<4;i++)); do 22 echo "${array2[i]}" 23 done 24 for((i=0;i<4;i++)); do 25 array2[i]=${array1[i]} 26 done 27 echo "Array1:" 28 for((i=0;i<4;i++)); do 29 echo "${array1[i]}" 30 done 31 echo "Array2: " 32 for((i=0;i<4;i++)); do 33 echo "${array2[i]}" 34 done 35 echo "Thank you for your time." 36 exit 0
lab46:~/src/opus/opus1/experiment$ ./array.sh Enter a value (0-9): 1 Enter a zero: 0 Enter a value (0-9): 2 Enter a zero: 0 Enter a value (0-9): 3 Enter a zero: 0 Enter a value (0-9): 4 Enter a zero: 0 Array1: 1 2 3 4 Array2: 0 0 0 0 Array1: 1 2 3 4 Array2: 1 2 3 4 Thank you for your time.
Now, the results from the Pointer Assignment Demonstration:
lab46:~/src/opus/opus1$ ./pa Please input four values for the first array 1 2 3 4 Here are the values in both arrays: Array1: 1 2 3 4 Array2: 0 0 0 0 Here are the results after setting 'array2' = to 'array1': Array1: 1 2 3 4 Array2: 1 2 3 4 Thank you for your time. lab46:~/src/opus/opus1$
Based on the data collected:
http://beastkong.com/wp-content/uploads/2012/05/success-baby.jpg
What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.
queue overrun condition
Queue Overrun/Overflow Condition happens when a program attempts to add an element onto an already filled queue.
stack (LIFO or FIFO?)
LIFO is an acronym that stands for “Last In, First Out.” When it comes to stacks, functions and procedures that are running become stacked on top of one another in memory (called a “push”). When an item is removed from the stack (or “popped”), it is removed from the top down. This computing action allows for stack integrity, and limits access/insertion.
FIFO means “First In, First Out.” In this regard, data and processing are handled on a first come, first serve basis through usage of a queue (or linear data structure). The first process in line is handled before any others are, and then the next, and so on.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
LIFO STACK (Last In, First Out)
(The number represents the order in which they were put into the list)
( 6 ) TOP (This would be the first one out, being the last one input, because it is on the top of the list) ^ | ( 5 ) ^ | ( 4 ^ | ( 3 ) ^ | ( 2 ) ^ | ( 1 ) BOTTOM (This would be the last one out, although it was the first one input)
FIFO STACK (First In, First Out)
(The number, just like above, represents the order)
( 1 ) TOP (This would be the first one out) ^ | ( 2 ) ^ | ( 3 ) ^ | ( 4 ) ^ | ( 5 ) ^ | ( 6 ) BOTTOM (This would be the last one out)
cartesian product
Cartesian Product is making one set that takes one from a set and pairs it with one value from another set. This is done for each of the values in each set. Example:
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
variables (environment/local)
A local variable is only known in the function that you created it in. It isn't known in any other functions and can't be used in any other function. Each time you use the function is starts at whatever value you assigned it to. Global variables are known and can be used by any function in the program. So if you make a variable outside of main() it is a global variable because it can be used in any function. If you make a variable inside main() it can only be used in main() so it is a local variable.
1 #include <stdio.h> 2 3 int glovar = 20; // Global Variable 4 5 int local( int ); 6 7 int main() 8 { 9 int localvarmain = 0; 10 11 printf("global variable: %d\n\n", glovar); 12 printf("Local variable cannot be demonstrated the same way because if the program tries\n"); 13 printf("to access a variable that doesn't exist, the program will not compile correctly\n"); 14 printf("and result in the program not running correctly\n\n"); 15 16 // Running local function to add the local variable (to the function) to the global variable 17 18 glovar = local( glovar ); 19 20 printf("New global variable: %d\n", glovar); 21 22 return 0; 23 } 24 25 int local( int glovar ) 26 { 27 int localvar = 10; 28 29 glovar = glovar + localvar; 30 return glovar; 31 }
The printed result:
lab46:~/src/opus/opus2$ ./unixdemo global variable: 20 Local variable cannot be demonstrated the same way because if the program tries to access a variable that doesn't exist, the program will not compile correctly and result in the program not running correctly New global variable: 30
shabang
A shabang is this: #! The shabang is used to read the following test on the first line after it to determine what interpreter the user would like to… use. Some example of interpreters (Taken directly from http://en.wikipedia.org/wiki/Shebang_(Unix):
PATH environment variable
The $PATH variable specifies a list of one or more directory names separated by colons.
The /bin, /usr, and /local directories are typically included in most users' $PATH settings. The current directory is sometimes included, allowing programs in the current directory to be executed. Superuser (root) accounts as a rule are not include in $PATH, however, in order to prevent the accidental execution of scripts in the current directory.
When a command name is specified by the user or an exec call is made from a program, the system searches through $PATH, examining each directory from left to right in the list, looking for a filename that matches the command name. Once found, the program is executed as a child process of the command shell or program that issued the command.
The following is an example of a $PATH:
lab46:~/src/opus/opus2$
The $PATH The home directory (~/) is the beginning of this specified $PATH, followed by the src directory, then the opus directory, and lastly the opus2 directory.
I downloaded VirtualBox and Debian to run on it, but when everything was installed, the possible resolutions were not available to me. I am going to experiment with it and figure out how to fix it.
I installed it with the help of Evan Olson, but the rest of my help will come from the internet and whatever I can find. Any websites used will be listed below:
I believe that I will need to install packages for the resolution. I don't think there will be much more to it, maybe some command line arguments to actually use the packages or something along those lines.
I will research VirtualBox and Debian and find how to fix the problems. I will document my research and experiment in the data section below with the use of screenshots and such!
Well, the first problem I ran into was that I wasn't a sudo user, so with your help, I made myself one by going to the terminal, going to the root command prompt, accessing the visudo file, and adding myself as a user. From there, I typed in sudo apt-get install virtualbox-ose-guest-x11, which, I think, installed the Guest Addition Driver X11. I ended up getting a larger resolution (1024 x 768) instead of the monitor's natural resolution (1600 x 900). I tried the other website's tactics, which were to update Debian, remove the OSE guest additions using sudo apt-get remove virtualbox-ose-guest* and then mounted the VBOXADDITIONS ISO by using the command sudo sh /media/cdrom/VBoxLinuxAdditions.run.
Based on the data collected:
I can conclude that I have an extremely hard time messing around with operating systems and it is a lot harder than I thought it would be.
prefix (polish) notation
Polish Notation, also known as Prefix Notation, is a form of notation that puts the operator at the beginning instead of between two numbers or other operations. Example:
Iterative Tree Traversal
Iterative Tree Traversal is the act of moving through a binary tree by the use of repetition. The function would most likely have nested for loops, which will result in more code than that of recursive tree traversal.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Demonstration of the indicated keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
/* * * PSEUDO CODE * */ queue[7] = 11, 22, 33, 44, 55, 66, 77; queuevalue = queue[0]; while node -> left != NULL node = node -> left; node -> value = queuevalue; node = node -> parent; node -> value = queue[1]; /* And this goes on until the tree is filled, resulting in: 44 22 66 11 33 55 77 */
kleene star
Kleene star is an operation that gives a single output (unary operation) and is used on sets of strings or sets of characters or symbols. Used a great amount in regular expressions, its purpose is to search a file for any combination of the given strings or characters.
Example:
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Karnaugh Mapping
Karnaugh Mapping is a method by which one can take a truth table, or an expression, and simplify it. The working example on wikipedia is VERY useful in understanding this - I would recommend drawing it all out on a whiteboard and going by step-by-step. That is how I was able to grasp an understanding of it. I'll attach a photo as well showing how I worked through the example.
Demonstration of the indicated keyword.
For my demonstration of Karnaugh Mapping, I performed the same steps as the person that defined it originally, and took a picture of it. It is used to simplify any truth table so that you can just represent the common truths as functions.
Example:
mesg/write/wall
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
bvi/hexedit
bvi: BVI is a binary visual editor, it allows you to visually see binary values and edit them.
Hexedit: Hexedit is a similar program that show's you the same values in hexidecimal instead of binary.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
For my final experiment of the semester, I took a computer from the LAIR and put all of the necessary parts back into it (hard drive, RAM) so I could have a computer of my own to work with during the upcoming semesters.
I received help from Tom and Evan when I put the computer together. I put my desktop computer together during the summer of 2011, but I received help from a good friend of mine and I didn't really pay much attention to what went where and how it all worked, which is why I wanted to do this, so I could get a better understanding of how things go inside of a computer.
I believe that this will be a good learning experience for me. Like I had previously stated, I need to understand the inner workings of a computer more and I feel as if this is a good start.
I am going to take a computer down in the LAIR that doesn't have all of the necessary components to run and fix it up so that it can. (The computer already has a CPU inside of it and, seeing as how I accidentally messed up my old desktop's CPU when trying to clean it out, I figure that I won't bother taking it out and putting it back in, I'll just explain its purpose without showing its installment).
The modern computer begins with the computer case. Every computer has a case to protect it from dust, dirt, fur, getting kicked, holds the power supply, motherboard in most cases comes with a usb port or two, and any other drives like the CD/DVD drive, floppy disk drive, etc.
The following is a picture of the case opened up:
The next piece of hardware that should be installed is the power supply. The power supply, as you probably could have guessed, gives all of the other hardware inside of the case power so that it can function. Power supplies range in the amount of power they put out.
The following is a picture of the power supply already installed:
Next, the motherboard should be installed into the case. The motherboard connects the circuit between all of the hardware in the case. In many cases, motherboards can come with integrated graphics, networking, audio, although the integrated hardware is not as powerful as the card counterparts (graphics cards, sound cards, network cards, etc.)
Directly connected to the motherboard are the CPU and the RAM.
The following is a picture of the CPU covered with a heat sink which cools the CPU due to all of the processes and currents running through the CPU:
The following is a picture of RAM connected to the motherboard:
The hard drive is the final necessary piece of hardware for the computer to run correctly. The hard drive is the storage for the computer and allows the RAM to access it whenever it is needed.
The following is a picture of the installed hard drive:
With all of the hardware installed, the computer did work, however, I found a better computer and I am using it now, so I uninstalled the hardware for others to use. But here is a picture of the hard drive and RAM before it was installed:
Based on the data collected:
What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.