anarres: (Default)

Lodnon 2102 - the official Oimplycs site

Wine merchants Oddbins has said that non-sponsors of the Olympic Games have been treated by LOCOG as ‘beggars on the gilded streets of the Olympic movement’. The company is planning a counter-strike for the next three weeks, with censored window posters....
anarres: (Default)
Hello, I am writing this post in VIM because that's how much of a dork I am. And I'm going to use a bash script post it. And then I guess I need to go magnetize some needles or sumfin like that.

more test

Jul. 18th, 2012 08:55 pm
anarres: (Default)
Post from friendica to dreamwidth worked, does it go the other way?
anarres: (Default)
Deutsche Welle, sort of a German equivalent of the BBC, provides short current-affairs-type programs written in simple German and read slowly, for German-learners to practice on. I've been working my way through these and my particular favourite is Gemeinsame Klug or "Together Wise", a charming story about a scientist who wants to find out how a swarm of fish are able to move as if they were a single individual. She builds a robot fish which swims among the real fish, and attempts to lead them away from food. When a group of only two fish are infiltrated by the robot, they do indeed follow it, but when Robo-fish infiltrates a larger swarm, the other fish refuse to follow its lead. The researcher concludes that the swarm will only follow if a certain minimum percentage of the fish take the lead.

I have no idea how true this story is but it really caught my imagination, and I found myself wondering exactly what determines whether the fish move as a swarm, and what advantage they gain from this.

Logo of Radical Routes network of housing co-ops

It's obvious that fish don't ALWAYS act as a swarm, otherwise there would never be any leader fish to lead the swarm in a new direction. So it must be that fish have both an autonomous-mode, where they make their own decisions, and swarm-mode, where they follow the group.

I'm pretty sure that if there was some kind of clear danger, say, a shark approaching, any given fish would autonomously swim away no matter what all the other fish (or robotic infiltrators) were doing. It seems to me the only situations where there would be an advantage to acting as a swarm would be those in which it wasn't entirely clear what the correct decision would be. For example, some of the fish in the swarm faintly detect a hint of danger, which might be an approaching predator, or might be something completely harmless (a passing submarine, say).

Let's say that one in twenty detect a faint whiff of danger. So 5% of the fish swim away, in autonomous mode. Since this is all the information we have about the situation, we can say that, there is a 5% chance of imminent shark attack.

