Joanna About this site

About

How this site is organized and what it's for

Weblog start page

The start page contains the most recent 15 articles.

Home page
The main home page of my website, not my weblog. Currently not used.
------------------
Articles by month
Click here to get all the articles for a particular month.
This month's articles (if any)
Current month
Today's articles (if any)
Articles dated 2009/07/05 only

------------------
Subtopics

------------------
My email address
Site map
Search my weblog
Sorry, search is disabled
Listing of all articles by date
Moving man
Flavours
There's more than one way to view this weblog; these links display the current page in other formats.
External links
These are a few of my favourite sites.
T E S T
Slashdot yesterday

Copyright © 2003-2009 Alternate Worlds Publishing, Boston MA USA


powered by blosxom -- www.blosxom.com
Wenhua dageming de zhongyao jiaoxun shi bixu fandui geren mixin
If I have been able to see further, it is because I am surrounded by midgets.
Never ascribe to stupidity that which can adequately be explained by malice.
"Your argument's repugnant and intriguing." "That's kinda my thing."

Danny's Weblog

2009 Jul 03 [ Fri ]

Wonderful example of accent variations

In the following blog entry: micah-john.blogspot.com [http://micah-john.blogspot.com/search/label/Language] the blogger John Micah points to a very impressive example of an actress, Amy Walker, who has mastered multiple accents: www.youtube.com [http://www.youtube.com/v/3UgpfSp2t6k&hl=en&fs=1&rel=0]

As the actress actually comes from the Seattle area, I found myself particularly impressed by her mastery of the third accent, the old-fashioned RP, which I can no longer do myself. But all of the 21 accents seem quite good. I thought the German one was a little weak, but that might be because Germans try quite hard, so you often encounter Germans who have conscientiously studied phonetics and get many difficult things right, but then display one or two features that are gratingly wrong, like doing a superfluous release on an "-ing" ending. Of course each such German has a different combination of flubs.

Irritatingly Micah is apparently sixteen years old. He also points to the British Library's repository of British accent examples: www.bl.uk [http://www.bl.uk/learning/langlit/sounds/]

This is very good, although I would have appreciated more analysis, in particular a table comparing each feature with each accent. In the case of a Belfast accent I listened to, the most obvious feature relative to more standard accents was the upspeak, although I'm actually not sure that's what it was – it seemd to be lexical as well as syntactic – and it was ignored in the gloss; I wished there was a fuller explanation.

I am always impressed when a foreigner can spot an accent. A few days ago a Slovakian guy whose English is imperfect heard me say a few words in a Scottish accent: /ʔʌ fjy 'wʌrədʑ ən ə ɕko'ɔːtʔəʃ ʔɑːk'ɕentʰ/

He identified it immediately without prompting. I was impressed and envious: I have never been able to identify any accent in Cambodian, and even in French my ability to identify an accent is pretty much limited to "I can sometimes understand it" or "I can never understand it".

2009 Jun 05 [ Fri ]

Some thoughts on Thai, on reading a shirt tag

I scanned a few product tags when I bought some stuff in Thailand, on general principles – this kind of ephemera is impossible to get when you're outside the country (although the need for it is probably less now that so much stuff is searchable on the internet).

This is a fragment of a tag that was attached to a shirt I bought, probably at Big C in Pattaya about 2 years ago.

Scan of part of Thai shirt tag at Big C

I was looking for something else today and happened to notice this scan: there are a few interesting points for the foreign student of Thai.

1. The shirt is referred to as a "sɪ̂ə ʧə́ət" (I hope your browser understands those characters, which are not Thai but part of the "IPA Extensions" in Unicode). The literal meaning of those two words is "clothing shirt".

As far as I know, neither of those words is a quantifier. That seems a little strange to me. I would have expected something like "item-of-clothing one shirt".

2. Also the word for "shirt" obviously comes from the English. That's understandable, though: Thai culture surely came up with words for clothing items which are an inaccurate match to the current Western clothing types.

The Thais made the right choice here. My (Cambodian) girlfriend still tries to use "shirt" to express things like "jacket" and "blouse", because the Cambodian word "អាវ" covers all these possibilities. Presumably the Cambodians don't use the English word in Cambodian the way the Thais do.

3. The phrase "คละสีรุ่น" was hard to translate. I normally like the "Thai-English English-Thai" pocket dictionary by Benjawan Poomsan Becker a lot, but in the case of the first word "คละ" I was unable to find it in the Thai-script section; on a hunch I found it in the phonetic-Thai section. It means "several"; I had a hunch that it did, although for some reason I thought it was a Cambodian word that I remembered!

Much worse was the "สีรุ่น" bit – "sǐi rûn".

The first word of course means "color", but what about the second? I found it easily in Google, but I could not guess the meaning from context. My best guess is that it just helps the meaning of "color": the first word is always used to identify *individual* colors by forming combinations like "color red". Still, I don't know how the Thais got there from the basic meaning I found in the dictionary, which is "time" or "period".

4. The bottom line means "fabric cotton". At least I *think* it does: that second word is pronounced "cotton". I couldn't find it in the dictionary.

I believe it has something to do with something I've remarked on before: the word that you find for cotton in the dictionary: "ฝ้าย" (fɑ̂ɑi) can really be used for any cotton-like fabric, certainly including blends like polycotton.

I think that the Thais try to use the English word to distinguish actual cotton, but it seems to be too late: whether you use the Thai word in Thai, the English word in Thai, or the English word in English to ask about a shirt, the Thai person will always answer "yes" (or "yet" in IPA).

5. I just thought of something else: the manufacturer's name and the product code are in Latin characters only. Of course this is because such products are international and their designations need to be unique and explicit in every country.

Still, it's worth considering what that has to mean for the whole chain of suppliers and retailers in Thailand. Every checkout girl and stock boy needs to be able to read these codes routinely at a glance (although I suppose in many cases the barcode scanner helps). Imagine trying to teach Thai script to such people in the West.

USA is losing more and more gold

One of the strange things about the continuing financial crisis is that the price of gold has not risen very much.

Gold transactions are normally reported in a way which makes them hard to track and verify. The following web page seems fairly clear: www.numismaster.com [http://www.numismaster.com/ta/numis/Article.jsp?ad=article&ArticleId=6745]

It's worth reading the whole page, but to give you the gist,

For 2008, there were net exports of 2,818 tons (90.6 million ounces) of gold compounds. In 2007, the net exports were 1,988 tons (63.9 million ounces).

The expression "tons of gold compounds" here means "tons of gold which is contained in non-pure forms". Gold coins, for instance, are normally considered compounds.

The exact *meaning* of these transactions is not clear. For instance, it may well just mean foreign governments who held their own reserves in the US have decided that it's much safer now in their own countries. Or it may just be that someone wants to make sure that the USA has no emergency reserves.

But at the very least, it's clear that movements of gold are taking place which are easily large enough to distort the normal signals which we used to think were sure indicators of the strength of currencies.

2009 May 17 [ Sun ]

The recent scandal in England over MPs' expenses

Over the last few days the London Telegraph has been publishing excerpts from a leaked database of the expenses claimed by members of the UK Parliament. These expenses are ultimately administered by the office of the Speaker. The British media has been full of condemnation of the cynical greed exposed.

I have the following thoughts:

1. Of course, the sums involved are of very minor importance. I recently saw that the total sum pledged *so far* in the current crisis to support the British financial "system" – ie major shareholders – was 150 billion pounds, probably ten thousand times as much as MPs make in expenses.

I don't understand why the British media devote a hundred times as much attention to the expenses scandal as they do to the beggaring of the nation. Or perhaps I do.

2. As Stalin used to say: who whom? It seems a little strange to me that the Speaker of the House of Commons recently tried to get the police to intimidate an MP, and after that failed a crisis caused by the Speaker's office has led to an attack by the media on every single MP.

A common tactic of gangster bosses is to make a new recruit carry out some horrible crime as an initiation. You can see how that would leave the recruit with no other friends.

I wonder if the Speaker – or his bosses – deliberately set up a situation where every member of the House of Commons was encouraged to dabble in petty fraud; just in preparation for a moment like this. The MPs took the bait because for years and years it seemed like nothing could go wrong – rather like buying a house over the same period.

Who whom? Who wins when the people are whipped into a frenzy against their last remaining weak, venal, stupid, craven representatives?

Review: PHP & MySQL for Dummies 2nd Edition 2004

This is quite an old book now but I was happy to spot it in my local library. I was actually looking for a PHP book as I more or less know MySQL at least as of a few versions ago, but a lot of the stuff you use PHP for needs to hook up to a database of some kind anyway.

I have already used PHP with MySQL for a couple of little projects, but I was hoping to get a better overview of how to set up and debug a project.

Overall, the book has some surprising omissions. For one thing, no object-oriented features are discussed. For another thing, there is a lot less emphasis on security than I was expecting. For instance "register_globals": I actually did not see any reference to it when I read through the book, and only found it just now when I was looking for the PHP version used for the book. (Most people know about this issue by now, although they might not have in 2004; if you don't, you should probably Google it right away.)

On the other hand, I liked the way it discussed the use of include files to make the code more understandable. I actually had not realized that you could put so much html in them and still have php variables that work (although you wind up depending on a lot of global variables, as opposed to using a bunch of subroutines as I'm used to doing in Perl).

The following is a list of items I noted.

1. p143 Chap 6 Joining comparisons with and/or/xor

"If you are familiar with other languages..." Apparently the "and" form has exactly the same precedence as "&&". That is *not* the same as Perl.

2. p 155 Chap 7 Creating arrays

$capitals = array( "CA" => "Sacramento", "TX" => "Austin", "OR" => "Salem" );

I find myself not really liking either PHP or Perl's fundamental syntax very much. As you can see from the above example, all PHP variables just have a leading "$", whatever they are – scalar, array, hash (although the book just calls a hash "an array ... viewed as ... a list of key/value pairs"). On the other hand, Perl wants you to designate a variable by the variable type it winds up as once you've appplied all the trailing items; eg "$orange[3]" is scalar element 3 of the array "@orange", but scalar "$orange" is a separate variable which has nothing to do with either of the former.

I prefer the object style, something like this: "@orange.element(3)" or even "orange.element(3)".

3. p 155 Chap 7 Viewing arrays

I was interested to see the example of the "print_r" function to print the contents of any array:

print_r($capitals);

I had no idea that PHP had this built in and it would certainly have made some of the debugging I've done easier.

Now I think about it I wonder how PHP really knows whether to display an array as pairs or individual elements. Presumably it always displays them as pairs; if there's a mixture of numeric and text keys... I leave that as an exercise for the reader.

4. p 156 Chap 7 Sorting arrays

The way "sort" and "asort" work seems a little arbitrary, although handy.

5. p196 Chap 8 Sending SQL queries

I often run into problems when I start forming a query string to eventually send off to the SQL server. For instance, I usually try to leave a semicolon on the end, even though that never works.

So it's good that the book has a section on this, However, I was surprised to see the following example:

$query = "UPDATE Member SET lastName='$last_name'";

The wacky thing is the single quotes around the variable name, of course. I think the way it works is that the quotes prevent PHP looking up the value of the "$last_name" at the time you assign the string to "$query". However, it *will* look it up when the string is inserted in "mysql_query":

$result = mysql_query($query);

I can't remember how I handled this problem before! I think I threshed around until something worked and then tried to put the horror behind me.

6. p199 Chap 8 Getting and using the data

This page has an example of using "extract($row)", which very neatly produces and sets all the variables you usually need from a row you get from the database. Example:

$row = mysql_fetch_array($result, MYSQL_ASSOC);
extract($row);

So if one of the fieldnames for the row was 'password', the value of that field for this row will be in $password.

When I've had to do something like this in the past, I've had to tediously create a bunch of variables individually, as well as doing an assign which is prone to error (especially when you modify the table definition).

7. p 302 Chap 11 Adding data to the database

The book suggests using the LOAD command to recreate a table easily while debugging:

LOAD DATA LOCAL INFILE "pets" INTO TABLE Pet;

Neither this, nor the section in Chap 4 which this section refers to, clearly makes the point that the LOAD statement is very limited in where it can read the data file from. My understanding is that for security reasons, the file *must* be in the same directory as the data file is located in; the text briefly says this, but I don't think the book has ever referred to *how to find* what the directory is. I think when I first ran into this many years ago, I had to create a table with a wacky name, run updatedb, and then locate to figure out where the data files are! (Try looking in /etc/mysql/my.cnf.)

Also, although it's nice to use LOAD sometimes because it can understand files that you can create in Excel – ie way before you have the rest of the database software set up to enter data in the required format – I think the author should have referred to the "mysqldump" command too, as well as the reverse of the LOAD command:

SELECT * INTO OUTFILE 'file_name' FROM tbl_name

8. p 320 Chap 11 Adding pets to the catalog

Listing 11-6 includes the following code:

if (@$_POST['newbutton'] == "Return to category page" or @$_POST['newbutton'] == "Cancel")

I was about to grumble about how wacky this syntax was, and then I remembered. This is explained on p124; the "@" sign has nothing to do with arrays, it just tells PHP to suppress error messages if the variable is not defined!

There are copious notes on the listing which do not include this point. Perhaps everyone else was paying more attention on p 124.

9. p 337 Chap 12 Building the login table

I mention this tiny point only in order to show that I sometimes *do* pay attention: the text says "MySQL will not allow two rows to be entered with the same loginName and loginDate". That "loginDate" should read "loginTime" to match the rest of the text.

10. p 337 Chap 12 Adding data to the database

This paragraph mentions "to test the programs while you write them you need to have at least a couple of members in the database". This deserves rather more consideration than the book gives it.

For instance, you need to do testing continuously, even after the database has gone live: you need to keep making sure all of the existing features are *still* working while you continue to add features. So you may need to retain a lot of artificial corner cases in the tables, like a customer who makes an order which includes 80 items, or a customer with a foreign address to make sure your new invoices still work with them, even though your company still hasn't actually had a foreign order.

Sometimes I actually include a flag field in every table to identify test records.

2009 May 04 [ Mon ]

How to say the Cambodian (Khmer) word for "go"

The "tl;dr" version is: You say the Cambodian word for "go" kinda like the English word "dove" (meaning "bird", not the American past tense of "dive").

(For the purposes of this article I decided to implement Khmer text and phonetics as a graphic, in case the user's PC does not properly support the Unicode used in the text. Numbers in the graphic below correspond to the any references in the text.)

1. Khmer script: ទៅ 2. IPA transcription: tɨʋ̒̚

Cambodian/Khmer word for go in IPA

The word for "go" is obviously important in any language and should be learned very early on, but it happens to be particularly hard for the foreign learner of Cambodian. I remember my first arrival on my own in Cambodia, when I ran to escape overpriced taxi touts and jumped on the back seat of a motorbike, telling the driver (I hoped) to "go! go!". He had no idea what I was saying until I said "go market!" The word "market" is much easier for the Westerner to pronounce understandably. This allowed the driver to guess that I did not mean "even if, scrub, polish, rub, exchange, barter, change, grow, spring up, bud, breasts, take off, remove, solve, attempt to solve, lion, bent over, unit of dry measure equivalent to about two pecks... market".

I had some idea of how bad my pronunciation was, because I had found the explanations of the elements of this word to be particularly vague. I am writing this posting to record my current understanding of the issue. I would have posted it much earlier, except I was trying to fix representation of Khmer in text on this site; but I've decided not to wait. Maybe people will find this and improve the pronunciation guides in textbooks.

It took me nearly two years of actually living in Cambodia to get fairly confident of my grasp of this word, and my pronunciation of it is still rather labored. I think the writers of the textbooks I relied on managed to write those books with only a partial grasp of the problems.

The basic problem is that every one of the three phonemes of this word does not exist in English. This makes it impossible to use a simple transcription like you might find in a travel guide. In the description below I have had to use a number of fairly specialized phonetics terms, which few Westerners are familiar with. You will need to Google them. Additionally, the final phoneme is pronounced "unreleased" (marked by that unusual diacritic), which changes the sound drastically for the Western ear, and that feature is poorly explained in most available texts on phonetics. Incidentally, I did not find a single hit for the IPA transcription I am using here on Google: to put it another way, this transcription of the word is my own. Being still rather hesitant about it, I have not marked it as either a broad or narrow transcription.

The wikipedia entry on the IPA phonetic system is worth looking at as a reference, although not very helpful to start learning from if you know nothing about phonetics:

en.wikipedia.org [http://en.wikipedia.org/wiki/International_Phonetic_Alphabet]

An additional problem is that Cambodians do not have any phonological training, much less the ability to communicate such information to the hapless foreign learner.

We have to go through each of those difficult phonemes in turn.

The first phoneme is an unvoiced, unaspirated dental, represented by Huffman as a simple "t". Perhaps I should say explicitly that although English and American speakers utter this sound on occasion, they do not know how to create it in an arbitrary location in an utterance. In English, the "d" sound is always voiced, and both the "d" and the"t" are sometimes aspirated and sometimes not, depending on one's regional accent as well as the surrounding sounds. But these variations correspond to *different words* in Cambodian.

Although the phoneme is not very hard to pronounce adequately (at least to the Western ear), it is not trivial to clearly maintain the differences between this and the voiced and aspirated versions of the dental phonemes, especially while you have many other things to think about – either when you are listening or speaking. Additionally, the best position of articulation of this sound (with the tongue curled up against the palate) is unnatural for the Westerner, so he is not used to incidental sounds which are routinely produced in different environments (see below).

The second phoneme is described by Huffman like this: "High central unrounded vowel made by raising the center of the tongue toward the soft palate while keeping the lips flat or spread". (Also, I hear the sound as nasal, and other sources agree.) Now you can see this is going to be hard to make compatible with the articulation of the preceding consonant. The result is that at the end of that consonant/beginning of the vowel the tip of the tongue has to flick sharply towards the lower front teeth to allow the vowel to be articulated clearly, resulting in a sharp click at the front of the vowel; and this motion is so sharp that there is also a sort of audible slap as the tongue falls to the lower jaw at the end of the vowel. The overall effect, for the Westerner who has not subconsciously learned how Khmer sounds interact, is that the "click" features (reminiscent of African click languages) overwhelm the true phonemes.

But the worst part is the final consonant. This is considered to be part of a single vowel sound in the word as written in the Cambodian spelling system, and perhaps because of this it is often represented as some sort of vowel in phonetic transcriptions, causing endless confusion.

Although it may well sound like a vowel to the Western ear (and even in English, the exact definition of the difference between vowels and consonants is not entirely agreed), Huffman and my favorite dictionary (whose title in Khmer is "Modern Khmer-English Dictionary", and which I believe to be a ripoff version of Headley's "Modern Cambodian-English Dictionary", 1997) agree that the final sound is a consonant. But what is it?

It turns out to be a variant of an English "v" sound, except that instead of the lower lip being clamped between the upper and lower teeth, the two lips are simply placed (loosely) together. (The symbol for this consonant is in the right position in the charts showing phonetic features, but actually I haven't found a good specific description of it and I just ope it's correct.)

Additionally the consonant sound, as usual at the end of Khmer words, is pronounced unreleased, ie very short and without opening the mouth again at the end, so that you can hardly hear what we would think of as the actual consonant sound, but instead the result (including the actual vowel) sounds rather like an "o" sound (as in "hello") to an English person: the articulation of the "v" sounds like the articulation of the English diphthong. (That's indicated in my transcription by the wacky diacritic over the last letter.)

Huffman gives a rather vague description including "with more lip-rounding", but I believe that is quite false.

Headley says that in the final position, this phoneme is pronounced like "w". This is largely true of the *result*, but gives the wrong impression of how the sound is actually articulated, and if you try to utter the sound that way it distorts surrounding phonemes.

Perhaps one day I will meet a Cambodian who has studied phonetics sufficiently to confirm all this. Or laugh at me.

Problems with Ubuntu updates and repository setup

I've been getting a warning icon about system updates on the desktop command bar. "Your information was last updated 17 days ago."

I tried to run update several times, but (after long delays) got error msgs like this:

Failed to fetch gb.archive.ubuntu.com [http://gb.archive.ubuntu.com/ubuntu/dists/gutsy-backports/main/binary-i386/Packages.gz] 404 Not Found

I went to System - Admin - Software sources and clicked Choose best server. This (after a minute) was judged to be ftp.ticklers.org (??).

I tried doing an update again, but (after a while) it still missed several files required for gutsy-backports.

I checked Google, and although there was no clear info, it looked like repositories tend to drop support fairly rapidly, even for versions like 8.04 which are supposed to have extended support. When this happens you need to track down a working repository yourself.

I tried adding various repositories, including old-releases.ubuntu.com, but I still got an error message about 404 looking for gb.archive.ubuntu.com – even when I changed back and had "main server" selected in Ubuntu Updates.

I hand-edited (sudo vi) the /etc/apt/sources-list and commented out other servers for gutsy-backports. It started working; I think now the only server for gutsy-backports is:

deb httx://old-releases.ubuntu.com/ubuntu gutsy-backports main universe multiverse restricted

(Change httx to http)

It found 14 updates, many to basic system files like linux-image and linux-libc. I'm not sure if I should have updated menu.lst or not: it looked like it was trying to install linux...24.24. I don't know how clever the updater is and I don't want to lose various setups in menu.lst like the splash screen.

Doing a "check" now results in no error msgs. "Last updated less than one hour ago." "System restart required."

I don't understand why what I did worked. Surely, if the Update Manager can't find a package at one server, it should try another in sources-list by default?

I rebooted. I opened the /boot/grub/menu.lst file and edited the default boot setup to use .24 for linux and initrd. Booting worked OK and dmesg confirmed that .24 was indeed running OK.

I edited menu.lst to add the new system version and then rebooted again. I had forgotten the "uname -a" command, but that confirmed that the new menu selection was working. I copied the new menu.lst to menu.lst.005 so that I can resurrect it if I ever allow an update to rewrite it.

2009 May 02 [ Sat ]

Book review -- Notes on Learning Perl (Schwartz, Phoenix, foy) (O'Reilly 5th edn 2008, for Perl 5.10)

I got this book out of the library a few weeks ago and want to retain some notes about it.

I think I first read this book many years ago, in the first edition. I no longer have that copy, but have a vague memory that the text had very whimsical examples which I found irritating. This edition has a non-grating style.

It's sort of embarrassing that so many of these points were actually new to me. Sometimes, like with the uses of the ternary operator, that just means I don't write programs which are as concise as they could be. But with other points, like using paired characters as the delimiters of a regular expression, this can cause real problems. Of course, Perl is notorious for having irregular syntax and side effects. I really like Perl and would rather program in it than anything else, but I have to admit it may be easier if you already speak Klingon.

1. p14 chap 1 Introduction – A simple program – Wonky version numbering – Perl 5.10 requires "use 5.010". Of course, I had run into this before, but I often forget it. I think the book should have sounded at least a little apologetic here. Why can't everybody just use the same format that's needed for a "use" statement? It's particularly bad that some versions like "use 5.8.8" appear to work, lulling you into a false sense of confidence.

2. p36 chap 2 Scalar data – The chomp operator – "except in cases where it changes the meaning to remove them, parentheses are always optional". Am I the only person who thinks this sounds circular?

3. p60 chap 4 Subroutines – Private variables in subroutines – can you put a space after my like "my ($m, $n)" – generally, what do parentheses mean? This is an example of the problems you get with learning Perl because so many language features – like parentheses – are reused to "do what I mean" in different contexts.

4. p87 chap 5 Input and output – Fatal errors with die – "If you don't want the line number and file revealed, make sure the dying words have a newline on the end" – completely wacky and perlish. I didn't know this before, although now I think about it I probably wondered why the die sometimes displayed the extra info and sometimes not.

5. p137 chap 9 Processing text with regular expressions – different delimiters – "But if you use paired characters, which have a left and right variety, you have to use two pairs: one to hold the pattern and one to hold the replacement string." I didn't realize this at all, much less that the two pairs of characters don't have to be the same – eg you could use []{}.

6. p137 chap 9 Processing text with regular expressions – Case shifting – "The \U escape forces what follows to all upper case". I don't remember this (or \L) before 5.010, although I see it works with 5.008008.

7. p 138 chap 9 Processing text with regular expressions – The split operator – it is unexpected to me that split returns empty leading fields but discards empty trailing fields. The book bleats "here's a rule that seems odd at first" – Yup. Actually, it *still* does. I have a feeling this caused big problems for me years ago when I was trying to scan through a data file.

8. p 139 chap 9 Processing text with regular expressions – The split operator – this refers to noncapturing parentheses, which I thought had not yet been introduced but were actually described on p 125 – blush.

9. p140 chap 9 Processing text with regular expressions – m// in list context – there is an expression here which does several things at once and I hope I can remember it when I get a chance to use it:

my($first, $second, $third) = /(\S+) (\S+), (\S+)/;

-1. It declares multiple variables with a single my
-2. It does a regular expression to set multiple variables
-3. It assigns multiple variables to a list

10. p142 chap 9 Processing text with regular expressions – Nongreedy quantifiers – there is an expression:

s#(.*)#$1#g;

which seems to be missing the <BOLD> tags which it needs to work – see the expression below (in the book).

11. p154 chap 10 More control structures – Autoincrement and autodecrement – there is a nifty expression:

$count($_)++ foreach @people;

This grabs each name from a list of people, and increments the hash value for that hash key for each time the loop encounters that name: ie, if "barney" is in the list three times, at the end of the loop $count{"barney"} = 3.

12. p 163 chap 10 More control structures – The ternary operator – there is an example of a nifty way to set a value to correspond to a range using the ternary operator:

my $size = 
  ($width < 10) ? "small" :
  ($width < 20) ? "medium" :
  ($width < 50) ? "large" :
                  "extra-large"; # default

13. p 164 chap 10 More control structures – The value of a short-circuit operator – "the value of a short-circuit operator is the last part evaluated, not just a Boolean value". I did not realize this. Also, I just had to re-read the section to the end of the chapter to figure out if the word forms "or" and "and", not just "&&" and "||", are also called short-circuit operators.

14. p 165 chap 10 More control structures – Logical operators – example of "my" inside a foreach, first described on p 180 with "this is the first time you've seen it".

15. p185 chap 12 File tests – Stacked file test operators – garbled text needs at least a punctuation fix: "This stacked example is the same as the previous example with just a change in syntax, although, it looks like the file tests are reversed, Perl does the file test nearest the file-name first."

16. p188 chap 12 File tests – Bitwise operators – Fig 12-1 is placed at the top of the page instead of within the "Bitwise operators" section where it belongs.

17. p192 Chap 13 – Directory operations – Moving around the directory tree – "Thus, a tilde prefix will not work with chdir." I keep making this mistake.

18. p249 Chap 17 – Some advanced Perl techniques – Trapping errors with eval – In the example:

eval { $barney = $fred / $dino } ;

it points out that "eval" is actually an expression not a control structure like "while", so it needs a semicolon at the end. I remember having endless problems with this when I was learning Pascal.

19. p252 chap 17 – Some advanced Perl techniques – Picking items from a list with grep – "While the grep is running, $_ is aliased to one element of the list after another. You've seen this behavior before, in the foreach loop. It's generally a bad idea to modify $_ inside the grep expression because this will damage the original data."

This is an important point and one which deserves to be stressed repeatedly like this. I remember being stunned the first time I noticed it.

20. p256 chap 17 – Some advanced Perl techniques – Slices – there is an example:

my($card_num, $count) = (split /:/)[1, 5]

I just think it's nifty that you can split $_ into an array of scalars, pick out elements 1 and 5, and assign them, and indeed declare with "my", all in a single line.

21. p273 Answers – Chap 7 exercises – "We showed you an 'or' operation (with the vertical bar, |), but we never showed you an 'and' operation. That's because there isn't one in regular expressions." I have often wondered about that but it's nice to see it explicitly.

2009 Apr 13 [ Mon ]

Using Google for Thai and Khmer words

In a photo of one of the demonstrations against the current Thai government, I happened to notice a small sign which I could just about read (as opposed to the large signs where I have no idea what half the characters even are). It seemed to just say "Trat", like the town/province in southern Thailand. www.telegraph.co.uk [http://www.telegraph.co.uk/telegraph/multimedia/archive/01382/protests_1382426c.jpg]

The London Telegraph captions the pic "Red Shirt anti government demonstrators face off the army lines outside the Pattaya Exhibition and Convention Hall Photo: EPA"

It didn't seem to make any sense that someone was holding up a sign with just the name of a town, so I vaguely wondered if some hapless taxi driver was trying to meet a client in that mob! Idly I tried to find it in Google, and couldn't. I figured I must be misreading the last letter, so I tried various possibilities, but still nothing seemed quite right. I gave up.

Later, it occurred to me to try to find Trat itself, so I found it. It looked just like my first guess at what was on the sign. I plugged it into Google, and indeed Google again could not find it. Actually, Google had found it, but for some reason only two out of the first ten hits actually found Trat. The rest found "rat" (pour, spill, top).

I think this sort of behavior is liable to be very common when we ask Google to search for words in Thai text, because both the webpages *and the text we're looking for* don't have whitespace at word boundaries. ...Hmm, at least I don't *think* it does. I wonder if Thai internet users are actually inserting some sort of nonprinting space at word boundaries in search terms? Anyway, I was looking for a *single* word.

If you want to try it, here it is in Unicode: ฅราด

...Wow, my editor points out it needs 12 Unicode bytes, to express just four Thai characters.

Cambodian (Khmer) suffers the same problem. Here is a simple word in Khmer which you can search for: តង

Google returns a bunch of hits which mostly refer to sentences which contain those two characters at the end of one word and the beginning of the next. Google also has an actual flub on one of the hits: a PDF file – whose sample text for some reason is displayed with all the jerng characters displayed on the normal instead of lower level – shows those two wanted characters followed by a bantaq diacritic, which by Khmer/Unicode spelling rules *must* belong to the preceding character... Hmm. I suppose that's fair enough. They're ignoring diacritics for the search, which matches their behavior for French, German etc.

2009 Apr 05 [ Sun ]

The banksters who caused the financial crisis

Here's a link to a Bill Moyers interview transcript. He's interviewing William K. Black, who was one of the investigators who dealt with the Savings & Loan crisis in the 80s. www.pbs.org [http://www.pbs.org/moyers/journal/04032009/transcript1.html]

The interview has a lot of insights which would make people wonder about the Bush/Obama response to the crisis.

It's notable that Black has many good arguments for treating the credit crisis as a result of straight criminal behavior. I have certainly wondered why people didn't start looking for the guilty parties as soon as this all started. But so far, the only people who regularly get blamed are people who took out mortgages on the assumption that the price of housing would continue to rise indefinitely.

He doesn't address the question of *why* the Feds allowed the regulators to look the other way while all this was happening (the FBI actually issued a specific public warning in 2004 about mortgage fraud, which was ignored). At the same time as it set up two land wars in Asia, and paid for them on its credit card. Hmm.

2009 Apr 01 [ Wed ]

Fixing a jammed "twist and turn" window

A "twist and turn" window has an ingenious design which allows it to be opened either hinged at the bottom or hinged at the side. You need to be a little careful about the way you handle it, or the mechanism can get in a state so that you can't close it.

That just happened to me, and I found the answer on the net: www.mendmy.com [http://www.mendmy.com/answers.php?id=113085] but the explanation was a little vague and didn't quite match what I found, so I'm going to note down my conclusions in case it happens to me again. You should read these notes to the end before trying to fix a window (especially as I haven't figured everything out myself).

1. These windows are in common use in Europe, although apparently they are fitted only in high-end dwellings in the USA, so if you travel to Europe from the USA you should probably prepare yourself for them.

2. The handle has 3 positions. All the way down, it's locked closed. Turn it up 90 degrees – ie, horizontal – and the window can be opened with the hinge at the bottom. Turn the handle fully up – vertical – and you can open the window with the hinge at the side.

3. My explanation above is, if you think about it, a little vague about intermediate positions of the handle, and that's where you need to be careful.

4. If the window is in the normal, fully closed, position, the way to open it is straightforward: just open the handle to the position you want, either horizontal or vertical, and then pull the window open. Be careful to avoid setting the handle to any intermediate position before opening.

5. The problem comes when you want to *close* the window. You must fully close the window before turning the handle.

6. The magical thing you have to remember is this: every time you close the window, you must then turn the handle to the fully down position.

7. Only then can you open the window again if you want – for instance, if you wanted to change from opening from the side to opening from the bottom.

8. If you fail to handle the mechanism just right, it will be difficult or impossible to close the window by normal means. You will not be able to put the handle in the down position.

9. The link above refers to a "black flappy tab" which unlocks the mechanism, ie allows the window to close. In my case, it was a rotating s-shaped thing, but it was likewise close to the handle.

10. I rotated the "s-shaped thing", and was then able to put the handle down and close the window.

11. My picture of the mechanism is this: the design is intended to prevent you letting the window drop completely out of the frame. So it has to keep you from changing between hinge sides because there has to be a range where neither hinge is engaged: therefore it is designed to prevent you moving the handle if the window is not closed.

12. However, this mechanism is imperfect, and can leave the window hinged on one side, but you can't close it because the rest of the mechanism is in the other state.

12. Rotating the s-shaped thing temporarily disables the feature, so you can rotate the handle to unblock both of the hinges, even though the latching mechanism which normally holds the window closed is not engaged yet.

13. Please realize that this means you must support the window carefully until you have closed the window and put the handle back in the down position! On my window there is a metal arm attached to the window which appears to be a safety measure, but it looks marginally capable of actually doing the job.

14. ...I just had a nervous few minutes while I tried jamming and unjamming a second such window. I conclude that I actually *still* don't have the perfect procedure for clearing all jams. The trick is certainly to rotate that "s-shaped thing" (or whatever similar device is on your window). However, the sequence is not clear to me after that. Also, I think the handle must be in a certain position to allow the "s-shaped thing" to work.

15. I get the impression that the handle must be moved to the position which corresponds to the most recent hinge state, and then the window must be lifted or shifted slightly to allow the various parts of the mechanism to clear at all positions on the window.

16. I would experiment more, but holding the window carefully so it doesn't smash while I'm fooling with it is a little wearing...

2009 Mar 23 [ Mon ]

Creating world maps

I have been thinking about creating a world map in Khmer for years.

Wikipedia has a world map in editable .svg form: en.wikipedia.org [http://en.wikipedia.org/wiki/File:BlankMap-World6.svg]

If you open it in Evince and try to zoom in, it looks blurry, but actually it's quite accurate, at least down to the level of England or Cambodia, when you open it in Inkscape.

This also led me to some discussion of how to handle that file: commons.wikimedia.org [http://commons.wikimedia.org/wiki/File_talk:BlankMap-World6.svg/Documentation]

and some software intended to automate some tasks with it: gsl-nagoya-u.net [http://gsl-nagoya-u.net/appendix/software/worldmap/]

In particular, the above software allows you to convert the projection used for the map so that it's the correct format to wrap onto a sphere.

The SVG format allows you to edit text inside the file with a text editor; gedit worked OK, even though the files were over 1 MB. It also makes it easy to define multiple areas as parts of one country (under a two-letter nation code eg "gb") and set their color using css. However, I could not figure out any clever ways to handle text annotations like the names of countries: I would have liked some sort of structure like

<country><name>gb</name><title code="en">Great Britain</title><title code="kh">ប្រទេសអង់គ្លេស</title></country>

However, that doesn't really work because you need to set the size and position of each title separately to get the most readable layout, especially when you have more than one language to get in the way.

The world map itself does not have *any* text visible. Here is an example map with a ton of text: commons.wikimedia.org [http://commons.wikimedia.org/wiki/File:Map_France_1477-fr.svg] As an experiment I added a little Unicode Khmer using gedit, which seemed to work OK. I could not see how to set text size inside the .svg however.

Furthermore, it seems one should somehow associate the text labels with the countries. The above sample file seems to have that, but to be honest I don't actually see how it's done. I'm guessing each label was manually grouped with the country (as well as manually located and sized).

Here is a .php page which edits web-accessible .svg files on the fly: toolserver.org [http://toolserver.org/~nikola/svgtranslate.php]

It seems to work with Khmer Unicode, to the extent I tried it.

Making Ktoon work

On the (very good) Steve Hanov blog I saw a grumble/sneer about the ktoon program having a bad user interface:

gandolf.homelinux.org [http://gandolf.homelinux.org/blog/index.php?id=34]

and decided to try it out. I installed using Synaptic. The first time I ran it, it wanted me to choose an install directory, but the "next" button did not work. Eventually I realized "finish" works.

It still wasn't usable. It looked like it couldn't find some of its parts, although there were no error messages. I tried allowing it to set the default install directory, and I think that worked a little better, but still not right.

I then found this page:

https://bugs.launchpad.net/ubuntu/+source/ktoon/+bug/188529

which suggested running this (assuming the default install locations I guess):

sudo ln -s /usr/lib/ktoon/plugins /usr/share/ktoon/

This worked fine and the app was then fairly impressive. You do need to open a new project with "File - Project" to get a normal editable window, but that's somewhat standard.

More irritating, but still only a holdup for a minute or two, was that you can edit a shape by clicking the button with balloon text "selection" and then selecting "contour".

Slow thumbnail generation in Nautilus

I had had Nautilus set to generate thumbnails, which was sometimes very slow, especially in the PDF directory, where Nautilus would take 20-30 s to generate all the thumbnails.

I vaguely remembered this could be set with

gksudo gconf-editor &

but the Nautilus options in gconf-editor did not seem quite what I wanted.

You can however set it inside Nautilus itself:

Edit - Preferences - Preview - Other previewable files - Show thumbnails: never

The only problem is that this is a global setting, and sometimes it's nice to see thumbnails.

Here is a good general discussion of thumbnail generation: ubuntuforums.org [http://ubuntuforums.org/archive/index.php/t-388168.html]

Among other things it mentioned that gqview has useful built-in thumbnail handling. In particular: Edit - Thumbnail maintenance - Shared thumbnail cache - Clear cache

You can also *force* thumbnail generation on a folder and subfolders.

...I then found a page which explained that gconf-edit *can* be used to set behavior for different filetypes individually, but under a key folder I had not looked into before: desktop - thumbnailers - application@pdf

This key shows the command line used to create thumbnails, and (separately) allows you to enable or disable it. Hmm. I didn't change the setting in gconf; I left thumbnails turned off completely in Nautilus (because I usually have all the info I need in the filename, and the icons are almost always too small to really see anything useful), but I may go turn them back on and just disable pdfs.

...I just added /usr/bin/gconf-editor to the System - Preferences menu. Why in heck isn't it installed by default??

Birdsong

A few days ago, you might have seen me on the street, awkwardly holding my cellphone up in the air for no apparent reason.

But a few yards away, up in a tree, a vaguely glimpsed black little blob was singing so beautifully that I wished I could listen for hours. So I tried to record it.

Irritatingly, it seemed to rest during periods when nothing else could be heard, and then start up at its best when a car would drive by.

Here is a link to a recent article in the London Independent, based on a book "Say Goodbye to the Cuckoo" by Michael McCarthy: www.independent.co.uk [http://www.independent.co.uk/environment/nature/the-sound-of-silence-the-cuckoo-is-vanishing-1650399.html]

I was truly moved by his evocation of the meaning of birdsong; a sense that the emotion I felt was shared with men a hundred years ago, or three thousand years ago. But perhaps not a hundred years in the future.

The link includes several links to sound files of various birds, from the Royal Society for the Protection of Birds (RSPB) website: www.rspb.org.uk [http://www.rspb.org.uk/]



I hope this information was useful. There may be a great deal more information on this site that is relevant to what you need. Take a look at the "site map" display at left; you can click on a topic to see many recent items on that topic.

Debug: hittotal: 3 startban: 0 dancookie: endbandate: banned: 0 tempdate: tert: jse: jsno jsh: 3