Skip to content

PHPlot, MySQL and the Dark Ages of Camelot

The Dark Ages of Camelot (DAoC) is one of a number of Massive Multiplayer Online Role playing games (MMORPG) available for people who like those types of things. Mythic Entertainment, the company behind DAoC decided to offer an xml feed with various statistics about the game including the number of active players. From April 2002 to July 2005 I used a cron job to query the xml feed once every 5 minutes, parse the results and store the statistics in a database table.

I made a graph of these statistics available on a fan site I operated. The graph used the open source PHPlot graphing class in order to draw a line graph charting the number of players playing the game by hour for a 24 hour period. Visitors to the site would see the line graph shown here, plotting the number of players per hour against a second line showing the day's average. Like many PHP graphing libraries, PHPlot assumes that you have the GD library installed and available to PHP on order for the graphs to work.

This was one of my early experiments with PHP, and illustrated its power and flexibility. Now that the site where the graph appeared is no longer online, I figured I would provide the code, and a small subset of the database, for people interested in how to program with PHPlot. At the time I created this code, PHPlot didn't have much documentation and required some trial and error experimentation. Of course, since then (several years now) PHPlot has been improved, and should definately be considered if you want graphing in your application. Because I don't want to spend time debugging old obsolete code, I've provided the library I used in the download along with the graph script. It would probably work with the latest release, but I don't have time to test it. You can download my example database, version of PHPlot and script here. The database contains one months data, so you can play with the script and explore the class.

Read on for some brief instructions and an explanation of the code. Continue reading "PHPlot, MySQL and the Dark Ages of Camelot"

Exploring Mysql CURDATE and NOW. The same but different.

Sometimes I see people attempting to use VARCHARS or CHARS to store dates in their MySQL database application. This is really fighting against MySQL, which has a variety of interchangeable date types. Internally MySQL is storing dates as numbers, which allows it to do all sorts of nice arithmetic and comparisons with very little effort on your part. For example, when you use a mysql DATE column to store a date, you don't have to worry about sortation, or comparing that date to another DATE, because MySQL already understands how to do those things internally. A lot of people also don't realize that they can output a DATE column in just about any way they choose using the DATE_FORMAT function. This causes people to shy away from using DATE, DATETIME, TIME, or TIMESTAMP columns, when they really should.

Continue reading "Exploring Mysql CURDATE and NOW. The same but different."

My First Serendipity Plugin

I've exploring the Serendipity API by writing an "event" plugin wrapper around GeSHi. GeSHi is an extremely cool php class that does color syntax highlighting for any computer language you want. Since I hop from language to language, this is exactly the type of capability I want. So without further ado, here's a test of my plugin, currently in alpha state:

First some PHP

    function generate_content(&$title) {
        $title = PLUGIN_EVENT_GESHI_NAME;
    }
 


Now some SQL

SELECT * FROM temptable WHERE USER= 10
 


and how about a hot cup-o...

Java
  1.  
  2. /**
  3.  * Java example for GeSHi
  4.  */
  5.  
  6. import javax.swing.JOptionPane;
  7.  
  8. public class Foo {
  9.         public static void main ( String[] args ) {
  10.                 JOptionPane.showMessageDialog(null, "hello, world!");
  11.                 int n = args[0];
  12.                 for ( int i = 0; i < n; i++ )
  13.                 {
  14.                         System.out.println(i);
  15.                 }
  16.         }
  17. }
  18.  


I have a lot to do (and learn about Serendipity) before I feel the plugin will be ready to release in beta state, but at least I thought I'd try it out and show a proof of general concept.


Defined tags for this entry: , , , , ,

New DSL

It's been a while since I updated. I have plans to move the site to a new server I bought and have been configuring. Part of the process involved getting my new ISP in place (thankfully, and after numerous false starts) I now have DSL again, courtesy of Megapath Networks. The new server is setup with RedHat 7, and is hosting several small gaming sites: Cali Tribes Players and LaLa-Lan. Eventually I plan to move Gizmola.com onto it. So obviously, I've been working on a few side ventures.

I'm also playing a lot of Ice Hockey at Culver city and Burbank, and learning PHP and MySQL in the process. I think I can now be considered officially nocturnal, as I find myself up most nights. Lately I've been playing a fair amount of Tribes2, and my Tribes2 team has climbed into the top 10 of the teamwarfare ladder. This is somewhat contributory to the nocturnal lifestyle, although I think the primary reason is that I'm just basically a night person, and without the constraints of a regular job to attend, my free running cycle allows for me to sleep when I'm tired. As I write this, it's 5:40am and I'm still awake.
Defined tags for this entry: , , , ,