This is an old revision of the document!
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:
This week we continued to become familiar with the use of the UNIX commands and how to access and edit text files containing html and php content. We also dabbled with outputting php to a webstream written within the html markup.
ls – lists files
pwd – print working directory, gives absolute path
mkdir php – makes a dir called php
cd public_html – changes dir to public_html
cp – copy files
mv – moves files
rm – removes files
man ls – shows online manual for ls
Pod colors:
Text Editor: nano
To open a file and edit: nano test.html
PHP:
Text files containing php have to be saved with the .php extension Echo outputs to webstream \ escapes quotes ; necessary statement ender
Bacon salt is a thing!
This week we learned how to access Firefox from the terminal with a super easy command, firefox &. We also started loops, more specifically loops within html tables. The if statement is a condition that resolves to true or false. The numeric for, while and do while loops are condition-based, but the list-based for loop is not. It still has stuff to go through.
ctrl K – cuts current line and stores in buffer
ctrl U – uncut from cutbuffer into current line
ctrl C – displays position of cursor
ctrl A – moves to beginning of current line
ctrl E – move to end of current line
Produce a checkerboard table using a combination of PHP, HTML and CSS.
Attempt 1:
Generated a 10px border around a 480px high and wide table. The two for loops added 8 red rows and 8 black rows running side-by-side and half the length of the table. Not exactly sure why that happened but at least there was output.
Multiple Attempts:
Generated a 10px border around a 480px high and wide table with a black square in the bottom right hand corner. I used two for loops to output the table row and table columns. I then added an if, else statement to add the red and black backgrounds. It was supposed to print a checkerboard but only printed a single black square in the bottom right hand corner of the table.
Another Attempt:
Did some research and found that you need to add the rows and columns before you use an if statement to output them in checkerboard fashion.
for ($i = 1; $i <= 8; $i ++) for ($j = 1; $j<=8; $j ++) $rowcol=$i + $j;
This week we ventured into the world of arrays and functions. An array is a container. It stores multiple values in one variable. The values are accessed using an index number. In PHP, arrays have value to key associations.
There are three different types of arrays…
Multidimensional →contains one or more arrays
Indexed →has a numeric index
Syntax:
$item [0] = “mango”; $item [1] = “banana”; $item [2] = “apple”;
Associative →has named keys
Syntax:
<?php $array( key => value, key => value2, key => value3, … ); ?>
The key can be an integer or a string and one array can contain both at the same time. The value can be of any type.
Always use quotes around a string array index. e.g. $item[‘papaya’] Do not put quotes around keys that are constants or variables.
Syntax:
Function functionName( optional: parameters/arguments ) { code to be executed; }
Function names can start with letters or an underscore but NOT a number. Information is passed to the function through comma-separated arguments.
Draw a picture using PHP. See php.net’s image processing and GD documentation for help.
Using the example code done in class (function.php) I attempted to create an abstract image using rectangles and ellipses. The xy coordinates were a little baffling at first but once I confronted the documentation things seemed to make some sense. I was able to create several rectangles of varying widths and lengths and even executed a transparent ellipse using imageallocatealpha over the center of the design.
Pro tip:
Next attempt might be an homage to the square.
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:
This week we were introduced to the pod and given directions on how to open a terminal session and ssh into Lab46. To become familiar with editing our Opus project UXIO had us customize our title and subtitle in addition to adding a brief introductory statement. We also subscribed to the class mailing list and sent a brief introductory message to the class. This task familiarized us with maneuvering within the mail program Alpine. Using the IRC or class chat is still somewhat unclear but the setup went smoothly.
Don't forget to read the MOTD!
Check your Lab46 email frequently!
This weeks project (arc0) relates to archive handling. Archives are containers that encapsulate things or files. Compression is an action performed on a single file.
The tar (GNU version) command stores and extracts files from a tape or disk archive. It also combines multiple files into a singe file.
xz is a data compression tool. It compresses or decompresses a file.
gzip compresses or expands files.
zip packages and compresses (archive) files.
tac concatenates and prints files in reverse.
rev reverses lines characterwise
To decompress the .tar.xz file use the tar xf filename command in the directory you want to extract the files to. Use the tac (cat backwards) and rev commands to help unscramble the files.
Mars’ two moons are Phobos and Deimos and are named after Greek mythological characters. The Latin translation of each is fear and panic respectively.
This week we learned about pipes, filters and the file system. Actually we learned about multiple pipes but the one most pertinent to us is the | command. Pipes are extremely useful and powerful. They allow the connection of two or more commands, which allows for the output (stdout) of one element to be the input (stdin) of the next. Each pipe tells the system to connect the standard output of the left element to the standard input of the right program. Pipes are unidirectional, meaning that data flows through the pipe from left to right.
Command Expansions: back ticks/back quotes
The File System:
Dir –points to many files. Home dir mounted from the file server.
. shows current location; doesn’t change
.. parent goes up in dir; takes you to home
Project Notes
This week’s project is the legendary puzzle box (pbx0)! As soon as I solve it, I will update this section with my notes.