Table of Contents

MY NAME's spring2015 Opus

OPTIONAL SUBTITLE

Introduction

A little about myself is that I have been developing programs in Java since I was 12, I also have taken the pursuit before that to practice HTML when I was 10. I just got into UNIX/Linux last year when someone was telling me about it, I then decided to Dual boot my Windows 7 laptop with a copy of Mint, then Ubuntu (All for fun). I one day hope to be a developer (Game designer) or anything that branches into that type of community for my line of work.

C/C++ Programming Journal

March 19th, 2015

Today in class, it was kind of laid back again as we reviewed structures or 'structs'

What exactly is a structure? Well a structure or struct is a type of frame work inside c that allows the user to create as many copies as you want of it.

This was originally developed in C to allow users, like I said to create several copies of the same thing. Later Java would take this concept and use Objects that are basically the same thing, the only real difference is that in Java, you can use functions inside them but in C you cannot. Another key difference between Java's Objects and C's Structs are that in Java, they can be called Constructors and are often alot bigger.

The linkage between the two is the same though, first you initialize your variable with the Struct's name and then you give that object/struct a name, kind of like a datatype and a variable with a name.

After that you can call as many copies of the struct as you want, I am not too sure though if you can create an array of structs with the same name like you can in Java, I'm sure you can though.

If you still aren't understanding fully what Struct's are designed for, think of it like a true real world situation.

You are on a plane and you have the following 3 Suitcases

  1. 1 contains hygenie essentails
  2. 2 contains clothes

Each of these suitcases represent what's inside by a specific order to what it needs, also like a building and the architect who built it.

The suitcase with clothes inside it must have the exact same layout, 2 pants, 2 shirts, 2 sunglasses for those hot days, and whatever else.

The bottom line is that structures organize your code so you don't have to continue rewriting the same layout for something when you can just continue copying it over and over again.

The link below like always links you to a pastebin page with the class notes from today.

Link: http://pastebin.com/bZp5b2ra

C/C++ Programming Journal

March 12th, 2015

Today in class it was kind of laid back as we entered into the world of nested loops. Giving the rest to finish afn0 and catch up as well.

Nested loops are awesome in using them for problem solving and displaying important data all at once.

To get an idea of what nested loops can do, take a normal loop.

Programs with 1 loop usually are used to search through LINEAR data or doing repitious activities such as game developers may use.

Programs with 2 loops usually are used to search through 2D data or display images/code on the screen.

Programs with 3 loops usually are used to search through 3D data or used in conjunction with the second loop and divide up lines –> My WordSearchCracker.java uses 3 loops to do so.

Loops are everywhere and I'll just stick to 2 Loops for a Nested Loop.

In class, getting us to use Nested Loops was an activity of extracting and converting hex rows into ascii characters and printing them to the screen.

My code

int i; int j;

for(i = 0; i < WIDTH; i++) {

   for(j = 0; j < HEIGHT; j++) {
   
        fscanf(file, "%hhx", &c);
        fprintf(stdout, "%c", c);
   
   }

}

This would grab each character from the given row and convert to ascii characters then print it to the screen.

The WIDTH and HEIGHT was 59 and 25.

To get a better idea of how nested loops work and even further loops, think of racing.

Say, to complete one lap on a track is 1000 feet. To put this data into a loop it would look like this.

int i; int j;

for(i = 0; i < LAPS_TO_WIN; i++) {

   for(j = 0; j < 1000; j++) {
   
        // runs 1000 times
   
   }
   // to get to here --> Where i++

}

This code says, a constant of LAPS_TO_WIN will increase by 1 when the j loop of 1000 ft completes 1000 times.

If the constant LAPS_TO_WIN was set at 3, it would take the car 3000ft to complete 3 laps.

You can get even further in depth with this and do 3 nested loops but I'm not going to touch that for a bit.

C/C++ Programming Journal

March 5th, 2015

For some reason my old post never happened for C so here is the latest updated copy but with March 5th.

In class, we went over some c programming techniques, located in the notes below.

http://pastebin.com/9avHEBxg

C/C++ Programming Journal

Febuary 5th, 2015

Today in class we reviewed some more techniques to use in C programming, one of which is very important.

We ended up learning about the if statement, it looks like this in C –> if (declaration) { do }

Now if statements can also have many more things inside it that will allow you to be as percise as possible, here is a list generated here at pastebin.

