• Testing network speed with raspberry pi

    Posted: by Joe Johnston

    This is a quick hack to test the Internet connection speed of your raspberry pi running rasbian linux.

    As you may know, I have a small farm of RPIs doing SETI@Home work. I have one head node that all that traffic flows through. This simplifies configuration and makes the farm portal. Here’s an architecture diagram via emacs artist-mode.

                                 -----+ node1 |
                                 |    +-------+
      +--------+   +---------+   |    +-------+
      | Public |---| Pi Head |---|----+ node2 |
      +--------+   +---------+   |    +-------+
                                 |    +-------+
                                 -----+ node3 |

    I was worried that perhaps the traffic from my six worker nodes was overwhelming the WiFi adapter of my head node. There are two approaches I used to do this.

    The first is to look at the performace of short-term bursts. This will give me a flavor for the peak capacity provided by the head node’s built-in WiFi adapter. To do this I need nload (a terminal program that provides histograms of network traffic per adapter) and wget.

    I open one terminal and run nload -i wlan0 (I do not use predictable interface names because I am ancient). Then I open a second terminal and run wget to fetch a large file. Fitting, the rasbian image is quite adequate for this.

    wget -O /dev/null https://downloads.raspberrypi.org/raspbian_latest

    Don’t worry about disk space. This command throws all the fetch data into the bit bucket.

    My head node is about 4-6 meters from the WiFi access point in my home. I get about 40 - 45 MBit/s on average from this load. Yes, there are a lot of reasons why the load may be delivered as consistently as in a lab setting, but this will give you a flavor for the capacity of your RPI’s WiFi service.

  • A systemd service file for plerdwatcher and more

    Posted: by Joe Johnston

    So you have plerd all happy on your system. You run plerdwatch start and your off to the races. But what happens if your machine reboots? You need to restart both Dropbox and plerdwatcher.

    If you are on a linux box that supports systemd, you’re in luck.

    The following file will restart dropbox for you (you will need to change {USER} to username of the account running dropbox).

    Description=Dropbox as a system service
    After=local-fs.target network.target
    ExecStart=/usr/bin/env "/home/{USER}/.dropbox-dist/dropboxd"

    This should be copied in /etc/systemd/system/dropbox.service.

    The plerdwatcher unit file is a little more involved since on my machine, I run plerd using plenv. Here is the file:

    Description=Plerd daemon that monitors incoming posts and handles webmentions
    ExecStart=/bin/bash -lc "cd /home/{USER}/src/plerd && PERL5LIB=/home/{USER}/src/plerd/local/lib/perl5 bin/plerdwatcher start"
    ExecStop=/bin/bash -lc "cd /home/{USER}/src/plerd && PERL5LIB=/home/{USER}/src/plerd/local/lib/perl5 bin/plerdwatcher stop"

    As with the previous file, you will need to replace {USER} with your account name. My installation of plerd is in my home directory in a directory called ‘src’. Inside of the plerd folder, I have a local directory containing Perl libraries needed for Plerd built for the version of Perl I run plerd with (5.26.1).

    You may need to tinker with this scripts a bit, but this should help you get started.

  • Taskboy Blogging again for the first time

    Posted: by Joe Johnston

    Welcome to my new blog. It is powered by Plerd, which is a OSS project I contribute to.

    More details later.

    This blog is also made by computer and powered by keys. You need a little humor in your blog.

    — My Son, Angus

  • Tags are working

    Posted: by Joe Johnston

    I have implemented blog post tagging in Plerd, although I confess the implementation could be a little better. There are attribute conventions within the Plerd.pm class than I may have trampled upon. Maybe I will just create a patch for jmac to look at.

    Changes include:

    • parsing out “tags” header from post
    • creating an index containing all tags
    • creating a page for each tag linking to all posts
    • allowing individual posts to list tags at the bottom
    • templates for same

    Blogging like it’s 2001 again.

  • Another quick post

    Posted: by Joe Johnston

    I am writing this post in a text editor on the iPad, as if I were a person free from RSI-induced back pain.

    I spent a great deal of time with Jason McIntosh’s plerd blogging software. It is with this software I hope to restart blogging.

    Plerd is fairly simple to install (if you’re a perl nerd) and configure. I hacked and continuing hacking the guts of the Plerd engine to produce the sort of HTML markup that validates and responds to mobile screens in the fashion I would like.

    Some of the upgrades I introduced were bootstrap 4.1, Font Awesome 5 and the use of the Monserrat font from Google. I am further working on getting some level of support for blog post tagging, which has to work statically. Heck, maybe I’ll even style a tag cloud.

    Need to understand how to upload pictures to plerd. If this isn’t yet supported, I will make plerd look at the source directory for and images folder or something.

  • It Begins

    Posted: by Joe Johnston

    This is an example of the kind of brilliant content I am looking to publish.

    Hold my beer.

  • Using jQuery with JSONP, a brief example

    Posted: by Joe Johnston

    Since I couldn’t find a jquery/jsonp example that I liked, here is my stab at it.

    JSONP is a way of getting around cross-domain restrictions browsers levy on javascript HTTP calls. The protocol makes the server return a JS code fragement of a function that it then executes. Sneaking, right?

    Imagine a server with this bit of perl CGI code:

    #!/usr/local/bin/perl --
    use strict;
    use CGI;
    sub main {
      my $q = CGI->new;
      my $callback = $q->param('callback') || 'foo';
      my $data = q[{id:0, name:'jjohn'}];
      my $ret = qq[$callback ($data);];
      print $q->header("-content-type" => "text/javascript"), $ret;

    When run, the output looks like this:

    Content-Type: text/javascript; charset=ISO-8859-1
    foo ({id:0, name:'jjohn'});

    This script is called “ws.pl”. It is smart enough to call use a different function name if one is requested by the client.

    On the client/JS side, you can use this data this way:

        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script type="text/javascript">
          $(document).ready(function () {
                    function (d) {
                      alert("got: " + d.name);

    Here, an alert box will appear. Notice that the callback function producing the alert has received the decoded JSON object and is able to use it directly. No need to worry about injecting SCRIPT tags, etc.

    jQuery takes the huge pain of javascript programming out of javascript programming.

  • Shorty turns 40

    Posted: by Joe Johnston

    Well, it had to happen. I reached my fortieth birthday this week.

    Given that my son is a year and change old, I don’t have as much time for blogging as I once did.

    They say parenthood changes your perspective on many things. Despite my best efforts, I am afraid that has happened to me too.

    I launched two web services this year in the social media space: Nestor and Linksnest. While neither is wildly popular, these tools helped me learn the latest web design principals and tools.

    Looking back at the start of the year, I see that I began with a stealth project for a friend that involved collaborative filtering and ajax. Need to get back to that at some point.

    I sponsored a few kickstarter projects and contributed a prize to the Interactive Fiction Competition. I guess if I can’t do stuff myself, I can at least help those who are.

    I got a mole on my face removed, but am experiencing some blow-back. Stupid organic body.

    I worked for three different companies this year, one of which I worked for twice. We got our house painted and traded in our cars for new ones. I tasted 30 year old Laphroaig. Materially, it was a better year than many others had and I know how lucky I am.

    We lost a great old lady cat, Miss Lulu, this year. She will be missed.

    I guess I’m not as reflective as I have been in the past. Not enough time.

  • Modeling RPG-style combat

    Posted: by Joe Johnston

    HAHA! Nerd!

    Following on to yesterday’s post about economics, I’d like to present this brief note about how to model role-playing game (RPG) style combat easily with math.

    Anyone familiar with Dungeons and Dragons will recall the very tortured set of combat tables broken out by class and level. A simpler method for resolving combat is found in Freeciv.

    Assuming a two party combat, you create two attributes for each member: an attack stat and a defense stat. In this system, the bigger the number, the better.

    To determine the chance of an attacker hitting the defender, use the following formula:

    P(hit) = Attacker->att/(Attacker->att + Defender->def)

    This is to say, the chance of an attacker hitting a defender is the proportion of the attacker’s ‘attack’ stat over the sum of the attacker’s attack stat plus the defender’s defense stat.

    If the attack succeeds, some amount of damage is subtracted from the defender’s health stat.

    I like this formula because it is simple and scales well to opponents of wildly differing strengths.

    Attack and defense stats must be greater than 0.

    Hope this helps.