User Tools

Site Tools


blog:fall2015:mp010784:start

Matthew J. Page

Matthew Page's Fall 2015 Opus

Journey into the Hot, Molten Core of Computing Awesomeness!!!

Previous Semester's Opi: (FYI: I have the same regurgitated Introduction on every opus)

Fall 2014 Opus Spring 2015 Opus

My website: www.matthewjpage.com

For help with wiki syntax:

Introduction

Welcome to this chronicling of my semester's computer science work at Corning Community College. My name is Matthew Page and I will be your guide through this adventure…buckle up cause it might get bumpy. I have an A.S. in Liberal Arts from CCC in 2002. Currently, I am enrolled in the Computer Science program at CCC this fall semester in 2014. I am taking 2 computer science classes that I will be documenting my work, progress, and thoughts on throughout the semester.

I have spent most of my life working with computers, but not ever as a profession, and not always as a major interest or pursuit in my life. When I was maybe 7 or 8 years old, which would have been late 1980's, my parents got me and my sister a Commodore 64, which I remember at the time it being hugely disappointing because all our friends had an NES, Nintendo Entertainment System (Mario, Duck Hunt, Tetris, Zelda, Punch-Out, etc.)and my sister and I never did end up ever getting an NES, more because it was superceded than anything else. Nintendo Entertainment System Nintendo Entertainment System

In retrospect, however, the Commodore 64 was an AMAZING tool at the time for me to play with, the first computer I had unlimited access to. In grade school we used Apple II's

Apple II Computer

Apple II Computer

but only for maybe an hour at a time once a week where we mostly did typing tutorials. The commodore 64 on the other hand originally it's main focus for me was to play games, I played some Mario clones, Hardball (a baseball game my dad and I religiously challenged each other to over and over.) I played with some synthesizer or music creating software. But I also got my very first taste of programming on the Commodore 64 when a babysitter of mine, who was taking a programming class in high school showed me some BASIC on the Commodore 64

Commodore 64 Commodore 64

This system used the old 5 and 1/4 inch floppy disks that predated the 3.5 inch disks that I used in middle and high school. But the whole system was a keyboard, a floppy disk drive and we had our TV used as our monitor, in addition to other periphials like some joysticks and a printer. But we booted the machine up to this blue command line and the exact command I used a million times to load my floppy disk games 'LOAD“*”,8,1' is shown in the image below. Next to it is a Hello World program on a Commodore 64.

Commodore 64 command line A Hello World program in BASIC

Commodore 64 command line on the left, A Hello World program in BASIC on the right.

Once in middle school we had moved on to a Windows 3.1 system on top of DOS 5.0, in which we booted up to DOS and started windows manually from within DOS. Some of our programs ran in DOS including America Online 2.0 and Doom, and others ran in Windows like Sim City 2000, Wordperfect, etc. You can actually experience what Windows 3.1 was like in a web browser here: Windows 3.1 OS in Browser

Windows 3.1 Sim City 2000 Doom

Windows 3.1 on the top left, Sim City 2000 on the top right, Doom on the bottom.

Around this time period in my life was when I was first discovering the Internet, which was a vast unknown that fascinated me. We used dial-up connections to connect to AOL 2.0 and up for the next several years. Back in those days (I feel like Grandpa Simpson when I phrase it that way)

Grandpa Simpson

Grandpa Simpson, from the “The Simpsons” animated TV show

we only got like “20 hours per month” for our monthly subscription, a limitation I could not fathom having to deal with in todays world where my machines do things online 24-7-365 sometimes. I remember the concept of a chat room was a novel thing at the time, so one of the things I frequently did on early AOL was join chat rooms and talk to people from all over, which quickly burnt through our monthly quota of internet usage, you could go beyond the limit, but it charged my parents credit card like 3 or 4 dollars I think per hour, maybe even 5 dollars later on, for exceeding your alloted hours in a month(Trust me, I got yelled at for this occurring because of me many times.) I quickly found a loophole. When people had technical support problems with AOL they would join tech support rooms, which were backed up with a poor ratio of tech support people to the number of users with issues, So you'd join and get a message saying “matthewpage you are now number 125 in the queue.” or something to that effect. The techs would address the current #1 in the queue and in the meantime people could crosstalk between other waiting users. But what made this exploitative was that your monthly quota clock stopped while in that chatroom, so I started to opt in lieu of the regular chatrooms to chat in tech support while waiting in the queue. Inevitably it would come time for me to ask my question and I'd either a) ask a troll-like nonsensical question or b) a question I already knew the answer to and then leave and rejoin the tech support room at the end of the queue. I was 13 at the time and it was amusing to me then, and it also bought me more “free internet time.”

America Online

Top: One of the early America Online main menus, Bottom: Video of AOL dial up connection noises.

In high school I took a programming class and learned some Pascal and I remember none of it at this point, but it was my first real formal teaching of any programming language. I used Windows 95 and 98 through high school and into my first time at Corning Community College on my home computer. At school we used Macinotoshs that looked like this in High School. this was also literally the last Apple product I have used to date(08/26/2014).

Macintosh Computer

Macintosh Computer made by Apple, Inc.