http://pastebin.com/SvqVX9AK

C/C++ Programming Journal

January 29th, 2015

Today in class we reviewed even more functions that you can use to allow a user to input text into their own program!

To do this we had to set up the default look of a program

[CODE] #include <stdio.h>

int main() {

}

[/CODE]

Next we learned about the scanf function, this allows you to specify the type of input that will be required without causing an error and specify what variable will be receiving that input. We also initialized a variable for a variable input.

[CODE] #include <stdio.h>

int main() {

   int number = 0;
   scanf("%d", &number);//This specifies that I require a digit and it will be numbers new value.

} [/CODE]

If you want to display that number, we had to use what we learned last class (January 22nd).

[CODE] #include <stdio.h>

int main() {

   int number = 0;
   scanf("%d", &number);//This specifies that I require a digit and it will be numbers new value.
   fprintf(stdout, "%d", number);//This prints the number

} [/CODE]

Just compile and run and Wala Again! Your program is awesome.

C/C++ Programming Journal

January 22nd, 2015

Today in class we reviewed on how to create a C program anywhere and how to run it in Linux.

- Starting a program should include an import or #include and what ever tools you will need to create that project

- The 'main' way to have that program operate is main. int main() { } should suffice.

- Finally as you may have noticed there were curly braces, these indicate the start and the end of a statement/code.

Other tools that we learned were outputting messages to the prompt. To do so you will need to import the following - #include <stdio.h> This helps the compiler indicate and what to add into the code (But you really can't see it)

- Next in the main (Were not using functions yet) you can use fprintf(stdout, “Message”); ←- That ends a line of code.

That will output the text "Message" but you can make it shorter by using printf("Message"); There are consequences though!

To execute the code you will need to save it, if your using a compiler you need to use nano project.c ←- This indicates that it's going to be a C program. - Save the file

- Compile by using the line gcc -o project project.c ←- If you leave project.c without a save path then it can be overwritten/ruined.

- Type ./project and Wala! Your project is done and you just ran your first C program.

MONTH Day, YEAR

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • 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?

UNIX/Linux Fundamentals Journal

March 24th, 2015

