Thursday 19 October 2006

Counting nodes

I had a problem where I needed to assign a unique integer to each node in a tree, as it was processed; using XSLT 1.0

XSLT 1.0 doesn’t have user definable functions, the only way to return values is as output which can be captured in an

<xsl:variable name="captured"><xsl:call-template name="generate-output"/></xsl:variable>

And, naturally, the tree recursion was already generating output and could not easily be used to return a count of nodes processed so far as well.

After a couple of hours of struggling and some syntax checking with my brother Ben (for things like $node/ancestors::* - thanks bro) we have a fragment that does the trick in one line!

count($node/preceding::rule[ancestor::*[generate-id()=$ancestorid]])

This is more clearly excodessed as:

count($node/preceding::rule[count(ancestor::*[generate-id()=$ancestorid])])

and in english reads as: to find the sequence number for $node, count all preceding nodes who are contained by the common ancestor identified by $ancestorid. Without the codedicate, it would count all preceding nodes in the entire document, instead of those with a certain ancestor.

However this is not complete. preceding does not take into account open nodes, i.e. the node to which it is being applied, nor any of it’s ancestors; so this correction is added:

+ count($node/ancestor::rule) - count($ancestor/ancestor::rule)

as the number of non-counted nodes is clearly the difference between the number of ancestors of $node, and the number of ancestors of $ancestor.

The full statement is:

count($node/preceding::rule[ancestor::*[generate-id()=$ancestorid]])

+ count($node/ancestor::rule) - count($ancestor/ancestor::rule)

I leave it to the reader to produce a version that reports the total number "rule" nodes under the current ancestor.

Finally I used this recipe:


  <xsl:template name="rule-number">
    <xsl:param name="name"><xsl:message terminate="yes">rule-number called without name</xsl:message></xsl:param>
    <xsl:param name="rules-node" select="//dbam-bandwidth-rules"/>
    <!– take the first occurance of each rule (no preceding of same ancestor) –>
    <xsl:variable name="all_rules" select="$rules-node//rule[not(@name = preceding::rule[count(ancestor::*[generate-id()=generate-id($rules-node)]) &gt; 0]/@name)]"/>
    <xsl:for-each select="$all_rules">
      <xsl:if test="@name=$name"><xsl:value-of select="position()"/></xsl:if>
    </xsl:for-each>
  </xsl:template> 

Tuesday 3 October 2006

Kenneth Cope

Greater Than us All is a great album.

I just shelled out some dosh (hard earned cash) to buy the CD version having played my casstte album to oblivion.

I was interested to see some tracks were re-recorded; and it comes to this:

Do you have an original CD album you could send me?

I don’t like the new recordings. They are not what my mind has become adjusted to, and even worse it starts to follow a trend set by the mormon tabernacle choir which seems to be to put inappropriate expression into the performance.

I probably should explain this last accusation a bit more, and I’ll use the tabernacle choir to explain.

I think the choir get bored singing the same old hymns and such so they try and jazz them up and put a bit more emotion into it, but that doesn’t make it better, it only makes it weird. Oh, but its probably more fun to sing.

(Did I mention I’m finding it hard to get decent mo-tab music lately? I’m thinking of downloading all the conferences and ripping the choir out of the middle ot build up a new compilation).

I want "Mo-tab: The same boring old hymns" type stuff, you know, "like momma used to bake" so to speak.

Now you haven’t done a bad job on the new cut of Greater Than Us All, but you are following the trend; a bit more unexpected desparation or wonder in the voice, delay the vocalists entry slightly by half a beat, drag out a middle phrase note for no good reason, it drives me mad. Not every phrase of the song needs to sound like some kind of epiphany or revelation; the song has to do that as a whole, but these days each phrase is trying to compete with the whole song.

It ends up sounding like the emotional expression of some other song overlayed onto this one. (Its nice variety for folk who have sung the song to death no doubt)

Please, be a nice man and send me what you hooked me on, not this slghtly freaky stuff. I like my music straight: A CD of your original cut of Greater Than Us All.

Thursday 31 August 2006

ASCII character conversion

The od command can be used after a fashion to convert from a character to its character code:

 echo -ne "A" | od -t u1 | sed -e "s/^[0-9]* *//"

But more awkward is converting from a decimal character code back to the character, but this does the trick, and took about 3 minutes to come up with:

$ X=65
$ HEX=(0 1 2 3 4 5 6 7 8 9 a b c d e f)
$ echo -e "x${HEX[$(( $X / 16))]}${HEX[$(( $X % 16 ))]}"


It works by converting which is less than 255 to hexadecimal, and then making use of echo -e which interprets \x as indicating an 8 bit character expressed in hexadecimal.

Tuesday 1 August 2006

Online Textbooks


Like many geeks I collect knowledge so that I will be able to do things if the need comes up, whatever things they are. Here’s a good list of refererences books supplied by nTensify who wrote:

There are a lot of free textbooks out there, some of them are better than others, but a lot are quickly becoming very good.

Plain and simple, everyone should have access to education, money shouldn’t dictate how educated someone can become.