In college I had no idea what I wanted to do, so I had a different major almost every semester I was in college which is why I ultimately ended up with an A.S. in Liberal Arts. My best friend from high school went away to college for electrical engineering and this is where I first heard about Linux, just off the cuff and in passing conversations, until I asked him and some of his friends from college about it enough that it had piqued my interest. At one point I bought a brand new Windows XP desktop and decided I'd try to set up a dual boot system with Windows XP and a Linux distro. At the time one of the popular ones was Red Hat(this was before Red Hat Enterprise Linux, approximately 2003-2004), and I think I downloaded the iso files (CD images) for Red Hat 9 if I remember correctly.

Tux Red Hat Linux

“Tux” the Linux mascot on left, and the Red Hat Linux logo on right.

After a lot of hair pulling, I had successfully set up a dual boot system, which was alot harder then than it is today. I bought a linux book, read through it, practiced some command line stuff, but ultimately whenever I encountered an issue or didn't know how to do something in Linux, I'd reboot and just do it in Windows XP. Eventually this setup lead to me staying in Windows XP most of the time and neglecting the Linux installation, so my learning stagnated, and after only 3 months I removed Red Hat and went back to Windows XP solely. This is why consequently in the last 4 or 5 years since I've been heavily using Linux systems, I try to make a point to find the solution, come hell or highwater, do whatever research I need to do, and exhaust all possibilities, to force myself to learn ways to solve problems instead fo retreating to what I know. So about 4 or 5 years ago I was reading about a distro that hadn't existed when I originally took a taste of linux. I was hearing a lot about the accessibility of Ubuntu, so I took my brand new Windows 7 laptop, and set up a dual boot system in no time, compared to my original venture 10 years ago. I decided to live in it ALL THE TIME, and I did. I bought books, read books, bought more books, read more books, re-read books, started to take an interest in learning some programming languages in addition to learning and using linux. So I started learning some Python alongside some C++ over the last roughly 4 years. When Ubuntu decided to ditch the GNOME desktop environment for their own Unity Desktop Environment…

Ubuntu running the GNOME Desktop environment Ubuntu running the Unity desktop

Top: Ubuntu running the GNOME Desktop environment, Bottom: Ubuntu running their own desktop environment created in house at Canonical called the Unity desktop.

…I bailed on Ubuntu as I despised Unity in its early days. I tried many of the popular distros: Fedora, Mint, OpenSuse, Debian. I had heard through linux communities of Arch Linux and was initially intimidated by the amount of what you were responsible for setting up on your own system, but also its reputation (which is greatly exaggerated.) I installed Arch and used it and forced myself to deal with issues that I encountered. This same time period I fell into an amazing and helpful linux community, The Linux Distro Community which I have been active with ever since. I live in their IRC channel #linuxdistrocommunity on irc.freenode.net and frequent their forums often (additionally I have 2 IRC channels of my own on irc.freenode.net that anyone is welcome to join #robgraves and #spoonbomb: Linux Distro Community This community has a lot of screencasters and youtubers and they had encouraged me to show how I had dealt with pacman-key errors in installation when they added key signing to packages to Arch and I had succeeded in installing Arch where others were failing so I actually have video documentation of my earlier days of using Arch Linux on my youtube channel in addition to being a guest on another members PodCast a couple times under my handle “robgraves”: My Youtube Channel

My actual desktop from a few years ago running Arch Linux with wmii tiling window manager Another actual desktop of mine from a couple years ago running Gentoo with the GNOME desktop

Top: My actual desktop from a few years ago running Arch Linux with wmii tiling window manager, Bottom: Another actual desktop of mine from a couple years ago running Gentoo with the GNOME desktop.

Later I decided also that I am officially game for trying any distro, so I learned and used Gentoo for over a year, used Slackware for a while, and made a failed attempt at Linux From Scratch on a virtual machine becuase the toolchain never compiled correctly, at some point I want to re-attempt to do that. I also have no experience with any of the BSD's and I want to at least use them enought to be familiar with how they operate.

Later I set up a machine at home with a LAMP stack (Linux, Apache, MySQL, and PHP) not for any real purpose, other than to 1) see if I could, 2) learn how to run a webserver and learn system admin like stuff and experiment. So I bought a couple domains, and my websites were less about making a useful website than it was to answer questions like “how do I host multiple websites on one webserver” and after playing around with virtual hosts and apache config, I had my server machine hosting 5 domains and real websites albeit mostly junk. The only 2 websites that remain today are my personal website: matthewjpage.com and the one I was originally planning on doing as a collaborative “sharing our efforts and not duplicating work” with my little brother (whom I have converted to the Church of Linux): spoonbomb.com. Both websites are rough, theres a lot of copying and pasting stuff into them, both were written from scratch in vim while ssh'd into the server machine, no IDE's, no WYSIWYG editor…vim, and I know ZERO HTML or any web design…for now. They both could desperately use a major overhaul, except I'm not sure of their purpose anymore. I had even set up forums, not for people actually use, but to see if I could and to deal with MySQL and try to learn that. Holy spambots, batman! I was innundated with spambots, eventually I got tired of banning accounts and trying to filter new registrations.

My geeky section of my bookshelf.

My geeky section of my bookshelf.

I have repos both on github.com and bitbucket.org, not that theres anything particularly amazing on either site, but specifically I'm trying to start accumulating dotfiles for configurations of Linux utilities on github, and any code I write to try to push those to one or both of the aforementioned sites.

–Matthew Page 08/26/2014

Data Structures

Week 1

