Kibibyte or Kilobyte?

Ever purchase a 1TB hard drive and find yourself disappointed when it showed up under ‘My Computer’ as 931GiB? If so, you may not have really understood why and felt cheated by the manufacturer. However, there is a simple and innocent reason for this. Computers evaluate numbers on a different base than humans.

As human beings, we generally perceive numbers and mathematics on a 10-base number system. Why? The simplest answer is probably that we have 10 fingers and toes. Thus, 10 is a number which is easy for us to make sense of. This is not the case with computers. Most people are aware that computers perceive data in binary form, or 2-base numbering. There’s always only 2 possibilities. A circuit is either on or off.

How does this relate to the hard drive?

Continue reading “Kibibyte or Kilobyte?”

MySQL DB Backup Script

The following is a bash shell script which I wrote to backup all databases on a MySQL server. It’s fairly simple to implement. First step is to fill in the necessary arguments in the commented region of the header. You will need:

  • The name of a MySQL user account with sufficient privileges to perform a backup. ‘root’, will likely suffice.
  • The password of the previously mentioned user.
  • The directory and file where you’d like the backup saved to. By default, backups are made to a /root/backup directory and files are named by *date*_db_backup.sql. If this directory does not exist, you’ll have to create it.
  • The specific database you’d like to backup.
#	MySQL user to execute dump
#	Password of MySQL user
#	Directory to place the updates
	db_backup_dir="/root/backup/$(date +%m_%d_%y)_db_backup.sql";
#	Specific database to backup. Removing this line and its usage in the mysqldump string will backup ALL databases with the added: --all-databases parameter.
mysqldump -u$db_backup_user -p$db_backup_password $db_backup_db > $db_backup_dir ;

Next, name the file with a .sh file extension and place it in a secure directory on your server. I recommend the root user directory (/root). This is a precaution since the file must be configured with the MySQL a user’s password in order to run properly.

Your next question may not be how to run it. You can manually run backups by executing the shell file within the shell (make sure it has execute permissions). An alternative is to automate database backups using crontab. Crontab is the better option for preventing catastrophic data loss since individuals may get lazy or genuinely forget to perform timely updates.

Please note, that there are many additional steps which may be taken to ensure the best integrity of backups. This tutorial merely shows a method for accessing the database files.

Java Normal Probability Approximation Method

Recently, I’ve decided that I want to write my own statistics package in Java (I’m too bored for my own good). Originally, I wanted to write my own classes to handle the probability calculations under curves. However, this became a bit much when it came time to do f and student-T distributions. As such, I gave up and am now using a Java class provided by CERN laboratories under the GNU license.

Before I gave up, I wrote a simple method for calculating the area under normal distribution curves based on Z statistics (the result of a statistical Z-Test). It uses the Error Function to approximate left-tail probability (-infinity  -> Z-statistic). Continue reading “Java Normal Probability Approximation Method”

Subnet Calculator and

I was recently contacted by the owner the website,, and asked to further develop my Subnet Calculator (mentioned in previous posts) from a WordPress template page to a full-blown plugin. NetTrain provides technical training to individuals seeking to acquire various Cisco Certifications. Thanks to their funding, I was able to allot time and convert the php code into a WordPress plugin, making several improvements along the way.

Much to my delight, not only is my work being paid for and used on another website, but the owner of NetTrain has allowed me to keep all the source-code open and free. As such, you may now download the new plugin via the following link: download

Also, if you’d like a working example of the code, please visit the Subnet Calculator Page on my website or the implementation of

Securing phpMyAdmin on Ubuntu 10.04

This will be the first in a number of tutorials which I plan to post regarding IT topics and solutions to problems which I run into both in a business environment and personal tinkering.

I currently run a Linux home server for the purpose of website development and testing prior to making content available online. However, it occurred to me following installation that the ‘www.hostname.tld/phpMyAdmin’ directory, while requiring authentication, is open to the internet and likewise, subject to brute force attacks. This tutorial will attempt to offer a number of solutions to securing such an installation. Continue reading “Securing phpMyAdmin on Ubuntu 10.04”

