Update: iStat on pfSense


pfSense 2.x runs on FreeBSD 8, instead of the previous 7. I wanted to get istatd working on my router, so I fetch'd libxml2 from here and the istatd binary (version 0.5.7) compiled against FreeBSD 7 from my previous blog post, here. For this to work, you'll also need the iOS app. When running istatd, it complained about some libraries. I simply created symlinks from the old library to the new one and everything worked fine, see below.

ln -s /lib/libz.so.5 /lib/libz.so.4
ln -s /lib/libkvm.so.5 /lib/libkvm.so.4

You can get a template for the configuration file here and put it in a nice place, like /etc/istat.conf 

Create your user, group and socket file and you're good to go:

pw user add -n istat
pw useradd istat -G istat
touch /tmp/istatd.sock

Then, you can run the istatd daemon with just

istatd -d -c /etc/istat.conf

 Now, you'll be able to monitor your pfSense box with iStat!






DeLicate Linux, still usable at 166Mhz

Linux, one way or another, really brings out your inner hacker. I've been tinkering quite a bit with DeLicate Linux. It's a lightweight distro made for old computers that uses the 2.4 kernel. Right now, I have DeLicate running on a Pentium 166 with 64MB of RAM. Surprisingly, Fluxbox and Xchat run without any huge problems. Replacing Bash with Dash helped free up some RAM as well. DeLicate uses pacman as the package manager, so building new packages is as easy as creating a PKGBUILD file.

I have also set up a DeLicate package repsitory and a Git repository for the PKGBUILD files.  So if you have an old Pentium laying around, go fire it up and check out DeLicate. There's an active community too.

SEOBudd WordPress plugin

I thought I'd mess around with WordPress and create a plugin or two. I ended up creating SEOBudd, a SEO stats plugin for WordPress. It retrieves stats about your website, such as average load time, social media mentions and incoming search words. It' has been approved and is now available for purchase on CodeCanyon.



I must say, working with the WordPress plugin API was no fun. Everything felt just so clunky. Unless I'm missing something, you're almost forced to use global variables and procedural functions. The amount of things you can do with the API is quite astounding (the shortcode functions are quite interesting), but the online documentation is difficult to navigate. I finally found the function reference that lists every available function after some searching.

At first, I opted to using my own CSS for the admin panel of SEOBudd. Of course I didn't really investigate more and ended up with a design that didn't fit WordPress at all. After some searching, I found this page "How To Design And Style Your WordPress Plugin Admin Panel"; you can inherit the administration CSS rather than using your own. I found that his created a more native experience.

Another function I found interesting was the options functions. Instead of creating your own database or table, you can let WordPress handle it for you. No need to worry about data types either.

Though it may have not been very much fun, it was easier, if I may say, than creating a Drupal module. I think that Drupal has a much more rigid structure that guides you along.

Anyway, I don't expect too many sales of SEOBudd, so I'll probably put it up on Github sooner or later.

4000 series CMOS 24 hour clock

 For the last couple months a friend and I have been working on a 4000 series based clock in electronics class. After having failed building a FM receiver, we opted for a clock. We didn't go the microcontroller way, but old school ICs. So, we created a circuit for a simple clock. I opted for a 24-hour version, while my friend made the 12-hour equivalent. 

The above image was the basis of the circuit. Not shown was a 4060 and 4013 IC to make a nice 1Hz signal which we can use for the seconds. The rest is fairly simple: allow the seconds and minutes to count to 59 and use AND gates to reset at 60. Also pictured is the buttons to set the time. We used two 2N2222 transitors to make a NOT gate. Though, this ended up being too glitchy so I opted for a 4011 to create stable square wave.

And here's the clock. Incredibly disorganized but it works.

A couple months learning and work and we finally have it working! We used a 7805 voltage regulator for the entire circuit since I didn't want to add resistors to the displays. 9 volts would be much better though. 

I started using EagleCAD for the schematic but I messed up. I was adding lines instead of nets. So, my friend found DesignSpark and we used that. As far as free goes, the program is pretty easy to get going. One pain in the ass was that DesignSpark didn't have the right 7 segment display. We ended up creating them from scratch, see the attachments to download it. 