I think I'm changing formats from writing stuff every single day to just writing a general synopsis for every week for each class to preserve my sanity.

For data structures this week we discussed the general idea of linked lists and looked at our first project (dsi0) which is pertaining to making an array list and having a user driven menu that changes data in the array list. We also talked about pointers and nodes.

“To achieve enlightenment you'll want to draw pictures in each stage.” –Matt Haas

Pointers have:
1) a name
2) an address
3) contents at address

* - means get the contents of what's at address.
& - means give me the address.

“Saving the planet, one keystroke at a time.” –Matt Haas with ending by Zack Golden.

Node code:

struct node    //defining struct node
{
    signed short int value;
    struct node *next;
};

typedef struct node Node;

Node *tmp;         //does the same thing
struct node tmp2;  //does the same thing

Node *tmp=NULL;           //setting both pointers tmp and tmp2 to NULL
struct node *tmp2=NULL;

tmp=(Node*)malloc(sizeof(Node));  //instantiating a node.

tmp->next->NULL;  //pointing back to NULL after the node.

tmp->value=7;  //setting the value in node to 7.

tmp->next=(Node*)malloc(sizeof(Node));    //instantiating 2nd node.
tmp->next->next=NULL;  //setting pointer of 2nd node to NULL.

tmp2=tmp->next; //pointing tmp2 to the second node.

tmp2-value=13;  //setting value in second node to 13. 

Week 2

First day this week we worked on getting accustomed to the pods and logging in and using the X system. On lab46 we set up and clone our mercurial repository on lab46 and ~/src directory if we didn't already have it. I spent most of the class working on my project dsi0, my program called arraylist.c

The other day of class this week week spoke in some depth to linked lists and some of the functions we may need to implement in upcoming programs in regards to linked lists, such as:
1) create()
2) copy()
3) clear()
4) insert()
5) append()
6) obtain()
7) setpos()
8) getpos()
9) find()
10) swap()
11) sort()
12) compare()
13) rmlist() (deallocate list)
14) empty() (empty the list to make an empty list)
15) displayf() (display forwards)
16) displayb() (display backwards)

Week 3

This week we had our first project for this class due on Wednesday, dsi0, which was to create an array program. This is the version of mine that I submitted, despite there being a couple of minor bugs I still wish to fix after the fact, but the core functionality is there:

/**************************************************
 *
 *  Matthew Page
 *  08/29/2015
 *  CSCS2320 - Data Structures
 *  Fall 2015
 *
 *  arraylist.c -   project dsi0 for data structs
 *                  where creating a program that
 *                  presents the user with a menu  
 *                  to build list, display list, 
 *                  insert into list, append into
 *                  list, obtain from list, clear
 *                  list, and quit.  This first 
 *                  project will be using an array
 *                  and functions for each option
 *                  in the menu, in later projects
 *                  we will use linked lists with 
 *                  nodes.
 *
 *************************************************/

#include <stdio.h>

    //Function Prototypes
    void menu();                        
    int buildlist(int, int *, int);     //passing index, array pointer, and buildinput
    void displaylist(int *);            //passing array pointer
    int * insert(int, int, int *);      //passing requested index, new value, and array
    int * append(int, int, int *);      //passing requested index, new value, and array
    int * obtain(int, int *, int*);     //passing index, array, and address of obt_value
    int * clearlist(int *);             //clears out the array, pass array

main()
{
    //variable declarations
    int input = 0;                      //user's choice on menu
    int buildinput = 0;                 //values entered to build list
    int quitflag = 0;                   //quit variable for main program loop
    int index = 0;                      //index associated with build list entries
    int array[21];                      //the array set to a size of 21
    int ins_index = 0;                  //index of desired insertion point for insert() function
    int app_index = 0;                  //index of desired appending point for append() function
    int ins_value = 0;                  //value entered at insertion point for insert() function
    int app_value = 0;                  //value entered at appending point for append() function
    int obt_index = 0;                  //index of desired value to obtain in obtain() function
    int obt_value = 0;                  //obtained and removed value from obtain() function

    clearlist(array);           //calling clearlist passing it the array, to enter all -1's in array

    //main program loop
    while (quitflag != 1)          
    {
        //calling menu function
        menu();               

        //User input
        scanf("%d", &input);

        //case switching statement
        switch(input)
        {
            case 1:         //Build List
                printf("Build List Function:\n");
                printf("Enter values into the list up to 20 values total.\n");  
                printf("Enter a '-1' to signify the end of data.\n");

                while ((buildinput != -1) && (index<20))
                {
                    printf("Enter value: \n");    
                    scanf("%d", &buildinput);
                    index=buildlist(index,array,buildinput);
                }

                if (index == 20)            //Testing for full array
                {
                    printf("Maximum values reached.  Array is full.\n");    //Full array message
                }

                break;
            case 2:         //Display List
                printf("Display List Function\n");
                displaylist(array);
                break;
            case 3:         //Insert into List 
                printf("Insert into List Function\n");
                printf("Enter index of array element to insert before: \n");
                scanf("%d", &ins_index);
                printf("Enter new value to insert before this index: \n");
                scanf("%d", &ins_value);
                insert(ins_index, ins_value, array);
                break;
            case 4:         //Append into List
                printf("Append into List Function\n");
                printf("Enter index of array element to append after: \n");
                scanf("%d", &app_index);
                printf("Enter new value to append after this index: \n");
                scanf("%d", &app_value);
                append(app_index, app_value, array);
                break;     
            case 5:         //Obtain from List
                printf("Obtain from List Function\n");
                printf("Enter index of array element to obtain: \n");
                printf("(This will remove this value from the list)\n");
                scanf("%d", &obt_index);
                obtain(obt_index, array, &obt_value);
                printf("Removing Element #%d : %d from the list. \n", obt_index, obt_value );
                break;
            case 6:         //Clear List         
                printf("Clear List Function\n");
                clearlist(array);                           //calling clearlist passing it the array
                break;
            case 7:         //Quit
                printf("Leaving...Have a Nice Day!! :)\n");
                quitflag = 1;                               //changing quit flag upon quit selection
                break;
            default:
                printf("ERROR: Invalid entry!\n");          //Error message for invalid entry
                break;                                    
        }
    }


    return (0);
}

