Skip to main content

Posts

Showing posts from April, 2012

Make your own 'prime factorization' diagram

The Prime Factorization Sweater is a lovely idea and I thought it would be fun to reproduce the same idea electronically so that I could print out a poster version for home.

Enter Processing.

With it I've developed a small program that produces a diagram of the first 100 numbers and for each number there's a circle broken up into arcs.  Each arc is a prime factor.  As in the original sweater each factor gets a unique color (assigning unique colors is rather complex and I ended up using the color difference method based on CMC l:c and a nice online tool that does the work for you).

Here's the finished product.  The top left corner is the number 1 and the numbers read right to left.  So the first red circle is a prime number (2), the second the next number (3, which is prime) and so on.


There's also an option to print the numbers involved.

The source code is in the pfd repository on GitHub and licensed under GPLv2. Processing is a really nice environment for this sor…

tacoli: a simple logging format

A post on Hacker News entitled Log Everything As JSON. Make Your Life Easier reminded me of my private logging strategy which has the following properties:

1. Easy to parse and analyze with Unix command-line tools such as grep, cut, sort, uniq, and wc

2. Easy to parse and analyze in code using Perl, Ruby, or Go

3. Compact

4. Easily expandable and lacking the ambiguity of simple delimited log formats

I call it tacoli (which stands for Tabs, Colons and Lines).  Here are the tacoli logging rules: Each log entry is a single line that starts with the date/time; the second entry on the line is a string called the 'generator' which indicates where the log line came from (such as the program or module); all the other entries have the format "key: value"; and entries are tab-delimited and no tabs are allowed in keys, values or the generator name.

That's it.  Here's an example log line from Apache in this format:

22/Apr/2012:06:29:07 +0000      apache  ip: 18.12.25.55 …

The Greatest Machine That Never Was

I was invited to talk at TEDx Imperial College and gave a talk about Charles Babbage's Analytical Engine called The Greatest Machine That Never Was. Here's the video of that talk:


All the other talks are here. The project to build the Analytical Engine is Plan 28.

Deglitching a Sparkfun 7-segment Serial Display

The display in my Ambient Bus Arrival Monitor is a Sparkfun 7-segment Serial Display connected to the TTL serial port.  I had noticed that occasionally the display would reset itself to 0000 (or sometimes 0, 00 or 000).  It was even possible to make it do this by touching the body of the bus.  It didn't happen often so I was able to ignore it but then it began to happen more and more.

After a very long and tedious investigation I discovered why.  I started out by blaming my code, my soldering, the cable I was using, the quality of the connectors, ...  Only having eliminated everything that I'd touched did I realize it must be something else.

The display has two input methods: serial (which I am using) and SPI (which I am not).  The SPI interface has a clock signal (which in the case of the display is acting as an input) called SCK.  The manual for the display says "The display is configured using SPI mode 0 (CPOL = 0, CPHA = 0), so the clock line should idle low".

Getting around the London 2012 branding police

The Guardian reported the other day on the London 2012 Olympics branding police who ensure that words like London, 2012 or Games aren't being used by people who didn't pay to use them:
As well as introducing an additional layer of protection around the word "Olympics", the five-rings symbol and the Games' mottoes, the major change of the legislation is to outlaw unauthorised "association". This bars non-sponsors from employing images or wording that might suggest too close a link with the Games. Expressions likely to be considered a breach of the rules would include any two of the following list: "Games, Two Thousand and Twelve, 2012, Twenty-Twelve".  Using one of those words with London, medals, sponsors, summer, gold, silver or bronze is another likely breach. The two-word rule is not fixed, however: an event called the "Great Exhibition 2012" was threatened with legal action last year under the Act over its use of "2012"…

More support for open software in science

In the space of two months both the most famous scientific journals world-wide have published pieces arguing for open source code.

Back in February myself and two co-authors had a paper in Nature arguing for open software in science.  That paper was entitled The Case for Open Computer Programs.  Last week the US journal Science published a piece entitled Shining Light into Black Boxes arguing the same thing and giving policy recommendations.

Is it not now time for an international cooperation on defining standards for code openness and associated policies?  The Science paper lays out suggested policies and could be used as a starting point:


Brief Plan 28 Update

Starting today people who asked to be kept informed about Plan 28 and the construction of Babbage's Analytical Engine have started to receive emails asking them to confirm subscription to the official mailing list.  People who want to join the mailing list can subscribe here.  The official Twitter account is @plan28.

Finally, Plan 28 is getting moving.

Over the next few weeks expect announcements about initial funding and the general schedule for the project.

Bletchley Park is Blooming

Despite the persistent drizzly rain yesterday it was clear that spring time had come to Bletchley Park in more ways than one.  The trees and flowers around the grounds were starting to blossom and bloom and inside the slightly rickety Second World War walls the museum is undergoing its own springtime.

After years of struggle to first save, then preserve and now, finally, improve this precious part of British history, the hard work by staff and volunteers is beginning to become obvious to even the most casual visitor.

I've been visiting Bletchley Park for a long time and for a while it was hard to take a non-enthusiast around because the museum itself was a bit of a jumble.  BP simply didn't have the money (or spare time away from fighting for survival) to create a fantastic museum suitable for all.  But now it's really happening and it's easy to see how Bletchley Park's spring time can turn into summer.

It's easy for me to sing the praises of Bletchley Park be…

In praise of... text files and protocols

The other night I had to debug a problem where CMYK colors specified in an OmniGraffle file weren't making it into an exported PDF (or at least appeared not to be). At first it looked like it might be a nightmare because what I really wanted to do was ignore the OmniGraffle UI and look inside the .graffle file and the PDF itself. But salvation was at hand: both .graffle and PDF are text formats. The OmniGraffle file is actually an XML document (in some cases it's a gzipped XML document but it can be decompressed with gunzip). Here, for example is part of the Colors.graffle file that's provided as a sample. It's easy to see the RGB colors that are specified and just as easy to modify them by adjusting the text file.

While fiddling around in the .graffle file looking at the CMYK colors I spotted that some straight lines that had been drawn in OmniGraffle were not quite straight. That's quite tricky to see in the UI, but dead easy in the XML document and you ca…