I didn't have enough time to create a PCB out of it which is disappointing. Although, my friend ended up making his, albeit with his schematic rather than mine, the PCB turned out to be a bit larger than an A4 sheet of paper. Not small at all.

Anyway, it was a fun project to make and I definitely learned quite a bit along the way. 

See the attachments at the bottom to download the schematic as a PDF or the DesignSpark project.

Edit: Note that the 1N4004 diodes should be 1N4148 instead. DesignSpark does not have these diodes in the libaries.

Pasteros is now on Github

I recently put Pasteros up on Github [link], the text storage service. What was once a singular file is now a collection of models, views and controllers. You can see it running here: paste.gelat.in. Feel free clone the repo and use it for your own projects.

Of course, it's not made as a turnkey solution so tables need to be created. Pastes can be forked and also compared to the parent paste (diff). It' has also been a huge stepping stone to not writing such terrible code, at least that's what I think.

Using Xdebug with NetBeans 7

There comes a time where it's unacceptable or inconvenient to stash var_dump() into your code. And then there's Xdebug. Xdebug makes it easy to debug your PHP application and with the intergration of NetBeans, it's even easier.

For the record, I'm using Debian 6.0.4 on my workstation and Debian Wheezy/Sid on my dev server.

First of all, lets install Xdebug on the server:

pecl install xdebug

Open up your xdebug.ini file, mine is located at /etc/php5/cgi/conf.d/xdebug.ini, and enable Xdebug. My xdebug.ini looks like this:








 The reason why xdebug.remote_connect_back is enabled is because it allows multiple developers to debug. Also, if it so happens that your IP changes on your workstation, you won't need to update the remote host value. 

 Run php -m and you should see xdebug at the bottom of the output. Great, this means that Xdebug is working on your development server. Now to configure Netbeans. 


Go to one of your projects and select Properties. From there, go to Run Configuration > Advanced. You can select "Do Not Open Web Browser" but you'll have to manually enter the URL to start the session. It's best to select "Default" and have Netbeans open your browser with the XDEBUG_SESSION_START variable, starting the session.

Then, change the debugger host to the IP of your server and the port to 9000. Now, you'll also have to add Path Mapping. In short, the path on your server has to match the path on your workstation. See the picture below for reference.


In the example, the current project is located at /home/easto/web/reddit-api-client while the files reside on the server at /data/reddit-api-client. 

Once that is completed, let's test to make sure everything works. Open up one of your projects and from the top menu, go to Debug > Debug Project (or file). If all goes well, you'll now be able to debug your project. Click on Window >Debugging > Variables to show the current watched variables. If you right click on any variable and select "New Watch...", you'll be able to view the variable's state. See below for an example.


No more messy echo or var_dump()! Debugging with Xdebug is much easier and cleaner. The great thing about this setup is that debugging is handled all remotely you won't have to run a web server and PHP locally.

Find the largest installed packages in CentOS

I recently bought a VPS to host a Counter Strike server. WIthout having any choice, I was stuck with CentOS 5. After getting everything set up, I wasn't left with much disk space left. So, I read the man page for sort and used the following RPM command to find the largest packages installed:

rpm -qa --queryformat '%{name} %{size}\n' | sort -k2n


The option -k2 sorts the second column (size) and the -n option sorts it numerically. I also found out that sort -h doesn't work under CentOS 5 since it has coreutils 5.97, as it requires coreutils >= 7.5.



So, I have this old Pentium 166 box laying around, so I thought I'd stick Linux on it (of course). At first, I used DeLi Linux and it ran quite well. The problem is, the project changed directions, to ConnochaetOS. They took a more modern take on things, using kernel 2.6 and other modern applications. Most of the newer applications don't run quite well on an older box. So, after finding a mirror of a DeLi Linux that I cloned to a local server, I now had a working respository.


Then I found DeliCate; a new forked version of DeLi still running kernel 2.4 but with updated software! The transition was really easy, simply by adding a new repository and upgrading the installation. On the forums, there's tons of resources to get it configured. Most namely, the PKGBUILD thread where you can compile applications just by the PKGBUILD file.

I have an old ISA NE2000 network card in there that didn't work out of the box. So I add the ne module to /etc/rc.modules:

/sbin/depmod -a

/sbin/modprobe ne

