• Spiroplot – An HTML 5 and Javascript spirograph plotter

    Spirograph plot

    Once upon a time I had a cool toy known as spirograph, I can remember this from when I must have been only 6 or 7 and use to have great fun drawing the shapes that it produced. It was basically a load of plastic circles with gears on the edge and you had fixed peices that and moving peices with holes for pens. The moving peices could be rotated around either the inside or outside of the fixed peices and each had a variety of hole positions for the pen. This produced all kinds of wonderful plots and patterns. So I had 5 minutes free and created an HTML 5 plotter which is included in this post below, it is capable of both the Hypotrochoid inside) and Epitrochoid (outside) types of plot. The controls are as follows, Radius A is the size of the fixed peice, if the radius value is negative then Hypotrochoid plots are produced if it is positive then Epitrochoid plots are produced. The Radius B sets the size of the moving peice. The offset parameter sets the % from the edge to the centre of the moving piece where the pen is. Original Spirograph had fixed holes for pens, but as this is software it does not have the same physical limits. The Gearing factor can be automatic which rotates the B peice at the correct gear ratio based on the A/B radius or you can use manual gearing inputs for plots that cannot be produced with physical Spirograph. The Auto Gear tick box enables/disables manual gear ratio entry. The other tick box shows/hides the tools that form the plots.


    A HTML 5 spirograph plotter. If you see nothing or it does not work you need a HTML5 compatable browser and javascript enabled.

  • Debian wordpress multisite woocommerse bug?

    For some unknown reason following the instructions I wrote out in the last post woocommerce broke and it looks like somehow it is getting the PLUGIN_URL wrong and using the PLUGIN_DIR instead/appended to so you end up with some horrible url requests from the woocommerce scripts eg :-

    File does not exist: /var/www/wordpress/www.example.com/plugins/var, referer: http://www.example.com/

    The easiest solution to this is to create the symlink :-

    /var/lib/wordpress/wp-content/plugins/var/lib/wordpress/wp-content -> /var/lib/wordpress/wp-content

    To fudge the problem. Its only woocommerce doing this out of all the plugins I have installed so far, so not 100% sure if its a general WordPress bug or a woocommerce bug. PITA but trivial to work around

  • WordPress debian multisite

    Before I forget, or kill some one next time I have to do this, I had better write it down.

    WordPress supports multisite out of the box these days, but Debian supported it long ago and to be honest I would rather use a Debian security team version of wordpress to get my automatic updates and security fixes along with the rest of the server security rather than having to manually mess about unpacking multiple tarballs to update multiple wordpress sites

    to install wordpress on a clean system

    apt-get install wordpress mysql-server

    Yep wordpress only recommends mysql-server so you need to add mysql-server too.

    By default the Debian magic scripts will work with data in /srv/www, I did not want this. I wanted my data under /var/www/wordpress/

    The two files


    are your friends here, the first one are some example apache confs to make the multisite magic work the second is a quick way to setup an empty wordpress site and to create the mysql user, the config and the folder structure needed.

    Before you do that, enable some apache modules to let the magic work, you need vhost_alias and rewrite as a minimum

    a2enmod vhost_alias rewrite

    Next copy the setup-mysql script, unpack it and mod it to the required folder structure :-

    cd ~
    cp /usr/share/doc/wordpress/examples/setup-mysql.gz ~/
    gzip -d setup-mysql.gz
    sed -i 's/\/srv\/www\//\/var\/www\/wordpress\//g' setup-mysql
    chmod +x setup-mysql
    ./setup-mysql -n databaseuser name.of.site.com

    where databaseuser is the name you want to use for mysql access (account will be created and all set up) and name.of.site.com will be the the physical name used in the /var/www/wordpress/ folder to keep the sites separate.

    Now the final thing to do is to configure apache

    What you probably want to do is create a new default virtual host that will grab any requests and handle them BUT do this as a lower priority to any static sites you may have. So create a new file in /etc/apache2/sites-available/50-wordpress with the following content :-

    ## Virtual host VirtualDocumentRoot
            NameVirtualHost *:80
            UseCanonicalName Off
            VirtualDocumentRoot /usr/share/wordpress
            Options All
            # wp-content in /srv/www/wp-content/$0
            RewriteEngine On
            RewriteRule ^/wp-content/(.*)$ /var/www/wordpress/%{HTTP_HOST}/$1

    Which is pretty much the first example in /usr/share/doc/wordpress/examples/apache.conf with my folder locations tweaked as I like them.

    then enable the site

    a2ensite 50-wordpress

    You will with this setup also want to remove the default

     a2dissite default 

    Then if you need to add any static sites in the future add them as regular vhosts with site names starting with numbers less that 50- then they will take priority. If no static matches are found it will try to dynamicly match via the wordpress configuration. If this fails you will get a ungraceful message from the debian wp-config.php file but I’m not really bothered about that at this stage.

    and finally don’t forget to restart the web server

    service apache2 restart