Today in class, we covered the ending parts of UDR2 (I haven't started it yet due to several reasons, conceptually and programming wise –> Using scripts vs. Commands)

We covered the following things to look out for in UDR2 and how to read it properly.

All of the following is in my notes located at the bottom and on the course homepage for projects in UNIX/Linux labeled projects in UDR2.

Firstly

Datatype –> This determines the Datablock (Length and Type)

Time_sec –> Refers to the current time it's running at, basically for how long.

Sub_sec –> Refers to the current speed at which the packet took to be created.

Msg_len –> Refers to the length of the Datablock. This will be key as the Datablock varies in lengths and reading it in may take longer than others.

Check_sum –> Total bytes of the packet. I'm not too sure how it will be used here, if we are going to identify a dead packet but in the real world, check sum's are used in Networking. When using a check sum, it checks the length of what was sent and the length of the actual packet that was sent, if they both match it proceeds but if it's not then the packet is corrupted. This corruption could have been from a hacker placing dangerous material inside the packet to infiltrate a network or just some mishaps along the way to cause it to become corrupted.

After all of that, we covered Time in Unix.

At the dawn of time, also known as December 31st, 1969 –> The great awakening, that is when Unix time has started.

The commands to find such time like how many seconds there are currently from the start to now is.

'date +%s' –> Takes the current time and adds it to the start of Unix time.

Other commands such as Cal returns a calender for you to look at, you can also punch in certain days, months, or even years to have a good look at what day you were born or what happened on that eventful day.

All of this was covered in class, if you want the notes, click the link below.

Link: http://pastebin.com/iudzNdmm

UNIX/Linux Fundamentals Journal

March 17th, 2015

Today in Unix Class, we went over some more of the UDR2 project that was going to give us a kickstart into it.

I totally forgot about Unix so here are the class notes and what we covered today.

Link: http://pastebin.com/ZheWz5T7

What we covered in class was the UDR2 project, this one is going to be a little small since I forget for the most part what we covered.

What we did was talk about the layout of the newest project and how it was going to be done.

The information we retrieved was in several packets (When I say several I am assuming over 100 –> 1000).

To read the packet we have to access the course homepage and where the project for UDR2 is listed, I grabbed the project by issuing my –> grabUnix.bash script that grabs the latest UNIX project.

After translating everything we covered the 'hexedit' and how the computer is in little endian, smallest byte goes first. It was designed for conceptual reasons of keeping ones peace with the computer so everything makes sense.

We also covered how some machines run Big endian and how people have to write programs to flip those bytes, so nothing bad happens and ones peace stays well with the computer.

That's basically it though, the next one should be a lot better for explanations.

UNIX/Linux Fundamentals Journal

March 10th, 2015

In class today, we reviewed more on searching and using our techniques to hone in on files/file names.

Files as such that you can apply scrabble hax that will allow you to develop a word in the english language to best a game of scrabble.

The notes are located here: http://pastebin.com/jcpxcNH0

Summary: Applying knowledge of the special characters functions applied in the scripting language/terminal built in UNIX/Linux you are able to utilize it to better your searches.

Examples of this can be using ^[listOfCharacters] | wc -l on a list of words and you would be able to pick out any words that begin with one letter (One worded words) that begin with that letter.

Other such techniques are located within the notes above.

UNIX/Linux Fundamentals Journal

February 24th, 2015

Today in class we reviewed more on loops in shell scripting and took notes on the 'Wild Cards' of Linux/Unix

Some of the notes are as followed

Pastebin link here: http://pastebin.com/pJGQPQQc This link holds the notes taken in class for that day.

These are all the notes taken in class, some of the commands you can do are

ls [t] | wc -w ←- This displays anything with a 't' in it.

More you can do is “ls [t*p] | wc -w” ←- That would display anything that begins with a t and ends with a p, no matter the length. The astrix acts as this, meaning infinite of any length or anything (Yes its crazy)

Lastly you can exclude certain values or letters. “ls [^aeiou] | wc -w” ←- Any words with these vowels are excluded.

You can do even more CRAZAY things with these Wild Cards

You want to specify the length of files you want to extract and have it count how many times it came up, type “ls [???] | wc -w” ←- The three ?'s specify the number one and of any character.

Another thing you can do is “ls [^aeiou]??? | wc - w” ←- Intead of actually only presenting a word without the vowels, you can also restrict it by making it only 3 letters long.

Thats basically all we learned, there are a few things that are left out but are minor.

UNIX/Linux Fundamentals Journal

February 10th, 2015

I do apologize for how long this entry took but retrieving my notes was some what difficult over break, having Internet issues and all.

Anyways …

In class today we reviewed on shell scripting and other forms of scripting, bash, sh, and some other freaky ones that people would obsess over. The scripting language we took to was “bash”, originally I have done some shell scripting for games that I have written that needed a quick compiling but this was a new frontier.

Here are some in class notes that I took on some of the techniques to scripting in shell/bash

Shell Scripting

sh –> Bourne Shell (Developer)

Learning Bash (Everything includes 'sh')

Bash –> Bourne Again Shell (Extends 'sh')

'~/src/unix/*.sh' –> Refer to this

Starting any shell script, use #!/bin/bash –> Shabang


# –> Comments

/bin/bash indicates what “language” you are going to be using /pathto/language –> Refer

echo -n “Hello” –> Prints a line of text between the two quotes 'String'

read name –> Name is now a variable that will be allocated what the user puts into the program.

Assigning a variable in a String, use $variableName

Other


now=“$(date+'%d')” –> Retrieves the current day of the month if [ statment ]; then else fi –> else is in it, fi ends the statement. n=$1) –> The $ 2) –> Use for script

Running


sh and bash are two different when running certain things, use bash


Some other notes to add are about 'if' and 'then' statement in scripting, every program needs in my opinion to run anything properly with suggestive cuts it should take.

The if statement is driven as such –> if [ statement ]; then declaration fi ←- Ends the whole thing.

Now there are more things you know about the if statement here in bash/sh, the statement given cannot touch the bracket around it, if it does it will be very upset about it.