Is it advantageous at this point for the fish to act as a swarm, all following the 'leaders' who are swimming away? There is a 95% chance that swimming away is the wrong decision, with no shark nearby (maybe the sound is really something harmless. It could be a bunch of marine biologists making a documentary, Jaques Cousteau-style. Making a correct decision has a benefit (not getting eaten by sharks) but making a wrong decision has a cost (wasting calories swimming away unnecessarily, and possibly swimming away from food and thus missing out on dinner). The benefit and cost are not equal: in this case the benefit (not getting eaten) weighs more heavily than the cost (wasting calories).

The minimum fraction F of fish swimming away which tips the rest into swarm behaviour should be determined by

FB + (1-F)C = 0,

where B is benefit and C is cost. So, when a fraction F of fish in autonomous mode swim away, then the benefit of escaping the shark, if it exists, weighted by the possibility F that there really is a hungry shark nearby, is equal to the cost of swimming away in the event that there is no shark, weighted by the possibility (1-F) that the shark is actually a distant submarine, a group of marine biologists and their film crew, or the figment of some over-anxious fishes' imaginations. The fraction F that optimizes the fishes' chances of survival has been determined by a very long series of experiments carried out by the process of natural selection, with the fraction being set randomly to different values by mutations, and those groups of fish having less-optimal values having a greater frequency of being eaten by sharks. Probably. I actually have no idea if that is right or not, since I'm neither a statistitian nor an ichthyologist.

I did a quick google images search for "Robot fish", and came up with this charming creature:
Actual robot fish. Apparently it is used to clean up pollution, somehow. It comes from this website:


Aug. 11th, 2010 07:59 am
anarres: (Default)
YAML is a "human-readable data serialization format", according to Wikipedia. Apparently it's terribly flexible and powerful. But I just want to make a simple configuration file to use with a Perl script. I worked out how to do this with help from Stackoverflow (I love Stackoverflow). Super-simple example:


image_width: 1000
show_values: 0


use strict;
use warnings;
use 5.010;

use YAML qw(LoadFile);

my $settings = LoadFile('test.yaml');
say "The image width is ", $settings->{image_width};

You can also go backwards: starting from the Perl code version of the configuration data you want, you can generate the YAML file:

use strict;
use warnings;

use YAML;

my %settings = (
foo => 1,
bar => [qw/one two three/],

print Dump(\%settings);

Hmmm, funny how the Stackoverflow people assume I'm a "he" though.
anarres: (Default)
Hmmm. It seems like it isn't possible on a Dreamhack to access a module in the ~/dw/cgi-bin/DW/Controller folder. This:


use lib "$ENV{LJHOME}/cgi-bin";
use DW::Controller::Nav;

produces this:

Name "Template::Filters::BASEARGS" used only once: possible typo at /usr/lib/perl5/Template/ line 49.
Name "Template::Context::BASEARGS" used only once: possible typo at /usr/lib/perl5/Template/ line 49.
Name "Template::BASEARGS" used only once: possible typo at /usr/lib/perl5/Template/ line 49.
Name "Template::Service::BASEARGS" used only once: possible typo at /usr/lib/perl5/Template/ line 49.
Name "Template::Provider::BASEARGS" used only once: possible typo at /usr/lib/perl5/Template/ line 49.
Name "Template::Plugins::BASEARGS" used only once: possible typo at /usr/lib/perl5/Template/ line 49.

and you get the same message if Nav is replaced with any other Controller module.

I could try to figure this out, or I could just work around it... I think I'm going to work around it :-)
anarres: (Default)
So... up until now I was doing my version control by keeping all the different versions of all my scripts in a series of folders on my home laptop, and pasting them into my Dreamhack. But I found that, since I'm working with quite a lot of different scripts, this gets cumbersome, and when things stop working it's quite hard to go back and find the exact combination of old versions of scripts that did work. So. I should use Mercurial.

It's a little bit complicated. You have to actually make changes and generate patches within ~/dw/cvs/dw-free, which is a copy of the working directory ~/dw. (The name 'CVS' is a red herring, since that is actually the name of a different version control system from Mercurial.) Then copy the changes to the working directories by doing this:

$ alias dwsync="$LJHOME/bin/ --sync --cvsonly"
$ dwsync

About generating the patches: there are different ways to do this, but I think the best way is using Mercurial Queues, which you can do because ~/dw/cvs/dw-free is a Mercurial repository. For learning how to generate patches and work with Mercurial Queues:

Hg Init: a Mercurial tutorial

Mercurial: The Definitive Guide. It's a whole book, but written quite snappily, and I find I mainly only ever look at chapters 2 and 12.

The patches live in ~/dw/cvs/dw-free/.hg/patches.


Dreamwidth Dev Version Control
anarres: (Default)
Dear Anarres of the future,

If you ever find yourself thinking, 'I don't reaaaaally understand this problem I'm working on, but instead of methodically learning how to do it properly I'm just going to wing it, and if I can't immediately get it to work, well, I'll just randomly try to change a bunch of things until it does, and I'm sure that will end up saving time in the long run'... no. No, no, no, no, no, no, no. Wrong, no points. You fail.

You've been told.

Anarres of the present.


Jul. 6th, 2010 06:43 pm
anarres: (Default)
Don't you hate it when your thoughts are all running together and you end up writing a blog entry about three different things instead of having separate posts?

I make electronic music as a hobby. Um... 'music' is almost too grandiose a word for what I do. I make electronic noises as a hobby. For a couple of years I had been generating sounds with AmSynth, and then one day I updated Ubuntu and, oops, AmSynth broke. So I spent some time in forums trying to find a way to fix it and, long story short, couldn't find a reasonably easy solution, and so gave up. I started using ZynSubAddFX, which I viewed as being OK, but not quite as good as AmSynth. So fast forward to a few days ago, I upgraded to the latest version of Ubuntu and, hey, AmSynth works again, yay!

Except, I played with it a bit and... I found that I actually prefer ZynSubAddFX now.

I've been having trouble getting the statistics pages /stats/site and /admin/stats to work on my Dreamhack, and after trouble-shooting it turned out that the Dreamhack server was simply too overloaded to deal with those pages, the solution was to get a shiny new Dreamhack on a different server, it works great, joy :-)

And I went on an epic quest to buy sandals today. Because it is around 30 degrees here most days and I am in the beautiful city of Berlin and I like walking around a lot, and the old sandals were not really comfortable for walking any distance. I wanted the kind that are basically like hiking shoes, but sandals. I went into 4 or 5 different shops (which was hard, shopping is my least favourite thing ever) and was thoroughly disgruntled by the fact that most of the comfortable, practical sandals are only available in men's sizes, while the women's section has rows and rows of useless flimsy things. Really, about 70% of the women's you can buy border on being torture devices, they do look very pretty but you wouldn't want to wear them. Maybe we should re-classify high heels as being ornaments rather than clothing? Then people would put the high heeled shoes on their coffee table as art and wear shoes that don't shorten their achilles tendons.

Anyway. I got some good sandals, the brand is Ecco and they are pretty comfy. They cost more than I have ever spent on sandals before but my feet tell me it was worth it.


Jul. 3rd, 2010 12:15 am
anarres: (Default)
I am very impressed with my friend Dan's project, VODO. They provide free legal bittorrent downloads of independent films, encouraging viewers to make a VOluntary DOnation to the artist. Somehow they manage to get paid for this, through mechanisms that seem to me incredibly convoluted and improbable. I watched Archon Defender not long ago, an ace bit of sci fi animation!

diff patch

Jul. 3rd, 2010 12:06 am
anarres: (Default)
Make a patch:

$ diff -u oldfile newfile >> file.patch

(> overwrites, >> appends). The -u means unified format. Apply patch to (some other version of) oldfile (yes it does have to have the same name, no you don't have to specify the name, it figures out on its own which file to apply the patch to, and yes it does overwrite the old version):

$ patch > file.patch

Creating a patch that creates a new file: to do this you have to compare directories, not files. Yikes! Before doing anything else get Dreamhack up to date, and then get rid of all the clutter.

To make a patch comparing directories:

diff -u -r -N ~/temp4 ~/temp5 > folder.patch

the -r makes it recursive, and the -N means new files can be created as part of the patch.
anarres: (Default)
First off, I just wanted to get something, anything, to work, so I would be able to play with it. It turns out there are a few different ways to use Template Toolkit, and Dreamwidth uses it via the Perl Template module. I installed this module on my laptop by doing this:

$ sudo cpan Template

Then following this tutorial: Devshed: getting started with the Perl Template Toolkit, I put the following two files in the same directory:

People of [% planet %], your attention please.

This is [% captain %] of the Galactic Hyperspace Planning Council.

As you will no doubt be aware, the plans for development of the outlying regions of the Galaxy require the building of a hyperspatial express route through your star system, and regrettably your planet is one of those scheduled for destruction.

The process will take slightly less than [% time %].
Thank you.

Read more... )
anarres: (Default)
My mission for today is to learn about the Template Toolkit. I've tried to look at TT a couple of times already, each time, aw, yeah, this is going to be really easy, but I came out feeling completely mystified. So I've been putting it off, and thinking, maybe I can get away with just using BML, but since Dreamwidth as a whole wants to move from BML to TT it seems like it would be a bit perverse to do new work in BML. So, today is the day that I sit down, drink coffee, and figure it out.

I've posted this, so now I have to :-P
anarres: (Default)
Exams are done, so now my project can finally get going! First off I'm working on a graphical front-end for the statistics system, that makes pie charts, bar graphs and line graphs. This is built using the GD Graph library, and it is awesome :-)

I really like this thread at Geek Feminism, where people listed their favourite female science fiction writers. I want to read all these books, although that will probably take about 5 years. Other things I want to read this summer: 'Bad Samaritans' by Ha-Joon Chang, and 'Gödel, Escher, Bach: An Eternal Golden Braid', by Douglas Hofstadter. And I plan to make a new, better version of genderBender, and, somewhat terrifyingly, learn German grammar.

Time flies by so fast, the cute fuzzy goslings of Castlefield Basin have become less cute, but still-charming-in-their-own-way adolescents:

anarres: (Default)
Gearman and Schwartz are both for running server scripts that will take more than a couple of seconds. Gearman does things at a precise time and Schwartz gets them done at some not-precisely-determined time. Workers use the Schwartz.

Check on how the Schwartz is doing by going to ~/dw/bin and doing this: $ perl schwartzmon --help

/admin/stats displays only if logged in as a user with 'payments' priviledges.

The stats system only works if bin/worker/stats-collection was run within the past 24 hours. This can either be done by a worker or run manually.

Both /admin/stats and /stats/site on dreamhack sometimes show only a blank page, but they sometimes work if you close all other tabs, or log out and then log in again.
anarres: (Default)
My particle physics exam is later today! I generally react to exam stress in funny ways, like procrastinating a lot and not being able to sleep. So..

There is a type of fundamental particles called quarks. Each quark can come in one of three "colours" (nothing to do with what the word "colour" means in everyday life). If you smash an electron and a positron together in a particle collider, you get a shower of particles, which can be divided into two broad types: hadrons (things made of quarks) and leptons (things that aren't made of quarks). Using the laws of particle physics you can predict what the ratio of hadrons produced to leptons produced should be. The actual experimentally measured ratio is three times higher than what you would expect if quarks did not come in three colours, so this ratio is taken to be evidence of the existence of colour.

This argument is based on the principle that if species Z can decay either to A or to B, it will decay faster than if it could just decay to A, all other things being equal. This principle comes up in physics a lot and it is always presented as being obvious, but it didn't seem that obvious to me. So I wrote a python script to simulate particle decay (notice the word "procrastination" in the title of this post :-P ). It's funny how writing a simulation can clarify your understanding of a system, because as soon as I started writing the pseudocode in my notebook I realized that for every time step, I would do two (simulated with a random number generator) die rolls, one to see if Z decays to A and one to see if Z decays to B, so yes, obviously a particle with more decay routes has a greater chance to decay (all other factors being equal) and it was silly of me not to realize that before.

But anyways I wrote a script (procrastination!) that does this:

For every time-step:
Z -> A with probability p
Z -> B with probability p
A -> Z with probability p
B -> Z with probability p

I let it run to see what the equilibrium concentrations of A, B, and Z would be. (By equilibrium concentrations, I mean that no matter what initial amounts of A, B and Z you start with, if you let the simulation run long enough you eventually get to a certain ratio that stays constant thereafter).

I thought the equilibrium concentrations would be: 50% Z, 25% A, 25% B, because I thought that SYSTEM 1 was equivalent to a simpler system:

For every time-step:
Z -> C with probability p
C -> Z with probability p where C = {either A or B}.

I think it's clear that SYSTEM 2 would lead to equal amounts of Z and C. But SYSTEM 1 didn't do what I expected - instead it went to a third each Z, A, and B! I can't figure out why it does this - somehow SYSTEM 1 knows that A and B are not the same, but how does it know this? It seems that A and B do the same thing and behave as if they were the same thing, but somehow the mysterious Laws of Mathematics can tell them apart.

So either I wrote the python script wrong, or my understanding of the system is wrong, dunno. I'll have another look at it later... (It's silly to write scripts when you're a) sleep-deprived and b) not going to have time to debug them, it just leads to confusion.)
anarres: (Default)
I'm doing the exam study thing, which is frustrating - my courses are interesting but exam study makes you forget this and just focus on getting marks. I'm really excited about the statistics project, but I have to wait for exams to be done before I'll be able to spend a serious amount of time on it.

On my way into uni I take a slight detour so that I can walk along Castlefield canal basin instead of along a motorway. Not many people come by this way. I usually pass by this family of geese, two big ones and five little ones.


The big ones are really very big and actually quite intimidating - they've got big, scary, bitey beaks and they hiss at me to let me know they're pissed off that I've entered their space. The small ones are fuzzy and yellow and very cute, and totally oblivious to me. I sometimes stop for a few minutes to watch them (from a respectful distance) and as far as I can tell they have three activities: pecking the ground for food, grooming themselves, and grooming each-other. They have a funny way of walking around, going a few steps in one direction, pecking the ground, then switching to a different, random direction. Brownian motion - not a good strategy for traveling from A to B, but a very good searching strategy. Their path has a fractal dimension somewhere between one and two and in theory if they walked for an infinitely long time their path would completely fill a two-dimentional area.

My procrastinate-o-meter is pinging, better get back to work.
Page generated Oct. 23rd, 2017 01:19 pm
Powered by Dreamwidth Studios