Subnet Calculator

Recently, I’ve decided to begin working toward the CCNP certification and have required significant review of CCNA material. As such, in order to review some of the subnet math, I decided to write a subnet calculator in PHP.

I’ve spent most of today working on it and hopefully it works well in all cases. However, the form handler may still allow some improper values. As long as proper input is provided, the calculator should produce accurate results. To view the calculator, visit the ‘Subnet Calculator‘ via the link provided above.

As always, I’m providing the source to my program. It’s currently set up to be used as a page template. Paste the code into a .php file and place it in the directory of a WordPress template to use it. Click here to download the source or ‘Continue Reading’ to view the source. Continue reading “Subnet Calculator”

Steam XML Parser

As mentioned in a previous post, I’ve developed a WordPress plug-in to display a user’s Steam Stats as a widget. It’s available for download here. However, this does no good to anyone without a WordPress-based-site and I wanted to make the source freely available. As such, I’ve included it below. Valve provides Steam profiles as an XML feed which can be parsed and formatted according to a developer’s needs. To personalize the script, simply edit the URL following the “$profileURL” variable.

/* Steam Community Widget
	//Variables. Edit Profile URL to match the link to your personal Steam Community Page.
		$ProfileURL = '';
		$xml = simplexml_load_file($ProfileURL . '?xml=1');
			//Begin Widget Content
					echo '<p><strong>SteamID:</strong> ';
					echo $xml->steamID . '<br /><strong>Member since:</strong> ';
					echo $xml->memberSince . '<br /><strong>Steam Rating:</strong> ';
					echo $xml->steamRating . '<br /><strong>Playing time:</strong> ';
					echo $xml->hoursPlayed2Wk . " hrs past 2 weeks</p>";
					for($i = 0; $i < 4; $i++){
						if ($xml->mostPlayedGames->mostPlayedGame[$i]->gameLink != "") {
							echo '<p><a href="' . $xml->mostPlayedGames->mostPlayedGame[$i]->gameLink . '"><img src="' . $xml->mostPlayedGames->mostPlayedGame[$i]->gameIcon . '" /></a> ' . $xml->mostPlayedGames->mostPlayedGame[$i]->gameName . ' ' . $xml->mostPlayedGames->mostPlayedGame[$i]->hoursPlayed . ' hrs</p>';
				echo '<p><a href="' . $ProfileURL . 'games">View all games</a></p><p align="center"><em>&copy ' . date(Y) . ' <a href=""></a></em></p>';
			//End Widget Content

Steam WordPress Plugin / Widget

Today I completed my very first WordPress Plugin to display a user’s Steam Gameplay Stats. To those unfamiliar with Steam, steam is a windows community application for video gaming. It allows users to store and purchase titles from many different publishers online and also offers an excellent community element to chat, browse the web and compare stats with friends. More information is available here: Steam is likely the future of pc gaming as it allows a much more secure and economical publishing method for many game studios.

I’ll likely be posting the widget for free distribution on WordPress’s site soon. I’m in the process of making the widget more accessible to normal users as it currently requires the manual input of a user’s steam account URL into a text file.

Update: I’ve release version 1.01 of my Steam Community Gamestats Widget. I’ve been sick recently and had a lot of time to revise the code and better adapt it to WordPress’  Widget Class implemented in WordPress 2.8.

Cisco CCNA Certified

Today I passed my Cisco CCNA exam with a score of 917 / 1000 which has left me incredibly content! The whole Cisco course has really taught me a lot about networking and I am pleased to have accepted it as a challenge. Furthermore, I did all of this a month before my goal of Thanksgiving and only a month after my last certification. One could say that I’m really on a roll. I hope I can continue to excel in college while getting my technical education on the side with these certifications.