User Tools

Site Tools


opus:fall2012:mwitter3:start

Matt Witter's Fall 2012 Opus

Introduction

Im Matt Witter and I probably wont talk too much if I don't know you. The only experience i've had with linux/unix is the little lab we did in website fundamentals and the only programming experience i've had is in c/c++ last semester.

Part 1

Entries

Entry 1: September 25, 2012

Today we started off talking about sorting. We tried to figure out how a program would sort numbers from least to greatest. We spent the rest of the class trying to write the program. After matt helped me with the loop I tried to get it to sort but it's a little harder than I thought it would be. I tried just putting the less than symbol in but that didn't work. I haven't figured it out yet but hopefully I will soon.

Entry 2: September 26, 2012

Today in linux/unix we talked about wildcards. We learned that ? = any single character, * = 0 or more of any character, [] = match any size of echoed and [^] = do not match any single. You can also combine then together with ls to find vowels or how many files have 4 letters. We played around with combining different kinds of wildcards with the ls and wc -w command. I had to leave about a half hour early and thats the last thing that I did.

Entry 3: September 27, 2012

Today in discrete I worked on the sorting program. I realize that I am not very good at programming but hopefully I get better soon because im feeling lost. I worked on trying to get it to sort and also just printing the list before it gets sorted. I spent just about all class trying to do this. I looked at the set program at first but I didn't work on it much. Most of the time I was trying to get numbers sorted.

Entry 4: September 28, 2012

Today we talked more about scripts. We went over that you need the #!/bin/bash before any script that you make, unless its a different language. We then made a game from a script. It asked the user try and guess a number using the $RANDOM variable. It would then say with it was equal with -eq, less than with -lt, or greater with -gt than the random number. At first we were getting really high numbers but then we changed the range from 0-9 by using the bc calculator. We went over if statements and if else statements and learned that to close if statements its fi and else if is elif. At the end we had a working guessing game that gave you six chances to guess the right number.

Keywords

discrete Keyword 1

nonimplication/difference/but not

Definition

Nonimplicion/difference/but not means that the only true output is if p is true and q is false. Everything else is false. So if p is 0 and q is 1 the output should be 0.

References

discrete Keyword 1 Phase 2

Converse Nonimplication

Definition

Converse Non-implication is the negation of the reverse of implication. implication is if … then where it is only false if the first term “p” is true and the second term “q” is false so converse non-implication is only true if the first term “p” is false and the second term “q” is true

References

Demonstration

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:

/*
 * converse nonimplication
 */
 
#include <stdio.h>
 
char nonimp(char, char);
 
int main() {
 
	char p;
	char q;
	char r;
 
	printf(" Nonimplicaton \n  Truth Table\n");
	printf("- - - - - - - -\n");
	printf("|  P | Q | X  |\n");
	printf("- - - - - - - -\n");
 
	p = 0;
	q = 0;
	printf("|  %d | %d | %d  |\n", p,q, nonimp(p,q));
 
	p = 0;
	q = 1;
	printf("|  %d | %d | %d  |\n", p,q, nonimp(p,q));
 
	p = 1;
	q = 0;
	printf("|  %d | %d | %d  |\n", p,q,nonimp(p,q));
 
	p = 1;
	q = 1;
 
	printf("|  %d | %d | %d  |\n", p,q,nonimp(p,q));
	printf("- - - - - - - - \n");
 
	printf("Number for p: ");
	scanf("%hhd%*c", &p);
 
	printf("Number for q: ");
	scanf("%hhd", &q);	
 
	printf("Number for r: ");
	scanf("%hhd", &r);
 
	printf("- -  - - - - - -\n  ");
	printf("%d | %d | %d | %d\n" ,p,q,r, nonimp(p,q));
 
 
	}
 
	char nonimp(char p, char q) {
 
	char r;
	char result;
 
	if((p == 1) & (q == 0) & (r == 0) )
		result = 0;
	else
		result = 1;
 
	return(result);
}

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ gcc -o cnonimp cnonimp.c
lab46:~$ ./cnonimp
 Nonimplicaton 
  Truth Table
- - - - - - - -
|  P | Q | X  |
- - - - - - - -
|  0 | 0 | 1  |
|  0 | 1 | 1  |
|  1 | 0 | 0  |
|  1 | 1 | 1  |
- - - - - - - - 
Number for p: 0
Number for q: 0
Number for r: 1
- -  - - - - - -
  0 | 0 | 1 | 1
