Lessons taught; Lessons learnt

Maths, teaching and beyond.

Archive for the ‘Computing’ Category

The downside of self-hosting

with one comment

Having just written about the advantages of self-hosting a Wordpress blog, it would only be right to mention one of the disadvantages: you’re now responsible for the security of the blog.

If you’re like me, then your blog will be something you check on and update only occasionally. It is, however, accessible to the internet 24 hours a day, which means that the opportunity for someone to hack into is it there, whether you are around to look after the site or not.

I’ve recently had someone attempt to hack this site, and redirect visitors to China TV and blueseek (whatever they are!). A quick Google search tells me that I’m not alone. As far as I can tell, all they managed to do was to alter one of the theme files to add a redirect to their website. I’m in the process of removing all the theme and plugin files and replacing them with clean versions… which is one reason why, if you visit this site (rather than use an RSS reader), it currently looks a little more boring than it did yesterday. I will also be sitting down this weekend and going over the file permissions of my entire site with a fine toothcomb… something I suggest everyone else with their own Wordpress blog does.

The message to take from this, I suppose, is never to assume that your personal site will be too unimportant for hackers to bother with.

Written by Jon Ingram

March 2nd, 2010 at 1:49 pm

Posted in Admin, Computing

Tagged with , ,

Geogebra in Wordpress

with 3 comments

Several people have emailed me recently, asking me how I include the Geogebra applets (like this one, showing the nine-point circle) in my posts. First, note that I’m using Wordpress, rather than any of the millions of other blog systems. Secondly, and more importantly, I’m self hosting.

Wordpress.com

As far as I can tell, it’s impossible to include Geogebra files in wordpress.com blogs. Wordpress severely restrict the content you can upload to wordpress.com, both for security reasons, and for financial reasons (you can pay them extra to be allowed to embed video/audio). When I tried, it just stripped out the applet information, leaving the ‘please install Java’ text behind.

If you have a wordpress.com blog, then, it looks like you are restricted to hosting your geogebra files on an external system, like Geogebra.org’s own Geogebra upload manager.

Self Hosting Wordpress

Self-hosting means that I’ve got my own Wordpress installation on this site, rather than using wordpress.com, or one of the other free blogging services.

While you might expect that all the wordpress.com restrictions would be lifted on a self-hosted site, this isn’t necessarily true. While there is no issue with using <applet> or <iframe> tags, I recently upgraded this site to Wordpress 2.9 (from the 2.8 version it was running previously), and found that the new version was much more picky about the file-types it allows everyone, even the site admin, to upload. While this is for good security reasons, it was still a little annoying!

There were several ways to deal with this increased security:

  1. I could start hosting the Geogebra files on an external site, as above.
  2. I could use the new fileless embedding feature which has recently appeared in Geogebra. This lets you embed small Geogebra creations without having to upload a separate .ggb file. Just make sure the ‘.ggb file and .jar files’ option in the Export dialogue is unticked, and the HTML it generates has the file embedding inside the <applet> tag (encoded using Base 64, from the looks of it).
  3. I could add .ggb as an allowed filetype to the Wordpress system.

The fileless embedding is useful, but is only sensible for small files — I wouldn’t want to embed a 500kb geogebra file directly into my HTML! For large files I do still want to upload the .ggb files. Rather than hand-editing the Wordpress source, I installed the PJW Mime Config plugin, which lets you edit the allowed filetypes from the standard admin section of the blog.

Other blogs

Another option would be to investigate switching to another blogging platform. For example, it looks like Blogger/Blogspot will let you embed applets in their free service, without too many problems.

Written by Jon Ingram

March 2nd, 2010 at 8:18 am

Posted in Computing

Tagged with , ,

Clumping and clustering

without comments

I've had a fun weekend playing with Processing and improving the clumping visualisation I posted earlier this week. The new version has been uploaded to OpenProcessing.org, a site which contains over 1000 visualisations, many of them containing beautiful and interesting mathematics:

A brief reminder of the situation: We have a grid of squares, of several different types. These squares are happy when they are surrounded by enough squares of the same type as them, and unhappy otherwise. We take two unhappy squares, swap them over, and repeat until bored!

There are two key parameters here: the number of different types of cell/person/house/whatever these squares are representing, and the happiness threshold: how many neighbours need to be the same as a cell for it to be happy.

Let's look at the types of behaviour that emerge for different values of the parameters:

A behaviour catalogue

Neighbours needed for happiness
2 3 4 5 6
Types 2
3
4
5
6

You find that it takes longer and longer for the state to settle down as you increase the number of types of cell. With 6 cells, and a happiness threshold of 4, for example, you can see from the table that it does eventually settle into a fairly stable clustered pattern, but it takes a very long time. After 50,000 swaps the grid looked like this:

