Xana/ xana2/ quanks
Here she comes, big as life

What seems like eons ago, I ordered one of those SheevaPlug Development Kits. After about six weeks, they got around to shipping it, and then, yesterday, after I assume a tortoise had piloted it across the country on broken tricycle, it was finally delivered to me.

I booted it up, observed that there was some kind of Ubuntu thing on it, and set myself to correct that problem. Within an hour I had managed to lock myself out.

Here is something I should have read beforehand.

Thanks to Martin Michlmayr, it is now running Debian and allowing me to log in.

Here are some steps to follow if you would like to boot Debian off of a USB stick plugged into your Sheevaplug:

That should be all there is to it.

Next I'm wondering if SDIO wireless cards work.

Posted Wed Apr 29 18:20:19 2009 Tags: armel debian kirkwood marvell quanks sheevaplug tbm
ZOMG vs. libre.fm

This is about two things that are not robust.

zomg, as of version 0.5.7, can play libre.fm radio streams without modification. It does not do this particularly well.

As of today a second type of libre.fm radio stream is available, so I will give two illustrative examples:

These stations lack the intelligence to avoid annoying duplication or much of anything but randomization. However, both zomg and libre.fm are free software, and anyone can chip in and improve this if desired.

In other news, the state of client support has moved a bit, though not as much as one might have hoped. You can get a picture of that here.

Posted Sun Apr 26 21:59:52 2009 Tags: free libre libre.fm music radio xspf zomg
Too bad that part is single-threaded

As far as I am aware (and I am unanimous in this), ZOMG is the only released software that can scrobble tracks to both libre.fm and last.fm near-simultaneously.

Posted Tue Apr 7 11:12:18 2009 Tags: audioscrobbler lastfm librefm quanks scrobbling zomg
Let us see what markdown mangles
certtool --generate-privkey > cakey.pem
echo 'cn = exampleCA' > ca.tmpl
echo 'ca' >> ca.tmpl
echo 'cert_signing_key' >> ca.tmpl
echo 'expiration_days = 732' >> ca.tmpl
certtool --generate-self-signed --load-privkey cakey.pem \
  --template ca.tmpl --outfile cacert.pem

for i in host1.example.org host2.example.org host3.example.org
do
certtool --generate-privkey > $i-key.pem
echo 'organization = Example' > server.tmpl
echo 'unit = Messaging' >>server.tmpl
echo "cn = $i" >> server.tmpl
echo 'email = postmaster@example.org' >> server.tmpl
echo 'expiration_days = 366' >> server.tmpl
#    echo 'tls_www_server' >> server.tmpl
echo 'encryption_key' >> server.tmpl
echo 'signing_key' >> server.tmpl
echo "dns_name = $i" >> server.tmpl
certtool --generate-certificate --load-privkey $i-key.pem \
  --load-ca-certificate cacert.pem --load-ca-privkey cakey.pem \
  --template server.tmpl --outfile $i.pem
done
Posted Mon Mar 23 15:29:18 2009 Tags: authority ca certificate certtool gnutls quanks script
Bowling for madducks

A long time ago, I had the idea of improving the interface between shell completion and the programs being completed. The result of this was the bzr shell-complete command (or bzr s-c for short), which was never fully fleshed out, and has since fallen into disrepair.

The principles behind this are + the program is the best place to store up-to-date and accurate information + the program already knows all these things (albeit usually in unparseable forms) + duplicating information and effort is annoying

Here is an excerpt from bzr s-c, which was intended to give a comprehensive list of subcommands, paired with short descriptions:

diff:show differences in the working tree, between revisions or branches
export:export current or past revision to a destination directory or archive
get:create a new copy of a branch
help:show help on a command or other topic
ignore:ignore specified files or patterns
ignored:list ignored files and the patterns that matched them
info:show information about a working tree, branch or repository
init:make a directory into a versioned branch

There is one subcommand per line, separated from its description by a colon. Next you can invoke something like bzr s-c diff to get the possible options and arguments for the diff subcommand, although the output you would see today is broken and nearly useless.

Since I've lost faith in bzr, I'll illustrate what the output might be corresponding to topgit's tg remote if topgit supported this kind of thing:

--populate
REMOTE

This would mean that tg remote can understand the option --populate, which takes no argument, and that the first non-option argument should be a REMOTE.

REMOTE would then be defined, for example, in zsh's _topgit function as some kind of git remote which is completed in the same way you might complete a git remote for git.

The exciting part then, is that if tg remote starts taking a --decimate option, the topgit completion helper subsystem will start outputting it and _topgit will do the right thing without having to be altered.

For tg export, things are a bit more complicated, so let's have it be described in the style of the zsh completion system:

'(--collapse)--quilt:directory:_directories'
'(--collapse -b --branch)'{-b,--branch=}':branches:BRANCHES'
'(--quilt)--collapse:branch:BRANCH'

This means that --collapse and --quilt are exclusive, that -b and --branch cannot be used with --collapse, that -b and --branch are equivalent, that -b and --branch take an argument in the form of BRANCHES, that --collapse takes an argument in the form of BRANCH, and that --quilt takes an argument that's a real directory in the filesystem.

Then _topgit would have logic to interpret BRANCH as a branch, and BRANCHES as a comma-separated list of branches.

A similar idea is the one used by axp. If you invoke axp self completion zsh, it will output zsh completion functions for you. To me this seems more onerous on both the developers and the end users, but I suppose it gives you immediate flexibility that a more generic interface would lack.

Posted Tue Nov 11 09:43:59 2008 Tags: battlefield bzr casino completion madduck quanks royale topgit zsh
VCS info in prompts