//User Menu Function
void menu()
{
    //output menu
    printf("---------------------------------------\n");
    printf("Data Structures Array List Program Menu\n");
    printf("---------------------------------------\n");
    printf("Please choose one of the following:\n");
    printf("1 - Build List\n");
    printf("2 - Display List\n");
    printf("3 - Insert into List\n");
    printf("4 - Append into List\n");
    printf("5 - Obtain from List\n");
    printf("6 - Clear List\n");
    printf("7 - Quit\n");
    printf("---------------------------------------\n");

}

//Build List Function
int buildlist(int index, int *array, int buildinput)
{
    array[index]=buildinput;
    printf("Array index %d is %d\n", index, array[index]);
    index++;
    return index;
}

//Display List Function
void displaylist(int *array)
{
    int i = 0;
    printf("The list is: \n");
    while ((array[i] != -1) && (i<20))
    { 
        printf("Element #%d: %d\n", i, array[i]);
        i++;
    }
}


//Insert into List Function
int * insert(int ins_index, int ins_value, int * array)               
{
    int i = ins_index;
    for (i=19;i>=ins_index;i--)
    {
        array[i+1]=array[i];
    }
    array[ins_index]=ins_value;
    return array;
}

//Append into List Function
int * append(int app_index, int app_value, int * array)           
{
    int i = app_index;
    for (i=19;i>=app_index;i--)
    {
        array[i+1]=array[i];
    }
    array[app_index+1]=app_value;
    return array;
}

//Obtain from List Function
int * obtain(int obt_index, int * array, int* obt_value)       
{                                                                      
    int i = obt_index;
    (*obt_value)=array[obt_index];
    for (i=obt_index;i<=19;i++)
    {
        array[i]=array[i+1];
    }
    return array;
}

//Clear List Function
int * clearlist(int *array)
{
    int i;
    for (i=0;i<=20;i++)
    {
        array[i]=-1;
    }
    return array;
}

We have now officially assigned, project sln0, a singly linked list set of pseudocode and pictures based project, due next Wednesday, September 16, 2015.

We also spent this week talking pretty extensively about the debugger sot hat we can start learning to use it effectively as a tool to help us resolve issues with our code.

GDB - GNU Debugger, cannot rely solely on the debugger. It can only help you to make better decisions in sorting out errors in your code.

3 Types of Errors:
- Syntax Errors
- Logic Errors
- Runtime Errors

  1. dividing by zero (computer cries and the universe explodes)
  2. segmentation fault (SEGFAULT) (tries to access memory that is not yours.) ZEUS Striking down lighting SEGFAULTS

“Mastering the debugger is the type of thing that will get you hired or incarcerated.” –Matt Haas

Using the GDB Debugger

To compile with “-g” to add debugging symbols to the program which for this class we will probably do for all compiling now, but in production code that needs to do intensive work this would have a performance hit:

$ gcc program.c -o program -g


To run the debugger with our program:

$ gdb ./program


This will give us a a gdb prompt that appears as so:

(gdb) 


From here we can enter commands like:

(gdb) help


To display help or:

(gdb) help all


to see all commands and hit ENTER to cycle through them.
You can get help on certain commands by running the help command followed by a command name:

(gdb) help list


which will show the usage of the list command on gdb.

At any point you can exit the debugger with:

(gdb) quit


(gdb) list


This displays the first several lines of code from the program, hitting ENTER will contine to show more lines from the code.

(gdb) list main


This would the main function, a few lines before and a few lines after.

(gdb) list menu


This show's the menu function and a few lines before and after.

You can also show a specific line by number and the preceding and following lines with:

(gdb) list 194


(gdb) run


Runs the program as normal.

(gdb) backtrace


OR:

(gdb) bt


Backtrace command which goes back through function calls to function calls, to go deeper down the rabbit hole.

(gdb) breakpoint 94


OR:

(gdb) break 94


Sets a breakpoint at line 94 so that when the program runs it will stop at line 94, if this is in a loop it will stop at that line every single iteration of the loop at that line.

(gdb) print i


Would print the value of i variable currently.

(gdb) print i+1


Would print the value of (i+1) at the current state.

(gdb) print array[i]


Would print the value at array subscript i at current state.

(gdb) print array[i+1]


Would print the value at array subscript i plus one at current state.

(gdb) step


OR

(gdb) s


Steps through the next line of the program (which includes into function calls)

(gdb) next


OR:

(gdb) n