Some other free books:
http://www.physicsforfree.com/ (three physics books from beginning physics to general relativity).
http://www.lightandmatter.com/area1.html (six physics books, variety of topics)
http://www.motionmountain.net/ (notably one of the best free physics books ever "published").
http://www.math.wisc.edu/~keisler/calc.html (intro to calc book under Creative Commons)
http://www.allaboutcircuits.com/ (a really cool free circuit design book I ran across a few years ago when I was leaving college).
http://www.gutenberg.org/ (obligatory gutenburg link, aggrigator of books out of copyright or otherwise set free).

(there are plenty more, but to spare you the boredom of a huge list here… go to google and search for digital library books, you’ll have a few million hits to look through ;) )

Thursday 29 June 2006

Smart Programmer, Smart Doctor


A smart programmer who can’t sleep and is told by his doctor to count sheep, will write a small shell script to do it for him.

The smart doctor will write a shell script to tell programmers who can’t sleep to count sheep.

A colleague pointed out that if I were a smart programmer I would have written a shell script to tell the joke. Instead I write it up on my blog, what does that say?

Of dweebs, nerds and geeks

munpfazy posted on slashdot, an excellent precis on the hierachy of dweebs, nerds and geeks.

Because I’m slack, I copy it here as well; read on:

Re:Clasic anti Nerd Propiganda


