This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
blog:spring2016:hheath:journal [2016/04/14 00:48] – hheath | blog:spring2016:hheath:journal [2016/05/05 03:59] (current) – hheath | ||
---|---|---|---|
Line 529: | Line 529: | ||
Not sure what direction I want to take at this point. | Not sure what direction I want to take at this point. | ||
+ | ====APRIL 13, 2016==== | ||
+ | |||
+ | ==Week 12== | ||
+ | |||
+ | For the Show and Tell project I chose to explore photo galleries using PHP. In my explorations I found several ways to implement a photo gallery using strictly PHP, PHP and jQuery, PHP and SQL, and PHP and Ajax. In addition, galleries have multiple storage options. Some galleries are created and stored in databases using MySQL and other galleries are created and stored in folders on the web server. I found a really old but very informative tutorial on creating an automated PHP gallery system using PHP, MySQL, GD and ImageMagick on the SitePoint website. It walks you through the process of setting up the database schema and building a browser-based uploading system, which sets up an index within the tables, stores the files, and automatically builds thumbnails. | ||
+ | |||
+ | Ultimately, I settled on something a little less complicated for a first timer. I chose to create a photo gallery using strictly PHP. I am working through the code to display the images as thumbnails until clicked where they are displayed full size. I need to upload some images to the server to test the code. I anticipate a good amount of troubleshooting to get everything processing correctly. Also, I need to figure out how to create the thumbnails. I have seen code that automatically does this process, which I’ll have to explore further. If I can get the initial photo gallery working I’d like to attempt to add a watermark feature to each image, but that is not a critical component at this time. | ||
+ | |||
+ | ====APRIL 20, 2016==== | ||
+ | |||
+ | ==Week 13== | ||
+ | |||
+ | The end of the semester is fast approaching as noted by the influx of final papers/ | ||
+ | |||
+ | First up is the variable declaration. These variables are used to declare the columns displayed, location of the thumbnails, and location of the full size images used in the gallery. | ||
+ | |||
+ | $images = " | ||
+ | $big = " | ||
+ | $cols = 2; // Number of displayed columns | ||
+ | |||
+ | $images builds the contact sheet or “thumbnails”. | ||
+ | |||
+ | Next step is to open the directory containing the images and loop through it to add the image files to an array. The first line of the if statement opens the directory where all of the images are stored. The while condition loops over the directory and adds every file it finds to an array called $files[]. The readdir function reads entries from the directory handle and returns the name of the next entry in the directory. Entries are returned in the order they are stored by the filesystem. Any directory entry name that evaluates to FALSE will stop the loop. The nested if statement prevents the . (the current directory), .. (the directory one level up), and the $big directory from being added to the array. If displayed in the browser, they would show as broken links. Any file in the $images directory is added to the array and rendered as an image so be careful what you place here. The closedir function closes the directory handle opened by the opendir function. | ||
+ | |||
+ | if ($handle = opendir($images)) { | ||
+ | while (false !== ($file = readdir($handle))) { | ||
+ | if ($file != " | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | |||
+ | Now it’s time to output the table that displays the images. The goal here is to display the thumbnails as a contact sheet while linking each to its full size image. The first echo statement outputs the first part of the table. The first line in the for loop tests whether $colCtr (initialized to 0 before the loop) is of equal value to $col (number of columns to display). If yes, the table row closes, a new row is opened and an hr line break is used to separate the rows. The next echo statement creates a link to the full size images. The output is an a href attribute that specifies the link’s destination. In this case the link is built using the variables defined earlier in the code, $image, $big, and $file. The img src attribute outputs the image using $image. $file. The last step before closing the table is to increment the $colCtr variable to output the number of columns needed for displaying the images. | ||
+ | |||
+ | |||
+ | $colCtr = 0; | ||
+ | |||
+ | echo '< | ||
+ | |||
+ | foreach($files as $file) | ||
+ | { | ||
+ | if($colCtr %$cols == 0) | ||
+ | echo '</ | ||
+ | echo '< | ||
+ | <img src="' | ||
+ | $colCtr++; | ||
+ | } | ||
+ | |||
+ | echo '</ | ||
+ | |||
+ | In comparing the process of creating a basic photo gallery using PHP and HTML/CSS it appears PHP has the advantage. The code is more streamlined meaning it uses far less steps to accomplish the same end result. | ||
+ | |||
+ | |||
+ | ====APRIL 27, 2016==== | ||
+ | |||
+ | ==Week 14== | ||
+ | |||
+ | The countdown to the end of the semester is approaching warp speed. The end is nigh. It’s final crunch time for end of semester presentations and projects, which some are scrambling to complete. I am slowly whittling away at the EoCE. I have started 0x0, draw a picture reflecting your interpretation of “April showers bring May flowers.” Conceptually, | ||
+ | |||
+ | I have discovered that the imagefilledpolygon function in PHP has the capability to draw a triangle using an array to define its points. My initial use for the triangle was to add texture to the grass section of the image, but after seeing the output I have discovered other uses for the imagefilledpolygon. Immediately after seeing the sharply pointed, pink object appear on the screen I wanted to use it to represent the sun’s rays. The challenge is figuring out how to wrap it around the outside edge of the imagefilledarc. This is something I need to explore as it may be beyond my skill level. | ||
+ | |||
+ | I have also started thinking about the binary table as I feel this may cause me to bang my head against a wall. I am exploring methods and ideas but haven’t settled on something solid yet. | ||
+ | |||
+ | |||
+ | ====MAY 4, 2016==== | ||
+ | |||
+ | ==Week 15== | ||
+ | |||
+ | This entry marks the last week of classes for the semester and therefore the last blog post for PHP. It’s been a semester full of fun and exciting new explorations. I’ve learned that PHP is not just for querying a database, drawing pictures is an excellent way to learn a new programming language, and there is a whole world of memes that lure you into a time suck. | ||
+ | Still working on the EoCE. Progress has slowed as I needed to focus on other courses, but with most other projects behind me I can return to drawing pictures, creating meme’s and binary tables. | ||
Line 1057: | Line 1129: | ||
This concludes the review session. | This concludes the review session. | ||
+ | |||
+ | ====April 20, 2016==== | ||
+ | |||
+ | ===Week 13=== | ||
+ | |||
+ | |||
+ | For the last two weeks or so we have been exploring the use of regular expressions. Regular expressions are used in conjunction with several different commands such as sed, ed, awk, and grep. We have focused primarily on sed and grep. Here is a brief recap of the commands and their syntax. | ||
+ | |||
+ | The grep command mentioned in an earlier post, but not fully explored searches standard input or text within a file for string patterns and prints any lines matching the specified pattern to stdout (the terminal). | ||
+ | |||
+ | It’s syntax is: | ||
+ | |||
+ | grep [options] PATTERN [FILE…] | ||
+ | grep [options] [-e PATTERN | -f FILE] [FILE…] | ||
+ | |||
+ | The sed command or stream editor is invoked by sending data to it through a pipe. The data sent passes through sed and goes to stdout without changing the input file. | ||
+ | |||
+ | It’s syntax is: | ||
+ | |||
+ | / | ||
+ | |||
+ | Where pattern is a regular expression and action is a command given. The slash characters are used as delimiters. Sed is line oriented meaning if you are using the substitute (s) command it will only replace the first instance of the string being replaced. If you have an input line that reads “One fish, Two fish, Red Fish, Blue fish.” and you want to replace “fish” with “FISH” by default sed will only replace the first instance of fish with FISH. | ||
+ | |||
+ | **Miscellaneous Notes** | ||
+ | |||
+ | Single quotes are literal quotes. Searches for what is literally within the ‘quotes.’ | ||
+ | |||
+ | Printf “%&s “ “ “ right justifies by default. “%$s “ ” ” adds padding value. | ||
+ | Printf “%-3s ” | ||
+ | |||
+ | |||
+ | ====April 27, 2016==== | ||
+ | |||
+ | ===Week 14=== | ||
+ | |||
+ | The end of the semester is upon us and the EoCE for UNIX has been deployed. Gulp! I have started to tackle the first problem, 0x0: Script Analysis, and found that once I created and ran the script I had a much better understanding of what it was doing. With my nerves eased I was able to settle in and begin answering the questions pertaining to the various components of the script. I have my responses captured in screen shots and randomly written on paper I just need to add them to the blog. This brings me to the next problem, 0x1: super puzzlebox 2 turbo, I had a feeling we weren’t done with the puzzlebox yet. I equate these to solving a Rubik’s cube. For some people finding the solution only takes seconds while others may spend minutes, hours or even days twisting the colorful cube to perfection. The last category of people spends many frustrating hours twisting that cube until they have two squares left to align. They are forced with the ultimate decision do I keep twisting knowing that I will destroy all progress or do I carefully peel back the corner of the sticker? I will know my fate once I open and start unraveling the puzzlebox. | ||
+ | |||
+ | ====MAY 4, 2016==== | ||
+ | |||
+ | ==Week 15== | ||
+ | |||
+ | This entry marks the last week of classes for the semester and therefore the last blog post for UNIX. It’s been a crazy, whirlwind semester filled with sharp twists and mind bending (numbing) experiences. Entering the course with much trepidation at the suggestion of a higher power I initially expected to flail and run. Over the course of the last 14 weeks I’ve gained what feels like an enormous amount of knowledge about a new OS. My skill level is still firmly planted in beginner mode, but I can at least nod and say I know about the super powers of the dd command. | ||
+ | |||
+ | I am still working on the EoCE. Progress has slowed or come to a screeching halt as I needed to focus on other courses, but with most other projects behind me I can return to puzzle boxes and scripting. | ||
+ | |||
+ | |||
+ | |||