clump-6-4-50k

Apart from the special case of two types, with happiness threshold five or six, the cells always seem to settle into a relatively small small clustered pattern (with small threshold), or to not stabilise at all (large threshold).

2 types; threshold 5: this is the case explored in the earlier post on this clustering behaviour. The cells cluster together fairly quickly, and then over the next 20,000 swaps or so the clusters join together into larger features, with the borders being long stretches of horizontal/vertical/diagonal lines.

2 types; threshold 6: this is perhaps even more interesting then the previous case. We do get some clustering, but the clusters don't hold together, but fray, and move around.

As with the previous post on this topic, I have wrapped left-right and top-bottom. This doesn't change the behaviour significantly. If you'd like to explore what happens without this wrapping, then go get the source code and dive in!

Emergent Behaviour.

This 'clumping' behaviour is just one of many examples of emergent behaviour, where small-scale local actions add up to a sometimes surprising global behaviour. Sometimes, as the old aphorism says, the whole is more than the sum of its parts.

One of the best known examples of this emergent behaviour is flocking, where groups of birds fly together in flocks that seem to require some collective intelligence, but are actually generated from purely local actions. This behaviour was modelled in Boids, a classic Artificial Life simulation from 1986. Here's an excellent 3D Boids simulation.

Written by Jon Ingram

April 12th, 2009 at 9:15 pm

Posted in Computing

Tagged with , ,

Geogebra Miscellancies

with 5 comments

Terminology

I've been wondering for a while what to call the little visualisations that I generate from time to time. I've seen quite a few terms used on different sites: interactivities, applets, worksheets, animations, miniworlds, interactive environments, etc. Now I can add another one: mathlets. I wish we could just pick one term and stick to it. For the rest of this post I'll refer to them as gromits.

Links

Elisha Peterson has created a number of interesting Geogebra gromits which are worth exploring, as well as a nicely written tutorial explaining how to generate an interactive Cobweb Diagram using Geogebra.

The Tools section of the Geogebra wiki is slowly building up a decent collection of Geogebra tools. The Tetris tools are particularly fun!

Splines

On the topic of tools, and following on from my earlier post on curves and splines, here's a Geogebra tool which implements a Catmull-Rom spline: cr-spline.ggt. Example gromit:


Sorry, the GeoGebra Applet could not be started.

Frustrations

I've been trying to delve into some of the new matrix capabilities of Geogebra 3.2, and I'm getting quite frustrated! They don't seem to be particularly well integrated into the rest of the system -- for example, I've been trying for about 30 minutes now to figure out how to 'extract' the number from a 1x1 matrix (represented by, for example {{-4}}), so that I can calculate with matrices and display the results. Element[] would be the obvious tool, but it just returns 'undefined'.

Written by Jon Ingram

April 11th, 2009 at 3:25 pm

Posted in Computing, Resources

Tagged with ,

Clustering and seating plans

with 2 comments

For the last few days, I've been diving into Processing -- basically an integrated Java wrapper which makes it easy to create simple graphical visualisations (see here for some beautiful examples). Coming from Python, I particularly like not being forced not to write the 500 pages of OO wrapping that turned me off Java in the first place a few years ago.

My first Processing visualisation demonstrates how seating plans degrade over time!

From mixed to clumped

Imagine you have a square array of seats, and a group of boys and girls sit in them, alternately boy then girl. If we highlight one of the sexes we will get a checkerboard pattern.

Now imagine that boys like to have more boys than girls around them (and vice versa for girls). To try and make everyone happy, we implement the following scheme:

  • Identify at random two people who aren't happy with their seat.
  • Swap them.
  • Repeat until everyone's happy.

If we repeat this procedure thousands of times, what will happen to the layout? Click below to find out:

Sorry, the visualisation could not be started.

Clicking again will restart the procedure.

You've probably noticed that I've wrapped left-right and top-bottom... which does move it away a little from the classroom context! This was basically to make the calculations easier.

Here are some examples of what happens if you let this run for a while:

Each frame of these animations represents 2000 swaps, and each animation covers 50000. You can see that there are similar phases in each one: a quick 'clumping', and then a much slower phase where the boundaries settle down into long straight/diagonal lines.

Notes and Extensions

There are many ways to push this visualisation further -- we could change the number of types (English, Welsh, Scottish?); change the 'happiness threshold' (which is currently 5 out of the 8 neighbours); perhaps even have different thresholds for each group. You find really interesting behaviour as you change the threshold -- too high, for example, and the pattern doesn't settle down because there are too many unhappy people.

If you'd like to use my visualisation as a starting point to explore these extensions, then the source is here: clump2.pde. Have fun!

Written by Jon Ingram

April 10th, 2009 at 6:07 pm