Monday, 9 November 2009

Lyx split listings inset

When converting program source into literate source using Lyx, it is
convenient in the first instance to allocate a listings inset for each
source file, but as I annotate and break up each listing it becomes
cumbersome to split the listing into parts.

I find that generally I want to select part of the inset I am working on
and move it to a new inset either above or below the current inset.

Perhaps I will select from the current position to the start of the
inset and want to split into two insets: i.e. split-at-cursor

Lyx 1.6.3 and before is pretty bad at that; but these macros can be
assigned to keystrokes:

To move selected text into a listing inset below; I assigned this to

command-sequence cut ; char-delete-backward ; escape ; listing-insert ;

To move selected text into a listing inset above; I assigned this to
SHIFT-CTRL-ALT-? (because ? is on the same key as /)

command-sequence cut ; escape ; up ; char-forward ; listing-insert ;
paste ; char-delete-backward

This makes it easy to split insets.

Friday, 23 October 2009

Intelligent machines

Reading The Leakproof Singularity and Simulation we have the quote from 1965 by British statistician IJ Good:
Let an ultraintelligent machine be defined as a machine that can far surpass all the intellectual activities of any man however clever. Since the design of machines is one of these intellectual activities, an ultraintelligent machine could design even better machines; there would then unquestionably be an intelligence explosion, and the intelligence of man would be left far behind. Thus the first ultraintelligent machine is the last invention that man need ever make.
count the some falacies here...

Never mind that the first statement may not actually be possible: "Let an ultraintelligent machine be defined as a machine that can far surpass all the intellectual activities of any man however clever.";

never mind that intelligence may or may not be embodied within machines, we have the questions:
  • "an ultraintelligent machine could design even better machines; there would then unquestionably be..." Would the unltraintelligent machine want to design a better machine? It may think it wiser not to.
  • Even if it were so, man might invent another intelligent machine to save himself from the ravages of the first.
  • Philosophically, there is a case to argue that man is such an intelligent machine created by the earth, and does she regret it now?

Friday, 19 June 2009

Justification for piracy

2 comments which say an awful lot; from slashdot story in which someone in the USA is fined $80,000 per song for copying 24 songs illegally.

As a side note, I've heard that in the UK it is not legal to copy a CD you have bought to your mp3 player in order to listen to it; copyright law was established before the means to replicate and distribute were available to the public - or indeed the desire or need to do so for private use (like copy to your mp3 player). It seems unfair therefore that copyright law is rigorously interpreted is this the context of today.

Also note; I am not justifying piracy but noting someone else's comments:

Re:Justifying piracy
(Score:5, Informative)

