Search Results: "xam"

11 August 2007

Russell Coker: Is Hand-writing Necessary?

The Washington Post has an article about handwriting, apparently for some university entrance exams in the US 85% of students write their essays in block letters. The article claims that students who have poor writing skills demonstrate lesser ability to construct sentences - and claims that this indicates that there is a link between hand-writing and mental processes. While the article didn’t cover the evidence in much detail I was left wondering whether there were any tests of teaching students to touch type and then assessing them on the same tests. I suspect that increasing the ability to record text in any way would increase the sentence length and the use of long words. While students who can only write slowly will have an incentive to write more briefly. My handwriting is quite poor, I was never able to write quickly or particularly legibly and since completing university I have had little incentive to improve my writing skills. When laptops became cheap enough for me to own one (in 1998) my hand-writing skills decreased and when I started seriously using a PDA about a year ago they decreased again. I don’t believe that my writing skills (in terms of conveying ideas and instruction to other people) have declined during this time. In fact the steadily increasing amount of writing that I have done has improved my skills a lot. I think that children should be taught cursive writing, but it shouldn’t be regarded as especially important - or more important than touch typing! Then there’s the issue of the Dvorak keyboard. If the government wanted to improve the efficiency of the nation (which is what they claim to be doing) then maybe teaching all students touch-typing on a Dvorak keyboard and subsidising the purchase of such keyboards for everyone would be better than some of the current ideas in education. Dvorak keyboards would certainly be better than flag-poles! News reports indicate that hand-writing skills are decreasing dramatically in Japan due to word-processors - and a significant number of students are never learning how to write any significant portion of the Japanese letters. But the sky doesn’t seem to be falling on them either. Mark Greenaway writes about having bad hand-writing and is apparently considering some sort of remedial course. I have to wonder how good Mark’s touch-typing skills are and whether he would benefit more from improvement in that area.

10 August 2007

Biella Coleman: For those in .nl and interested in pedagogy

Pedagogical faultlines, being held in Amsterdamn in mid-September, re-examines pedagogy in light of new media technologies as well as traditional institutions…. Hopefully they will have the programme up soon, but it certainly looks quite intriguing.

9 August 2007

Michael Janssen: UI Peeves: Locking, Proximity and Purpose

I have had, on occasion in the past, a reason to use the wonderful TortoiseSVN software. It is, by all standards, a really great solution for someone wanting to use SVN in a MS Windows environment, and uses the official svn client in order to leverage open source as much as possible. Recently I have been using it a bit more as I work at Honeywell as a programmer. I've come across a couple things that bug me about the interface.

The first is that some actions inexplicably lock the place that initiates that action. The best example I have of this is when I am looking at the window for an Update, and want to see what happened in the log, I click the button to open the log, and I can't use the window while the log downloads. Sometimes this can be an issue because the server is pretty slow at producing logs for some reason (it's beyond me, and NotMyProblem(tm) because I'm not in charge of the admin). This makes it irritating because I can't inspect other files while the log is downloading. Strangely, the server actually will return other requests quickly, like the request needed to see the diff between the working copy and the tree. It would be much better if the windows were separate - they're not related to each other in effect, so the locking of the initial window is completely useless. I could have called up the log from another action, that would leave the update window perfectly usable, so I know it's possible.

The second problem that I have run across more than once relates to the proximity of actions in the right click menu while committing a change. Take a look at the screenshot of this menu.
TortoiseSVN commit context menu

There have been many times when using this window that I realize that I forgot to add a file that I need to commit, so I right click on the file and move down to the "Add" menu item, only to miss and click on the "Delete" item. "Delete", when used on a unversioned file, performs a windows delete, causing me to curse at the (now missing) entry in the commit log and go running to the recycle bin to retrieve this temporarily lost file. These two options in the context menu are entirely too close to each other. The "Delete" and "Add" actions have completely opposite meanings and effects, and having the program do exactly the opposite of what you expect is what I consider to be a Very Bad Thing. I would move the "Add" action up to the top of the list (it is, by far, the most common reason for me to use the context menu), or at least place another menu item in between.

I'm feeling like I'm being very unhelpful here, complaining about these issues in an open source project and not producing a patch to fix these issues. I may produce one in the near future - unfortunately when I'm not at Honeywell, I don't really have a Windows development environment setup.

Comments: (1) Trackbacks: (0)

Comments
  1. JD: The reason diffs are quick is because svn keeps a copy of the original file in the checkout, so diffs and reverts don't need to hit the server.
Trackbacks
  1. No Trackbacks

8 August 2007

MJ Ray: Two Answers for All Serious Free Software Contributors