Does the same thing as step but does NOT go into function calls which include not going into things like the scanf function, which if you step through you end up in library code.

(gdb) continue


OR:

(gdb) c


Continues to the next breakpoint.

(gdb) display i


(gdb) display i+1


(gdb) display array[i]


(gdb) display[i+1]


These are like the print statements earlier, except print only does it once, whereas this will keep showing you the values of these variables as you step through the program or through different iterations. You lose these once you quit the debugger.

(gdb) watch i=139


(gdb) watch i=149


(gdb) watch i>150


Watches the value at the condition. Like a time machine jumping to that iteration or that point in the program running where the value of the variable is at the specified value.

(gdb) x array


Examine array address.

(gdb) delete break 1


Deletes breakpoint #1.

(gdb) set var i=770


Sets the value of variable i to 770.
Tricks it into thinking i is 770, hard wired it to 770.

With this you can put bad data into your variables to stress test your code.

You can also make scratch variables to use solely in debugging:

(gdb) set var j=32


then display it with:

(gdb) print $j


(gdb) help set watchdog


For use with timing based programs.

(gdb) (*int) 0x7ffff03f0


(gdb) (*int) 0x7ffff0310


(gdb) print (array+0)


(gdb) print (array+1)


Forgot what these lines were exactly.

(gdb) x/4 0x7ffff03f1


Gives 4 units of data from the array in this case.

(gdb) x/8 0x7ffff03f1


Gives 8 units of datafromt he array.

(gdb) help x


Shows help page on x for examining contents of memory.
0xffffff is -1 because of Two's compliment.

(gdb) x/20 0xffff03f1


Shows all of the array.

(gdb) x/32d 0xfffff03f1


Converts it to decimal.

(gdb) x/32t 0xfffff03f1


Converts it to binary.

(gdb) x/32o 0xfffff03f1


Converts it to octal.

(gdb) x/32u 0xfffff03f1


Converts it to unsigned integer.

(gdb) x/32d 0xfffff03f1


Converts it to signed integer.

$ gdb /bin/ls


Opens ls in gdb.

(gdb) break _start


Breaks just before main function.

(gdb) run


Runs ls, which ended up giving us a memory address.

(gdb) x/20i 0xfffff3310


Dumps the assembly language code for ls.

$ gdb ./debug-sample


rerunning debug-sample in gdb.

(gdb) break main


setting breakpoint at main.

(gdb) print &main


I think that's right, having trouble reading my writing, but should print memory address of main function.

(gdb) x/20 0xffff3310


Examine the memory for your code.

(gdb) x/20i 0xffff3310


Examine the memory to find assembly code of your code.

Week 4

Something something dark side.

We watched a very old and…different video on pointers on youtube this week as part of our project:

Binky Pointer Fun:


Make and Makefiles

We learned about make some this week. This week's project sln1 has a Makefile in it which are instructions to the make command to make compilation and linking multiple files together much easier. on lab46 for sln1, when we type in “make help” we get a list of some usage commands for make:

lab46:~/src/data/cscs2320/sln1$ make help
****************[ Data Structures Node Implementation ]*****************
** make                     - build everything (libs, units, apps)    **
** make debug               - build everything with debug symbols     **
** make check               - check implementation for validity       **
**                                                                    **
** make libs                - build all supporting libraries          **
** make libs-debug          - build all libraries with debug symbols  **
** make apps                - build unit tests                        **
** make apps-debug          - build unit tests with debugging symbols **
** make units               - build unit tests                        **
** make units-debug         - build unit tests with debugging symbols **
**                                                                    **
** make save                - create a backup archive                 **
** make submit              - submit assignment (based on dirname)    **
**                                                                    **
** make update              - check for and apply updates             **
** make reupdate            - re-apply last revision                  **
** make reupdate-all        - re-apply all revisions                  **
**                                                                    **
** make upgrade-sll0        - upgrade to next project (sll0)          **
** make clean               - clean; remove all objects/compiled code **
** make help                - this information                        **
************************************************************************
lab46:~/src/data/cscs2320/sln1$

The Makefile for this project accounts for some extra's but we can use this as a blueprint for future Makefiles:

SHELL = /bin/bash -e
INC = -I inc/
CCFLAGS = -Wall 
OPTS =
CC = gcc $(CCFLAGS) $(OPTS) $(INC)
OBJ = 
AR = ar
DEBUG = 
DESIG = data
SEMESTER = fall2015
PROJ = $(shell /bin/pwd | /bin/sed 's/^.*\///')
NEXTPROJ = $(shell /bin/cat /var/public/$(SEMESTER)/$(DESIG)/projlist | /bin/grep "^$(PROJ):" | /usr/bin/cut -d':' -f2)
OTHER = $(shell /bin/cat /var/public/$(SEMESTER)/$(DESIG)/projlist | /bin/grep "^$(PROJ):" | /usr/bin/cut -d':' -f3)
NEXTPATH = /var/public/$(SEMESTER)/$(DESIG)/$(NEXTPROJ)
OTHERPATH = /var/public/$(SEMESTER)/$(DESIG)/$(OTHER)
LIBS = src
UNIT = unit
APP = app
ALL = $(LIBS) $(UNIT) $(APP)
BIN = 
default: status-begin libs units apps status-end
debug: status-begin libs-debug units-debug apps-debug status-end