lab46:~$ 

unix Keyword 1

local host

Definition

Local host is the name given to your computer. Its ip address is 127.0.0.1 to the local network but for the outside network or internet it would have a different ip address. The ip address 127.0.0.1 is used for loopback. If you send out packets and get the same packets back using 127.0.0.1 it is loopback. People use it for setting up servers and finding a database.

References

Unix/Linux Keyword 1 Phase 2

Version Control

Definition

Version control refers to managing the changes in a document, source code, or other collection of information. The changes are usually documented by a revision number, timestamp, and who made the change. Revisions can then be compared with or restored to a previous revision. Version control uses a repository, which stores both the current and previous data of the files being version controlled. Version control repositories can either be local only, client-server, or distributed.

Local only repositories are outdated and obsolete. In a local only system, all users must share the same computer system. In a client-server version control system, users share a single repository. While not as outdated or obsolete as a local only repository, it is still not the optimal choice. A distributed revision control system (DRCS) creates a peer-to-peer network, where each user has their own local repository. Changes are then shared between repositories. One of the biggest upsides to a DRCS is that it does not rely on a central node, and therefore is more durable. Two of the most popular DRCS's are Mercurial and Git.

References

Demonstration

Demonstration of the indicated keyword.

Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:

lab46:~$ cd src
lab46:~/src$ hg push
http authorization required
realm: Lab46/LAIR Mercurial Repository (Authorization Required)
user: mwitter3
password: 
pushing to http://lab46.corning-cc.edu/hg/user/mwitter3
searching for changes
no changes found
lab46:~/src$ hg pull
http authorization required
realm: Lab46/LAIR Mercurial Repository (Authorization Required)
user: mwitter3
password: 
pulling from http://lab46.corning-cc.edu/hg/user/mwitter3
searching for changes
no changes found
lab46:~/src$ hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
lab46:~/src$ 

Experiment 1

Question

What does the > mean in vim.

Resources

Hypothesis

I know » indents but maybe > indents less or maybe half of an indent. State your rationale.

Experiment

Im going to type a bunch of words that dont really make any sense. After I get done typing im going to do the » command to see an indent first and then the just the > to see what happens.

Data

what I typed before doing anything.

  1 this is the experiment i dont know what im
  2 typing i just need a
  3 bunch of words and im trying to think
  4 of ideas but im running out so im going to
  5 go because i think i have enough words now

What happened when I used the » command

  1 this is the experiment i dont know what im
  2 typing i just need a
  3 bunch of words and im trying to think
  4     of ideas but im running out so im going to
  5 to go because i think i have enough words now 

What happened after I did the > command on the last line. Nothing happened.

  1 this is the experiment i dont know what im
  2 typing i just need a
  3 bunch of words and im trying to think
  4     of ideas but im running out so im going to
  5 to go because i think i have enough words now 

Analysis

Based on the data collected:

  • Was your hypothesis correct? No my hypothesis wasn't correct at all. The command did nothing.
  • Was your hypothesis not applicable? I think my idea was good but it didn't really do anything.
  • Is there more going on than you originally thought? (shortcomings in hypothesis)It might be waiting for another command after the > or a number before maybe like the number of indents like 1> or 1»

Conclusions

I found out that although the » indents the > command does not do anything. I tried the 2» command too and it doesn't indent twice either. So unless it is used differently than what I'm trying to do I think the » command is the only command using the greater than symbol. Also you can only indent once at a time, but its very quick so maybe thats why they didn't add that

Part 2

Entries

Entry 1: October 17, 2012

Today we talked about the ps and top command. The ps command shows all the processes I'm running on the terminal. The ps a command shows all the processes associated with the terminal. We also talked about the top command which shows all the top running processes on the system. I found out that there is 15 ways to kill things in linux. I forget which one we don't want to do very often. I think it might be number 9 but they all pretty much do the same thing with just a few little differences. We also made a small c program that finds the average of 4 numbers using printf and scanf. We then made another c program that does the same thing just using fprintf and fscanf. With fprintf and fscanf you have to put stdout or stdin.

Entry 1: October 24, 2012