etbe: Two Questions for All Serious Free Software Contributors asks:
"What do you think is the most important single-sentence of advice that you can offer to someone who wants to contribute to the free software community?"
He who does wins, so don't let the bastards grind you down.
"If you had the opportunity to say one sentence to someone who knows about computers and free software (EG they have used both Linux and Windows and done a small amount of programming) to convince them that they should join the free software team, what would it be?"
Imagine every bug you found could be fixed by you if you want, or a friend, or an enemy, or someone you hire, or the original developer, or whoever and that it's your choice who you ask to do it, with no veto from the copyright holder: that's free software. The second sentence is a bit long, but I found it hard to encapsulate the power of that freedom in one. I use the bug example rather than costs or anything, because I think that's what will be most attractive to someone who has done a bit of programming: the right answer to "why can't I fix this trivial bug?"

7 August 2007

Andrew Pollock: [debian] Doing random repository things with Python APT?

Dearest Lazyweb, I want to write a program that I can point at a standard repository, and an in-house one, so I can track version differences between common packages. I wanted to write this in Python, so python-apt sprang to mind, however the documentation is somewhat lacking, and none of the examples include retrieving a package list from anything other than the local APT cache. The documentation in libapt-pkg-doc is also rather lacking. So before I go giving up on using a "proper" library for the task, I thought I'd reach out. Love, and sloppy kisses, Andrew

Russell Coker: Blog Memes

A common pattern in blog communication is referred to as a Meme. Here is one example of the commonly used definition of the term as applied to blogs. One common factor that doesn’t seem to get directly mentioned much when people define the term (but which always seems to be mentioned in passing) is the idea of tagging people. So the definition of a meme as applied to blogs seems to be a silly question that you answer in a blog post and then request that some other bloggers (usually 5) answer as well. At the end of this post I have included the dictionary definition of the term (here is the Wikipedia definition). I believe that it is incorrect to call a question such as “which superhero do you most identify with” a meme. Instead I think that there is a Memeplex associated with such posts. One meme is that when someone “tags” you (requests that you answer a question) it should be considered an honour (someone in the blog-sphere likes you enough to ask you random questions in a public forum). Another meme is that such discussion is a good thing (although an increasing number of people in the more serious part of the blog-sphere oppose this). A final one that is apparent to me (I’m sure that there are others) is that so-called memes and lazyweb posts are the same thing (I believe this to be wrong). I believe that lazyweb posts if written about interesting topics can contribute significantly to the community knowledge base. I also believe that chain lazyweb posts (here is a link to the only such post I’ve made so far) can also contribute if created in a sensible manner. Chain posts that don’t require any thought or input from the person re-posting them (EG “please post this message to all your friends so that they can know of the terrible war/famine/earthquake/whatever in some foreign part of the world”) are of course quite useless (you can make a post of links once a month if you want to spread the news about such things). Now I agree that some amount of conversation among bloggers in a community that is personal and not directly related to the main topics of discussion is good for building the community. From Jargon File (4.4.4, 14 Aug 2003) [jargon]: meme
/meem/, n. [coined by analogy with gene’, by Richard Dawkins] An idea considered as a replicator , esp. with the connotation that memes parasitize people into propagating them much as viruses do. Used esp. in the phrase meme complex denoting a group of mutually supporting memes that form an organized belief system, such as a religion. This lexicon is an (epidemiological) vector of the hacker subculture’ meme complex; each entry might be considered a meme. However, meme is often misused to mean meme complex. Use of the term connotes acceptance of the idea that in humans (and presumably other tool- and language-using sophonts) cultural evolution by selection of adaptive ideas has superseded biological evolution by selection of hereditary traits. Hackers find this idea congenial for tolerably obvious reasons. PS This evening I had planned to go to a LUV meeting and see my friend Andy Fitzsimon (blog) give a talk about Inkscape (for which he is famous). I also had a day off work, so it was going to be a day of non-stop fun. But instead I got some sort of cold/flu, stayed in bed for much of the day, missed the meeting, and was late in my blog post. This sucks.

Cameron Dale: DebTorrent Release 0.1.3 (in package form!)

Today I have released the next version of DebTorrent. This is the first release to be available in a binary package (.deb) form, and most of the changes are related to the packaging I still consider the program to be alpha quality, though all the functionality for a beta release is there, it just needs to be tested (so tell your friends). I run the program daily and use it for my apt-based updating, so I'm pretty sure it works, but there are definitely bugs. If you do find one please submit it to the DebTorrent mailing list. The installable binary can be found on the Alioth project, or in my personal repository which can be added to your sources.list like so:
deb http://debian.camrdale.org/ unstable main contrib non-free
Once installed, it will start running automatically, and will restart on bootup, so all that is needed is to modify your sources.list files to point them at DebTorrent by prepending localhost:9988 to the mirror name. For example, the entry above for my personal repository would become:
deb http://localhost:9988/debian.camrdale.org/ unstable main contrib non-free
Here's the changelog:

6 August 2007

Kai Hendry: Digital Signage that does not crash

How many times have we seen something like: Digital signage done wrong Far too many times! I believe Windows isn’t stable enough for Digital Signage. Enter the Webcfullscreen mode option: Webconverger Fullscreen Ok, this photo slideshow example is done with Adobe Flash, however I think Flash is a suitable option and it can perhaps behave better if the connection goes down temporarily (the offline problem). Could try complex betaware like Google gears... Or customers might want a proxy feature (squid), which can be customised, so that if the Internet drops, the Digital sign could still work. Another avenue is to host user’s Web pages on a local Web server. I am not keen on this as local data would be against Webc’s design. If any of you have your own Digital Signage ‘solutions’ you would like to share, please do. Webconverger is a Free software project based on Debian. In other news Webconverger has an entry over at distrowatch. Excellent news and thanks for all your support.

Uwe Hermann: Rebuilding the whole Debian archive using the Open64 compiler

I got bored recently, so I rebuilt the whole Debian archive on one of my machines. To make this not a completely useless excercise, I used the Open64 compiler instead of gcc and created build logs for your perusal. So what is Open64? From the Wikipedia page:
Open64 is an open source, state-of-art, optimizing compiler for the Intel IA-64 (Itanium), AMD Opteron and Intel IA-32e architecture. It derives from the SGI compilers for the MIPS R10000 processor. It was released under the GPL in 2000, and now mostly serves as a research platform for compiler and computer architecture research groups. Open64 is licensed under the GPL. Open64 supports Fortran 77/95 and C/C++, as well as the shared memory programming model OpenMP. It can conduct high-quality interprocedural analysis, data flow analysis, data dependence analysis and array region analysis.
Open64 installation The installation is pretty easy fortunately:
$ wget http://ovh.dl.sourceforge.net/sourceforge/open64/open64-4.0-src.tar.bz2
$ tar xfvj open64-4.0-src.tar.bz2
$ cd open64-4.0
$ export TOOLROOT=/opt/open64
$ make
$ make install (as root)
I think you need gcc-3.4 (gcc 4.x is not yet supported), and for some odd reason you also need csh as one of the install scripts seems to use it. It would be nice if someone could package Open64 for Debian, I definately don't have the time to maintain such a huge package (a whole maintainer team would probably be good here). Rebuilding the Debian archive There are several possible ways (and tools) to rebuild the Debian archive; I've used pbuilder/cowbuilder with the rebuild scripts from Bastian Venthur, which are now included in pbuilder. First we need to install the required packages, setup a cowbuilder base chroot, and get the list of packages:
$ apt-get install cowdancer grep-dctrl wget devscripts sudo
$ cowbuilder --create --distribution lenny --basepath /var/cache/pbuilder/testing-base.cow
$ cp -r /usr/share/doc/pbuilder/examples/rebuild .
$ cd rebuild
$ ./getlist lenny
Now we add Open64 into the cowbuilder chroot and fix up the chroot by pointing the gcc/g++ symlinks to Open64:
$ cp -a /opt/open64 /var/cache/pbuilder/testing-base.cow/opt
$ chroot /var/cache/pbuilder/testing-base.cow
$ cd /usr/bin
$ mv gcc gcc.orig
$ ln -s /opt/open64/bin/opencc gcc
$ mv g++ g++.orig
$ ln -s /opt/open64/bin/openCC g++
$ exit
In addition, we set the CC and CXX environment variables to Open64, which will make 90% of all (autoconf-using) packages automatically use Open64. We need a small script for that:
$ cat c.cfg:
export CC="/opt/open64/bin/opencc -m32"
export CXX="/opt/open64/bin/openCC -m32"
Now edit the buildall script. Change the Debian mirror used there (optional) and make it use our c.cfg script by adding the --configfile /path/to/rebuild/c.cfg option in the "pdebuild" line. We can now finally start building the archive:
./buildall list.lenny.i386 lenny
You can also run multiple buildall instances at once to speed up the archive rebuild on SMP/multicore machines, and you can even abort the command and simply restart it later. The script will continue where it left off. Results The whole rebuild (with 2 instances of buildall running at the same time) took ca. 9 days on an AMD64 Athlon64 X2 (dual core, 1.8 GHz each) machine with 1 GB of RAM. I really should have used something like apt-proxy to speed up the rebuild and save some bandwidth, but I read about apt-proxy too late... All log files from my rebuild are available for detailed analysis if anybody is interested (you can browse the logfiles online or download all of them as tarball). I didn't perform any detailed analysis, just some rough numbers here: If anybody does some more elaborate analysis, please let me know.

5 August 2007

