Work Results

Site Fight

Sometime back in 2006, I found some code on a now-defunct site that enabled PHP scripts to fetch a domain's Google PageRank. Using this, I created a very basic tool that compared to sites, and told the user who "won." (A.K.A. had the higher rank.) a la Google Fight or AIM Fight.
Tags: site, fight, google, pagerank

ImageEvolution


...Images don't necessarily die out like they do on Philipp Lenssen's Mutating Pictures. Instead, images simply become less likely to be shown to the user for comparison. Images that are not chosen as being more like the target object are slowly phased out, but there is still a possibility for it to be displayed. However, this chance decreases each time an image "loses."
...The basic idea is that as users continue to choose images with ideal qualities, at least one of the offspring will be even more favorable. If not, the offspring will be "naturally" phased out.
...On the technical side of things, it's fairly simple. Images are generated from an array of data using PHP's GD functions, and cached. This array is what is modified when an offspring is produced, stored in a MySQL database (In addition to other basic info such as the subject of the image) by using multiple levels of implode.
Tags: PHP, image, imageevolution, gd, evolution, mutating, picture,

PHP: uniqid() speed test

There have been several comments in the notes of the uniqid() manual page about uniqid() being very slow. I set off to see for myself if this were true, using several combinations of input. I tried different length prefixes, as well as toggling the function's more_entropy parameter. For those interested, the code looks something like this:
...[code]<?php
...image
Tags: php, uniqid, test, speed, compare, time

wma2mp3

A simple program that will call mplayer and lame to convert all .WMA files in the current directory into .mp3 files. MPlayer and LAME must be accessible, either in the same dir as the program or in %PATH% somewhere. Place this program in %PATH% and call it...
Tags: php, wma, mp3, convert, php5

Followup: PHP: rand() vs. mt_rand()

My past comparison of rand() and mt_rand() only compared the speed, and I saw very little difference. This time I'll compare how truly random the numbers each function produces are. The code used to test this is:
...[code]<?php
... imagecolorallocatealpha(
... imagecolorallocatealpha(
...On Linux (Slackware 10.2), the results looked fine, two seemingly random graphs were produced. On Windows (XP), however, the results were drastically different between functions:
...rand()
...mt_rand()
...So, if your code relies on random numbers, and you plan on using it on multiple operating systems, mt_rand() appears to be the way to go.
Tags: php, rand, mt_rand, test

PHP: rand() vs. mt_rand()

The documentation for mt_rand() says that it produces numbers four times faster than the standard rand(). So, being that I use random numbers in my code often, I decided to test this.
...[code]<?php
...On my laptop running a slightly outdated version of PHP 4.4 (around 4.4.0 if I remember correctly), the results were not as I expected. Most of the time, rand() was faster than mt_rand() by about 0.02 seconds. Of course, this isn't a big performance difference, but it's not the four times faster that was promised.
...On TechnoServ, the results were closer. Usually rand() won by 0.01 seconds or less. Once again, not the supposed "four times faster."
...So, despite the PHP documentation, rand() and mt_rand() are about the same speed, rand is just slightly faster.
Tags: php, rand, mt_rand, test

Clinton Country Club

My first paid job. The site itself uses a lot of previous code, but the backend I'm working on is really new. I'll explain more once I finish
Tags: ClintonCountryClub, job, php, backend

Portfolio V1

Version one of my portfolio didn't turn out the way I wanted. The code was messy, the layout was kind of boring, and there was no way to manage the content except by using a tool like phpMyAdmin.
...As if that wasn't bad, I had a PHP script accepting requests for images rather than just linking to the images. I also had my template mixed in with the code way more than it should have been.
Tags: portfolio, code, php, graphics

SHS Robotics

This year (2006) our robotics team (230) completely recoded our website, and I'm the main and only web site coder. The layout was desgiend and made by my sister, and implemented in PHP by me. All code on the site was from scratch, with no premade scripts. I got a lot of practice, and learned a lot doing this. I've used some of the code parts elsewhere in other sites I've made, and I'm sure some of that code made its way to this portfolio. For example, the database library I made is definitely used on this site.
Tags: robotics, first, 230, shs

Points extends Graph

An extention for the graph class that allows you to add labeled points. You can also create rays and lines between two labeled points. Include AFTER including the graph file, then initiate it with $graph = new points();
Tags: graphing, php, gd, points, lines, rays

Graphing Class

This is a class to create graphs. You can plot Linear or quadratic equations, line segments, circles, etc. The background on this page and my avatar in the news on this site was made using this class.
... · Added a parameter $truecolor to newplot(). If you input a 1, this activates the truecolor feature. I also changed all of the instances imagecolorallocate() so that if truecolor is on, imagecolorallocatealpha() will be used instead.
... · Changed changelinecolor() so that color changing works the way I stated above. I also added a $alpha parameter which allows you to change the transparency of lines.
Tags: graphing, php, gd, image, png, truecolor, gif, line, graph

MySQL Class


... · Implemented a beta form of error(). All it does for now is die() and print the error after closing the connection. ... · Changed num_rows() so if mysql_num_rows() returns 0 but mysql_affected_rows() returns a number other than zero, it'll use mysql_affected_rows(). This way the function can be used for INSERT, UPDATE, or DELETE queries. ... · Added a close() function. Use this to close the DB link when you're done with something like register_shutdown_function().
Tags: mysql, php, database, access, class