Today we went over regular expressions. We talked about the different kinds of regular expressions we could use to find the data that we want. The ^ matches the beginning of a line, the $ matches the end of line, the \< matches the beginning of the line, \> matches the end of the word, . matches any single character, * 0 is 0 or more of the previous character or whatever you put in front of the *, [] matches any of the characters enclosed, [^ ] ddoes not match any of the characters enclosed. Then there is also extended regular characters or egrep. Those are () which is like \( \), | which means or and + which matches 1 or more of the previous character. After we got done talking about and experimenting with regular expressions a few of us still had to finish the puzzlebox 2. The puzzlebox took a little but I finished it a few minutes after class was over.

Entry 2: October 25, 2012

Today we worked on the set program 2 as well as just worked on anything that we needed to work on. I looked at the set program for a little while until I got a little frustrated so I decided to have a little break. I started working on the entries for days since I haven't started any and its almost the end of the month. After I get done doing this entry I'll probably start looking at examples that I haven't done yet. Maybe I won't wait until the very last day this month.

Entry 4: October 31, 2012

Today we went over the spring 2013-20121026.html and tried to change it so that we could look up the type of classes that we want. We started talking about it for the first half of class and got a good start on it. About half way through class we started trying to figure it out on our own. Started experimenting with the sed command and got it to look a little better than it did before with all the default classes tag and a few other little changes like that. I ended the class with this command cat spring2013-20121026.html | egrep '^(<TH CLASS=“ddtitle”|<TD CLASS=“dddefault”>)'| sed 's/< */ /g' | sed 's/> */ /g' | sed 's/TD CLASS=“dddefault” */ /g' | sed 's/TD */ /g' | grep -A 8 MATH The last part I needed help figuring it out.

Keywords

discrete Keyword 2

variables (environment/local)

Definition

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.

References

discrete Keyword 2 Phase 2

Intersection

Definition

Two sets A and B is the set that contains all elements of A that also belong to B (or equivalently, all elements of B that also belong to A), but no other elements.

Example:

  The intersection of the sets {1, 2, 3} and {2, 3, 4} is {2, 3}.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

Demonstration

Demonstration of the indicated keyword.

Example:

 The intersection of {1, 2, 5, 7} and {1, 5, 6, 7} is {1, 5}
 
 Intersection of {red, white, green, blue} and {green, yellow, blue, white} is {green, white, blue}
 
 Intersection of {1,5} and {1,5} is {1,5}

unix Keyword 2

here string

Definition

The symbol for a here string is «< . A here string puts whatever input you want into a command. Like bc «< 2+2 sends 2+2 into the calculator and it will come back as 4. So it does the operation in one step instead of going into the calculator and typing 2+2 or whatever you want to solve.

References

* Notes from when we talked about here strings and the binary calculator.

unix Keyword 2 Phase 2

variable expansion

Definition

Variable expansions are defined by lines using ':=' It does not contain any references to other variables; it contains their values as of the time this variable was defined.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

Demonstration

Demonstration of the indicated keyword.

#include <stdio.h>
 
int main()
{
        int x = 20;
 
        printf("The value of x is %d\n", x);
}

The output of this is The value of x is 20

Experiment 2

Question

In the script from puzzlebox 2 Im wondering if I replace tail with head if it would do the same thing. I think it will as long as I move my username to the top.

Resources

The man page and wikipedia page on the head command says that it prints out the first 10 lines unless you specify how many lines you want it to print out. Thats pretty much what I thought it would do.

http://ss64.com/bash/head.html

Hypothesis

I think that the script will do the same thing with the head command as it did with the tail command. Since the tail command looks at the last line with the -1 argument I'm guessing the head command with the -1 will do the opposite and look at the first line. The man page and wikipedia page seem to say that I'm going to be right.

Experiment

Im going to change the script from the puzzlebox a little and see if it does what I think it will.

Data

It seems that my hypothesis was right. I still got the token at the end of the script. I changed the tail -1 to head -5 and ran it using the same symbolic link. Hopefully the symbolic link wasn't why I still got the token.

Analysis

Based on the data collected:

  • My hypothesis was kind of correct. Since Im pretty sure the #!/bin/bash line has to be first I ended up putting the username line on the 5th line and changing the -1 to -5.
  • I don't think there was any shortcomings in my experiment I still got the token. I switched the tail -1 command to a head -5 and moved the last line to the end of the comments at the top.
  • If I had to make a new symbolic link my experiment was probably not updated but I don't think I would have to do that.

Conclusions

I found out that the head command and the tail command work in about the same way just the tail looks at the bottom and the head command looks at the top. I still got the token at the end of the script. As long as you know how many lines you want it to look at than it will do the same thing. I almost messed up and put the username line before the #!/bin/bash line but realized it before I did it.