Russell Coker: Real Servers vs White-Box

Many people think that white-box machines (IE the cheapest no-nam PCs you can buy) are suitable for use as servers. There are several factors that make white-box machines totally unsuitable for use as a server (and IMHO unsuitable for any other task). Firstly white-box machines are not designed. A set of parts are designed, some combinations of parts are tested, but most aren’t. For example a motherboard manufacturer will test their latest motherboard design with the current video cards and a video card manufacturer will test their new cardss with current motherboards. If you have a new video card and a new motherboard then there has probably been little testing of the combination. This compares to a name-brand machine where the entire unit has been tested and found to work together. White-box assemblers (they aren’t “designed” or “manufactured”) will often use different combinations of parts for each machine that they assemble. If a video card manufacturer sells two cards with the same part number that have different chips then they may be installed in two machines with the same description. So taking an image of one white-box machine and installing it on another that was described as being identical might not work. For these reasons I have ceased using white-box machines as desktop machines or as low-end servers (EG internet gateway machines). I use second-hand name-brand machines for low end servers and for desktop machines. When comparing servers the case for name-brand systems is even stronger. Real servers have ECC RAM as a standard feature, it is possible to get white-box servers with ECC RAM - I have seen such a machine on one occasion. But the vast majority of white-box machines lack such features. See my previous posts about getting ECC RAM in a cheap machine and desktop machines with ECC RAM about some of the issues in this regard. Another feature of servers is better storage options. There are white-box server machines with hot-swap hard drives, but they are significantly more expensive than regular white-box machines - if you are going to spend that much money then it’s better to get a refurbished HP server machine at auction (HP seems to be selling a lot of almost-new server gear at auction at quite reasonable prices with warrantee). A cheap machine (typical white-box or a very low end server from a company such as HP) will have hard drives that don’t support hot-swap. Lack of hot-swap means that a hard drive failure requires that the machine be disassembled to swap the dead disk - it also means that there is sometimes difficulty in identifying which disk has the problem (the error light on a hot-swap drive is quite handy). Then the process of swapping the disk will take at least 10 minutes of hardware work before the machine can be booted up again. With hot-swap disks you can identify the failed disk via a flashing light, remove it while the server is still running, and then initiate a RAID rebuild after installing the new disk. Hot-swap disks cost more and the mounting brackets etc are also expensive, but it’s a good option to have - especially considering that disks are more likely to fail at busy times which is when down-time is least acceptable. These features make disk expansion particularly expensive for servers, people often miss the benefits of servers and say “I just bought a 3000G disk for my home PC for $2, why can’t you just do the same for the server” (I am exaggerating slightly). Another advantage of name-brand servers is remote access. There have been a variety of remote access cards that you could install in a white-box PC and also a variety of devices to digitise a VGA signal for remote KVM access, but they are all rather expensive and remove the price advantage of white-box hardware. A final benefit of name-brand hardware is that you will be running the same hardware as other people. If I was to experience a problem running Linux on a HP DL380 G4 server then I can enter that text in to Google and get many hits. If I was to experience a similar problem with a white-box machine then I would need to perform searches on each of the parts that might have a problem - which would be particularly inconvenient if I couldn’t determine some of the part numbers through software and needed to disassemble the machine first!

Ross Burton: Idiotic British Press

Daniel pointed me towards this blog today, a great mix of insightful thought and humour to generally ridicule the British right-wing tabloids. This article for example is fantastic.

Miriam Ruiz: More on gettext for C and C++

Now for the real world applications. While internationalizing some programs with gettext, I found that some of them tend to use global defined variables for handling the menus (for example fluid, or hex-a-hop), usually defining some lists of structures globally, with the texts directly written on them. Something like:
const char *lines[] =  
"Line 1n",
"Line 2n",
NULL
 ;
In this case we have a problem, because if we just replace the strings by _(”string”), it won’t directly work. Remember that _ is a macro for the function gettext. In C, it just won’t let us call it from the constructor, because the string should have to be assigned statically. In C++ it will let us, but the resulting program will happen to call gettext() on them before our initialization in main(), and thus it will simply not work. I’ve made available an example on how those situations could be handled both in C and C++.

Miriam Ruiz: Recipe: Internationalizing a C program with gettext