libs-debug: CC += -DDEBUG -g
libs-debug: DEBUG = debug
libs-debug: libs

libs:
ifneq ($(MAKECMDGOALS),debug)
	@for i in $(LIBS); do make -sC $$i $(DEBUG); done
else
	@for i in $(LIBS); do make -C $$i $(DEBUG); done
endif

status-begin:
	@if [ `cat .updates/current` -lt `cat /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/latest` ]; then echo "*********************************************************"; echo "*** NEW UPDATE AVAILABLE: Type 'make update' to apply ***"; echo "*********************************************************"; fi

status-end:
	@if [ `cat .updates/current` -lt `cat /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/latest` ]; then echo "*********************************************************"; echo "*** NEW UPDATE AVAILABLE: Type 'make update' to apply ***"; echo "*********************************************************"; fi

status-quit:
	@if [ `cat .updates/current` -lt `cat /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/latest` ]; then echo "*********************************************************"; echo "*** NEW UPDATE AVAILABLE: Type 'make update' to apply ***"; echo "*********************************************************"; /bin/false; fi

units-debug: CC += -DDEBUG -g
units-debug: DEBUG = debug
units-debug: units

units:
ifneq ($(MAKECMDGOALS),debug)
	@for i in $(UNIT); do make -sC $$i $(DEBUG); done
else
	@for i in $(UNIT); do make -C $$i $(DEBUG); done
endif

apps-debug: CC += -DDEBUG -g
apps-debug: DEBUG = debug
apps-debug: apps

apps:
ifneq ($(MAKECMDGOALS),debug)
	@for i in $(APP); do make -sC $$i $(DEBUG); done
else
	@for i in $(APP); do make -C $$i $(DEBUG); done
endif

check: status-begin
	@/var/public/${SEMESTER}/${DESIG}/.eval/verify-$(PROJ).sh