Part 3

Entries

Entry 1: November 14, 2012

Today was a work on stuff day. People were all working on the Super Puzzlebox 2 Turbo. I had it done so I worked on my Unix and Discrete keywords 3. I finished them pretty quick and just kept looking up different arguments for them to add in my definitions. Before class really started we were talking about ASCII art and 4chan.com. I wanted to go to it but we decided it probably wasn't the best idea to do it here. I also have to remember to watch the TED video of the guy who made or owns 4chan, moot I think.

Entry 2: November 28, 2012

Today we went over all the stuff we have to do for the EoC projects. After we got done going over everything we started a work on stuff day

Entry 3: November 29, 2012

Today we made the CCC logo with the gd library. Im really glad we did it because I wasn't real very confident with the gd library. After we got the first C in CCC the the other two C's went pretty easy. The only trouble I really had after the first C was trying to get them to touch just a little and make it actually look like the CCC logo.

Entry 4: November 30, 2012

Today was a work on stuff day. I started working more on my opus because for some reason I waited until the last day again. I did the combination and the cron/crontab/at demonstration. Hopefully I will get the experiment done before I leave today too.

Keywords

discrete Keyword 3

regular expression

Definition

Regular expressions are commands that match a pattern or characters in a string of characters or words. Some of the regular expression commands are the ^ that matches the beginning of a line, the $ matches the end of line, the \< matches the beginning of the line, \> matches the end of the word, . matches any single character, * 0 is 0 or more of the previous character or whatever you put in front of the *, [] matches any of the characters enclosed, [^ ] does not match any of the characters enclosed. Then there is also extended regular characters or egrep. Those are () which is like \( \), | which means or and + which matches 1 or more of the previous character. Usually you have to use a combinations of these to get what you want.

References

discrete Keyword 3 Phase 2

combination

Definition

A combination is a set containing a certain number of objects that have been selected from another set. In combinations, the order of the elements does not matter.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • wikipedia
  • class

Demonstration

Demonstration of the indicated keyword.

Example:

If you have three people Ted, Sue and John there 6 different ways or combinations you can order them. 
Ted, Sue, John; 
Ted, John, Sue;
Sue, John, Ted;
Sue, Ted, john;
John, Sue, Ted; 
John, Ted, Sue;

unix Keyword 3

sort/uniq

Definition

The sort commands sorts the the lines of text files in order. You can use different arguments like -r to sort them in reverse order. The uniq command is used with the sort command to remove duplicate lines in the file that you are sorting. There are also arguments for uniq like -d that only prints duplicated lines or -u that only prints unique lines.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

unix Keyword 3 Phase 2

cron/crontab/at

Definition

      Is the time-based job scheduler in Unix-like computer operating systems. 
      Enables users to schedule jobs (commands or shell scripts) to run periodically
       at certain times or dates. 
      It is commonly used to automate system maintenance or administration.
      
      __Crontab_ (cron table) file, a configuration file that specifies shell 
      commands to run periodically on a given schedule. 
      

References

  • Wikipedia
  • Sean Edwards
  • Harley Hahn's Guide to Unix and Linux

Demonstration

Demonstration of the indicated keyword.

lab46:~$ at 16:08 
warning: commands will be executed using /bin/sh
at> echo "hi"
at> <EOT>
job 319 at Fri Nov 30 16:08:00 2012
lab46:~$ at -l
319	Fri Nov 30 16:08:00 2012 a mwitter3

Experiment 3

Question

if you can use sort -r to reverse the order on the EoCE script in linux

Resources

I know thats what it does but I'm not sure if it will work with the EoCE script.

Hypothesis

I really don't think it will work, but I'm not positive. You never know it might work.

Experiment

Im going to test the experiment by changing the script a little and seeing if it works.

Data

I put sort -r in the script and it didn't seem to work.

Analysis

Based on the data collected:

  • Was your hypothesis correct? Yes my hypothesis was correct.
  • Was your hypothesis not applicable? I think that it was applicable.
  • Is there more going on than you originally thought? (shortcomings in hypothesis) There might be. I might need more in there than just sort -r.
  • What shortcomings might there be in your experiment? You might need more than just sort -r

Conclusions

The script in the EoCE is using something different than sort so sort -r is not working. My hypothesis was right but I was kind of hoping that it would work.

opus/fall2012/mwitter3/start.txt · Last modified: 2012/12/31 04:33 by 127.0.0.1