converting php/mysql/apache app from latin-1 to utf-8
April 27, 2009
these are the notes i wrote to myself as i was preparing to port a big and old app to utf-8. i do not claim they are correct but they worked for me. most of this is not original but derived and condensed from other web pages as noted below. the purpose of this list is as a cheat sheet or to-do list. feel free to leave comments but try to be polite and don’t yell at me if i got something wrong.
wordpress insists on displaying simple single quote and simple double quote characters in random open/close forms in the following. sorry. please ignore and imagine they were all just the simple vertical versions.
useful web sites
- http://www.phpwact.org/php/i18n/utf-8
- http://www.phpwact.org/php/i18n/charsets
- http://www.phpwact.org/php/i18n/utf-8/mysql
- http://devlog.info/2008/08/24/php-and-unicode-utf-8/
- http://www.sitepoint.com/blogs/2006/08/09/scripters-utf-8-survival-guide-slides/
- http://www.nicknettleton.com/zine/php/php-utf-8-cheatsheet
- http://www.cs.tut.fi/~jkorpela/chars.html
immediately after opening a mysql connection, either:
- SET NAMES ‘utf8′;
- or mysql_set_charset(’utf8′, $connection_handle);
use <form accept-charset=”utf-8″> on every form
convert html, php, js, css and other text files
declare css files as utf-8: @charset “UTF-8″;
declare linked js files in html tag as utf-8
if using htmlspecialchars, use htmlspecialchars($s, ENT_COMPAT, ‘UTF-8′);
- use ENT_COMPAT mode, e.g. so that if putting attribute values with ” into html tags from a script, it won’t screw up.
add to top of every script ?
- $default_locale = setlocale(LC_ALL, ‘en_US.UTF-8′);
- ini_set(’default_charset’, ‘UTF-8′ );
and just before page output PHPLIBtemplates.inc.php:
- header(’Content-Type: text/html; charset=utf-8′);
in apache config
- AddDefaultCharset utf-8
in php.ini
- mbstring.func_overload=7
- default_charset=UTF-8
- mbstring.internal_encoding=UTF-8
mbstring.func_overload=7 covers ereg and some string functions as listed in mbstring functions and detailed below. many string functions are still not safe.
PCRE
- all pregs need the utf8 u modifier: preg_match(’/myregex/u’, $str)
- avoid pcre i modifier
- avoid \w \W \b \B
to find the byte count of a multi-byte string when you are using mbstring.func_overload 2 and UTF-8 strings:
- mb_strlen($utf8_string, ‘latin1′);
to validate form input as utf8, http://devlog.info/2008/08/24/php-and-unicode-utf-8 says
- (strlen($str) AND !preg_match(’/^.{1}/us’, $str)) // true means bad utf-8
but http://www.phpwact.org/php/i18n/charsets says this cannot be trusted. so use mb_check_encoding() to get a true/false answer
to quietly sanitize utf8 input strings (http://blog.liip.ch/archive/2005/01/24/how-to-get-rid-of-invalid-utf-8-characters.html):
- $s = iconv(”UTF-8″,”UTF-8//IGNORE”,$s);
which quietly deals with bad utf-8 input. it’s safe to use the result but it doesn’t require adding code to send the form back to the users for re-entry.
test strings
$strs = array( 'Iñtërnâtiônàlizætiøn', 'החמאס: רוצים להשלים את עסקת שליט במהירות האפשרית', 'ايران لا ترى تغييرا في الموقف الأمريكي', '独・米で死傷者を出した銃の乱射事件', '國會預算處公布驚人的赤字數據後', '이며 세계 경제 회복에 걸림돌이 되고 있다', 'В дагестанском лесном массиве южнее села Какашура', 'นายประสิทธิ์ รุ่งสะอาด ปลัดเทศบาล รักษาการแทนนายกเทศมนตรี ต.ท่าทองใหม่', 'ભારતીય ટીમનો સુવર્ણ યુગ : કિવીઝમાં પણ કમાલ', 'ཁམས་དཀར་མཛེས་ས་ཁུལ་དུ་རྒྱ་གཞུང་ལ་ཞི་བའི་ངོ་རྒོལ་', 'Χιόνια, βροχές και θυελλώδεις άνεμοι συνθέτουν το', 'Հայաստանում սկսվել է դատական համակարգի ձեւավորումը', 'რუსეთი ასევე გეგმავს სამხედრო');
to be lazy, sanitize $_GET and $_POST input with
function clean_input(&$a) {
if ( isset($a) && is_array($a) && !empty($a) )
foreach ($a as $k => &$v)
clean_input($v);
elseif ( is_string($a) && !mb_check_encoding($a, 'UTF-8'))
$a = iconv('UTF-8', 'UTF-8//IGNORE', $a);
return true;
}
replacement for strtr()
function mystrtr($s, $p1, $p2=false) {
if ( is_string($p1) && is_string($p2)
&& mb_strlen($p1, 'UTF-8') == mb_strlen($p2, 'UTF-8') ) {
$t = '';
for ( $i=0; $i < mb_strlen($s, 'UTF-8'); $i++ )
$t .= ($j = mb_strpos($p1, $c = substr($s, $i, 1), 0, 'UTF-8')) === false
? $c
: mb_substr($p2, $j, 1, 'UTF-8');
return $t;
} elseif ( $p2 === false && is_array($p1) ) {
return strtr($s, $p1);
}
trigger_error('mystrtr() called with bad parameters strlen(p1)=' . mb_strlen($p1, 'UTF-8')
. ' strlen(p2)=' . mb_strlen($p2, 'UTF-8'), E_USER_WARNING);
return $s;
}
notes on specific functions learned from own tests, links noted above and in the table
| addcslashes | DO NOT USE |
| addslashes | DO NOT USE |
| chop | see rtrim |
| chr | only use for ascii |
| chunk_split | SUSPECT, probably works on byte strings |
| count_chars | operates on byte strings, use only on ascii or 8859 |
| crc32 | see md5 |
| crypt | see md5 |
| echo | presumably mb-safe? |
| explode | SAFE, but can use preg_split |
| fprintf | DO NOT USE, http://www.php.net/manual/en/function.sprintf.php#89020 |
| fscanf | DO NOT USE, http://www.php.net/manual/en/function.sprintf.php#89020 |
| html_entity_decode | DO NOT USE, see htmlspecialchars |
| htmlentities | DO NOT USE, see htmlspecialchars |
| htmlspecialchars | OK but use htmlspecialchars($s, ENT_COMPAT, ‘UTF-8′) |
| implode | probably OK? |
| join | same as implode |
| lcfirst | DO NOT USE, mb_convert_case |
| levenshtein | SUSPECT, testing needed |
| localeconv | ? |
| ltrim | OK without a $charlist 2nd param. or use preg_replace(’/^\s+/u’, ”, $s); |
| mb_strtolower | DO NOT USE, confirmed buggy! mb_convert_case($s, MB_CASE_LOWER, “UTF-8″) |
| mb_strtoupper | DO NOT USE, confirmed buggy! mb_convert_case($s, MB_CASE_UPPER, “UTF-8″) |
| md5_file | probably ok |
| md5 | probably ok, i guess it returns the MD5 of the byte string, as one would want |
| metaphone | SUSPECT |
| money_format | ? |
| nl2br | DO NOT USE, preg_replace(’/\n/u’, ‘<br>’, $s); |
| number_format | ? |
| ord | only use for ascii |
| parse_str | Use mb_parse_str |
| presumably mb-safe? | |
| printf | RISKY. ONLY use on 7-bit ascii, http://www.php.net/manual/en/function.sprintf.php#89020 |
| quotemeta | SUSPECT, preg_replace |
| rtrim | OK without a $charlist 2nd param. or use preg_replace(’/\s+$/u’, ”, $s); |
| setlocale | ALWAYS USE |
| sha1_file | see md5 |
| sha1 | see md5 |
| similar_text | SUSPECT |
| soundex | SUSPECT |
| sprintf | RISKY. ONLY use on 7-bit ascii, http://www.php.net/manual/en/function.sprintf.php#89020 |
| sscanf | RISKY. ONLY use on 7-bit ascii, http://www.php.net/manual/en/function.sprintf.php#89020 |
| str_getcsv | OK if local and LANG set correctly |
| str_ireplace | DO NOT USE, preg_replace |
| str_pad | DO NOT USE |
| str_repeat | SUSPECT |
| str_replace | SAFE, or use preg_replace |
| str_rot13 | DO NOT USE except on 7-bit ascii only |
| str_shuffle | DO NOT USE |
| str_split | > mb_split or use preg_split instead |
| str_word_count | SUSPECT |
| strcasecmp | DO NOT USE |
| strchr | SUSPECT, use mb_strpos or mb_strrichr |
| strcmp | according to comments on php.net, ok if is locale set right |
| strcoll | according to bug reports, ok on posix systems, not windows. but set locale |
| strcspn | DO NOT USE |
| strip_tags | DO NOT USE |
| stripcslashes | DO NOT USE |
| stripos | > mb_stripos |
| stripslashes | DO NOT USE, preg_replace(array(’/\x5C(?!\x5C)/u’, ‘/\x5C\x5C/u’), array(”,’\\’), $s) |
| stristr | > mb_stristr |
| strlen | > mb_strlen, OK unless you need byte length, e.g. to save a file, then use mb_strlen($s, ‘latin1′); |
| strnatcasecmp | SUSPECT |
| strnatcmp | SUSPECT |
| strncasecmp | SUSPECT |
| strncmp | SUSPECT |
| strpbrk | SUSPECT, use preg |
| strpos | > mb_strpos |
| strrchr | SUSPECT, use |
| strrev | DO NOT USE |
| strripos | > mb_strripos |
| strrpos | > mb_strpos |
| strspn | DO NOT USE, use preg_match |
| strstr | > mb_strstr |
| strtok | DO NOT USE |
| strtolower | DO NOT USE. mb_strtoupper fails on some cases when mb_convert_case($str, MB_CASE_UPPER, “UTF-8″) does not |
| strtoupper | DO NOT USE. mb_strtolower fails on some cases when mb_convert_case($str, MB_CASE_LOWER, “UTF-8″) does not |
| strtr | DO NOT USE with 3-params. 2-param version ok with valid utf-8. |
| substr_compare | DO NOT USE |
| substr_count | > mb_substr_count, or preg_match_all? |
| substr_replace | DO NOT USE |
| substr | > mb_substr, see also mb_strcut & mb_strimwidth |
| trim | OK without a $charlist 2nd param. or preg_replace(’/(^\s+)|(\s+$)/’, ”, $s); |
| ucfirst | DO NOT USE |
| ucwords | DO NOT USE, mb_convert_case($str, MB_CASE_TITLE, “UTF-8″) |
| vfprintf | DO NOT USE, http://www.php.net/manual/en/function.sprintf.php#89020 |
| vprintf | DO NOT USE, http://www.php.net/manual/en/function.sprintf.php#89020 |
| vsprintf | DO NOT USE, http://www.php.net/manual/en/function.sprintf.php#89020 |
| wordwrap | SUSPECT |
| urlencode | OK |
| rawurlencode | OK |
| urldecode | SUSPECT |
| rawurldecode | SUSPECT |
| utf8_encode | only use on ascii or 8859-1 |
| utf8_decode | ? |
Neophyte errors at Quabbin Reservoir Road Race
April 26, 2009
i was in the 4/5 35+ race. the pace was pretty strong and i’m glad there were downhill stretches between the ups. it’s 63 miles with very little flat. nice course with good quality surfaces and safe wide downhills.
by 25 miles in there were only about a dozen riders left in the group i was in. having kept close the the front, i was under impression it was the lead group. at 35 miles i got a flat and pulled over to wait for the support vehicle. it never came.
eventually the support for the 4/5 open race drove by without acknowledging me. later the women came by and a vehicle stopped. an official said she had no support with her but took my number and said the wheel truck is only a minute behind. it too blew past me.
it seems that the error i made was to misconstrue the organizers’ promise of support, as stated in the flyer and then explained to us before the start of the race. i spoke to an official after the race and he explained that the support vehicle only supports the race leaders and vehicles aren’t supposed to help riders in other races.
so there must have been a break ahead of us that i was unaware of. though i rode near the front (i thought) until i flatted i didn’t see them go and i didn’t see the support vehicle pass. i guess it must have been a small number of riders in the lead group.
thus in a relentlessly hilly race like quabbin, in which the field necessarily gets strung out, it seems that when they say that support is provided, this has to be construed as meaning that no support is provided to 95% of the riders. unless confident of being in the money, you must assume that you’re on your own.
i wish i had known that in advance.
anyway, i chased the women’s support truck for 8 miles on a flat without catching it. i stopped to talk to the policeman at the turn in hardwick and asked if there was a way to contact the support crews. he said he had no idea and bemoaned that he had been completely unprepared, that nothing had been explained to him.
a back-marker from the 4/5 open race came past then and offered me co2. i remembered that i had sealant in my tires so i accepted and it worked. the tire stayed inflated to the finish. i’m very grateful for that. i rode on my own except for about the last 8 miles with one of women from the group i passed.
my other error was: forgetting to get the 3-hour bottle of perpetuem out of the cooler box before going to the start line. with spending half an hour waiting for imagined support i was out of water with more than an hour of hot riding to go and very thirsty. 3 bottles was not enough. i was getting bonkers towards the end. i have only myself to blame for that dumb error.
astonishingly, the results put me 60th out of 70 starters and 67 finishers, 45 minutes behind the winner. i though my ride was bad enough; i’d love to hear the stories of the 6 behind me.
Commenting Philip Dawdy’s comments on bipolar II
April 12, 2009
Regular readers of Philip Dawdy’s excellent Furious Seasons web site will be familiar with his opinion of the DSM’s bipolar II diagnosis. In keeping with his idea of “a free market of ideas in the mental health world” I would like to contribute my opinions on this topic.
First, let me be clear: I admire Phillip’s work on Furious Seasons, have supported his fundraisers, and hope he keeps at it.
The opinion that causes some controversy is succinctly put in his interview with Christopher Lane in Psychology Today.
Here’s the quote in full:
I may be the only writer in America who thinks BP2 is controversial and I can hardly think of any doctors who do. For me, it’s a questionable classification and something of a cop-out by the DSM writers for a couple of reasons: One, BP2 isn’t bipolar disorder, properly understood. There’s no mania, there’s no hospitalization for mania, and there’s no one running naked down the street. The most prominent features of BP2 are depression (and that covers the vast majority of a person’s time who is diagnosed with BP2) and bursts of energy, broadly understood. To me, that sounds a whole lot more like depression and agitation than it does manic-depression.
Two, the minute someone gets hit with a bipolar disorder diagnosis of any subtype, then they are faced with a profoundly bad set of social assumptions; they get stigmatized by friends and family; and they lose their jobs. I know of multiple cases along these lines, including one of a sheriff’s deputy in King County, Washington who was fired from her job as soon as the brass learned she had BP2, even though she had a stellar track record as a cop and had done nothing wrong on the job. That hardly seems fair when we’re talking about a disorder that doesn’t involve hallucinations or psychosis and has none of the off-the-charts impulsivity of true manic-depression. While it’s nice of researchers and mental-health advocates to claim that we’ve got to end this kind of stigma, in the real world that would take generations and by then people with BP2 today will have reached the ends of their natural lives.
Why BP2 wasn’t called something else is beyond me, but the diagnosis has sure caused a lot of unfair social damage.
I have a BP2 diagnosis, the comical history of which you can read here, and Phillip’s description in the first paragraph doesn’t characterize my experience at all well. The reason I have a BP2 dx rather than BP is that I haven’t suffered “marked functional impairment” in any of my “hypomanic episodes”. If I had then DSM 4’s criteria would have me as BP.
Hospitalization is not a required criterion for diagnosis of mania or BP. Nor is running naked down the street. What I experienced included delusions (e.g. I once began planning to become Prime Minister), paranoia, demented spending (thankfully I had no lines of credit when the behavior was worst when I was younger or it would have been ruinous), crazy creativity with loss of my self-critical faculty, no sleep, ludicrous self-esteem and embarrassing incidents the memory of which make me wince decades hence. This is a bit more than a “burst of energy, broadly understood”. And there is suspicion of genetic evidence: my father’s odd behavior and suicide smacks of manic depression. I rather agree with my shrink that the criteria of mania and BP are met rather closely except that, because I never lost a job, got kicked out of school, got arrested or was hospitalized, it lacks “marked functional impairment”. In other words, I got away with it. Apparently that makes it BP2.
Nor is this behavior agitated depression. I have a lot of experience with that and it is entirely different. In agitated depression my mood is dysphoric, pessimistic and cynical but I can’t sleep, relax or let up with the negativity whereas in hypomania I am euphoric, self-confident, optimistic and at one with the world. There’s no way to confuse these states, in my experience.
On Philip’s second point, I don’t really disagree but the statement sounds a little sweeping. I’m sure some people have suffered negative and unfair social consequences but I’m not aware of any affecting me, at least not so far and certainly not within the first minute of diagnosis.
Whether or not a different name for this disorder would, on the whole, have been better for patients, I really don’t know. Would the social consequences for something called, say, Major Depression with Hypomania (with, as most new psychiatric disorders have, a three letter abbreviation, say MDH) be any better? I don’t find that very convincing but I honestly don’t know.
Moreover, I imagine there may be benefit to patients from the BP2 name. It seems clear from the reading I’ve done that it’s important to treat BP2 in basically the same way as bipolar, especially in regard to the dangers of antidepressants. I imagine that many (most?) physicians are aware of these concerns in bipolar. My own GP refused to prescribe an antidepressant because of his suspicion of bipolar. He sent me to a psychiatrist who refused to prescribe an antidepressant without first a robust mood stabilizer. It took two years to get that right before I was given the antidepressant. According to, for example, Husseini Manji, this is the safest approach. (He even prefers in cases of MDD that are familial.)
If BP2 had instead a name that failed to make the association with bipolar, I wonder if some physicians, especially those who aren’t psychiatrists, might be less likely to recognize these risks. Given that most BP2 patients present with depression, the association with the bipolar word may spare them some risk.
Bontrager inForm RXL saddle review
April 10, 2009
Bontrager inForm RXL saddle review
Summary: I tried out a Bontrager inForm RXL saddle for two weeks and took it on two 70+ mile rides. It was ok on short rides but after about 40 miles it started to hurt. By the end of the two long rides I was hurt so bad I needed a couple of days to recover. The saddle also has a fairly slippery cover that I also found undesirable. I prefer a saddle that presents more resistance to lateral forces so I don’t slide around unexpectedly.
Background and requirements: I am 44 years old, male, with 40+ years cycling experience. I ride long distance events and recently started road racing. On my long distance comfort bike I usually ride a Brooks B17. It is generally comfy but puts too much pressure on the perineum when riding low on the drop or on aero bars. I can start to feel my family assets go numb after only about 100 miles on a B17. That’s ok if I’m in no hurry because I can sit up more but I’m planning on riding the Saratoga 24-hour time trial this July and would like to do 400 miles if I can. A B17 isn’t going to work for that. I need a saddle that will be comfortable for 24 hours with a lot of that spent low on the drops or aero bars.
My racing bike has a Specialized Toupé saddle that is pretty good but also not comfortable enough for long rides. After about 80 miles the tissue under my public arch (the bone cyclists sit on) gets sore. So I’m looking to solve that problem too.
I was interested in the Bontrager inForm because of their claim to have put some formal scientific study into the physiology and biomechanics relating to saddle design. I was also attracted by their 90-day trial period. I was measured and chose the RXL medium width. It was good as far as reducing pressure on the perineum was concerned. The problem, like the Toupé, was with the tissue under the public arch. I became so sore after about 40 miles on both the longer rides that I found myself standing far too often just to relieve the pressure. The pain was present for a couple of days after both rides. It is a wonder that anyone could achieve such an uncomfortable saddle design. I returned it.
So I’m still looking for the right saddle. Fizik Airone has many followers, perhaps the Tri version. And I was recommended Sella Italia Flite Gel Flow and SLC Gel Flow. Any other ideas? Trial and error can get expensive in this game.
Recovering from lithium
March 25, 2009
In late August 2008 I consulted my GP about the Lithium, frequent urination, dehydration and associated symptoms. He knew a lot about lithium-related diabetes insipidus (which means watery pee) and has several patients on lithium with the side effect.
He considered my theory that lithium was responsible for loss of athletic performance plausible given that the symptoms began when I started taking the drug and that dehydration can produce these symptoms. His view was that putting up with these urinary problems as an active 44 year old man was not a good choice. For an old person who mostly sits at home, perhaps the decision would be different but for a person with decades of active life ahead it’s not a good way to live.
I took a few other factors into consideration. The effects of lithium on the kidneys may get worse with duration of treatment. The effects may be only partially reversible or not at all with the chances of recovery worsening with treatment duration. Moreover, cycling is beneficial to my mental health: the flow, the accomplishments, the fun. And it’s the closest thing to meditation that I’ve experienced – it changes my mental state.
My GP advised that I try another mood stabilizer but warned me not to stop the lithium without consulting with my shrink.
So I stopped taking lithium immediately without consulting my shrink. I’m like that sometimes. It was a mistake. I don’t recommend it. I became really depressed very quickly and ended up back at my shrink in a couple of weeks with my tail between my legs.
She offered either valproate or trilptal. Valproate appears to be more effective but has worse side effects. Trileptal doesn’t look all that impressive from the trials data but it doesn’t have the threat of serious weight gain. I chose Trileptal.
At low dose made me irritable, anxious, jumpy, easily angered and sometimes confused. So we decided to try a higher dose which made these side effects even worse and made thinking quite hard at times. Then we switched to valproate.
The trileptal side effects went away and I started to feel myself again. Depressed. Mild to moderate depression was my baseline condition by now. It had been like that for about three years. But I wanted to give it time to see if the valproate was working as a mood stabilizer before adding an antidepressant. What’s happened mood-wise since then is a story for another blog entry.
But the main point for this story is that about 6 weeks after quitting lithium, I noticed that my cycling performance was improving. Then it improved quickly over the next two or three weeks, after which I had a couple of rides that confirmed that I was back on form. I was pretty much back to my former condition. Since I’d never quit training, my legs and cardio system were still strong and it seems that all I needed was for my kidneys to recover so I could get my hydration back to normal.
That was back in October and was very encouraging. I’ve kept the training up over the winter and I’m planning to start racing in a couple of weeks and have plans to ride the Saratoga 24-hour time trial in July.
D2R2 really delivers
August 26, 2008
- Photo gallery below, after my comments
I first heard about D2R2 while riding a brevet in 2006. I think it was the BBS 400 km. I was with two riders who spoke of it. I think they were Ted Lapinski and Russ Loomis. They talked about the ardors and cruelty of the ride, the relentlessly steep rough roads, the pain and suffering, the exorbitant length and breadth of the thing, the sadism and masochism, and the DNF rate. I listened while they went on. And on. And I listened on. Eventually I had some sort of a brain malfunction, perhaps an overload of the brag detection centers, and I blurted out, “So why would anyone do this other than to prove how much pain and hardship he can endure? Is that the whole point of it?” I think it was something like that.
Ted, I think it was, corrected me. I had it all wrong. It’s a beautiful ride, one of the nicest in the region, one of the nicest he’s done. The views – splendid; the roads – quiet; the terrain – varied; the sights – all overwhelmingly picturesque. I immediately regretted my outburst and made apologetic sounds (uh huh, mm mmm, right, yeah) as though I understood. Since then I heard a lot more riders talk about D2R2, usually about its vicious brutality.
I didn’t get to ride D2R2 in 2006 or 7 but this year, 8, I did. Clearly I was going to ride the 100 km variant. I wasn’t going to spoil what sounds like a very enjoyable ride by choosing the 170 km death march. I know how my mind works: concern about finishing would cause me to focus on the difficulties and finishing and would distract me from enjoying the ride. I don’t need to drive a gasoline-fueled motor car four and a half hours round trip from Boston for that. Besides, the nine o’clock start for the 100 km is quite civilized.
So what can I tell you about the ride besides the already well known? I used a road bike with 35 mm cyclocross tires, standard Shimano triple (30t granny) and 12-27 cassette. It was fine. I used the 30/27 ratio a lot. I put SPD pedals on for this ride but I’d probably have been alright with KEO too. I unclipped on the climbs only twice. Once, when a stick got caught in my chain-set and the chain dropped off inwards. The other time, close to the first climb, was more educational.
There was a tight group at the front on the flat roads before the first climb. They made me nervous. It was like I feel on CRW centauries – too many of the riders (a few is enough) in the front group looked more eager stay attached than skilled. There were a lot of skinny tires in that group. I let a gap develop without going so slow that I got swamped by those behind me. In short, I wanted some space. But the gap wasn’t enough. On the first climb, which, in the D2R2 genre, is steep and rough, the lead group got off and walked. It only takes a few riders to put a foot down (and discover, teetering, that they can’t get stated again) to block the road. I slowed down as much as I could and looked for a gap to get through. One opened and I went for it, only for another cyclist to ride into it ahead of me stop, right there, to get off and walk. Sigh.
After that I spent way too much of my attention on other riders rather than on enjoying where I was and what I was doing. Things only settled down in terms of overcrowding after the first water stop.
Lesson learned: give the leaders a few minutes head start. Or ride the route some other day.
D2R2 is a swell ride. Really lovely. It’s picturesque to the point of absurdity in places: vistas seemingly composed for the photo shoots of exaggeratedly pastoral picture postcards and glossy Vermont tourist calendars; the sort of views that flat-landers might sprinkle croissant crumbs over in the Sunday Boston Globe while reading the tips on where and when to find the best leaf-peeping.
Also remarkable is how the route avoids roads with much traffic. This was impressive. We touched Route 2 briefly and that was about it. But beware: these dirt roads are not entirely devoid of traffic and some of the locals are fast. Don’t assume and don’t, as I witnessed a couple of times, take a blind bend riding fast downhill on the left.
Anyway, I loved it. Immensely. D2R2 really delivers. I want to do it again soon when leaves are turning.
I recommend it to anyone who’s ok with steep climbs and rough dirt roads and who likes overlooks with old-timey country goodness. Don’t let the D2R2 war stories put you off – it’s not that hard. Nor do I think that’s what this ride is about. Certainly the 100 km route isn’t. It’s relatively hilly by Massachusetts standards in that there is proportionately less flat and gentle riding than is typical. But it’s far from mountainous and none of the climbs are long.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Wayne’s 2008 Summer Party Photos
July 12, 2008
Essex County Pancake Ride
July 12, 2008
On July 5th 2008, 5 cyclists including myself joined Melinda Lyon on a very lovely bike ride of her design. It was 83 miles with about 20 of them on unpaved surfaces ranging from decent dirt roads to rivers deeper than my knees and stuff I probably wouldn’t be able to do even on my mountain bike.
It was one of the most enjoyable bike rides I’ve done. The route took in the best and the variety of beauty available in that corner of Massachusetts. The roads ranged from nice for cycling to top-notch. The off-road stuff was entirely away from traffic and, it seemed, hardly used (why not?). Among us, only Ted had a mountain bike, the rest on road bikes with wide knobby tires. Young John made it through the tricky bits on his Surly LHT, a touring bike with absurdly long wheelbase, much better than the rest of us. We took the whole thing at a gentle pace that caused no stress. I had a really swell time. I hope Melinda runs it again in the fall.
The ride passed by the famous Clam Box in Ipswitch. Here’s a high-res of the parking-lot scene: click the thumbnail.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Pitiless, insatiable, man-eating monsters
June 12, 2008
A recent conversation with my friend Ken touched on the astonishing drama that fills the lives of many of the students at the community college at which he works and how starkly this contrasts the lives of his own milieu. I described my view of the opposite regime: the middle-class suburb where the safe standardized environments of home, school, church and neighborhood enforce strict bounds on thought and behavior and indoctrinate their own narrow values and aspirations to produce a homogenized, neutered humanity. Later the same day I happened to read the following passage in Thomas Bernhard’s memoir that addresses the same issue but in Bernhard’s dazzling prose.
Background to the excerpt: Thomas Bernhard, was a sensitive child and had a mostly very unhappy childhood which spanned WW2. His family was impoverished but essentially middle-class in values, behavior and ambition. Shortly after the war, living in Salzburg, Bernhard was attending grammar school, which he hated, when one day while walking to school he took the opposite turn on the Reichenhaller Strasse from the direction to the school and instead visited a labor exchange where he got a position as apprentice at a grocery store in the blighted Scherzhauserfeld Project.
The excerpt is from Gathering Evidence by Thomas Bernhard, chapter 3: “The Cellar: an Escape” pp192-194 in the David McLintock translation published by Vintage in 2003.
What I was seeking was something different, something I had not known before, something that might be stimulating and exciting, and I found it in the Scherzhauserfeld Project. I did not go there out of any feeling of pity: I have always detested pity, and especially self-pity. I did nor permit myself to feel pity; my only motive was the will to survive. Having come so close co putting an end to my life, for every possible reason, I had the idea of breaking away from the path I had taken for many years because I was too stupid and too unimaginative to choose another, and because I had been set upon this path by those who brought me up to fulfill the dreary ambitions they entertained on my behalf. I did an about-turn and ran back along the Reichenhaller Strasse. At first I simply ran back, without knowing where I was heading. From this moment on it’s got to be something different, I thought—in my excitement this was the only thought in my head—something that is the very opposite of what I have done up to now. And the labour exchange in the Gaswerkgasse was exactly in the opposite direction. Under no circumstances would I have turned again and gone in any other direction. The farthest point in the opposite direction was the Scherzhauserfeld Project, and it was on this farthest point that I set my sights. The Scherzhauserfeld Project was the farthest point in every respect, not just geographically. There was nothing there to remind me even remotely of the city and of everything in the city that had tormented me for years and driven me to despair, to thinking of scarcely anything but suicide. Here there was no mathematics master, no Latin master, no Greek master, and no despotic headmaster to make me catch my breath whenever he appeared. Here there was no deadly institution. Here one did not continually have to keep oneself under control, keep one’s head down, dissimulate and lie in order to survive. Here I was not constantly exposed to the disapproving looks I had found so deadly. Here no outrageous and inhuman demands were made on me. Here I was not turned into learning and thinking machine. Here I could be myself. And all the others could be themselves. Here people were not constantly being pressed into an artificial mould as they were in the city, in a manner that daily grew more sophisticated. They were left in peace, and from the very first moment I set foot on the Scherzhauserfeld Project I too was left in peace. One could not only think one’s own thoughts: and one could express them, when and how one liked and as loudly as one liked. One was not in constant danger of being attacked for being headstrong. One’s personality was suddenly no longer suppressed and crushed by the rules of the bourgeois social apparatus, an apparatus designed to destroy human beings. In towns where stupidity reaches such alarming proportions as it does in Salzburg, human beings are constantly tweaked and shaken, constantly hammered and filed into shape, and they go on being hammered and filed into shape until there is nothing left of the original human being but a revolting, tasteless artifact. In towns of medium size (I will say nothing of small towns, where everything is grotesque) every effort is directed toward turning human beings into artifacts. Everything in these towns is opposed to human nature; even the young are nothing more than artifacts from A to Z. The human species today can preserve itself only in the unadulterated country or in the unadulterated big city—only in the unadulterated country, which still exists, or in the unadulterated big city, which also exists. In such conditions one still finds natural human beings—beyond the Hausruck or in London, for instance, and as far as Europe is concerned one probably finds them nowhere else. For in Europe today London is the only genuine big city; admittedly it is nor on the continent, but it is in Europe all the same; and beyond the Hausruck I can still find the unadulterated country. Everywhere else in Europe one finds only artificial human beings, people whom the schools have turned into artifacts. Whoever we meet in the rest of Europe turns out to be an artificial human being, a tasteless replica of the real thing. The number of such products runs into millions and—who knows?—will perhaps shortly run into billions; and all their movements are controlled by various educational systems, which are in reality pitiless, insatiable, man-eating monsters. All the time our ears are assailed, if we are still capable of using them, by the sickening din of mass-produced marionettes with not a single natural human being among them. It is possible that in the Scherzhauserfeld Project I experienced the Hausruck or London effect, but I was not conscious of this at the time. I had obeyed my instinct and gone in the opposite direction.
Update on dehydrated lithium athletics
June 8, 2008
Since I published my fairly optimistic May 27 2008 post on this topic, I’ve a few observations and thoughts to add.
1. It takes considerable discipline to keep up with my drinking, especially now the hot weather is here. (I don’t like to use the central AC if i don’t need to. I just strip to my shorts when it’s hot.) For a couple of days I attached a 45 min timer to a pint bottle, and that worked, but…
2. It seems to be quite easy in hot weather to wake up dehydrated. I have a pint every time I pee at night but I guess you can evaporate quite a lot during 8 hours in bed. Don’t really want to
3. I’ve had several long rides and it seems quite feasible to maintain hydration. If I drink at least 1.5 oz/mi or 2+ in hot weather then I don’t seem to be dehydrated at the end. I have the impression that the kidneys take a break on their polyuria craze while exercising.
4. I’ve had some very good rides and no really bad ones since I upped the drinking. But there have been several on which it seemed as though I was staring at the end…
If a well rested and prepared cyclist goes out for a ride, she or he can ride very hard for a couple of hours. After that, things slow down and effort level (as monitored by heart rate) diminishes as though approaching a steady state of roughly 65-70% of max heart rate as the limit of what can be sustained. After many hours riding, huffing and puffing up a hill and enduring considerable muscle pain, you can get it a little bit higher than that. But that compares with taking a similar hill at the start of the ride much faster and with ease at 90-95% max HR.
The difference, as I understand it, very roughly, is that at the beginning you have the glycogen reserves available which can be metabolized quickly and anaerobically. At the end you have to rely on metabolizing fat aerobically. Some of your muscle cells are the type that burns glycogen, other fibers burn fat, and some others can do a bit of both. So at the beginning of the ride you can use all your leg muscle as both fuels are available, at the end only the fat burners are working.
I figure effort level using heart rate. There’s a lot you can read about on the web about why that’s reasonable. The graph shows my best guess, based on experience, how my sustainable heart rate depends on ride duration, which is on a log time scale from 10 seconds to 100 hours (assuming I’m well warmed up for the short rides).
I’ve had several rides recently when I felt like I was starting at the end of a ride. The heart rate I could sustain at the beginning of the ride was around 145 to 155. There were no other issues. I recently rode, for the fifth time overall, the Boston Brevet Series 300 km in 12:24, 16 minutes faster than my previous best. So I’m riding fairly well but it’s definitely different.
It feels and seems as though I’m starting my rides with depleted glycogen reserve. And I think this may be the case. My suspicion is that lithium produces chronic dehydration which, among other things, cripples the glycogen recovery between rides.




































