by munpfazy (694689) on Wednesday June 28, @01:40AM (#15618760)

Nonsense, I say. Worse still - blasphemy! To place the nerds above the geeks is an offense of the worst kind.

There *is* a clear distinction and a value hierarchy among geeks, nerds, and dweebs, but you’ve got it all wrong.

What follows, I claim, is the one true classification of geekdom. It has stood up to rigorous peer review (loud arguments amongst drunken physics students) for years, and I stand by it.

A dweeb is someone without social skills who either doesn’t recognize or is unable to accept that they are unusual. They constantly *try* to fit in, with disastrous results, and dedicate a significant portion of their daily lives to obsessing over how to pass as normal.

A nerd is someone without social skills or popular interests who recognizes that he or she is unlike most people and feels no shame in it.

A geek is a nerd with technical skills and passionate interests; in particular one who has a myopic dedication to a particular specialty. (This is the subspecies *true geek,* distinct from but related to the *common geek,* or nerd who is generally technically savvy and useful to have around.)

To summarize, the dweeb is the guy wearing a slightly out of fashion hipster shirt who generally creates embarrassing silences at parties by saying awkward things about pop stars or sports teams.

The nerd is the guy who skips the party in order to achieve moderately high scores on a popular video game while eating unheated canned peas with a spoon and listening to recordings of experimental music.

The geek is the guy who skips the party in order to code a popular video game, figure out the angle of repose one might expect for a pile of canned peas, or compose and record some experimental music.

On the college campus, geeks make up virtually the entire population of physics and math majors (as well as a majority in classics, many of the less trendy engineering sub-disciplines, linguistics, physical anthropology, and some of the more obscure languages.)

The nerds are the guys who drop out of school after one semester but stay in a college town working in a bookstore, where they get great discounts on whatever genre books they happen to like and talk to their geek friends about writing their own books yet never seem to actually finish any of them.

The dweebs largely end up in engineering or the quantitative business disciplines, in the hopes that they can earn enough money to buy the respect of powerful and attractive people. Those in engineering have a tough time of it, as they are publicly ignored by the normals whom they so admire while simultaneously earning the scorn and contempt of the geeks in their departments. Those in business do rather well, since they have a good chance at fooling their colleagues into thinking that they are geeks. (Normals may not invite geeks to parties, but they do like to hire them.)

Friday 2 June 2006

Orange GPRS on SPV C550

Recently I impressed my boss by getting the company Motorola RAZR support phones to connect to Orange GPRS in about 10 seconds flat with the help of google and this script (sorry, can’t find the site it came from now, let me know if you can [dear reader])

#!/bin/bash

/usr/sbin/pppd connect ‘/usr/sbin/chat -v ABORT "NO CARRIER" "" "AT&F" OK "AT+CGDCONT=1,\"IP\",\"orangeinternet\"" OK "ATDT*99#" CONNECT’ \
/dev/ttyACM0 115200 defaultroute crtscts noauth deflate 0 asyncmap 0 mtu 1500 mru 1500 noipdefault idle 600


anyway, I thought some variant of this would work on my SPV C550, but it was hell!

Finally, thanks to Mikko Rapeli and his SPV specific notes I came up with this variation in my /etc/rc.local (bootup hacks)

rmmod usbserial
modprobe usbserial vendor=0×0bb4 product=0×00cf


Now, I just use the Applications/Modem applet on my SPV to enable USB modem before plugging it in, and I have a modem on /dev/ttyS0

Mikko’s pages were somewhat helpful and so was Paul Perkins but the main gotcha with this SPV is that it needs to login, it really needs to, it goes on begging until it is allowed to, so the username is: user and the password is: pass.

It was only reading pppd man page and thinking about Paul’s chap-secrets (which everyone else ignored) that tipped me to this, so I used Mikko’s gprs config but changed the username in the /etc/ppp/peers/gprs file to: user and turned on noauth (which is about the remote called end authenticating back to the caller).

My /etc/ppp/chap-secrets entry looks like this:
"user" * "pass" *

and all’s well with the world.

And why does Ubuntu dialup network configuration seem worse than for SCO 3.2v4.2?

There’s no need for custom dialup scripts for most things these days, yeah a chat connect/disconnect script might be needed for a specific modem type, but  after that all modems follow the same patterns; a couple of init strings, a number to dial, and then a username or password and some ppp options for the data connection.

So what's with ubuntu’s ppp0 (and only ppp0) tricks?

Tuesday 30 May 2006

Web Colours

A while I go for my employer I wrote some php that would rotate the colour palette of a gif file in hsl colour space. It let me do things like "get the green version of that blue button"

- I’m not so hot with colours you see, I need things to constrain my choice of possibilities, which is why I appreciate the Accessability Colour Wheel, I can now choose colours on technical reasons instead of asthetic reasons.

I’m more comfortable with this.

Saturday 20 May 2006

BBC Flash Update

[UPDATE: I have to say it was all my fault. Even though I had the non-free flash plugin install in ubuntu, it wasn’t activiated, I was using GPL Flash 4. Shame! The BBC were blameless - almost - IMHO they should have shown a popup dialog to warn the user and then gone on to see if their flash player could handle it; however thats a minor point compared to my foolish mistake]

To follow up on my previous post, and to prove that it is the javascript flash detection code at fault, I edited the html source of one of the offending pages from this:

if ((ssit_FlashPresent == 2) && (ssit_FlashVersion >= 5)) {
document.write (’<object id="hideandhelp" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100%" height="85%"><param name="movie" value="intro.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFF66"><embed name="hideandhelp" src="intro.swf" quality="high" bgcolor="#FFFF66" width="100%" height="85%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" swLiveconnect="true"></embed></object>’);
}
else {
document.write(’<img src="/cbeebies/totstv/music_sounds/images/console.gif" alt="" width="500" height="300" border="0">’);
}


to this:

if (1 || (ssit_FlashPresent == 2) && (ssit_FlashVersion >= 5)) {
document.write (’<object id="hideandhelp" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100%" height="85%"><param name="movie" value="intro.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFF66"><embed name="hideandhelp" src="intro.swf" quality="high" bgcolor="#FFFF66" width="100%" height="85%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" swLiveconnect="true"></embed></object>’);
}
else {
document.write(’<img src="/cbeebies/totstv/music_sounds/images/console.gif" alt="" width="500" height="300" border="0">’);
}


(In otherwords "just show me the flash anyway, foolish computer); and suddenly the flash all started working again.

If the BBC are buying this ssit flash detection code from a commercial company then I think they are wasting their money, if they would adhere to well known standards there wouldn’t be this problem in the first place.

This would be a better solution:

<object id="hideandhelp" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100%" height="85%"><param name="movie" value="intro.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFF66"><embed name="hideandhelp" src="intro.swf" quality="high" bgcolor="#FFFF66" width="100%" height="85%" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" swLiveconnect="true"><img src="/cbeebies/totstv/music_sounds/images/console.gif" alt="" width="500" height="300" border="0"></embed></object>

If they really want to use the ssit stuff… they still shouldn’t. The answer would be to only explicitly block combinations known to fail, rather than only permit those known to succeed; but their source for these combinations known to fail would probably be as faulty as their current code is, and so is doomed to fail.

I’m just writing up a firefox plugin which will be available worldwide on the firefox plugins page to fix known faults with the BBC’s CBeebies website; unless of course the BBC manage to fix their website first….

I have posted my feelings and proofs to the BBC at http://www.bbc.co.uk/feedback/tech_fault_web.shtml

Update: nobody just writes a firefox plugin for the first time. I have more fun finding the fault than writing a work-around which I hope will soon be unnecessary.

BBC and FLASH on Linux

It looks like the BBC web team have changed the way they detect flash support in various browsers.

For example CBeebies pages like Tots-TV no longer work for me.

Where I was able to view flash in BBC websites, I now cannot, even though I can use flash in other websites like www.homestarrunner.com

I have multiple computers running the official flash 7 plugin from macromedia, with a firefox browser and Ubuntu Linux operating system.

Flash works fine for my family on many sites, and used to work on BBC until recently.

A common error with flash  support detection java script is for the person who wrote the script to think that they have covered all cases.

A common unfortunate consequence is for the flash detection javascript to actually be the obstacle instead of the helper.

Flash detection code should offer help or support in case things turn out to work but the  default fallback should always be to try the usual standard way of doing things without clever browser specific tricks.

Friday 21 April 2006

Key-value pair files to xml

This sed script will read in a key-value pairs file, you know, like this:

NAME=Joe & Freds
CLASS=Cafe


into xsl attribute lists, like this:

name="Joe &amp; Freds" class="Cafe"

ready to be stuck in the middle of a tag.

sed -e '
/=/{ # make sure it has an = sign in
h # save current line
s/=.*/=/
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/

x # get back original line
s/^[^=]*=// # loose attribute name
/./{ # anything left?
 s/&/&amp;/
 s/"/&quot;/
 s/</&lt;/
 s/>/&gt;/
 s/^/"/;
 s/$/"/;
 H #append to stored line
 x # get it all back
 s/\n//
 p
}
d
}
d
'


Tuesday 18 April 2006

ALSA stuttering sound

Trouble with applications playing audio stuttering badly, particularly mplayer with:

alsa-space: xrun of at least 0.068 msecs. resetting stream0.4% 10 0
alsa-space: xrun of at least 0.069 msecs. resetting stream0.4% 10 0
alsa-space: xrun of at least 0.065 msecs. resetting stream0.4% 10 0


Wonder no more, read on at the ALSA Wiki, particularly the comment by Daniel further down on why 48000 is sub-optimal in most cases.

Friday 7 April 2006

Closed Source Kernel Drivers with B#

I commented in recently on use of B# for Linux kernel modules, a B# VM can be done in 8K or less, has a small instruction set and can implement interrupt handlers.

On reflection this is more likely to be popular under the BSD’s who don’t have so much GPL philosophy to contend with.

Hardware manufacturers could provide one set of cross-platform B# binary drivers to run under MAC-OS X and *BSD - any architecture.

Hardware drivers need to make use of a very limited part of the kernel API, the main purpose of a hardware driver is to manage resources for the hardware and implement a standard API for that piece of hardware.

The B# glue layer - somewhat like ndis-wrappers - will be the layer that copes with evolving kernel API’s. And possibly also get ported to the linux kernel - and I really don’t know if this a good thing.  Although Linus has commented against static kernel APIs to support binary modules, he has also refrained from heartily condemning suppliers of binary only kernel modules - often providing their on source-based API glue to the binary module.

While I’m a GPL fan and paying member of the FSF (not card carrying:- my bootable FSF membership card had developed some nasty blemishes making it unbootable by the time I came to need it, so I threw it away) I can see that simpler provision of hardware drivers could speed adoption of a broader selection of  hardware platforms and operating systems.

It remains to been seen to what degree adoption on the wrong terms, i.e. without free software rights, is harmful. If more open source drivers follows the borader consumer adoption, it is maybe beneficial; I’m not yet at the level of Stallman where I can say "free software or no software" - I like my nvidia drivers, although I really wish they were free.

I’m just hoping that B# drivers would require enough meta data to link to make decompilation easy, I do want my source and the ability to fix bugs.

Which might mean that B# is just a glitzy gadget and for the kernel, a bad idea after all.

Monday 3 April 2006

XSLT Hex to Decimal Conversion

Here’s a trick I came up with to convert some XML values from hex to decimal.

I made clever (awful?) use of substring-after and substring-before and a string-based lookup table.

Very nasty, but with whats available, very neat:

  <!-- output $hexNumber as decimal, recursive so not too many digits please... -->
  <xsl:template name="HexToDecimal">
    <xsl:param name="hexNumber" />
    <xsl:param name="decimalNumber" >0</xsl:param>
    <!– If there is zero hex digits left, output –>
    <xsl:choose>
      <xsl:when test="$hexNumber">
        <xsl:call-template name="HexToDecimal">
          <xsl:with-param name="decimalNumber" select="($decimalNumber*16)+number(substring-before(substring-after(’00/11/22/33/44/55/66/77/88/99/A10/B11/C12/D13/E14/F15/a10/b11/c12/d13/e14/f15/’,substring($hexNumber,1,1)),’/'))" />
          <xsl:with-param name="hexNumber" select="substring($hexNumber,2)" />
        </xsl:call-template>
      </xsl:when>
      <!– otherwise multiply, and add the next digit, and recurse –>
      <xsl:otherwise>
        <xsl:value-of select="$decimalNumber"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!– If it begins with 0x then parse it for sure, else return it –>
  <xsl:template name="asDecimal">
    <xsl:param name="number" />
    <xsl:choose>
      <xsl:when test="substring($number,1,2)=’0x’">
        <xsl:call-template name="HexToDecimal">
          <xsl:with-param name="hexNumber" select="substring($number,3)"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$number"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


Invoke with
  <xsl:call-template name="HexToDecimal">
    <xsl:with-param name="hexNumber" select="@hexValueAttribute"/>
  </xsl:call-template>


Or some such

Friday 31 March 2006

Unattributed

"He’s more deceptive than he looks"
"On the surface he’s very caring but deep down he’s a shallow person"
"Nostalgia isn’t what it used to be"

Solar Roof

See on TreeHugger.com, If you are not looking to convert your loft anytime soon, you might want to look at adding electricity-generating solar panels to your roof.

They don’t look like the ugly water-heating solar panels you may have seen from time to time, which look rather like roof-top cucumber frames; these panels could be mistaken for glitzy roof tiles.

Take a look at SolarCentury, as well as maybe getting a 50% grant towards instalation cost, you have the peace of mind of knowing that not only have you reduced your carbon footprint, you’re earning some cash helping others to do the same by selling surplus electricty to your electric company!

Bobby Robson quotes

"I wouldn’t say that we underestimated them. No. It’s just that they played far better than we expected."

"He’s very fast and if he gets a yard ahead of himself, nobody will catch him"

"My father had 5 sons, I had 4 brothers"

"They’re 2 points behind us, so we’re neck and neck"

"I’m not going to look beyond the semi-final - but I would love to lead Newcastle out at the final"

"Well, we got nine and you can’t score more than that"

"I do want to play the short ball and I do want to play the long ball. I think long and short balls is what football is all about"

"Eighteen months ago they (Sweden) were arguably one of the best three teams in Europe, and that would include Germany, Holland, Russia and anybody else if you like"

"He never fails to hit the target. But that was a miss"

"I’d say he’s the best in Europe, if you put me on the fence"

"Tottenham have impressed me: they haven’t thrown in the towel even though they have been under the gun"

"I played cricket for my local village. It was 40 overs per side, and the team that had the most runs won. It was that sort of football"

"Both teams - and Brazil even - got better on their way to the World Cup final"

"There will be a game where somebody scores more than Brazil and that might be the game that they lose"

"We don’t want our players to be monks, we want them to be football players because a monk doesn’t play football at this level."

"All right, Bellamy came on at Liverpool and did well, but everybody thinks that he’s the saviour, he’s Jesus Christ. He’s not Jesus Christ"

Wednesday 29 March 2006

Shell script wrappers

Sometimes a bash script needs to invoke another program, but for temporary compatability reasons needs to override some environment variables to affect it’s behaviour.
A common way is to do this:

flanger() {
  MODE=compat /usr/bin/flanger "$@"
}

flanger-test() {
  MODE=compat /usr/bin/flange-test "$@"
}

and then call flanger as normal.

I had a case where this kept cropping up so I finally wrote this:

env_wrap() {
  local env=""



  # collect VAR=VALUE pairs for environment
  while :
  do
    case "$1" in
      *=*) env="$1 "; shift;;
      *) break;;
    esac
  done



  for prog in "$@"
  do
    eval "$prog() { $env `type -p $prog` \"\$@\"; }"
  done
}


Now I just do

env_wrap MODE=compat flanger flange-test

And it’s all taken care of

Beggars can’t be choosers

There’s many software projects I would donate to, but don’t because they don’t take paypal. Why does this matter?

Paypal is quick, doesn’t involve getting my wallet out and typing in a long credit card number and trying not to make a mistake. And I don’t want to give me credit card number to every random Joe who is short of cash.

The latest is OpenSSH. I don’t know if they have particularly severe financial problems, but I use openssh often enough that I figure I owe them some money.

So I click on the make a donation to the OpenSSH project link, but they don’t take paypal. So I click on the Discuss this article on the forum link so I can suggest "Hey guys, why don’t you take paypal?" but I have to register first… already I can’t be bothered.

It’s a similar story with the Debian Software Foundation, and Advocates For Free Government, both vaguely worthy causes in need of a bit of cash, but they don’t make it easy to give.

So I didn’t.

On the other hand I pay £3 a month to Cedega so I can play battlefield2 under linux.

Sam

UPDATE:

Thanks Natalia (below);

From OpenSSH Donations at:
http://www.openssh.com/donations.html

I go to:
https://https.openbsd.org/cgi-bin/donations

and then:
http://www.openbsd.org/donations.html

and I can donate to OpenBSD via paypal.

I didn’t find this very obvious. That link on the OpenSSH donations page talked about credit cards, not paypal, hence I didn’t click.

I want to donate to OpenSSH not OpenBSD - yes I can recognize that 2 pages away from the paypal page it said I could mark the payment for "OpenSSH" but I’m beginning to lose confidence that my money will go to OpenSSH. DFSG (Debian) donations also got this complicated.

However, I have now made a donation to OpenBSD put down to OpenSSH

Natalia, thanks ot you OpenSSH has another $20

Saturday 25 March 2006

Dapper Dodges

I dist-upgraded from Breezy to Dapper - a bad mistake, lvm shutdown and unmounting at reboot failed and corrupted my root FS like a Labour Lord,

In the end I had to do a re-installation of Dapper flight 5 which leaves the problem of all the Ubuntu missing packages that are required for a useful system.

Here are some of the harder ones, saved for posterity:

For Amarok, install amarok-xine and configure xine to use ALSA - yay!

For dvd playing, add this to sources.list

deb-src ftp://ftp.nerim.net/debian-marillat sarge main

And then after apt-get update do

apt-get -b build-dep libdvdcssapt-get -b source libdvdcssdpkg -i libdvdcss2_1.2.9-0sarge0.0_i386.deb libdvdcss2-dev_1.2.9-0sarge0.0_i386.deb

My sources.list is:

deb http://gb.archive.ubuntu.com/ubuntu/ dapper main restricteddeb-src http://gb.archive.ubuntu.com/ubuntu/ dapper main restricted

deb http://gb.archive.ubuntu.com/ubuntu/ dapper-updates main restricteddeb-src http://gb.archive.ubuntu.com/ubuntu/ dapper-updates main restricteddeb http://gb.archive.ubuntu.com/ubuntu/ dapper universe multiversedeb-src http://gb.archive.ubuntu.com/ubuntu/ dapper universe multiverse

deb http://gb.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiversedeb-src http://gb.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu dapper-security main restricteddeb-src http://security.ubuntu.com/ubuntu dapper-security main restricteddeb http://security.ubuntu.com/ubuntu dapper-security universedeb http://security.ubuntu.com/ubuntu dapper-security universe

deb-src http://security.ubuntu.com/ubuntu dapper-security multiversedeb-src http://security.ubuntu.com/ubuntu dapper-security multiverse

deb-src http://ftp.debian.org/debian testing maindeb-src ftp://ftp.nerim.net/debian-marillat sarge main

Friday 24 March 2006

b# for kernel modules?

Reading from http://www.embedded.com/showArticle.jhtml?articleID=183700818;

B# (pronounced “be sharp”) is a tiny, object-oriented, and multi-threaded programming language that is specially dedicated for small footprint embedded systems.

It has a mini-kernel, and can implement interrupt handlers. What I want to know is; can it be used to write portable cross-platform linux kernel modules?

More info, and sign up as a beta test at http://www.deepobjectknowledge.com/

Thursday 23 March 2006

Is Joker.com Joking or Choking?

Joker DNS servers are unavailable from most parts of the world for a few days now.

http://www.dnsstuff.com/tools/lookup.ch?name=joker.com&type=A

fails miserably, as it does for most joker hosted domain names.

I’m only using their website now because of an /etc/hosts entry pointing to 194.176.0.86

194.176.0.86 www.joker.com joker.com

All these fail:

nslookup www.joker.com 207.44.185.10

nslookup www.joker.com 194.176.0.2

Whats going on? I’ve filed a support ticket, lets see what they say…

DDOS Attack on Joker.com Nameservers
Joker.com currently experiences massive distributed denial of service attacks against nameservers.
This affects DNS resolution of Joker.com itself, and also domains which make use of Joker.com nameservers.
We are very sorry for this issue, but we are working hard for a permanent solution.
Thank you for your understanding,

Your Team of Joker.com

Sunday 19 March 2006

KISS of death (Keep it stupidly simple)

GNOME takes the biscuit (Americans seem to like that word lately).

The new GNOME Screensaver UI is so stupid you can’t actually do anything useful apart from choose the screen saver.

I upgraded Ubuntu from Breezy so at least my GLSlideShow screensaver works, cos I configured it before I upgraded to Dapper, but some poor folk are stuck! Dapper GNOME screensaver UI doesn’t even let them tell GLSlideShow WHERE to find the photos! See their cries of pain in their bug report.

GNOME is going so far backwards that only a granny will be happy with it, any one with an ounce of sense will quickly graduate to KDE so that they can do someting the way they want to, see my cries of pain at regressing from a quick cross-fading slideshow of all my photos to a ghastly 5 times showing over 10 seconds for each photo. 

When family members pass around new photos I don’t spend 10 seconds looking at a single one, I certainly don’t want to spend 10 seconds on a load I’ve seen before.

Of course with GNOME, thats what I’m doomed to, until the GUI designers think it worthwhile, but I doubt that they’ll descend from their abstract usability values to something so concrete as actual usability.

Of course I could fork GNOME (free software is all about freedom, which GNOME are denying me) or just move to KDE.

Thank goodness for Kubuntu.

Saturday 18 March 2006

A house, for One Red Paperclip

I was looking for cabin style bunk beds on ebay and ended up getting myself a real ebay bargain: A holday cabin in Wales for renting, for only 10 pence. (preserved for posterity  here)
Rename to .pdf to view full document
I was going to rent it out (as the buyer suggests) but I think I could trade it on One Red paperclip, it could be the house he is looking for! I don’t want the recording contract but maybe he can get something else…

Thursday 2 March 2006

Drivers License Checking

This company, Intelligent Data Systems, provide a driving licence checking service which works directly off DVLA data.

Why would anyone want to do that?

Bank charges and pension post offices

In the UK the banks closed branches "cos there’s cash machines and its cheaper".
Then they decided to charge a quid a time to use the cash machine (now there’s few branches left).
Idiots.

it didn’t last long before all the banks were boasting they THEY didn’t charge for ATM use.

Co-op bank NEVER charged for ATM use and also allowed post offices to be used as branches.
-Which also makes it funnier about pensioners complaining about pensions being paid into bank accounts and not collectible from the post office, and even stranger that the Co-op bank didn’t say "hey guys, get your pension paid into a co-op account and then come and get it out the post office".

Weird.

Saturday 25 February 2006

Postscript Layout

Normally I pipe my postscript printouts through xpp. Sadly xpp’s multiple copies doesn’t seem to work for my printouts, and it also lacks the ability to scale and rotate the image to get multiple smaller copies per page.

I wrote a quick bash script I put together so I can scale A4 postscript printouts to fit multiple images per page, so to print 4 per page, with 2 pages I now pipe through:

| psmul 4 2 | xpp

Here it is:

#! /bin/sh
MUL=${1:-8}
PAGES=${2:-1}
SPEC="0"
C=1

while test "$C" -lt "$MUL"
do
  SPEC="$SPEC,0"
  C=$(($C+1))
done

NUP="$SPEC"
C=1

while test "$C" -lt "$PAGES"
do
  SPEC="$SPEC,$NUP"
  C=$((C+1))
done

pstops $SPEC | psnup -$MUL

Thursday 23 February 2006

Hard to buy from DELL

I have a friend who wants to buy a laptop. At work I use a nice Dell M70 with a good Nvidia 3D graphics card. Very nice to play Battlefield2.

It’s very hard to find a Dell laptop with a 3D graphics card, or a way to select Dell laptops with this option.

I thought I’d point out this deficiency to Dell and ask for their help.

The Dell contact web page has a link to Customer Care general Order enquiries but I have to create an account before I can ask a question or point out their problem that makes it too hard to buy from them. It’s too complicated. I don’t even know if I want to buy a Dell laptop, I’m looking for someone else.

So I just closed my jolly browser and got down to watching Pride and Prejudice with my wife.

Wednesday 1 February 2006

Amarok Spasms

Amarok happens to be the best media player out there. Apart from windows media player which I think is pretty hard to beat, but Amarok has all the essential features.

Sadly, recent Ubuntu KDE updates have had Amarok unable to run more than a few seconds, so after depriving my family of music for a few days I came home to find my daughter trying to stuff what turned out to be compact discs into the CD player. She was doing it right, it just un-nerved me.

Time to get out the Breezy backports from Dapper Drake and see if a new Amarok fixes things for me.

I used source-o-matic to cough up the latest official backports repository to add to my /etc/apt/sources.list

This gives me Amarok 1.3.7 which thankfully does manage to stay up for more than a few seconds.

Faking bash history

In the bad old days, hackers get a root shell and disable bash_history so the true owner of the system wouldn’t know what they’d been up to.

These days they get a reverse shell via icmp or some such and don’t even generate a bash history so it doesn’t really matter that bash with readline enables the selective prevention of command logging in bash_history.

Try this;
  1. get a bash shell
  2. type a command; maybe: zookie
  3. close the bash shell
  4. get a bash shell
  5. press the up arrow, there is your command, nicely in bash history.
  6. close the bash shell

Now try this:
  1. get a bash shell
  2. type a command, maybe: secret-command
  3. press the up-arrow
  4. ^U (or lots of backspace) to delete the command
  5. type a new command but don’t press enter, maybe: mundane-command
  6. press down-arrow
  7. press enter

Now if you press up-arrow you will see mundane-command instead of secret-command, if you quit the shell and get a new shell, your command history shows the mundane-command which you did NOT execute instead of the secret-command that you DID execute.

Interesting

Tuesday 17 January 2006

Sweet KDE file views

Take a look at this KDE4 screenshot.

It looks like it merges the GNOME button address bar AND the old typeable address bar. Sweet! Just what I wanted!

The whole lot of screenshots look amazing. Usually such screenshots are more a way to show off wallpaper that the GUI, but KDE4 makes me say I want it.

I tried KDE3 over GNOME, but the blinding appearance overcame the lack of usability in GNOME, so I stuck with GNOME. I can’t exmaplin what is wrong with KDE3 look and feel that is fine with GNOME, although I can say it isn’t the paucity (lack) of being able to do things in general with GNOME.

Another annoyance with GNOME. I want to turn off my grid for my desktop layout but not for folder layouts, and I want the default view for lots of folders or non-image files to be list view.

Friday 13 January 2006

Prank Callers Revenge Complete

Here is the final part on how I got my modem to automatically answer and drop phone calls from certain numbers that had been troubling me.

My Intel 536EP is famous for not supporting CLI, and slightly famous for the odd Intel engineer saying it does support CLI. No-one in the world has made it work.

Luckily, my sister in law returned my USR 56K external modem on Sunday, so I stick that in ttyS0 and remove the graphics stylus I wasn’t using anyway. This modem gives no problem recognizing CLI.

I decide to write my CLI Dropper in bash, for fun, and get more grief then you could imagine. It sounds easy, a quick stty, echo a few strings to the modem port and then enter a while loop to read back the response. Sadly bash’s bufferred IO reads too much (naturally) but then tries to put back the extra stuff using seek on a pipe. Well! This fails on a tty, and so lots of the output gets lost. It took me quite a while and use of strace to work this out.

Instead now, I use cat to pipe the output of the modem into a bash segment. Because cat is reading from a tty it is unbufferred, but also bash’s seek works, so everything is fine.

cat /dev/ttyS0 | while read line 

So now I just keep a list of banned phone numbers in /etc/clidrop. Banned callers get treated to about 5 seconds of modem noise before getting hung up on. All calls are logged in /var/log/messages, so I can look back and see what went on.

Here is my shell script, complete and tested:

#! /bin/sh

: ${MODEM:=/dev/ttyS0}

# modem on stdout
exec > "$MODEM"
stty igncr 38400 min 1 time 5 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke < $MODEM

send() {
  echo -ne "$*\r"
}

command() {
  send "$*"
  echo ">$*" >&2
  read response
  test "$response" == "$*" && read response
  echo "<$response" >&2
}

checkNumber() {
  echo "Check $1" >&2
  grep "^$1\%CONTENT%quot; /etc/clidrop &> /dev/null
}

# nasty cat hack cos bash "read" can’t unread extra lines from a tty
# but cat doesn’t buffer if it reads from a tty
cat "$MODEM" | (
command "AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0"
command "ATL0M0" # turn of speaker
command "AT#CID=1"

while read -s response
do
  case "$response" in
    "NMBR = "*)
      NUMBER="`expr "$response" : ‘NMBR = \(.*\)’`"
      if checkNumber "$NUMBER"
      then
        logger -t CLIDROP "Drop call from $NUMBER"
        echo "<$response DENIED" >&2
        send ATA
        sleep 5
        send ""
      else
        logger -t CLIDROP "Permit call from $NUMBER"
        echo "<$response PERMITTED" >&2
      fi;;
    *) echo "<$response" >&2;;
  esac
done


My /etc/clidrop file is has these numbers in:
08700500524
01413018000


Why does bash try to seek on input stream after a read? It’s so that it can pretent that it did not read more than it returned, and then any internal or external commands spawned will be able to get stdin from that point. Of course such external commands are not so nice, sed …/q will have slurped more of stdin than it ought to and so some of the remainder won’t be available to the calling bash script; so why is bash trying to be nice? Ah well… it’s what comes of pretending that a collection of commands and bash are a homogenous programming environment like perl.

Saturday 7 January 2006

Prank callers revenge

I mentioned previously that I got Caller-ID (or CLI) enabled on my line because of prank calls, or more likely, a broken call centre dialler.

As I expected, knowing who is calling doesn’t stop them calling, it just gives me a strong hint as to whether or not the caller will hangup as soon as I answer.
In the UK, CLI is passed before the first ring; so with a bit of cunning I should be able to get my PC to answer and hangup on these idiots without even disturbing me!

Time to try and get my built-in modem working under linux. I’m very pleased with my PC, it’s a Medion brand from Toys-R-US who for a long time know have done the best value PC’s, followed closely by ALDI. A bit of help from the scanModem utility at http://linmodems.technion.ac.il/ identifies my modem as being based on the intel 536EP chipset. It’s hard to get up-to-date drivers that compile and work, but this message led me to what appears to be a hidden intel download of version 4.71 hurrah; that works, although make-install fails, so I have to do a few copies by hand (boo, hiss). As far as I can tell AT+VCID=1 will turn on CLI, te rest can be done with a bash script, but first I need to set up a phone extension cable…

My ADSL modem is in a different room to my PC, I don’t have a convenient phone socket near my PC, but I do have some CAT5e network cable from my ADSL modem to my PC, so I can use the two spare CAT5 pairs to carry the phone signal. I take a modem cable and cut it in half and attach an RJ45 network connector to the cut ends. I can now transfer my phone line over my network cable. As I only have one network cable and I’m already using it, I borrow a couple of network economizers like this from work; they are a sort of Y junction that map the regular UTP network pins on one socket to the spare strands in the cable so you can carry two network connections over one cable.

I’ll probably use my new phone/network cable to allow me to put my ADSL modem next to my computer and take the splitters back to work.

Thursday 5 January 2006

Prank Callers

Recently, twice a day my home telephone is called by 0141 301 8000. When I answer, the caller hangs up, and if I return the call they hang up immediately.

0141 is a Glasgow area code, home to many call centres (bless them) and I suspect one me these is home to a rouge dialer, either that or they don’t have enough staff to take my call when I answer. However, nigh on twice a day for a week is too much, and my guess about a call centre might even bestow too much legitimacy to the incidents. Something must be done.

Treating the whole thing as maliciously executed by an unknown human, I call my BT operator to see what remedies they offer these days. Without the need to speak to a human, I am directed to call 0800 661441 where I am entertained with useful and practical ways to deal with prank callers. Finally, the robot voice offers me free caller ID if I take it at the same time as BT register my number with the telephone preference service, (which they also offer to do).

Bargain! So I can’t stop the calls, but I can avoid answering to those idiots, and I get caller ID as sort of compensation - with a marginal cost to BT of nill, and without them even needing to involve any expensive customer service call handlers. Big wins all round, them. Oh, apart from the call centres who will have to stop calling me in 28 days, thanks to the idiots behind 0141 3018000.