gettext is the GNU internationalization (i18n) library, and it is one of the most important standards in Free Software about i18n of programs. Translators are used to it, and there are really lots of useful tools to work with gettext data, so I’d recommend anyone to avoid trying to invent their own yet-another-gettext-but-not-quite-as-the-real-one. Gettext also works for Windows, so no excuse. It’s really easier than it sounds. Here goes the quite recipe: Add this to the headers of the C module in which you have your main() function:
#ifdef USE_GETTEXT
#include "libintl.h"
#include "locale.h"
#define _(String) gettext (String)
#else
#define _(String) String
#endif
And add this at the beginning of your main() function:
#ifdef USE_GETTEXT
setlocale (LC_MESSAGES, "");
setlocale (LC_CTYPE, "");
setlocale (LC_COLLATE, "");
textdomain ("my-program");
bindtextdomain ("my-program", NULL);
#endif
That’s all for the initialization of gettext, lets go now with its usage from the rest of the modules. In each of them, you’d have to add this to the headers:
#ifdef USE_GETTEXT
#include "libintl.h"
#define _(String) gettext (String)
#else
#define _(String) String
#endif
After all that stuff, you should be able to i18n for whichever texts you want, just write _(”whatever”) instead of whatever:
printf(_("whatever");
Don’t forget to compile your program with -DUSE_GETTEXT if you use the same #defines as I do, or at least to #define USE_GETTEXT somewhere. Now, lets go to the second part, generating the .pot templates, and installing the .mo translation modules in your system:
xgettext -k_ -o my-program.pot *.c *.h --from-code=iso-8859-1
If you prefer, you can create different .pot files for the different parts of your programs instead a really big one to help translators, and then joining all the .po files inside a single one before converting it to .mo with msgcat:
msgcat -o my-program.es.po my-program.part1.es.po my-program.part2.po my-program.part3.es.po
To compile the .po files into .mo, just do:
msgfmt my-program.es.po -o my-program.es.mo
Then, don’t forget to install it in the proper directory of your system:
cp my-program.es.mo /usr/share/locale/es/LC_MESSAGES/my-program.mo
Of course, you can tell your program to look for the .mo file in a different directory, even a relative one, instead. Just read the man pages, this is only a quick recipe on how to do it :) Note: Please, use #include [smaller than]whatever.h[bigger than] instead of #include “whatever.h”, as I have put in my examples. My WordPress weblog seems to be having problems with the those symbols. That’s the magic of HTML.

4 August 2007

Russell Coker: Small PC for Creating Word Files

A friend recently asked for advice on a “REALLY small laptop/word processor thingy that would pretty much fit into a (big) pocket, and that only needs to write/word process“. The first problem here is that most people associate “word processing” with desktop publishing and document management. Programs such as MS-Word are considered as having the features required of a word-processor (which includes spelling and grammer checking/correcting, annotations, colours, etc). Programs that have all those features take a lot of CPU power. A Pentium-4 system might be considered the minimum requirement for running a recent version of MS-Word. But a hand-held device can’t have such a powerful CPU (it’s too small to be able to dissipate the heat from such a CPU or contain batteries that can produce enough power to tun it). The next problem is the issue of screen space. A VGA resolution screen (640×480) is regarded as high resolution in the PDA market. Such a resolution does not work with a word-processor that has three toolbars at the top of it’s screen and a paperclip taking up space at the bottom right! I’m sure that everyone who was using computers in the early 1990’s can recall the minimal word-processing programs. One thing to consider is that 640×480 in a 15 inch CRT screen is much more useful than 640×480 in a hand-held device as the larger screen can have fewer pixels per character and therefore display more text on the screen. An added complication is that there are two methods of input for PDAs. One is to have a hardware keyboard (which may be a separate device or may be part of the PDA) and the other is to have a keyboard displayed on the screen. A hardware keyboard makes the device larger and a software keyboard takes up precious screen space (you just can’t win). My PDA is an iPaQ model h3900. It has 64M of RAM, 32M of flash, no hardware keyboard, and a screen resolution of 320×240. I have done some serious writing on my iPaQ (including writing an entire article for Linux Journal) and it works reasonably well. For serious writing you can produce plain text on a PDA and then easily paste it into your program of choice on a PC later (PDAs generally support connection to a PC via serial port and/or USB). The challenge is editing files that originate on a PC using a PDA. Generally I try and use HTML and TeX for my formatted documents so the text versions of those formats are easy to edit once you have learned them. Taking data from a MD-Word file, editing it on a PDA, and then taking it back to the PC would cause many problems and probably wouldn’t be worth attempting. Recently I have been using my iPaQ for writing notes about email and blog posts that I will write. If I get an idea then I immediately write some notes about it on my iPaQ and then usually type it again instead of downloading it. For example the notes for this post were “write about RAM, storage, and screen resolution”. Often getting the initial ideas to start writing is the hard part. Writing a 500 to 1000 word blog post or message is easy once I have the ideas. If I was going to buy a new PDA now I would prefer one with a hardware keyboard, the loss of screen space for a keyboard on the touch-screen is a serious impediment to writing. The maximum amount of text that can be displayed on the screen at any one time limits the complexity of what I work on (see my post about monitors for developers). Another factor is the fact that for small notes the amount of time taken to remove the stylus from it’s bay is greater than the amount of time saved by using it. So I end up writing small notes using my finger-nail on the touch-screen which is significantly slower than using a keyboard (even the crummy ones that PDAs have). Of course the keyboard would still have to be QWERTY and have raised keys so that I can touch-type. I haven’t investigated this seriously as my iPaQ is good enough to last me for another year or two at least and I’ve got an unused spare iPaQ to replace it when it fails. But if anyone has any recommendations of Linux based PDAs with keyboards then I would appreciate some comments.