by hairyfeet (841228) <`bassbeast1968' `at' `'> on Thursday June 18, @08:28PM (#28383463)

One sentence- Steamboat Willie is STILL under copyright! The man has been pushing up the daisies (or sitting in the freezer, whichever you
prefer) for over half a fricking century, yet his FIRST work, one made when planes were made out of cloth and antibiotics were just a dream, is STILL under copyright.

Most of us here are for fair copyright.
Of course most of us would consider the outright bribery of our elected officials by multinational corporations to be treasonous. The US copyright system, which is being forced down the throats of more and more nations, was a CONTRACT, nothing more. In return for a LIMITED monopoly in the form of government imposed copyrights We, The People got in return a richer and more diverse Public Domain for all of us.

But we have been robbed, and the contract broken. We, The People are no longer represented anymore, because we can't cut individual checks to bribe our own elected officials like the multinationals can. Until We, The People are once again represented at the bargaining table then ALL copyrights should be considered by the people of this country and all those who have American copyrights forced upon them null and void and completely ignored. Crooked laws created by bribed officials should be looked upon as the illegal acts that they are. Period

Re:Justifying piracy (Score:5, Insightful)

by nine-times (778537) <> on Thursday June 18, @10:29PM (#28384575) Homepage
The US copyright system, which is being forced down the throats of more and more nations, was a CONTRACT, nothing more. In return for a LIMITED monopoly in the form of government imposed copyrights We, The People got in return a richer and more diverse Public Domain for all of us.

Somehow this is what seems to get lost in a lot of copyright discussions. Not to give a complete history of the copyright, but there was a time when we had no copyright, and people wrote books, painted, composed music, and performed it because they wanted to, and often they found ways to get paid for their expertise and talent. One common way was to do work that someone else wanted them to do on commission, whether they wanted to do it or not. Though many artists wished to have control over their own work, it was just silly to expect as much. Another artist would copy your painting, or another author might rewrite your story, and that's how culture developed.

And basically all that was fine until the the printing press arrived, and book publishers started making a fortune from printing books, neglecting to pay the authors. People recognized this as unfair and discouraging to those who might want to write a book, so they invented the idea of the copyright. The idea wasn't to ensure profitability for  publishers by forcing readers to pay for the right to read a book, nor was it meant to allow authors to control the destiny of their work, but it was solely a way to help authors get a share of the huge profits publishers were already making.

Flash forward to the present, and now copyrights are being  manipulated in such a way as to have almost the opposite effect that was intended. Copyrights are being used to guarantee profits for the publishers, while the artists are being denied their fair share of the profits. If anything, the Internet should allow us to go back to  pre-copyright days, since distribution doesn't really require a "publisher" in the same way.

Now I'm not saying we actually should drop copyrights, but only that convention has twisted the purpose of the copyright and given bad expectations about what copyrights will accomplish. Now we think that people own, buy, and sell ideas. Further, that if you own an idea, you should retain ownership and complete control forever. That's just an unsustainable situation.

I import much of my music from mp3sparks in Russia, which as far as I can tell (and I've spent over an hour researching) is legal. I'm sad that the artist doesn't get their 2 pence per track (or whatever) but consoled by the fact that the immoral music industry doesn't get the other 98 pence. The fact that music publishers have directed artists not to register with the Russian copyright agency to receive their Russian equivalent of 2p makes me laugh even more. The only widely acclaimed moral response is actually to not buy music published by immoral publishers at all.

Saturday, 23 May 2009

Mormon Radio - In Latin!

Mormon radio is available at

Sadly, the media transport is RTMPT, a proprietary adobe format, which limits reception to those with an adobe flash plugin. That also means x86 PC architecture.

This excludes all streaming audio devices in the world except Adobe Flash. Oh - and there will be iPhone support soon.

How can this seem nearly OK? There are loads of widely supported mechanisms for streaming audio - why choose one with such limited support? This is like publishing the bible only in Latin - because everyone speaks Latin - or at least everybody who needs to read the Bible speaks latin. And what's so special about the iPhone that cuts out my streaming radio?

(Read more at:

Vatican radio on the other hand does it quite well:

It supports wma, real (and mp3 in the left column) and no need for any freaky platform-restricted plugins.

So, I'm a church member and I can wake up to Vatican Radio, but not Mormon Radio - why, exactly?

Someone has to make an active decision and sign a large purchase order to do things as wrong as this.

However, by standing on the shoulders of advocates of software freedom, using wireshark to look at the network packets and recognize RTMP as the protocol, swfmill to take to pieces the flash radio player to get the audio addresses, and flvstreamer to dump the audio, I managed to cobble together a system that allows the stream to be converted into an MP3 stream so that mp3 players can pick it up. I've called this the Wycliffe hack in commemoration of John Wycliffe who strove to make religious material available to everyone.

flvstreamer/flvstreamer_x86 -v -r rtmpt:// -s> -p -o /dev/stdout > RADIO.flv

Of course I don't want to dump to a file called RADIO.flv, I want to convert the stream to mp3, but commands like this work:

cat RADIO.flv | ffmpeg -f flv -i - -f wav -

if they read from flvstreamer stdout, they fail!

So while I've solved the hardest problem, I need to sort out the glue.

Saturday, 2 May 2009

About a year ago I was called as second councillor to the Bishop in Wakefield Ward.

One of my responsibilities is to arrange the meeting programme and to give out speaking assignments, and then conduct the meeting for four months of the year.

I like to be well prepared for things which would otherwise be embarrassing, so to help me I produced an open office writer template that has four pages.

The first page is a meeting programme, with some grey fields to be filled in with things like,
  • the date and meeting type
  • the person conducting the meeting
  • the speaker names and topics, and duration etc.
By filling this in I get a regularly formatted meeting programme which helps me when conducting the meeting.

The bonus, however, is pages 2-4, which are speaker assignment letters and are automatically filled in for me. They inform each of the speakers of
  • the date and topic
  • how long they should plan to speak for and at what time they should finish
  • what other topics will be addressed in the same meeting
  • some tips on good preparation
  • who to contact for further information
So I write out the meeting programme and the computer generates a helpful invitation letter which I can edit if particular speakers need additional information or encouragement.

And I hit print!

Recently the template broke because I used a variable date internally which now (I guess) seems to conflict with some changes in OpenOffice 3. As OpenOffice documents are zip files, the simplest fix was to unzip the template and do a search and replace on the document xml, to replace date with mdate:

$ mkdir t
$ cd t
$ unzip ../vSacrament\ Meeting\
$ sed -i -e 's/name="date"/name="mdate"/g' content.xml
$ zip -r ../x.odt .

And then open and re-save the document in OpenOffice

Thursday, 23 April 2009

Practical Jokes

Practical Jokes - all the fun of mean tricks with none of the guilt.

Ever have trouble coming up with a mean trick that is appropriate to the
situation and also compliant with your nice personality? Of course you

Practical Jokes have none of these problems, and are often expected to
be in bad taste. What's more you'll gain the reputation of being fun to
be with.

Stop your individualistic and crass cheap bullying and buy our practical
jokes today! People will like you for it!

Monday, 20 April 2009

Wild virtues

While reading Daniel Hannan's "If you pay people to be poor, you'll never run out of poor people" blog post, I came across this lovely quote from G. K. Chesterton:
"When a religious scheme is shattered, it is not merely the vices that are let loose. The vices are, indeed, let loose, and they wander and do damage. But the virtues are let loose also; and the virtues wander more wildly, and the virtues do more terrible damage. The modern world is full of the old Christian virtues gone mad. The virtues have gone mad because they have been isolated from each other and are wandering alone. Thus some scientists care for truth; and their truth is pitiless. Thus some humanitarians only care for pity; and their pity is often untruthful." - GK Chesterton

Tuesday, 17 March 2009

Auto-mount of windows shares on Ubuntu login

Based on and updated:

$ sudo apt-get install libpam-mount smbfs
$ echo "@include common-pammount" | sudo tee -a /etc/pam.d/gdm
$ echo "@include common-pammount" | sudo tee -a /etc/pam.d/login

fix up server= and mountpoint= below

$ sed -i -e '/<!-- Volume definitions -->/a<volume user="*" fstype="cifs" server="" path="users/%(USER)" mountpoint="/home/%(USER)/ntfs" options="uid=%(USERUID),gid=%(USERGID),iocharset=utf8,fmask=0770,dmask=0770" />' /etc/security/pam_mount.conf.xml

Make sure unix password is same as windows password and unix username same as windows username unless we use ldap in nis, but thats another story…

Monday, 9 March 2009

MS PPTP VPN server with linux

I've been tearing my hair out for the last 8 working hours trying to get my Ubuntu Hardy VPN helper to connect me to a Windows 2003 PPTP service.

A windows PC would connect fine, but my linux clients would all fail, generating this message in the Windows server Event log: "You do not have permission to connect using the selected authentication protocol."

I'd done what I could to make sure my RAS policies specified MSCHAP, MSCHAPv2 and had EAP disabled (I had no certs and was fed up of RAS failing for lack of them). My linux clients were also selected to use only MSCHAP and MSCHAPv2 - but still no joy!

The final missing tip was the last post at:
where it seemed that I had to make sure the RAS servers own authentication methods matched (or probably were a superset of) the authentication methods of the policy. Once that was fixed, it all worked fine.

While I was there I also set the correct adaptor for use by DHCP/DNS/WINS as I only have one active adaptor anyway!

Tuesday, 17 February 2009

USB-B3G on Asterisk

I got a couple of the yealink USB-B3G from Maplin Electronics at £3 each, meaning to get them to work with asterisk.

By being busy I get last-movers advantage and find it all works from years of other people doing it for me:
  1. The kernel already has the USB drivers installed.
  2. USB2KAPI provides a libusb style daemon to control the device, available from
  3. The asterisk driver for that is written at

Monday, 9 February 2009

Debugging Makefiles

Debugging makefiles is hard work, and makefiles that make extensive use of @ to hide invoked commands make it hard to see what command failed.

Dr Dobbs has some useful tips from which I derive the simple solution to my problem, to use /bin/sh -x as SHELL; i.e.

make SHELL='/bin/sh -x'

then the shell will print out the invoked commands, even if make won't!

Monday, 19 January 2009

Sins of the children? Israeli war machine copies Nazi war machine

Sometimes the children pay for the sins of the fathers.

It seems like the Israeli war machine (which is opposed by many Israeli citizens) is committing the sins that their fathers paid for.

Look at this side-by-side picture selection - it’s only the newer colour images and better quality photographs that distinguish the Jews as victims Jews as aggressors.