Eric's Blog

Kaku 1.2 Released

It has been a long time coming, but today I am pleased to announce that Kaku 1.2 has finally been released on GitHub, and it only occupies 328 kilobytes of disk space!

This new version of Kaku features an all new system for generating content, numerous bug fixes, improved performance, and a smaller file size than ever before. For a more detailed summary of changes, please view the release notes on GitHub.

Since its inception, Kaku has remained true to its original goal of being lightweight and flexible. Each release has seen the system shrink in size yet grow in functionality and performance.

As I look to the future, my hope is to continue to improve upon Kaku, its performance, and its functions. In particular, I would like to make Kaku more user-friendly and accessible to the average user. Perhaps version 1.3 will see these hopes realized.

Which features do you look for in blogging software? Let me know in the comments!

A Game About Pushing Blocks

I've been on a big Sokoban kick these past few days. Sokoban, if you didn't know, is an old puzzle game all about pushing boxes into designated spaces. It was well-received upon its release for its many well-designed puzzles and spawned many clones.

I thought it'd be fun to make my own clone of Sokoban, so I did. I call it "Blox".

A screenshot of the third level of Blox.
A screenshot of the third level of Blox.
Blox is a very simple block-pushing game inspired by Sokoban. In Blox, you play as a smiley face whose job is to push blocks into the designated areas. It features simple graphics and sounds, and a handful of levels. I made it in two days just for fun.

You can click here to play Blox or you can click here to view Blox's source code.

What are your thoughts about Blox and its puzzles? Let me know in the comments!

Easter Hack 2017

It was only a few months ago that I created my last game for a game-making event, and already I am back at it again—this time with Keebo's Quest.

Keebo's Quest was created over the course of a single week for Easter Hack 2017, a game jam where the goal was to improve upon an existing game and to give it an Easter twist. I chose to improve upon Mori, the first game I ever created for a game-making event.

A time-lapse video of the development of Keebo's Quest.
Improvements include an experimental doodle-like art style, a movement system that is not locked to individual tiles, and the ability to blow things up with bombs. Several of Mori's original features, like trading and having conversations, remain intact.

You can play Keebo's Quest in your browser right now at this link. While you are at it, feel free to leisurely peruse the development logs here.

Let me know what you think of the game in the comments! Happy Easter!

How to Leverage Server Side Caching in PHP

Back in the early days of the Web, many sites were made up of mostly text and maybe just a few images, making for a speedy browsing experience. The need to speed up sites with caching was almost nonexistent back then, but gone are those days.

These days, many sites use content management systems to dynamically generate pages on the fly, often resulting in increased load times. As a result, there is a greater need for snappy caching solutions now more than ever. I think I have one such solution.

Here is my code to quickly and easily cache Web pages dynamically using PHP:


class Cache {

  private $path; // The full path to cached files.
  private $expiration; // How long files will persist before expiring.

  public function __construct($directory, $expiration) {

    $this->expiration = $expiration;

    // The full path is the cache directory and the current hashed URI.
    $this->path = __DIR__ . "/$directory/" . md5($_SERVER["REQUEST_URI"]);

    // Scan the cache directory for cached files.
    $cached_files = glob($this->path . "*.cache");

    if ($cached_files != false && !empty($cached_files)) {

      // A cached version of this page exists, so display it.

      // Stop the rest of the page so only the cached file will be shown.

    // This page hasn't been cached; store its contents to be saved later.
    ob_start([$this, "save"]);

  private function load($file_name) {

    // Display the cached version of this page.
    require $file_name;

    // Get the time of when the cached file was created.
    $creation_time = str_replace([$this->path, ".cache"], "", $file_name);

    // Check to see if the cached file has expired.
    if (time() > $creation_time + $this->expiration) {

      // The cached file has expired, so delete it.

  private function save($page_contents) {

    // Save the contents of the page to a cached version.
    file_put_contentss($this->path . time() . ".cache", $page_contents);

    // Display the page like it would be normally.
    return $page_contents;

The above script functions by first checking whether or not the current page has previously been cached. If it has, it displays the cached version and then determines if the cache has expired; otherwise, it immediate caches the page for later use.

Now put the following at the top of your Web pages to cache them automatically:


// Include the Cache class.
require "cache.php";

// Instantiate the Cache class. Set the cache directory
// to "cached" and the expiration time to one hour.
$Cache = new Cache("cached", 3600);


That is all there is to it to achieving convenient, automatic server-side caching. Be sure to set the cache directory's permissions to "writable", or else it may not work. I found that cached pages load an average of 24 times faster than non-cached pages in testing.

Beyond improving load times, server-side caching is great for reducing database queries and memory consumption when using a content management system.

Feel free to use my caching code in your own sites and projects, and let me know what you thought of this post in the comments!