Marc 'Zugschlus' Haber: [EMAIL PROTECTED]

Dear admins of mail-archive.com, I think that “protecting” E-Mail addresses in a public archive of a technical mailing list which has the topic of E-Mail is a very bad idea. This leads to archive quotes like
We’ve been getting many many strange mailman-bounces. It seems that somewhere the mailman-bounces address is mis-configured. It should be [EMAIL PROTECTED], but mail seems to be sent as [EMAIL PROTECTED] (note missing “u”). That’s causing bounces to bounce all over the place...
which has better not been archived at all - it doesn’t help when vital information is removed from the archived mail. Yes, this example was taken from an actual archive entry. Sheesh.

3 August 2007

Russell Coker: Getting Work in Another Country

Often there are possibilities to earn more money or gain valuable experience by working in another country. I learned (and earned) a lot while working in London and Amsterdam and recommend travelling if you get the opportunity. There are two ways of getting work in another country. One way is to work for a multi-national company and get transferred, this gives benefits of having the company sort everything out for you (creating a bank account etc). But it isn’t an option that is open to many people. Getting a job directly in another country is in some ways more difficult than expected and in some ways easier. Here are some of the factors that make it easier:
Here are some of the problems that you will face:

John Goerzen: Haskell Fun

Bryan O'Sullivan noted over at the Real World Haskell blog that Haskell made quite the impact at OSCon. And I can attest to Simon Peyton-Jones having trouble leaving the building because of all the people that wanted to talk to him about Haskell. It was interesting to think about "why now" for Haskell's popularity. Bryan's post has links to the video of Simon's talks, which are great. (Sample quote: "Oh look, a whiteboard has appeared as if by magic! What joy!")

I followed Bryan's link to the Haskell/OSCon-related blog posts at Technorati. Here's an interesting one by chromatic, who gave some Perl talks at OSCon. Favorite quote:

I sat next to Nat Torkington at the tutorial. He kept rubbing his temples. At one point I leaned over and said, The interesting thing about Haskell is that its functions only take one argument. He turned green.

In all seriousness, well-factored Haskell code resembles well-factored Smalltalk code: if you have functions (or methods) longer than a handful of lines, you re probably doing too much. Lower level languages such as C rarely give the opportunity for composition and abstraction that you can get out of functional languages. The presence of pure functions functions which never change global state and which return the same output for the same input is also immensely important.

It s actually the combination of the two features which give these languages such power. When Haskell forces you to mark impure functions explicitly, it gives you tools to isolate behavior which can change global state in the smallest possible scopes, and prevents you from composing impure and pure code together accidentally. When Haskell lets you compose functions into larger functions, not only does it help you write code more concisely, but it provides well-defined units of behavior which work along well-defined and isolated boundaries.


So what is this business about Haskell functions taking only one argument? Let's look at a quick example. Say I wanted to write a function to multiply two numbers. I'd write:

mul a b = a * b

I could give the type of this function like this:

mul :: Int -> Int -> Int

You could read that as "mul takes two Ints and returns an Int". And you can think of it this way. But you could also write the type this way:

mul :: Int -> (Int -> Int)

It means the exact same thing and is valid to Haskell. To read it, you'd say "mul takes an Int and returns a function that takes an Int and returns an Int." And truly this is what Haskell functions that take multiple parameters are doing. Now, I can say:

fifteen = mul 3 5
mulByThree = mul 3
fifteen' = mulByThree 5
fifteen'' = (mul 3) 5


mulByThree has type Int -> Int; it's a function that we got by simply not applying "mul" to all its arguments. fifteen'' illustrates what is going on internally when you write "mul 3 5". It turns out that being able to call a function with multiple arguments is just some syntactic sugar to Haskell.

This is a tremendously useful feature. For instance:

filter (>= 10) [1..20]

I've applied >= to only one argument here. That's fine; it returns a function that's exactly what filter wants.

I've been watching the video of Simon's Taste of Haskell talk. I could *hear* when the audience grasped the utility of this because there was a collective "Oooooo!" from them.

By the way, Haskell has type inference, so I didn't have to give types at all. Oh, and you can also refer to the function itself by not giving any arguments.

mul = (*)

