Search Results: "daniel"

21 November 2007

Daniel Burrows: Facebook comments

My blog is syndicated on Planet Debian, Planet GSLUG, and Facebook (through their "notes" system). I occasionally get a comment about one of my posts over on Facebook, and every time I do I remember one of the reasons I avoid that site.


[someone] made a comment about your note "note title".

To see the comment, follow the link below:
[link to Facebook]


What's missing here is of course the actual text of the comment. Blogger does this right: the actual comment is emailed to me. Not only does this impose the annoyance of having to click on the link, but I often read my email offline, and so a message like this is worse than useless for me. (worse as I have to postpone it for later, which means I need to deal with it twice) It would be even better if I didn't have to click to reply, but with a Web service you kind of expect that. (one of the reasons that I'll be setting up my own blog at some point: I can use software that actually allows me to compose replies offline)

I don't know why Facebook does this, but my guess is that either (a) they haven't thought about it, or (b) they want to drive up page views and make it annoying for me to not use their site. If it's (b), then that apparently works for a large swathe of the population, but it makes me want to avoid them like a bad cliche.

Daniel Burrows: Good ideas in customer service: kill the hold period

The lender for one of my student loans has apparently started using a rather cool system to manage incoming customer service calls. If all the call-takers are busy, then instead of forcing you to sit there listening to a call telling you how important your business is to them, they let you request a call-back. They ask you to enter a phone number where they can reach you, then give you a time window in which they'll be calling (in my case I think it was about two minutes wide). When my turn came up, they called me and I was able to speak with a human immediately.

This is such a huge improvement over the typical call center experience that I'm amazed it hasn't caught on more broadly.



I'm guessing that this option will be available in more and more places as companies computerize their telephone systems. Another nice twist, if there are any telephony guys reading this, would be to allow me to request the customer service call from a Web page, eliminating the toll-free call altogether and presumably saving some expense for the company.

An interesting question for me is how they generate those estimates of when they'll be able to help you. I'm guessing that they use some queueing theory to estimate the most likely wait time for the next incoming customer, but this is something I have only a fuzzy awareness of. However they did it, the estimate seemed accurate enough to me.

20 November 2007

Daniel Burrows: cwidget gets a Web page

I spent some time last weekend putting together the infrastructure to generate a basic Web page for cwidget. The Web page is generated by Ikiwiki (thanks to the incomparable Joey Hess for a really nice piece of code there) and doubles as the cwidget documentation; it will be included in the next upload of libcwidget-doc. It can be found in the source tree under doc/ikiwiki.

It's currently a bit skeletal: in particular, it really needs some tutorial/HOWTO material for new users. But it at least has all the basic information that I personally expect from a project Web site.


I was playing with ikiwiki for a week or so prior to setting this Web site up, and the more I use it the more impressed I am. When I get my new Slicehost instance set up (probably next weekend), this blog will probably migrate to an ikiwiki installation over there. Being able to edit my posts offline (about half my hacking time is offline), being able to expose a change history for posts, and not having to maintain an installation of a monster PHP program (as the docs put it, if you don't run the CGI then ikiwiki has the security implications of cat(1)), are all absolutely killer features for me, and I look forward to expanding my use of this tool. Joey has struck gold yet again.

12 November 2007

Daniel Leidert: GNU make vs. BSD make - a practical problem experience

I’m currently evaluating Olivier Sessinks jailkit to maintain a small cvsd CHROOT with an included SSH server. The cvsd-buildroot command e.g. doesn’t handle the libpam-modules dependency in the CHROOT. So I tried to update the Debian packaging files included in the jailkit source. During this work I found some issues with the build environment - e.g. no DESTDIR support and some other stuff (another user already complained, that there might be problems with the SUID installation part for jk_chrootsh, jk_uchroot and jk_procmailwrapper of the Makefiles). So I began to check and “fix” the Makefiles and the configure script and then sent everything to Olivier. I did not only add the DESTDIR variables. I also made use of built-in rules, common variables (also for implicit rules), … and such stuff to make the Makefiles shorter and easier to maintain. My fault: I tested everything with GNU make. Now Olivier complained, that BSDs make doesn’t work anymore. So we began a short hack session to check for the problems. My first issue: I had to find some BSD make to test it myself. I found it in the freebsd5-buildutils, that contains the freebsd-make command. Then we began to check for incompatibilities and that’s the result:
  1. ifdef statements differ in syntax
    • GNU make uses ifdef VAR
    • BSD make uses .ifdef VAR
    solution: We replaced the statement with a construct similar to AM_CONDITIONAL. But we do not use this macro, because it would need to be shipped in aclocal.m4, which is currently not necessary. The code simply sets a variable foo_TRUE to ‘# ‘, if the condition is wrong, or the variable is left empty, if the condition is true:
    if test "x$my_condition" != "xno" ; then
        AC_SUBST([foo_TRUE], [])
    else
        AC_SUBST([foo_TRUE], [# ])
    fi
    FILES = bar
    @foo_TRUE@FILES += foo
  2. prerequisite variables differ in syntax
    • GNU make uses $<, $^, $@, …
    • BSD make uses $ .IMPSRC , $ .ALLSRC , $ .TARGET , … (note, that both *SRC variables hold a list of source files)
    Unfortunately both make implementations doesn’t seem to share a variable for the list of prerequisites. So the only solution is to list all prerequisites in the rule again. A variable would be much more comfortable. Maybe one could write a function, that first tests $ .IMPSRC and falls back to $^. Maybe that’s an alternative, but it’s IMHO not a very good solution. We’ve chosen to write down all prerequisites in a rule instead of using a variable. This is a little bit “harder” to maintain, but it works.
  3. built-in rules are not shared and do not use the same variables
    • GNU make ships built-in rules to build objects from sources and link them; rules consider CPPFLAGS
    • BSD make ships built-in rules to build objects from sources, but there are no rules to link them; rules do not consider CPPFLAGS
    In the case of GNU make, one can simply write:
    myprog: foo.o bar.o
    and GNU make will automatically create foo.o from foo.c (.c.o:, ditto for bar.o) and at least link myprog (.o:). But BSD make will only create the object files. There is no final link-step. So we had to include the rule to link the program in the Makefile.
Finally we got it and it looks good now. I/We learned a lot of new things (I learnd a lot about BSD make) ;), but it took us 1-2 hours to understand and fix the problems. Here a list of URLs, that might give some more information about the programs, their syntax and limitations:

11 November 2007

Daniel Burrows: ANNOUNCE: cwidget

I've just uploaded the first release of libcwidget to Alioth and NEW. libcwidget is a high-level C++ library for developing user interfaces that run in a terminal using curses as the display and input layer. It uses widget abstractions similar (but of course not identical) to those found in GTK+ and Qt, with signals and slots provided by libsigc++.

Background

Back when I started writing aptitude, I had one general goal:

Just because it runs in a terminal doesn't mean it has to suck.


I tried to apply this in the user interface, but I also applied it internally. The curses programs I looked at before writing aptitude all had very ad-hoc UIs. In many cases the code was structured with each "view" that appeared mapped to a custom C function call; if the author was feeling ambitious, similar-looking screens might be abstracted into a single function call, but the basic structure of the interface still reflected the call graph of the program.

aptitude had a primitive interface abstraction layer from the get-go; over the years, I borrowed ideas from GTK+ and restructured this layer into a full widget set. libcwidget is this code, disentangled from the guts of aptitude and slightly cleaned up. Because of its history, it is missing widgets that aptitude doesn't need (like a multi-line text editor), but it provides an extensible base that you can build upon.

Getting cwidget

The cwidget library is available (both as source and as an i386 .deb) from the cwidget Alioth releases page. There is also API documentation automatically generated from the upstream repository, which, while it is woefully incomplete, should provide some information: I've tried to write Doxygen tags into most of the code I've added in the last 4 years or so.

The upstream code repository is in git (because what fun is a new project if you don't learn a new VCS?) and available here. To retrieve a copy of the repository for yourself, run this command:

git clone git://git.debian.org/git/cwidget/head cwidget

10 November 2007

Manoj Srivastava: Manoj: The Secret Servant

I bought this book by Daniel Silva last week at SFO, faced with a long wait for the red eye back home, since I recalled hearing about it on NPR, and reading a review in Time magazine, or was it the New Yorker? Anyway, the review said he is his generation s finest writer of international intrigue, one of America s most gifted spy novelists ever. I guess Graham Greene and John le Carre belong to an older generation. Anyway, everything I read or heard about it was very positive. Daniel Silva is far less cynical than Le Carre, and his world does not gel quite as well, to my ears, as Smiley s circus did. The hero, Gabriel Allon, does have some super human traits, but, thank the lord, is not James bond. I was impressed by Silva s geo-politics, though - paragraphs from the book seem to appear almost verbatim in current event reports in the International Herald Tribune and BBC stories. I like this books (to the extent of ordering another 7 from this author from Amazon today), and appreciate the influx of new blood in the international espionage market. Lately, the genre has been treated by lack luster, mediocre knock offs of the Bourne Identity and the engaging pace of the original has never been successfully replicated in the sequels. And Silva s writing is better than Ludlum s.

8 November 2007

Ross Burton: Perils Of Commerical Software

daniels: lightroom makes me so unbelievably content
daniels: if i were a doe-eyed schoolgirl
daniels: and you were showing me this in the back of your car
daniels: i'd let you take me, there and then
I knew showing Daniel Adobe Lightroom was a bad idea... It is a truly majestic application though, with that killer combination of a very clean interface and incredibly well thought-out features.

7 November 2007

Andrew Pollock: [life/americania] "As keen as mustard"

Daniel observes that the simile "as keen as mustard" isn't grokked by Americans, and had some trouble explaining the etymology of it. As far as I understand it, it derives from a brand of mustard, known as Keen's. Keen's mustard

6 November 2007

Christian Perrier: And now for something completely different...

... I just learned how to use Mercurial after Daniel converted his darcs repository for aptitude to Mercurial. Being such a VCS wizard when you're told to be the DD with no programming skills is kinda scary...:-)

5 November 2007

Daniel Burrows: Building rails

In the 1860s, in the middle of one of the largest wars America has ever been involved in, a 690-mile railroad was built in a period of seven to nine years (depending on how you count), a rate of about five days per mile of track. Now, it's certainly true that this was accomplished through labor practices that were, by today's standards, more than a little bit questionable. However, I still am amazed that it's apparently going to take us twenty years to construct fifty miles of track in the Seattle area. By my count, that's a hundred and forty six days per mile of track. And I haven't even mentioned the harsh environmental conditions the transcontinental line faced, which a line in the Seattle metro area by and large does not.

I haven't decided how or whether to vote in the election tomorrow, but the timescale they're projecting is ... astonishing.

4 November 2007

Daniel Burrows: Lessig at the University of Washington

On Friday 2007-11-02, I watched Larry Lessig give a presentation at the University of Washington entitled Is Google (2008) Microsoft (1998)? Since it was Lessig, the talk was articulate and thought-provoking, and he used his slides very well (unlike many presenters who just read bullet points).

The argument he made is that Google is like Microsoft in some ways (and so are other companies like Facebook). In his analysis, the problem with Microsoft was that so many companies made themselves Microsoft-dependent, which both forced other companies to follow suit (due to network effects) and gave Microsoft leverage they could use against everyone in their ecosystem (e.g., Netscape). According to Lessig, Microsoft was not evil to use this leverage, but you have to recognize that Microsoft will do what is best for Microsoft, and this may not be what is best for you. He then suggested that we should be aware of the potential for the same thing to happen; in support of this point, he quoted excerpts from the terms of service from the APIs of Google and Facebook, which contain typical statements like we reserve the right to terminate your use of this service for any reason or for no reason, and asked: What if Microsoft had written this license agreement?

But it seemed to me that this wasn't his main point. He was using this observation as a springboard to talk about issues revolving around competition and public policy. Specifically, he feels that we should work towards a more just model of interaction between companies and users whose work makes the company more valuable (by contributing to a software ecosystem, by posting content on the Web site, etc). But the correct way to do this (he says) is not via competition, after-the-fact litigation, or voluntary codes of conduct: competition may not be around to enforce good behavior (as we've seen with Microsoft), litigation may be too late and ineffective (again, see Microsoft), and voluntary codes of conduct will disappear as soon as they get in the way of the bottom line. The correct approach, he argued, is across-the-board regulation so that all the companies have to play by the same rules.

From there he went on to talk about governmental corruption. He said (quoting Robert Reich's book Supercapitalism) that the reason we consistently look for solutions in the market and in voluntary compliance is that our governmental system is broken and does not effectively regulate corporations in the public interest. But Lessig is optimistic that we can change things (he joked that his publisher was unhappy with this point of view, because his brand has been built on pessimism). In his view, the politicians in Washington, by and large, want to be honest and do good, but they aren't able to within the current political system. For instance, on the few occassions that he managed to get access to lawmakers to discuss copyright issues, it was often the first time they had heard that there was more than one side to the argument. He thinks we need a national political movement that will shame politicians into being less corrupt.

This is all a simplification of what he said, of course; unfortunately, I wasn't able to find a recording of this talk on Lessig's Web site, or I'd point you at primary source material. I don't know if this is because he chose not to post it, or because it just hasn't been made available yet.

My view

In general, I thought that the speech was very interesting and well thought out. But as much as I'd like to buy into his optimism that we can fix our system, I don't think it's well-founded, for two reasons.

First, he argued that competition will resolve some of these problems (that was before and after he said we can't rely on competition, which I found confusing and may indicate that I misunderstood something). His evidence for this seemed to be that when Microsoft was dominating the world, users responded by reducing their dependence on Microsoft products and by switching to alternatives such as Linux. But, in fact, although more people may be using Linux than in the past, virtually everyone is still only using Windows, it's still almost impossible to find a programming job that isn't Windows-only, and Microsoft is still raking in money hand over fist; indeed, they're doing so well that they're planning to expand their workforce by a third. To take just one data point of many: I ride the bus to Seattle and back, and I regularly see other people using laptops as they commute. Virtually all the laptops run Windows. Occasionally I'll see a Mac, and every few months I'll see a guy running Linux on his laptop; I say "a guy" because it's the same guy every single time. So by my estimation, use of Linux on laptops in buses on the 545 route from Redmond to Seattle is way below 1%, with Macintoshes somewhere around 5%.

To broaden my point, I think Lessig has fallen into a trap that highly intelligent people, particularly those in academia, tend to fall into. In academia, you are surrounded by people who value learning and thinking deeply about the world. These are people who will give serious and unbiased consideration to questions like what is the social effect of my acceptance of the Facebook Terms of Service? and If I become dependent on this service, will that possibly affect me in five years if the company decides to act against my interests? The problem with this is that these people are not representative of the population at large. The population at large thinks why is this check-box getting in the way of me sending pictures to my friends? And I have no doubt that any kid who, e.g., refuses to sign up for Facebook as a protest against their TOS will be roundly mocked in their social circles for being a weird antisocial nonconformist. (of course, this may not apply to the small minority of people like myself whose social circles consist of weird antisocial nonconformists)

Second, Lessig's optimism about the political system seemed to be based on his observation that the people in government are, by and large, not venally corrupt: they want to do good, but the system is constructed in a way that makes this impossible. To me, that's a tremendously disheartening statement. If our problem were simply a few, or even many, corrupt politicians, this would be a solvable problem: even nowadays, Americans have some ability to choose who gets elected, and I believe that a sufficiently well-coordinated campaign could replace bad politicians with good ones.

But if the problem is that the system is corrupt even when the individuals are honest, it's a much deeper problem and frankly one that I don't know how to solve. While individuals have some direct control over who gets elected, we have no way to directly change the system that produces the corruption; the levers to do this are in the hands of the politicians elected through that broken system. It's unlikely that the politicians themselves will fix the problem, because they've benefited deeply from it: if the system is left as it is, well over 90% of Congress members will keep
their jobs
in the next election cycle, and any effective change seems likely (by definition) to disrupt this cushy arrangement.

On the other hand, running new candidates for office will not fix the problem. After all, if the problem is that the system is corrupt even when the participants are honest, then putting more honest people into government will have no effect. In order to get elected, these new politicians will have to become just as corrupt as the old ones, because that's how the system is set up. So we might change the faces, but we'll have the same old problems.

I recall two specific concrete proposals that Lessig made to make the system more responsive. First, he suggested shaming politicians who engage in corrupt behavior -- presumably taking large donations from interested parties. I don't see how this will help. Americans generally have a very low regard for the political class as it is; will pointing out particular examples of politicians taking money really make a difference when it comes to votes? And if it doesn't, will it really produce any change in their behavior? Politicians are motivated by votes the same way corporations are motivated by money; unless they stand a chance of losing their job (which is virtually impossible in any event), there's no reason for them to change how they behave.

His second proposal was for a system of contributions where it's impossible for any individual to prove they had donated a particular amount of money to a particular candidate. Even assuming it could be implemented perfectly, I don't think this will really solve the problem, for two reasons. First, it's not generally a secret what moneyed interests want. Politicians who want to attract large donations can just take positions that they know will appeal to donors of that sort. The donors themselves can make this easier on the candidates by, e.g., posting public position statements on issues of the day. Secondly, and this is far more insidious, even if politicians honestly represent their positions, then because success in running for office is so tied to the amount of money the candidate can raise, only candidates who hold opinions favorable to large corporations and wealthy individuals will be able to get elected. In fact, for all I know this is what happens already!

But with all that said, it was a really interesting talk and Lessig tied together some things you might not think would go together. If a video or Flash presentation becomes available, I would recommend watching through it. And hopefully my pessimistic predictions will be wrong; it's certainly happened before.

3 November 2007

Andreas Schuldei: Dear Lazyweb: How to make less coding errors

I just read Daniel J. Bernstein's paper on how to write secure software. It basically boils down to "Don't make programming errors!". This reminded me of an article which I read roughly a decade ago in c't magazine about a technique to reduce the numbers of errors when coding. If i recall correctly it worked like this: Write code, then debug it and pay attention what kind of errors you made and in what part of the process you made them. Then figure out ways to avoid those errors in similar situations in the future.

Despite spending some quality time with google I could not find a trace of this technique, let alone a name. Can someone please help me?

31 October 2007

Daniel Burrows: Mail

Amusing tidbits you pick up in the mailing industry...

No, you can't mail running chainsaws. At least I'm pretty sure about that; I don't know a specific regulation against them, but USPS takes a dim view of anything that puts its employees and machinery at risk.

On the other hand, you can mail live scorpions if you package them appropriately. Note that, however, that this is limited to the US; apparently doing so in Australia is not a good idea. The same page also gives the rules for mailing baby chicks (which must be not more than 24 hours old) as well as adult chickens (Express Mail only, please; and no refund if the chicken dies in transit unless the container was damaged).

30 October 2007

Daniel Burrows: Here we go again...


[10/30/2007]
Version 0.4.7 "Where did all these
balloons come from?
And why am I wearing
a fake nose?"

- New features:

* The options dialogs have been completely replaced by a new
interface, based on a top-level list view. This fixes many
deficiencies of the old interface: it handles long strings more
gracefully, avoids many of the focus-handling bugs that the old
dialogs had, and should generally be better-behaved.
(Closes: #197976, #331200, #424708)

* Prompts that ask you to enter text will now wrap to multiple lines
when the text gets long, rather than hiding parts of the string.

* The online help and other Help-menu itmes are now top-level views,
which should make them somewhat more usable. (Closes: #434349)

* Support for the "Breaks" field and for trigger states (thanks to
Michael Vogt and Ian Jackson for patches and prodding).
(Closes: #438543)

* Two new styles, "PkgDowngraded" and "PkgDowngradedHighlighted",
are provided to control how downgraded packages look. By default
these packages look like any other installed package.
(Closes: #434442)

* aptitude can now display homepage URLs stored in the Homepage
field of packages.


There are bug-fixes too, but those aren't as fun. So instead I think I'll include some diffstat output. Everyone likes diffstat!


daniel@alpaca:~/programming/aptitude/head$ hg diff -r 0.4.6.1:0.4.7 diffstat
.hgtags 1
NEWS 92 +
b/src/apt_config_treeitems.cc 477 ++++++
b/src/apt_config_treeitems.h 156 ++
b/src/generic/util/browser.h 42
configure.ac 20
doc/en/aptitude.xml 187 ++
help-fr.txt 10
po/ChangeLog 24
po/dz.po 188 +-
po/es.po 82 -
po/gl.po 19
po/ne.po 1277 +++++++++--------
po/pt.po 20
po/ru.po 97 -
po/sv.po 1854 ++++++++++++--------------
po/zh_CN.po 23
src/Makefile.am 2
src/apt_info_tree.cc 4
src/apt_options.cc 598 +++++---
src/apt_options.h 12
src/cmdline/cmdline_action.cc 6
src/cmdline/cmdline_check_resolver.cc 2
src/cmdline/cmdline_do_action.cc 134 +
src/cmdline/cmdline_prompt.cc 124 -
src/cmdline/cmdline_search.cc 4
src/cmdline/cmdline_show.cc 20
src/cmdline/cmdline_why.cc 64
src/defaults.cc 4
src/dep_item.cc 1
src/desc_parse.cc 2
src/generic/apt/apt.cc 32
src/generic/apt/apt.h 30
src/generic/apt/aptcache.cc 54
src/generic/apt/aptcache.h 21
src/generic/apt/aptitude_resolver_universe.cc 28
src/generic/apt/aptitude_resolver_universe.h 57
src/generic/apt/infer_reason.cc 22
src/generic/apt/log.cc 8
src/generic/apt/matchers.cc 531 +++++--
src/generic/apt/matchers.h 28
src/load_grouppolicy.cc 25
src/menu_tree.cc 12
src/pkg_columnizer.cc 19
src/pkg_grouppolicy.cc 27
src/pkg_grouppolicy.h 9
src/pkg_info_screen.cc 10
src/pkg_item.cc 31
src/pkg_item.h 7
src/pkg_subtree.cc 22
src/pkg_subtree.h 12
src/pkg_tree.cc 4
src/pkg_tree.h 1
src/pkg_ver_item.cc 31
src/pkg_ver_item.h 5
src/pkg_view.cc 24
src/reason_fragment.cc 10
src/solution_fragment.cc 5
src/solution_item.cc 76 -
src/solution_item.h 14
src/ui.cc 179 +-
src/vscreen/fragment.cc 140 +
src/vscreen/fragment.h 40
src/vscreen/ref_ptr.h 5
src/vscreen/testvscreen.cc 20
src/vscreen/vs_editline.cc 310 +++-
src/vscreen/vs_editline.h 33
src/vscreen/vs_tree.cc 113 +
src/vscreen/vs_tree.h 40
src/vscreen/vs_treeitem.cc 4
src/vscreen/vs_treeitem.h 21
src/vscreen/vs_util.cc 1
72 files changed, 4853 insertions(+), 2754 deletions(-)

Daniel Burrows: Just rub it in, why don't you!

One of my co-workers told us about a message he saw posted on a British message board about Royal Mail. For people whose job does not involve postal systems, Royal Mail is the semi-governmental semi-monopoly that handles mail in the UK; it's a little like the USPS in the States.

The funny thing about the message had little to do with the mail: apparently the poster was saying that Royal Mail's standards have deteriorated because he can no longer pick up his mail at 9:30 AM, before he goes to work. Dude! You don't even have to leave for work until 9:30 and you're complaining about when your mail comes?

I bet he gets four weeks of paid vacation, too, and then complains about how that isn't enough.

29 October 2007

Piotr Roszatycki: New YADA released.

I made a new release of YADA, the packaging helper different than others. New version of YADA supports Homepage field in debian/control file which appeared in dpkg last time. Wow. The YADA supported Home-Page field many years ago. YADA is very different that other Debian packaging helpers. Most important is that no Makefile have to be edited at all. This is the strongest and the weakest point of the YADA. People loves it or hate it. Some people even have a vendetta against YADA. Other people find the tool is very simple. Well, I think the YADA is some kind of prosthesis for native Debian packaging system, but even this prototype is much better than any Makefile-based aids just because I don't need to edit any Makefile. YADA had a black PR and much of bad FUD. There was opinion that it violates Debian policy, it is problematic for NMUs and security updates and maintaining of Debian patches is very difficult. This tool is very powerful and has some pitfalls but it doesn't mean it is evil by design. I really don't know how to make i.e. the iceape-l10n package without using YADA and its macro engine. It have to be more complicated and with much redundancy for metainformations. I think I could switch from YADA to another packaging tool, but please... Just create it! :)

25 October 2007

Daniel Jacobowitz: An adventure in Unicode PC fonts

I have always had some trouble with my eyes. One bizarre side effect of this is that switching fonts is very unpleasant. I recently got fed up with fighting things to live in the stone age of pre-Unicode fonts and locales and started hunting for a new console font. First I looked for nice new ones already designed for Unicode, with a selection of accented characters and so forth. The nicest I found was Terminus, but I’ve had trouble adjusting to it. So eventually I decided to stick with the font I’d been using - at least for now. I have been using the same font for my consoles since before 1997. This is, or at least was, the default Linux console font back when I did all my work on a VT on Linux/PPC: /usr/share/consolefonts/default8x16.psf.gz. When I started using X routinely I missed it quite a lot. Mostly that was because I used BitchX, and BitchX is written for an IBM437 code page set of line drawing characters. So I opened up that console font in xmbdfed and converted it to a PCF file. If you have Debian’s BitchX package installed, you’ve got a copy of this work in /usr/share/fonts/X11/misc/default8x16.pcf.gz. So I’ve done the same trick again. Here’s the steps I followed: Actually, after all that I was having trouble with the font’s name and eventually getting scary resource errors from X. I opened the font in gbdfed and saved it, which added some attributes and modified the bitmaps. Then I tried again and it worked. And now, I can use a UTF-8 locale and gcc’s error messages come out with foo’ (”angled” quotes) instead of display corruption! The resulting font is uni8×16, if anyone else would like it. I have switched to using it for all my terminals other than the one I run BitchX in; BitchX still needs the IBM437 version in order to display correctly. Of course, as soon as I finished this Paul Brook informed me that Konsole includes basically the same sort of font. I do not know the origins of KDE’s console8×16, but I do know that it’s a slightly different font (the @ has a smaller center, for example). And I know that I’m mighty annoyed it didn’t get added to my font path correctly when I installed konsole ages ago, since I might otherwise have found it!

24 October 2007

Daniel Stone: you can't hide from the truth

Dear Zeeshan,

yep, that's zeeshan

Ahem.

13 October 2007

Daniel Burrows: Mercurial repositories for the aptitude Debian tree now publically accessible

Since I switched the aptitude repositories over to Mercurial, I've been using hg-buildpackage to produce Debian packages. I wasn't sure at first if it would work out, so I didn't publish the repositories, and then I got swamped with work. But I've had good luck so far with hg-buildpackage, so I've uploaded the Mercurial trees to Alioth. You can find the upstream branch here:

http://hg.debian.org/hg/aptitude/debian-upstream

and the Debian branch here:

http://hg.debian.org/hg/aptitude/debian

Daniel Burrows: Monad.Reader

The Reader monad is a simple and easy-to-use structure from the Haskell library that solves a common problem.

Very often, it's the case that you have a lot of functions that all need to use the same values. For instance, you might be laying out some text on a page, and you need to keep the details of the page size around in all your layout algorithms. Typically, you handle this situation by adding a new parameter to all your functions which represents the state. So,


layoutPage :: Text -> Page


becomes


layoutPage :: PageLayoutParams -> Text -> Page


This works just fine, but it can get really ugly. Every single function gets a new parameter, which must be threaded through to every related function that it ever calls. This causes visual clutter, particularly for functions that don't actually use the parameter themselves but just pass it on.

A function written in the Reader monad is augmented with a hidden parameter. For the hypothetical example above, we would write:


import Control.Monad.Reader
type LayoutFunc = Reader PageLayoutParams

layoutPage :: Text -> LayoutFunc Page


Note that the Reader monad is partially applied here. The result, LayoutFunc, is a new monad that adds a parameter of type PageLayoutParams to any code that runs inside it.

So, now that we have this monad, how do we use it? The "ask" operation retrieves the parameter that's hidden in the monad:


ask :: Reader a a


or, specialized to LayoutFunc:


ask :: LayoutFunc PageLayoutParams


In order to remain close to the example in question, I will provide specialized type signatures for the rest of the library functions. You can find the generic type signatures in the Haskell library documentation for Control.Monad.Reader.

Suppose that layoutPage started out like this before it was moved into the monad:


layoutPage st txt =
let width = pageWidth st
...


In the Reader monad, this becomes:


layoutPage txt =
do st - ask
let width = pageWidth st
...


As you can see, we've gone from one line of code to two. As this is clearly unacceptable for a clutter-reducing device, the Reader module provides a convenience function encapsulating the above pattern:


asks :: (PageLayoutParams -> a) -> PageLayoutFunc a


This allows us to simplify the monadic implementation to:


layoutPage txt =
do width - asks pageWidth
...


It's quite common, when multiple functions share context information, to invoke a function in an altered context. For instance, we might have a layoutSubPage routine that changes the page width:


layoutSubPage st newWidth txt =
doLayout (st pageWidth = newWidth txt)


The Reader equivalent of this idiom is the function "local":


local :: (PageLayoutParams -> PageLayoutParams) -> LayoutFunc a -> LayoutFunc a


local executes an operation in a context modified by its first parameter. For instance,


layoutSubPage newWidth txt =
local (\st -> st pageWidth = newWidth ) txt


Finally, to actually invoke a computation in the Reader monad, use runReader:


runReader :: LayoutFunc a -> PageLayoutParams -> a

main = showPage (runReader defaultPageParams someText)


For much more information on the Reader monad, see All About Monads, or the Haskell library documentation.

Next.

Previous.