I was recently working on a project that generated PNGs using Java from a Java2D canvas. Along the way someone wanted to change the graphics to have transparent backgrounds and because they were needed for display on the web I knew this would become an issue because IE doesn't support transparency in PNGs out of the box. And so my journey started.
After reading a post on hacking Akismet to add graphs I decided I liked the idea but I didn't want to store the data in a database. It seemed like it would be better to store it using a RRD and then use the PHP RRD library. So after a little hacking I've created a version that does basically the same thing except uses a RRD.
Now that you can create a streaming Flash video player with PHP or Ruby and you know add metadata for cuepoints to Flash videos you are ready for something else. The following code will show you how to create a video player with PHP that will watch for metadata events and display annotations contained inside the metadata either over the video itself or in a div on the same page as the movie.
I mentioned in creating Flash videos using FFMpeg that you could use Ming to create your own Flash video player. I've added a patch to the ruby -ming extension for video streaming so now it is possible to create a streaming player with both PHP and Ruby using their Ming extensions. The following examples show you how.
Some time ago I was looking at how to re-size uploaded images in a way that looks good using PHP. I was impressed that when I uploaded a 4M picture to flickr it managed to re-size and compress it into a smaller version that looked correct. I knew they weren't just resizing it so I went on a quest to find out what it took to do the same thing with PHP. The following is step one in that process.
On a number of occasions I've wanted to map a section of a site hosted with lighttpd onto a single PHP file that could then be used as a controller. Here is how I go about doing it.
The first part is to re-write the given part of the site to the PHP file you want to be the controller. Add the following to your configuration file:
url.rewrite = (
"^/(.*)" => "/controller.php"
You can then start with a simple example to see where you will get your URL information from:
<?php echo $_SERVER["REQUEST_URI"]; ?>
The $_SERVER["REQUEST_URI"] value will be the requested URI. You can now break it up into multiple parts with explode:
<?php $urlParts = explode("/", $_SERVER['REQUEST_URI']); echo $urlParts; ?>
At this point you have an array of the URI parts and can map those however you want using PHP.
On a number of occasions I've used RRDTool to graph network traffic and the like. A few years ago when I started using cacti I started wondering how to make the graphs myself. Creating the graphs on the command line isn't that hard once you know how to set things up and it turns out doing the same in PHP is just as easy.
I think by now most sysadmin types know about rrdtool and the nice graphs it makes. I recently wanted to create some graphs by hand using PHP so I turned to the php-rrdtool extension. I found that it takes a little work to get it to compile but that could be because I'm not constantly recompiling PHP and just don't know better. You can get this module as an rpm for fedora (php-rrdtool) but I like to compile php by hand so I couldn't use it. I'm going to assume that you know how to compile PHP normally with whatever other items you want to include and that you have the rrdtool development libraries installed or have compiled and installed rrdtool from source.