This is one small reason I like to say "Haskell manipulates functions with the same ease that Perl manipulates strings." Mind-bending, isn't it?

Jan Wagner: Conditional greylisting (with postfix, policyd-weight and postgrey)

In case you think that greylisting might have some disadvantages but give you also some benefits, you probably have thought about to use greylisting with some conditions. For example if you checked some parameters of the mail and you (or better your mailsystem) guess it may be spam, greylisting could be very usefull.
Until now, I was using plain policyd-weight. But mails with $REJECTLEVEL <= score <= $DEFER_LEVEL where in some conditions defered (see policyd-weight default) and if they come back with the same conditions, they will be defered twice. So it makes sence to me to greylist them and if they return within $DEFER_LEVEL, they will pass cause the greylist will allow them.
At first let’s create a restriction class which we can call from policyd-weight within main.cf of postfix:

# restriction class for use with polw (DEFER_ACTION)
smtpd_restriction_classes = greylist
greylist = check_policy_service inet:127.0.0.1:60000 To call postgrey for $REJECTLEVEL <= score <= $DEFER_LEVEL you need to make use of the restriction class “greylist” and let $DEFER_STRING match all defer strings, to get them all greylisted:

# echo “\$DEFER_STRING = ‘NOT’;” >> /etc/policyd-weight.conf
# echo “\$DEFER_ACTION = ‘rc:greylist’;” >> /etc/policyd-weight.conf
# /etc/init.d/postgrey restart Also you may have a look into The DNSBL countries.nerd.dk. This might be a way to score connections comming from well known spamming countries. But keep in mind, that there may also legitim mails comming from those! ;) , , ,

Evan Prodromou: 15 Thermidor CCXV

It's been a few days since I posted on my blog -- since I left Montreal for Taipei and Wikimania 2007. My time has been upside-down and backwards as I've traveled around to the other side of the clock and a day into the future, and I've just been insanely busy with other work. My flight to Taipei was dreamy. I travelled enough last year to get Air Canada's "silver" frequent-flier level, which earned me a couple of system-wide upgrade certificates. They came in handy, since I bumped up to business class on the leg between Montreal and Vancouver, and then to the "Premier Laurel" class on the EVA Air codeshare between Vancouver and Taipei. That was first class across the Pacific Ocean, and man, it's the only way to fly. Jimmy Wales was on the same plane (but back in business class...), so we got to chat a bit and we shared a taxi to the conference site. Jimmy's really fun to talk to -- it's always nice talking to another entrepreneur who's passionately dedicated to Free and Open Content. (We were in line for customs together, too, and I tried to peek at his passport to find out his date of birth, over which there is some confusion. But he had his thumb over the day (intentionally...?), and all I got was "Aug 1966", which everyone agrees on anyways. Dang! My personal theory is that Jimmy was born on 6 June 1966 and uses 8 Aug 1966 instead to avoid the demonic stigma.) The conference centre we're in is great -- a really big, clean, modern place. It's nice when we're inside, but Taipei in August is muggy and hot like a laundromat in rural Mississippi. I find myself rushing between buildings. tags:

IM IN TAIPEI HACKING UR DAYS I came in a couple of days early to participate in the Hacking Days event. This is a pre-conference meetup for MediaWiki developers and those who love them. The meetup was really unstructured and fun because of it, although there were a few points of uncomfortable silence when people stopped talking and we all realized we had 14 more hours of meetings and not much left to say. There's also a real tension between the conference organizers, who've encouraged non-developers to come to Hacking Days, and the core developers who really want to just be left alone and get some work done. This year the 2-day event was split into "Hacking Days" and "Hacking Days Extra", with the first being invite-only and the second being open to all. I think it's a tension that needs to be resolved -- if outsiders aren't invited to Hacking Days, we just need to say that and live with it. We shouldn't let people think they're going to participate and then cut them out. That's a bait-and-switch tactic and it's unfair. I think that there's a need for an open-attendance MediaWiki conference; I also think that MW is a big enough piece of software that third-party conference organizers would be eager to make an MWCon work. And core developers could get hefty fees for coming to talk! tags:

Announcements I've been having problems sleeping here. I've been falling asleep at the wrong times and waking up at the very wrong time. Last night, I missed the Wikitravel Eat-together because I fell asleep at dinner time and didn't get up for the event. Make mental note: don't miss your favorite wiki's user get-together! Fortunately Jani covered for me and apparently the event was a lot of fun. Speaking of Jani: this morning he announced a new venture that Maj and I have been helping him with. Wikitravel Press is an independent company that will be publishing a line of printed travel guidebooks (yes, paper books! That you can hold in your hand!) based on Wikitravel content. I think it's a great project and I'm really glad we're going to finally be fulfilling this important goal of the Wikitravel project. I also think it's going to be a great way to attract a new round of contributors -- people who are more reliant on their paper guidebooks than to a search engine for learning about their destinations. I think that the idea that they can change and improve the books they have will be a really important incentive for these folks. And like it or not, there are still a lot of people who don't consider digital information "real" in the same way as analog-stored info. So putting Wikitravel guides on paper is like Pinocchio becoming a Real Boy. Thank you, Blue Fairy! More info at the project's announcement and the on-site discussion (Wikitravel:3 August 2007). tags:

Called out This morning's keynote address by the Wikimedia Foundation chairwoman Florence Devouard was informative and interesting. She even talked about ways to bring money into the Foundation... including selling books based on the site content. I was giggling about this with Jani as she moved on to talking about the attention economy, to hear, "For example, Evan is not paying attention right now and talking to his neighbour." D'oh! Lesson learned: don't mess with User:Anthere! tags:

2 August 2007

Russell Coker: Starting a Heartbeat Resource Without Heartbeat

The command crm_resource allows you to do basic editing of resources in the Heartbeat configuration database. But sometimes you need to do different things and the tool xmlstarlet is a good option. The below script can be used for testing Heartbeat OCF resource scripts. It uses the Heartbeat management program cibadmin to get the XML configuration data and then uses xmlstarlet to process it. The sel option for xmlstarlet selects some data from an XML file, the -t -m options instruct it to match data from a template. The template is the /resources/primitive part. The --value-of expression will print the values of some labels from the XML. The script will concatenate the name and value tags and export them as environment variables (see my post about Configuring a Heartbeat Service for an explanation of the use of the variables). The TYPE variable is the name of the script under the /usr/lib/ocf/resource.d/heartbeat directory. In recent versions of Heartbeat (2.1.x) the OCF_ROOT environment variable must be set before an OCF script is called. Setting it on older versions of Heartbeat doesn’t do any harm so I unconditionally set it in this script (which should work for all 2.x.x versions of Heartbeat). The first parameter for the script is the id of the service to be operated on and the second parameter is the operation to perform (start, stop, and status are the only interesting values). The script will echo the exit code to the screen (0 means success, 7 means that the service is not running or the operation failed, and any other number means a serious error that will trigger a STONITH if Heartbeat gets it). #!/bin/sh
$(cibadmin -Q -o resources xmlstarlet sel -t -m \
"/resources/primitive [@id='$1']/instance_attributes/attributes/nvpair" \
--value-of "concat('export OCF_RESKEY_',@name,'=',@value,'&#010;','TYPE=',../../../@type,'&#010;')")
OCF_ROOT=/usr/lib/ocf /usr/lib/ocf/resource.d/heartbeat/$TYPE $2
echo $? Below is another version of the same script that instead uses crm_resource to get the XML data. The output of crm_resource has a couple of lines of non-XML data at the start (removed by the grep) and also only gives the XML tree related to the primitive in question (so the /resources part is removed from the xmlstarlet command-line). #!/bin/sh
$(crm_resource -r $1 -x grep -v ^[a-z] xmlstarlet sel -t -m \
  "/primitive/instance_attributes/attributes/nvpair" --value-of \
  "concat('export OCF_RESKEY_',@name,'=',@value,'&#010;','TYPE=',../../../@type,'&#010;')")
OCF_ROOT=/usr/lib/ocf /usr/lib/ocf/resource.d/heartbeat/$TYPE $2
echo $? The problem with both of those scripts is that they rely on Heartbeat being operational. Performing any operations other than a status check while Heartbeat is running is a risky thing to do. If Heartbeat starts a service at the same time as you start it via such a script then the results will probably be undesired. One situation where it is safe to run this is when a service fails to start. After it has failed repeatedly Heartbeat may stop trying to restart it (depending on the configuration) in which case it will be safe to try and start it. Also you can put in temporary constraints to stop the resource from running by repeatedly running crm_resource -M -r ID until all nodes have been prohibited from running it (make sure you run crm_resource -U -r ID afterwards to remove the temporary constraints). The following script does the same thing but directly reads the XML file for the Heartbeat configuration. This is designed to be used when Heartbeat is not running. For example you could copy the XML file from a running cluster to a test machine and then test your OCF resource scripts. #!/bin/sh
$(cat /var/lib/heartbeat/crm/cib.xml xmlstarlet sel -t -m \
  "/cib/configuration/resources/primitive [@id='$1']/instance_attributes/attributes/nvpair" \
  --value-of \
  "concat('export OCF_RESKEY_',@name,'=',@value,'&#010;','TYPE=',../../../@type,'&#010;')")
OCF_ROOT=/usr/lib/ocf /usr/lib/ocf/resource.d/heartbeat/$TYPE $2
echo $?

Next.

Previous.