Category: Uncategorized

Introducing the Dota Database

I’ve spent some recent weeks building a cool new web site which exposes a lot of Dota 2 game data which may not be easily accessible to most players. You might be thinking, but I already use DotaBuff for all my Dota 2 needs! DotaBuff is great, but it doesn’t cover everything.

For starters, the new Dota Database that I’ve created is useful to see some of the finer details regarding heroes, hero abilities, items, item abilities, cosmetic items for purchase in the store, and more. This includes details like spell and ability behaviors, which shops you can purchase an in game item, hero level progressions, cosmetic item sets, and even pro player autographs. The information for these specifics comes directly from the game files and the Valve provided Dota 2 web APIs.

Live League Game Listing

This page will give you a paged listing of all currently live league games. Some games will display blank data when still in the hero picks/bans phase. Each listing shows the league, the team names, elapsed times, spectator counts, series scores, team scores, player scores, player picks, team worth, and team XP. Click in to the listing to see all the live updated details for the match.

See it in action


Live League Game Details

When you click in to a live league game, you’ll see a page full of information about that game. Every 20 seconds, the page will refresh and show you the latest updates about the match. All data is provided by Valve through its Dota 2 league web API.

LiveLeagueGameDetailsTopAt the top, you’ll first see the league and its details, team picks/bans, and some details about the match itself such as match id, series scores, spectator counts, and the duration of the game. Click any hero to go to the details page for that hero.

LiveLeagueGameDetailsMiddleLiveLeagueGameDetailsTopIn the middle, you’ll see the “meat” of the game such as individual player details, map positions, tower statuses, team worth, Roshan status, items purchased, and more. This is basically the section that you’ll want to pay attention to as the game progresses.

LiveLeagueGameDetailsBottomAnd finally, near the bottom of the page, you’ll see a table which contains the overall status of every player in the game. This allows you to quickly sort and compare every player against each other with things like XP, kills, deaths, gold, and more. It’s a good way of determining which team is probably in the lead. Just keep in mind that player stats don’t necessarily indicate which team is winning.

Heroes and Details

Interested in the heroes you can choose from in game? Want to know everything about them? Ever wonder what specific behaviors were attached to their abilities? Then this page is perfect for you.

HeroGridBy default, you can view all heroes by a grid of their icon. This provides a highly compressed and easily visualized selection of which hero you want to read more about. However, comparing heroes against each other is impossible in this view. To remedy that, check out the next way of viewing the data.… Read more

Object-Oriented Connection Class in PHP

I started out in professional web development by using ASP.NET, so I was spoiled by the fact that Microsoft offers a SqlConnection class to use for various database related connectivity features. When I started with PHP, I decided to do some research and write a similar (albeit, much simpler) Connection class. Keep in mind that this class example only supports MySQL.

I started by defining some members of this class and came up with six useful members.

  • Database connection object returned from mysql_connect
  • Boolean to determine if the connection is currently open or closed
  • Database server host name
  • Database catalog name
  • Database user
  • Database password
class Connection
    public $dbConnection = null;
    public $isConnectionActive = false;
    private $dbServer = null;
    private $dbCatalog = null;
    private $dbUser = null;
    private $dbPassword = null;

In order to use this class, we need to add a constructor. I began by creating a default constructor that simply initializes values of the member properties. Take notice that not all of the properties are initialized by the default constructor. $dbConnection is not initialized until the Open() method is called and $isConnectionAlive is already false by default.

    public function Connection($server, $database, $username, $password)
        $this->dbServer = $server;
        $this->dbCatalog = $database;
        $this->dbUser = $username;
        $this->dbPassword = $password;

Now that the class can be instantiated, we need to add methods to allow operations. Below are the two methods that will perform the opening of the database connection and the closing of the database connection. Refer to the comments inline to understand what is happening.

    public function Open()
        if (!$this->isConnectionActive)    // if the connection is not alive, try to open
                // open the mysql connection with the member properties, select the catalog defined in the member property
                $this->dbConnection = mysql_connect ($this->dbServer, $this->dbUser, $this->dbPassword, true);
                mysql_select_db ($this->dbCatalog);

                if (!$this->dbConnection)    // if the connection failed, throw an error
                    throw new Exception('MySQL Connection Database Error: ' . mysql_error());
                    $this->isConnectionActive = true;    // the connection did not fail, the connection is now active
            catch (Exception $e)
                echo $e->getMessage();
        else    // the connection was already open
            return "Error: The connection has already been opened.";

    public function Close()
        if ($this->isConnectionActive)    // if the connection is open, try to close it
            $this->isConnectionActive = false;
        else    // if the connection is not open, it cannot be closed
            return "Error: No connection has been established to the database. Cannot close connection.";

That’s it! This is now a fully functional database connection class that allows for instantiation with opening and closing behaviors. See below for an example of its use. Note that the below example is not contained in the Connection.class.php file and is instead located in some other page that will be instantiating a Connection object.

$connection = new Connection($dbServer, $dbCatalog, $dbUser, $dbPassword);

// queries and other database operations here


The cool thing is that this class can be expanded to work with other databases.… Read more

Solving a Simple ODE with Simulink

If you have just started learning Simulink, one of the easiest tasks is solving a simple ordinary differential equation. In fact, most of the beginning guides you will find through web searches will probably be similar to the example I am going to provide. Let’s start by assuming you have the following common spring-damper system. For reference, m is mass, c is the damper coefficient, k is the spring coefficient, x is the position, x-prime is the velocity, x-double-prime is the acceleration, and f(t) is a step-input function with a magnitude of 3.


We begin first by solving for the second derivative of x. In this case, it ends up solving to:


Now, it is time to place this into Simulink using the following blocks:

  • 2 integrator blocks
  • 3 gain blocks
  • 1 sum block
  • 1 step input block
  • 1 scope output block

Step 1) Connect two integrator blocks together to simulate a double integration as seen below:

Step 2) Add the appropriate gain blocks to simulate c*x’ and kx.

Step 3) Add the sum block to simulate f(t) – cx’ – kx.

Step 4) Add the gain block after the summation to simulate the multiplication of (1 / m) and the step input function as the third input to the sum block added in Step 3. Make sure the step input function has the properties of Step Time = 0, Initial Value = 0, Final Value = 3.

Step 5) Add the scope block for output after the second integration to view the plotted contents of the numerical solution.

Using the following values for variables and initial conditions, you should see the plotted results as follows:
x(0)=0, x’(0)=0, x”(0)=0, m=0.25, c=0.5, k=1
resultsRead more