Another thing are the else statements, declaring an if [ statement ]; then declaration elif [ … and so on.

Declaring that allows the program to choose between the two, if this statement isn't true then execute this basically.

I took it to myself to write a program as such to my lazy nature and have it retrieve the latest project in the class repository.

The program goes as followed.

[CODE]

#!/bin/bash # grabs the latest project, copies to project directory

# retrieving data dir=/var/public/unix/spring2015/ cpDir=~/src/unix/projects/

# main cd $dir name=$(ls -t | head -n1 ) cp -avr $name $cpDir exit 0

[/CODE]

Doing this took a quite a bit of research, online over at stackoverflow and even on the manual pages provided by the OS.

To break it down, it enters into the class repo by a set given path when it starts up. It then searches for the most recent entry (Earliest Date) to grab and copies it into my UNIX repo on my profile. This here gives me the chance to be lazy and not worry about diving into the depths of the directories just to get to this repo.

UNIX/Linux Fundamentals Journal

February 3rd, 2015

In UNIX/Linux we learned about the magical world of Bob Joy and his VI/VIM program.

Now VI and VIM are similar but VI came first, VIM is a more easy to use approach for the modern world.

VI was developed in order to provide some sort of new method of typing with eaze and editing lines on lines of code without any troubles.

VIM followed after when a GUI's started popping up everywhere and having people perform tasks on those, to modernize and keep VI in use and more userfriendly, they added some new features.

Now VI actually does contain quite a large amount of commands but I wrote down what we focused on during class.

Copy This Link : http://pastebin.com/AJdUKMnv –> It will take you to the notes taken in class, the site is messing up the notes for some reason.

After reading all those notes on VI, it comes in handy when you want something done fast for sure. I'm glad we actually went into using this instead of using NANO or any other text editor in CLI.

UNIX/Linux Fundamentals Journal

January 27th, 2015

In class, we reviewed a little bit more on directories and were introduced into the world of passing files and error messages around files.

Here are all the class notes for that class.

Types of Files

- Regular (-) [Files]

- Directory (l, d) [Folders, Symbolic Links]

- Special (p,s,b,c)

UNIX Philosophy

- Everything is a file

- Small is beautiful (Makes life better [Can be broken when pushed])

- Do one thing, and do that one thing extremely well

Commands

- who (Displays who is currently logged into the system)

C/C++ (Appears in UNIX/Computers)

- STDIN [Default input file (Keyboard)]

- STDOUT [Default output file (Monitor/Terminal)]

- STDERR [Default output error (Monitor/Terminal)]

I/O Redirection + Search Commands

- '<' Redirect STDIN from a file (Read)

- '>' Redirect STDOUT to a file (Write, Overwrite)

- '2>' Redirect STDERR to a file (Write, Overwrite)

- '»' Redirect append STDIN

- '2»' Redirect append STDERR

- '|' Pipe (Takes the output and converts to input)

- 'grep' Searches for things

Example of '|' Pipe: who | wc -l Takes the output of who and takes it to wc -l which takes the length/# of lines in the output of who.

Example of 'grep' Search Takes anything that contains a letter after that argument. grep 'a' – In the given directory, it takes anything listed with an a into a list.

UNIX/Linux Fundamentals Journal

January 20th, 2015

Today in class, we reviewed the grading policies and what we are required to do in and out of class.

We also reviewed a few commands on UNIX/Linux based operating systems, these commands allow the user to create/modify/read contents on files and change directories.

Findout out your home directory - pwd (Print working directory [Current])

List Objects In Current Directory - ls (List)

-l Lists an entire list of privlages

Arguments Are Typed With A Dash (-) Then Argument

Creates A File In The Given Directory - touch file (Raises The Island)

Opens Terminal Text Editor - nano file

Reads/Inspects File Currently On - cat file

Copies File To Another Spot - cp [fileName] [newFileName]

Makes A New Directory - mkdir [name]

Moves File To New Directory - mv [name] [newDirectory]

Moves To New Directory (Next) - cd [directoryWithin]

Moves Back A Directory - cd ..

Manually Take Control (View Everything With That Command) - man [command]

Finally after reviewing all the commands, to connect to the class website via Terminal. Issuing the command ssh lab46 allows you to securely enter the site in the terminal. There is a drawback though, I have tried connecting outside the network located in the “Lair”, you aren't able to connect outside but instead you need to connect via Web browser.

MONTH Day, YEAR

This is a sample format for a dated entry. Please substitute the actual date for “Month Day, Year”, and duplicate the level 4 heading to make additional entries.

As an aid, feel free to use the following questions to help you generate content for your entries:

  • What action or concept of significance, as related to the course, did you experience on this date?
  • 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?

Portfolio

cprog

unix

1)
i%5
2)
Math Friendly