clean: status-begin
	@printf  "Cleaning out object code    ... "
	@for i in $(ALL); do make -sC $$i clean; done
	@rm -f errors bin/* lib/*
	@printf  "OK\n\n"

copy:
	@echo    "Commencing copy process for project $(PROJ)"
	@echo
	@echo -n "Creating project $(PROJ) directory tree           ... "
	@mkdir -p ~/src/$(DESIG)/$(PROJ) ~/src/$(DESIG)/$(PROJ)/.updates && echo "OK" || echo "error"
	@echo -n "Copying $(PROJ) files into project directory  ... "
	@cp -av /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/* ~/src/$(DESIG)/$(PROJ)/ && echo "OK" || echo "error"
	@echo -n "Synchronizing $(PROJ) project revision level      ... "
	@cp -f /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/current ~/src/$(DESIG)/$(PROJ)/.updates/ && echo "OK" || echo "error"
	@echo -n "Establishing sane file permissions for $(PROJ)    ... "
	@chmod -R u=rwX,go= ~/src/$(DESIG)/$(PROJ) && echo "OK" || echo "error"
	@echo
	@echo "Copy Complete! You may now switch to the ~/src/$(DESIG)/$(PROJ) directory"
	@echo
	@echo "[${USER}] obtaining project '$(PROJ)' (revision `cat /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/latest`) in `pwd` (`date +\"%Y%m%d%H%M\"`)" >> /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/log

save: clean
	@echo
	@echo    "Project backup process commencing"
	@echo
	@echo -n "Taking snapshot of current project ($(PROJ))      ... "
	@(cd ..; tar cf $(PROJ)-`date +%Y%m%d-%H`.tar $(PROJ) && echo "OK" || echo "error")
	@echo -n "Compressing snapshot of $(PROJ) project archive   ... "
	@gzip -f -9 ../$(PROJ)-*.tar && echo "OK" || echo "error"
	@echo -n "Setting secure permissions on $(PROJ) archive     ... "
	@chmod 600 ../$(PROJ)-*.gz && echo "OK" || echo "error"
	@echo
	@echo    "Project backup process complete"
	@echo

submit: save
	@submit $(DESIG) $(PROJ) `/bin/ls -1 ../$(PROJ)*gz | tail -1`
	@echo "[${USER}] submitting project '$(PROJ)' in `pwd` (`date +\"%Y%m%d%H%M\"`)" >> /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/log

use-test-reference: clean
	@if [ -f "/var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.datastore/refimp.sh" ]; then sh /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.datastore/refimp.sh `pwd` "$(SEMESTER)/$(DESIG)/$(PROJ)"; fi
	@echo "NODE reference implementation in place, run 'make' to build everything."

use-your-own-code:
	@if [ -f "/var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.datastore/locimp.sh" ]; then sh /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.datastore/locimp.sh `pwd` "$(SEMESTER)/$(DESIG)/$(PROJ)"; fi
	@echo "Local node implementation restored, run 'make clean; make' to build everything."

update:
	@for((i=`cat .updates/current`+1; i<=`cat /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/latest`; i++)); do sh /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/$$i $(SEMESTER) $(DESIG) $(PROJ); echo "[${USER}] applying revision $$i of '$(PROJ)' in `pwd` (`date +\"%Y%m%d%H%M\"`)" >> /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/log; done
	@chmod -R u=rwX,go= .
	@echo "Updated from revision `cat .updates/current` to revision `cat /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/latest`"
	@cat /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/latest > .updates/current

reupdate:
	@for((i=`cat .updates/current`; i<=`cat .updates/current`; i++)); do sh /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/$$i $(SEMESTER) $(DESIG) $(PROJ); echo "[${USER}] re-applying revision $$i of '$(PROJ)' in `pwd` (`date +\"%Y%m%d%H%M\"`)" >> /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/log; done
	@chmod -R u=rwX,go= .
	@echo "Re-applying revision `cat .updates/current`"

reupdate-all:
	@for((i=1; i<=`cat .updates/current`; i++)); do sh /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/$$i $(SEMESTER) $(DESIG) $(PROJ); echo "[${USER}] re-applying revision $$i of '$(PROJ)' in `pwd` (`date +\"%Y%m%d%H%M\"`)" >> /var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.updates/log; done
	@chmod -R u=rwX,go= .
	@echo "Re-applied updates from revision 1 to revision `cat .updates/current`"

upgrade-$(NEXTPROJ): status-quit clean save
	@echo    "Commencing upgrade process from $(PROJ) to $(NEXTPROJ)"
	@echo
	@echo -n "Creating project $(NEXTPROJ) directory tree           ... "
	@mkdir -p ../$(NEXTPROJ) ../$(NEXTPROJ)/.updates && echo "OK" || echo "error"
	@echo -n "Copying your code to $(NEXTPROJ) project directory    ... "
	@cp -a * ../$(NEXTPROJ) && echo "OK" || echo "error"
	@echo -n "Copying new $(NEXTPROJ) files into project directory  ... "
	@cp -a /var/public/$(SEMESTER)/$(DESIG)/$(NEXTPROJ)/* ../$(NEXTPROJ)/ && echo "OK" || echo "error"
	@echo -n "Synchronizing $(NEXTPROJ) project revision level      ... "
	@cp -f /var/public/$(SEMESTER)/$(DESIG)/$(NEXTPROJ)/.updates/current ../$(NEXTPROJ)/.updates/ && echo "OK" || echo "error"
	@if [ -f "/var/public/$(SEMESTER)/$(DESIG)/$(NEXTPROJ)/.updates/prune" ]; then echo -n "Pruning obsoleted files from $(NEXTPROJ) project tree ... "; sh /var/public/$(SEMESTER)/$(DESIG)/$(NEXTPROJ)/.updates/prune ../$(NEXTPROJ) && echo "OK" || echo "error"; fi
	@echo -n "Establishing sane file permissions for $(NEXTPROJ)    ... "
	@chmod -R u=rwX,go= ../$(NEXTPROJ) && echo "OK" || echo "error"
	@echo
	@echo "Upgrade Complete! You may now switch to the ../$(NEXTPROJ) directory"
	@echo
	@echo "[${USER}] upgrading to project '$(NEXTPROJ)' (revision `cat /var/public/$(SEMESTER)/$(DESIG)/$(NEXTPROJ)/.updates/latest`) in `pwd` (`date +\"%Y%m%d%H%M\"`)" >> /var/public/$(SEMESTER)/$(DESIG)/$(NEXTPROJ)/.updates/log

get-$(OTHER): status-quit clean save
	@make -C /var/public/$(SEMESTER)/$(DESIG)/$(OTHER) copy

help: status-begin
	@if [ "`echo $(PROJ) | cut -c3`" = "s" ]; then echo "****************[ Data Structures Stack Implementation ]****************"; elif [ "`echo $(PROJ) | cut -c3`" = "q" ]; then echo "****************[ Data Structures Queue Implementation ]****************"; elif [ "`echo $(PROJ) | cut -c3`" = "l" ]; then echo "****************[ Data Structures List Implementation ]*****************"; elif [ "`echo $(PROJ) | cut -c3`" = "n" ]; then echo "****************[ Data Structures Node Implementation ]*****************"; elif [ "`echo $(PROJ) | cut -c3`" = "t" ]; then echo "****************[ Data Structures Tree Implementation ]*****************"; else echo "****************[ Data Structures Code Implementation ]*****************"; fi
	@echo "** make                     - build everything (libs, units, apps)    **"
	@echo "** make debug               - build everything with debug symbols     **"
	@echo "** make check               - check implementation for validity       **"
	@echo "**                                                                    **"
	@echo "** make libs                - build all supporting libraries          **"
	@echo "** make libs-debug          - build all libraries with debug symbols  **"
	@if [ -d "app/" ]; then echo "** make apps                - build unit tests                        **"; echo "** make apps-debug          - build unit tests with debugging symbols **"; fi
	@echo "** make units               - build unit tests                        **"
	@echo "** make units-debug         - build unit tests with debugging symbols **"
	@if [ -f "/var/public/$(SEMESTER)/$(DESIG)/$(PROJ)/.datastore/refimp.sh" ]; then echo "**                                                                    **"; echo "** make use-test-reference  - use working implementation object files **"; echo "** make use-your-own-code   - use your own implementation code        **"; fi
	@echo "**                                                                    **"
	@echo "** make save                - create a backup archive                 **"
	@echo "** make submit              - submit assignment (based on dirname)    **"
	@echo "**                                                                    **"
	@echo "** make update              - check for and apply updates             **"
	@echo "** make reupdate            - re-apply last revision                  **"
	@echo "** make reupdate-all        - re-apply all revisions                  **"
	@echo "**                                                                    **"
	@if [ -r $(NEXTPATH) ]; then /usr/bin/printf "** %-24s " "make upgrade-$(NEXTPROJ)"; /usr/bin/printf "- %-39s **\n" "upgrade to next project ($(NEXTPROJ))"; fi
	@if [ ! -z "$(OTHER)" ] && [ -r $(OTHERPATH) ]; then /usr/bin/printf "** %-24s " "make get-$(OTHER)"; /usr/bin/printf "- %-39s **\n" "obtain new project ($(OTHER))"; echo "**                                                                    **"; fi
	@echo "** make clean               - clean; remove all objects/compiled code **"
	@echo "** make help                - this information                        **"
	@echo "************************************************************************"

Week 5

This week we talked about the sll0 project, our first singly linked list project, after the previous project of working on singly linked nodes (sln1). But on the current project (sll0) we were given some class time to work on this project. This project includes writing code for the functions mklist(), displayf(), getpos(), setpos(), and insert().

Week 6

I finished sll0 by the skin of my teeth in the last hours. I almost submitted it broken the other night as time was winding down and I figured I'd submit mostly functioning code on time over being late with finished code. But it bugged me that I couldn't complete it all on time and have it 100% functional. But with some assistance from wedge over IRC I was able to finish it and have everything working, namely the insert() function, but previously I had an infinite loop in my insert() function that showed “0 → 1 →” repeating over and over.

This week sll1 was unveiled and I decided to start working on the displayb() function first, displaying backwards. I already have an infinite loop in this one also, where it displays “← 4” repeating. I have a screenshot off my laptop of this behavior for fun:

Infinite Looping

Week 7

This week I worked on sll1 and got everything working correctly except for the compare function. I think the problem became that I started writing that function to the test instead of thinking out the logic of what I had to do to make it do what it needed to do. After turning in sll1 with still failing 3 of its tests I lost some points on it, but its probably a drop in the bucket in the grand scheme of things. Now sll2, sll3 and sll4 have been revealed. Through break week I did literally nothing. I had a lot of personal stuff going on. First day back from break we also have Richard Stallman on campus. And I'm gonna have to work around that and for the next three days trying to do the entirety of sll2 in three days. I probably can do it, but I'm gonna have to bust my ass for 3 solid days.

Week 8

Will continue after the Richard Stallman Experience…

The Richard Stallman Experience

This week started off with the “Richard Stallman Experience.” We had Richard Stallman from the GNU Project and the Free Software Foundation at our little podunk redneck college, Corning Community College. He spoke fo Free Software and Your Freedoms. Which is what he always talks about really. Its not anything I haven;t heard 100 times before in things I've seen of Dr. Stallman online, but it definitely was cool to be able to experience the man before he dies. We got to actually hear the man fart so loud that it came through the microphone. He was selling merch too, but we also got a metric ton of free stickers to plaster in the bathrooms or or laptops or where ever.

So for future reference, Dr. Richard Stallman was at CCC on Monday, October 19th, 2015.

Week 8 continued

This week as I did literally ZERO school work over break I came into school on Monday with the entirety of the sll2 project still to do. I worked on and completed 3 of the 5 functions: obtain(), clearlist(), and rmlist() all before going to see Richard Stallman's presentation on Monday. I started to work on the swap() function but I still need to get that one functional and then work on my sort() function in these next two days. Hopefully i can complete all that in the limited time I have left.

Week 9

This is the last week to drop and I'm in a bad place. Depression has sweeped over me and I can't break free. I sleep all the time. I hate my life. I just don;t care about anything anymore. I want to care but I don't have anything left. My psychiatrist says I check myself into the hospital. I am resisting solely because I know it will mean the end of this semester if I do.

At this point I missed Tuesdays class, I've got about 24 hours until sll3 (which was suppose to be the quick easy one) and sll4 are due. I'm still stuck on sll3 and my mind is a fog. at some point I'm just gonna have to do the submit and upgrade from sll3 and see if I can get anything functioning in sll4 in the next day and submit that. But if I could have done that I already would have. We'll see if I'm still here next week.

Week 10

This week we moved on to doubly linked lists from singly linked lists. We are finishing up dln0 and dll0 and then moving on to dll1.

Week 11

I've fallen out of the cycle of working on the projects as of late, I'm trying to jump back into it working on dll2 project due next week on Wednesday, November 18, 2015. However with this particular project I've discovered a potential issue or complication. The dll2 project should be a fairly simple one as we are only adding functionality for a qty (quantity) in our list functions. However since I'm currently using the test reference code as I haven;t been keeping up, this leaves me having to fully implement those functions, making dll2 a much larger project if I do in fact do dll2. I'm tempted to just skip dll2 and start on the stack project as at least it would be working with all new code.

Week 12

This week started working on the stack project dls0. I finished the mkstack(), rmstack(), and isempty() functions for dls0 project. This project is due on Wednesday. After that we have dsq0 which has 2 weeks to work on through our Thanksgiving break.

Week 13

This week is our last week of official classes for data structures. We are working on trees and finishing up our stack and queues projects before starting on our eoce, which will take the rest of our time the rest of this week, all of next week and possibly into finals week working on our end of course experience.

EOCE Work and Rick and Morty Pic

ricknmorty.jpg

Been working on the EOCE for data structures right up until the end…it's almost over…

blog/fall2015/mp010784/start.txt · Last modified: 2015/08/27 09:44 by 127.0.0.1