Then the network card worked. I also removed net from /etc/rc.conf so the network didn't start on boot, making a faster bootup. 

If you have a serial mouse (like I do), I had to configure X11 to see it. I configured it like so:

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "Microsoft"
        Option      "Device" "/dev/ttyS0"

You can run dmesg | grep tty to find your serial device. Other than that, everything is running quite smoothly, well as fast as a Pentium 166 with 64MB of RAM can run ;) 


Google Analytics to Twitter bot

The last week, I've been tinkering with Google's Analytics API. What I wanted to do was have daily reports on my website which then  tweets the difference from yesterday to today. The ideal situation was I would have it SMS me the results. The problem is that my phone carrier (Rogers) complicates things. For most carriers, you can email a carrier-supplied address (5555555@att.com for example) which in turn would send an SMS to that address. But, what Rogers does is once you receive a text, you have to respond back with REPLY to view it. Stupid huh.

To get around this, I subscribe to my bots account via text message and for every new tweet, I get a text message.

What you need: Google Analyrtics API class [download] and twitteroauth [download]

For this to work, you need to create an app on Twitter Developers which creates your consumer key, consumer secret, OAuth secret and token. You also need to create gabot.txt for the bot to cache to.

See the code below for the bot or download at the bottom.



    $website_info = $ga->getWebsiteProfiles();
    // set the date range we want for the report - format is YYYY-MM-DD

    $to = date("Y-m-d", strtotime("now"));
    $from = date("Y-m-d", strtotime('Yesterday'));
    $ga->setDateRange($from, $to);

    // get the report for date, showing pageviews and visits
    $report = $ga->getReport(
            array('dimensions' => urlencode('ga:date'),
                'metrics' => urlencode('ga:pageviews,ga:visits'),
                'sort' => '-ga:pageviews'

    //convert the associative array to a numeric array so we dont have to use the $from date as a key
    $report_n = array_values($report);
    //what we're going to tweet
    //0 = today 1 = yesterday
    $stats = $website_info[0]['title'] . " today: pageviews: " . $report_n[0]['ga:pageviews'] . " - visits: " . $report_n[0]['ga:visits'];

    //string to write in file
    $string = $report_n[0]['ga:pageviews'] . '#' . $report_n[0]['ga:visits'];

    //difference from yesterday to today
    $visits_difference = $report_n[1]['ga:visits'] - $report_n[0]['ga:visits'];
    $pageviews_difference = $report_n[1]['ga:pageviews'] - $report_n[0]['ga:pageviews'];

    //open the file for the old saved data
    $fh = fopen($file, 'r');
    $data_read = fgets($fh);

    //compare read data to latest data
    if ($data_read != $string) {

        $fh = fopen($file, 'w') or die("can't open file");
        fwrite($fh, $string);

        $connection = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthSecret);
        $connection->post('statuses/update', array('status' => $website_info[0]['title'] . " difference: visits: $visits_difference pageviews: $pageviews_difference"));

        echo $stats;
} catch (Exception $e) {
    print 'Error: ' . $e->getMessage();



Kobo Vox eReader

 Kobo just released their Vox eReader a couple of days ago and I've had the chance to play with it this weekend.

It's quite heavy compared to other ereaders. I found that it's even heavier than the mighty Kindle DX. See below for a comparison to a Canadian quarter.

(As you can see, there's some nice greasy fingerprints on it). Having never played around with Android before, it's quite easy to use. After firing it up the first time, it had to update the firmware, which over wifi, takes a while. After the update, I was finally able to play with it. Checking the version info in settings revealed that it's running Android 2.3.3 atop kernel version 


Kobo has it's own Android market place at http://kobo.getjar.com. Most of the applications seem like crap, other than a few larger named ones like Skype. The included Youtube application and the one I downloaded from the store was nothing special. All it did was open http://m.youtube.com up in the browser. 

After I enabled USB debugging in the settings, I was able to mount it under Linux and send files to it. Though, the puzzling thing about the Vox is that it doesn't charge by USB which means that you'll have to use the wall charger. 

 The back of the Vox is nothing special. It's nice that it comes in two pieces in the event needs changing or such.

The display on it is actually quite crisp and livens things up. As far as extended periods of reading, I'm not too sure. I'll have to experiment more with it.