For a while, lots of people have been using their zsh prompts to display information about their current VCS (git in particular) working directories. I am no exception, though I was just doing a simple git rev-parse and git symbolic-ref in my precmd().

Starting with zsh-beta 4.3.6-dev-0+20080921-1, I am now using the vcs_info subsystem developed by Frank Terbeck. It has backends for bzr, cdv, cvs, darcs, git, hg, mtn, p4, svk, svn, and tla. These backends can be enabled or disabled via configuration.

To get it working quickly, do something like

autoload -Uz vcs_info

precmd() {
  psvar=()

  vcs_info
  [[ -n $vcs_info_msg_0_ ]] && psvar[1]="$vcs_info_msg_0_"
}

PS1="%m%(1v.%F{red}%1v%f.)%# "
Posted Sun Sep 21 11:52:25 2008 Tags: git prompt quanks vcs zsh
bts show

Freshly stolen from Europe:

b() {
  setopt localoptions extendedglob

  if [[ $# -eq 1 ]]; then
    case "$1" in
      ([0-9]##)
    links "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=$1"
    ;;
      (*@*)
        links "http://bugs.debian.org/cgi-bin/pkgreport.cgi?submitter=$1"
        ;;
      (*)
        links "http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=${1%%_*}"
        ;;
    esac
  else
    print "$0 needs one argument"
  fi
}
Posted Sun Dec 9 12:31:47 2007 Tags:
Stuffing the flash

I needed to quickly stuff a bunch of random music onto a ridiculously small vfat medium. I used this:

#!/bin/zsh
# also released under the gnocchi-ng license
zmodload -i zsh/datetime

zomg_shuffle() {
  declare -A h
  local +h -Z 5 RANDOM=$EPOCHSECONDS
  integer i
  for ((i=1; i <= $#; ++i)) { h[$i.$RANDOM]=$argv[i] }
  reply=( $h )
}

zug=( /pathtomusic/ogg/**/*.ogg )
zomg_shuffle $zug

for i in "$reply[@]"
do
 cp -v "$i" /media/tinyflashdrive/"${${i:t}//[:?\"*]/_}" || { rm -v /media/tinyflashdrive/"${${i:t}//[:?\"*]/_}" ; exit 1}
done
Posted Wed Dec 5 19:49:14 2007 Tags:
zrockboxing out

Someone gave me an MP3 player. He did so for somewhat devious reasons, but that's outside the scope of this post. It is a SanDisk Sansa—stop thinking of pulp fantasy—and it has roughly 500 gigs too little storage space. The FAQ says such cute things as “The original firmware is recommended for charging at this time,” and “Rockbox does not currently provide either functionality so you will need to continue using the original firmware (for now) in MSC (UMS) mode to add music to the Sansa.”

Please don't tell my Sansa about this FAQ because it thinks that both of those claims are false.

I want my newfangled device to participate in the spyware fiesta known as last.fm, and Rockbox has an option for supporting that; if you turn it on, it fills a /.scrobbler.log file with tab-delimited lines for your parsing pleasure.

Rather than download additional software to cope with my new lifestyle, I whipped up the following script (released under the gnocchi-ng license) which “converts” the log to something you can just stuff into your ~/.zomg/cache file and send up to the submission server at your next appropriate invocation of zomg. I'm afraid you'll have to handle any timestamp sorting by hand, but if you script it, be a dear and implement some kind of cache file locking.

#!/bin/zsh
# Copyright (C) 2007  Clint Adams.  All rights reserved.
# This program has no name and is released under the terms of
# the gnocchi-ng license.

audioscrobbler_urlencode() {
  if (( $+options[multibyte] )); then
    setopt localoptions extendedglob nomultibyte
  else
    setopt localoptions extendedglob
  fi

  input=( ${(s::)1} )
  print -- ${(j::)input//(#b)([^A-Za-z0-9_.!*\'\(\)-])/%$(([##16]#match))}
}

audioscrobbler_constructquery() {
  local sid="$1"
  local artist=$(audioscrobbler_urlencode "$2")
  local track=$(audioscrobbler_urlencode "$3")
  local album=$(audioscrobbler_urlencode "$4")
  local mbid=$(audioscrobbler_urlencode "$5")
  local length=$(audioscrobbler_urlencode "$6")
  local ttime=$(audioscrobbler_urlencode "$7")
  local source="$8"
  local tracknum="$9"

  reply=("&s=${sid}" "&a[0]=${artist}&t[0]=${track}&i[0]=${ttime}&o[0]=${source}&r[0]=&l[0]=${length}&b[0]=${album}&n[0]=${tracknum}&m[0]=${mbid}")
}

while read -r line
do
  local -a field

  field=("${(@ps:\t:)${line}}")

  if [[ $field[6] == L ]]; then
    audioscrobbler_constructquery "" "$field[1]" "$field[3]" "$field[2]" "" "$field[5]" "$field[7]" P "$field[4]"
    print "$reply[2]"
  fi
done <<(grep -v '^#' .scrobbler.log)
Posted Thu Oct 25 23:11:25 2007 Tags: rockbox
Too many colons

The zsh-lovers man page contains the following example.

# Show me all the .c files for which there doesn't exist a .o file.
$ c=(*.c) o=(*.o(N)) eval 'ls ${${c:#(${~${(j:|:)${o:r}}}).c}:?done}'

What's with the ugly dollar-sign prompt? I'd do it this way instead.

print *.c(e_' &#33; -e &#36;REPLY:r.o '_)
Posted Sat Oct 6 17:16:51 2007 Tags: