A client asked me if I knew of a way to remove the spurious line feeds in a text that you copy from, say, a PDF into the textarea editing box for the wiki. The problem, which you may have seen, is that highlighting a couple of paragraphs of text in the source document and then pasting them into a textarea in your browser will end up with funny, unintended line breaks.

For example, copy the first paragraph of the second section of this paper and then pasting it into a textarea using Firefox gives this result:

The text should be divided into sections, each with a
separate heading and consecutive numbering. Note, how-
ever, that single secondary, tertiary, and quaternary sec-
tions remain unnumbered. Each section heading should be
placed on a separate line using the appropriate L
A
T
E
X com-
mands. For more detailed information on different sections
and their formatting see the Authors’ Guide.

After looking around a bit, I found lots of people talking about pasting problems, but no one offering a solution that would work in the browser instead of just on one particular web page.

After reading about JavaScript and pasting, poking around in the Firefox addons, I figured I knew enough to address the problem with GreaseMonkey.

jsfiddle provided a nice REPL for testing my code and it wasn’t too hard after that to put this together in GreaseMonkey and upload the result to UserScripts.org (after I recovered the password to my long-dormant account).

So, after all that, here is the result of the previous paste:

The text should be divided into sections, each with a separate heading and consecutive numbering. Note, however, that single secondary, tertiary, and quaternary sections remain unnumbered. Each section heading should be placed on a separate line using the appropriate L A T E X commands. For more detailed information on different sections and their formatting see the Authors’ Guide.

Hopefully this will be useful to others.

Scenes from Matanda, Malawi
This girl is going to have to walk 1km home. Photo from kym54 on Flickr.

This week, if you’ve seen any of my action on Twitter or Facebook, you probably know that I was admitted to the hospital on Monday for blood clots in my lungs. Three years ago I had a pulmonary embolism while I was in the hospital. To avoid the out on my third strike, I’m going to have to live the rest of my life regularizing my leafy green intake and taking Coumadin.

So, fine. I had a blood clot (again!) and I could have been one of the 100,000 Americans that die every year (one every 5 minutes) from a blood clot.

But I’m not. I survived. I’m very happy to be alive. I don’t really know how I would feel if I hadn’t survived this, but I know that my wife and children were quite upset when they came to see me in the hospital — their lives would be completely different had I not survived. And so, I’m happy for them that I’m sitting here in my back yard listening to the cicadas while my daughters play with the bugs they’ve caught today.

If the blood clot didn’t result in brain damage (i.e. a stroke), then the inconvenience of Coumadin is probably the most debilitating long term effect that most people suffer. There are even (very expensive) drugs available that take care of thinning the blood without being affected by diet. I’m on one now because the Heparin I was in the hospital for wasn’t getting my INR up quickly enough. But it costs $40 per dose. Paying $280 per week for preventative medicine doesn’t really work for my budget when there is a cheaper alternative (Coumadin) that has been working for 60 years.

But now when I tell people I’ve had two blood clots, they tend to freak out. “That sounds scary!” Or “I‘m praying for you.”

I understand this. When a friend of mine showed me a clot that he had in his leg, I was pretty surprised that he was up and about and not falling over in front of me. “Shouldn’t he be more worried?” I thought.

But now I think I understand his point of view a little better. People die from blood clots. Like I said, an American dies once every five minutes from one.

Maybe it is just that those of us who have had one (or two!) of them and survived realize that we are past the deadly part — we’re alive and life keeps happening.

I appreciate that the possibility of death looms every second that I’m alive. I appreciate the prayers of others for my health and my family’s well-being. Really, I’m grateful!

But I’m also grateful for drinkable running water. Water is essential for living, but most Westerner’s don’t spend time thinking about how blessed they are that they don’t have to walk to a communal well every day to get their water. And I don’t spend time telling them how lucky they are to have running water.

Death looms, but I’m alive.

It takes a lot of infrastructure and work that we don’t usually see to get plenty of fresh water, but I can take a nice long shower.

I’m lucky to be alive. There, I’ve acknowledged it. Can I just get on with living?

Asian food.jpgLast night, I ate dinner twice. The first time I got an education about Israel’s wars in 1967 and 1973.

But at the second dinner, Amir told me he read my blog. So, of course, this post is about the discussion I had with him then.

He asked me why I make a point that I am Orthodox when I talk about my Christianity here. I suppose that from the outside, these differences look sort of petty. Yep, you’ve got bells and smells and they have a praise band. So what?

The first part of my answer was from Stuff White People Like: It is different than my parent’s religion. I remember when my wife and I were looking at Orthodoxy some 15 years ago. There were a lot of heated discussions with my parents — especially my dad. That made an impact on me and, even though the differences don’t mean much to someone who isn’t a Christian, they mean a lot to me. It is a distinct part of my identity. The point is not that if you’re the wrong kind of Christian (let alone an atheist) you are going to hell. Instead, it is simply a restatement of my identity.

To borrow from Tom Morris post on identity embracement, I’m an Orthodox, freetarded capitalist, and a straight, white, American father of four. When I post about an area where I feel like my identity is in the minority — like being an Orthodox Christian American — I dwell on it a bit more and that is reflected in what I write.

(Photo credit: No, that isn’t my dinner.  It is from John Martinez Pavliga and used under the Creative Commons Attribution 2.0 Generic license.)

Flu in Hong KongIt has been a while since I posted anything here and I’m only posting now to tell you that I’m in Hong Kong.

After Markus Glaser and I won the contract for MediaWiki release management from Wikimedia, he suggested that I come to Wikimania so that we would have a chance to talk to developers.

Markus has been busy in chapter meetings, so I’ve been spending some time talking to developers and getting ready for the MediaWiki architecture discussion later today.

Today, a client asked for a way to hide the content of one page from casual browsers. I came up with the following:

$wgHooks['BeforePageDisplay'][] = 'stopDisplay';
function stopDisplay( $output, $skin ) {
        if( 'Passwords galore' === $output->getPageTitle() ) {
                global $wgUser, $wgTitle;
                if( !$wgTitle->userCan( "edit" ) ) {
                        $output->clearHTML();
                        $wgUser->mBlock = new Block( '127.0.0.1', 'WikiSysop', 'WikiSysop', 'none', 'indefinite' );
                        $wgUser->mBlockedby = 0;
                        $output->blockedPage();
                        return false;
                }
        }
        return true;
}

There may be another way to do this and this is certainly not secure against all attempts to read page content. For instance, if you want to hide a Wiki page like [[Passwords_galore]] from people using this technique, all they would have to do is include it using a template to get around this hack: {{:Passwords galore}}.

I’ll be looking at more ways to access the page and more ways to block it soon.

This is just a general reminder that life sucks, not a navel-gazing, self-pitying examination of my own life. I’ll save that for another day. This is just a rambling rant that I felt the need to write down.

Most of us who don’t live in war zones get complacent. We like safety and comfort. We like predictability. We want tomorrow to be only moderately different than today. Not exactly the same, mind you. We saw Groundhog Day already and are pretty sure that would be a nightmare.

Even if we do like to mix it up some — Skydiving, anyone? — we are still looking for exciting, exhilarating life experiences, not life changing catastrophes.

But the reality is that life is filled with pain and heartache. The reality is that danger is ever-present and tomorrow, let alone the next second, isn’t guaranteed.

Too often, we come up against this hard reality and we wonder “Why me? What did I do to deserve this?” Yes, something you did probably contributed to how your life sucks, but even if you lived perfectly and we can find nothing to fault you with, life sucks and, worse, it isn’t fair so your life will suck or, if you’ve somehow been able to live a life of pure bliss in which you did nothing wrong (ha!), you are still going to die.

But that isn’t all. Before you die, you’ll see people you care about, even those you love, having a sucky life and dying.

So, yeah, your life will suck. You’ll end up miserable and experiencing more pain than you deserve.

Instead of asking “Why me?” — instead of thinking that you shouldn’t have to live in misery and fear, remember that everyone’s life sucks. If you spend a little time reflecting on it, you’ll probably realize things could be worse. At the very least, you should realize that your misery isn’t unique. Everyone else’s life sucks at some point, so a better question is “Why not me?”

Instead of looking at the person you despise who is in misery and feeling smug or thinking “Well, that person deserved it!” try asking yourself “Why not me?” If you do that right — if you realize there really is little reason for you to escape suffering for what you’ve done while that person is in misery — you’ll find yourself hoping that the person you despise quickly recovers.

Yes, life sucks. Yours, mine, and everyone else’s. There is no escaping it. Misery and suffering are inevitable.

I love to read, and I love to read books that make learning fun; The Information is one of those books.

I’ve been enjoying the trip the book provides. It talks about the some of the oldest written language we have and quotes Plato sounding like a teacher complaining about the invention of the pocket calculator:

For this invention [writing] will produce forgetfulness in the minds of those who learn to use it. … You have invented an elixir not of memory, but of reminding; and you offer your pupils the appearance of wisdom, not true wisdom.

Imagine if Plato saw how many of us use more modern technology — an always-available Internet search engine, for example — so that we don’t even have to think twice about getting access to entire libraries of “the appearance of wisdom”.

It goes on from there to explain how people in Africa developed long-distance communication with their “talking drums” long before Europeans had strung up the first telegraph. He uses the telegraph to lead into a discussion of cryptography, information theory, and data compression.

Over and over, he returns to this idea of how we communicate and collect and understand our knowledge. In the process he introduces people like Gödel and his incompleteness theorem or lesser known people like his student, Gregory Chaitin, a mathematician who so fascinated me that I went looking for the source of a quote and discovered his “Paradoxes of Randomness, a piece of which I’ve managed to quote in my email signature:

Sometimes mathematical truth is completely random and has no structure or pattern that we will ever be able to understand. It is not the case that simple clear questions have simple clear answers, not even in the world of pure ideas, and much less so in the messy real world of everyday life.

Of course, any recent book about how we think about what we know and how we collect and classify what we know wouldn’t be complete without some discussion of Wikipedia. And, here, there was a hidden gem for me. I discovered that I know one of the characters in a story he tells about the growth of an article about a butcher shop in South Africa. Jimbo Wales, co-founder of Wikipedia, created a stub article about a butcher shop he visited and a few hours later, ^demon, a developer I’ve worked with at Wikimedia and grown to respect for his keen eye for detail proposes deletion.

I fairly squealed when I saw ^demon’s handle in the book.

But even if you don’t know ^demon or appreciate the finer details of information theory, you’ll likely enjoy the book. I asked my 14 year old son to read a bit and he quickly tore through the first few chapters before agreeing that it was well-written, fairly entertaining, and accessible.

Sunset may 2006 panorama.jpg
Today marks 40 years since my birth.

It is a birthday I share with Lady Gaga (but she is 13 years my junior); the Three Mile Island leak (when I was 6); Anheuser Busch, Jr., a beer brewing magnate; and the death (four years before my birth) of President Eisenhower (one of my favorite presidents for his prescient words about the “military-industrial complex”: the potential for the disastrous rise of misplaced power exists and will persist. (As it happens Ronald Reagan was shot just two days after my eighth birthday, but I would have to wait exactly four months for my wife to be born.)

There is a lot more you could learn about March 28 in the news or in the Orthodox Church (my chosen religious tradition), but I’ve spent far too much time navel-gazing for now.

Instead, I’ll just note that the past 10 years have been a lot better than I ever thought they would be. I’ve been lucky enough to survive an head injury and I moved to the East Coast but I still haven’t got my first billion dollars. Somehow I still manage to be happy and satisfied with where I’m at with my family, friends, and life.

(Photo is CC BY-NC. Photographer is Fir0002/Flagstaffotos.)

Old-Train-Engine.JPGYoda is well known for (among other things) his admonition to Luke Skywalker: “Do or do not. There is no try.” I like the saying, but when I’ve mentioned it to some people, they’ve taken offense. Americans, in particular, seem to be put off by this sentiment.

My impression is that our concept of “trying” is influenced by the story of the The Little Engine that Could. We look at our failures and console ourselves with “Well, at least I tried.”

Now, of course there is nothing wrong with trying. But sometimes that is the entirety of our effort. I came across this quote today that helped me think about this some more:

[I]t is important to distinguish “training” from “trying.” I might try very hard to win a marathon race, but if I have not trained, I will not even finish, not to mention win. Without training, the resources simply are not in my muscles, they are not in the ingrained habit structures of my body. On the day of the race, no amount of trying will make up for the failure to train. It is the training that will enable me to participate effectively in the race.

Richard Foster in Christianity Today


The quote was part of larger chapter on askesis (Greek: ἄσκησις) or spiritual exercise. But leaving aside the spiritual component, the Richard Foster quote above makes it clearer why just putting in an effort to accomplish something is insufficient.

In discussing “trying” vs “training” this morning, I came to a realization: trying something lasts only as long as our interest. In order to try, we don’t have to plan or prepare. Who knows? It is possible you’ll succeed if you try without any preparation. Indeed, some people will try so many times (taking the to heart the aphorism “If at first you don’t succeed, Try, try, try again.”) without any more preparation that the culmination of all your effort (and the practice that comes with it) will result in success.

But any real effort to achieve a goal will require some planning. It will require effort even when we don’t feel like trying any more because our failures have so discouraged us.

With this understanding, Yoda’s words (“Do or do not. There is no try.”) become clear. He isn’t telling us failure isn’t an option, but that we can’t be satisfied with just making an effort. If we’re really interested in finishing successfully, making an effort isn’t enough.

An example from my life is probably the best way to clarify this. I’ve been trying to lose some weight for quite some time. Instead, since my accident (when I lost a few pounds), I’ve gained almost 25lbs (11kg or 2 stone). I was trying to lose weight but the whole time I gained weight. But I didn’t have a plan. Without planning, I ate more than I needed to for the work I was doing. Without planning to, I gained weight. I should have realized “there is no try”.

p5rn7vb

Gyárfás_Piety.jpgI had an interesting discussion with a friend about piety and morality after I pointed to Fr. Stephen’s essay on “Godless Morality on Twitter.

This led me to look up what these two words have to do with each other. From Wikipedia:

Piety
The word piety comes from the Latin word pietas, the noun form of the adjective pius (which means “devout” or “good”). Pietas in traditional Latin usage expressed a complex, highly valued Roman virtue; a man with pietas respected his responsibilities to gods, country, parents, and kin.

Morality
Morality (from the Latin moralitas “manner, character, proper behavior”) is the differentiation of intentions, decisions, and actions between those that are “good” (or right) and those that are “bad” (or wrong).

So, moral behavior would be derived from the piety one felt and what that respect would mean. Morality, to put it bluntly, cannot be objectively quantified. All morality is relative.

(We usually say “filial piety” when we mean respect to the family to distinguish it from respect for one’s god. It is interesting that the original Latin word could be used to talk about piety towards one’s country. Today, we use the word “patriotism” for that.)

As a result of this etymological search I don’t see a separation between piety (in the more general, Latin, sense) and morality. It looks to me like morality flows from the pieties one maintains.

That is, if you don’t have piety for my God, you won’t be motivated to do things that are in the moral system I have that results from the pieties I maintain.

Most of us have piety (that is, respect) for at least some sense of order and life, so prohibitions against, say, murder fit into our moral frameworks.

However, I have piety (respect) for God that others don’t share. Many people have a great piety towards science or reason that I don’t share. So they will do things that I wouldn’t do and I’ll do things that they won’t do. (For example, I am more ready to embrace the irrational, and many people don’t bother with loving God.)

So, when you hear people ranting about how immoral some people are, they’re absolutely right. However, they can’t expect anyone who doesn’t share their pieties to share their morality.