February 12, 2008

Ruby regexp search

I just started learning ruby, and have run into the problem that the Regexp class doesn't have a search method for matching all occurances of a pattern in a string. With a little help from ruby-lang irc, I am now using this extension for Regexp:

class Regexp
def search(string, offset=0)
string.scan(self) { |txt| yield Regexp.last_match }
end
end

Ruby 1.9 has a match method that takes an offset, but it only returns a single MatchData object. The above is much simpler to use IMHO.

November 06, 2007

Ready, Steady, Go!


Ready, Steady, Go!
Originally uploaded by HugoD
Adlaï is crawling and very happy to discover the increased mobility he is too!

October 04, 2007

Water


Beaker
Originally uploaded by HugoD

Adlaï has been watching us intently every time we drink water for a while. So we got him a beaker and gave it to him. He was intrigued, to the point where he was quite happy to chase the beaker around the floor for a good ten minutes. Who needs electronic games.

September 29, 2007

Logitech, never again

I have just spend close to a month trying to track down unrepeatable behaviour in an application I am writing. The application is pretty hairy, and contains lots of matrices that are nearly singular, and I was imagining all sorts of weird numeric problems. But no. The problem was with the software that I installed for my Logitech video/web camera.
Essentially Logitech, in their wisdom, decided it would be a good idea to inject their lvprcinj.dll into everything possible, my program included. Something in that dll was causing unrepeatable behaviour in my program. Thank you Logitech for your malware. Problem solved. I for one will never buy a Logitech product again.

Children and toys

We end up buying a lot of toys for our children. Certainly for our son we seem to have amassed many more toys than I imagined we would have. They toys range in price and sophistication, and our son's interest in any toy varies over time, but there is no correlation I can discern between either the cost or sophistication and his enjoyment of the toy. There seems to be a general idea that expensive sophisticated toys make the best presents for a child, but in reality all he really needs is our love and constant provision of a secure and nurturing environment, and for us to show him how the world works. Like so much in this world, what works for children can easily be transferred to an adult scenario.

September 28, 2007

Burma

Reading about the situation in Burma it is intersting to see the role being played by the Buddhist monks. Not only are they involved in politcal protest, but leading through their own use of peaceful means, they have raised the level of their protest to one of morality and basic human rights. In so doing they have shown more leadership than anybody I can think of since Ghandi.
One could only hope that their example inspires those trying to change the Middle East, and the world owes them our support, to ensure that peaceful protest has demostrated results.

Update:  Monk stencils

Adlaï is 6 months old today!


Two little monkies
Originally uploaded by HugoD
Adlaï is already six months old. What a humbling experience it has been so far, in so many different ways. Having somebody rely on you all day every day for all their needs teaches much about patience and tolerance. At least I get breaks; Gabriela has been breast feeding and so doesn't get much time off.
Seeing Adlaï come alive over the last few months is a marvelous experience. You can see his hearing, sight and motor abilities change from one day to the next, and his fascination with the world is renewed and heightened every time he gets to experience it in a little richer form.
Having a baby suddenly makes people very friendly, and it makes you think about how reserved we normally all are with each other. Just having the excuse of admiring the baby is enough for many people, both complete strangers and also those we see on a regular basis in shops, neighbours, etc, to start talking with us.

November 28, 2006

cygwin, mingw and runtime libraries

I have been trying to get gcc to compile dll's that I can use with msvc 8.0. Turns out that the accepted practice involves taking the standard mingw/cygwin install and copying and renaming library files.

The compiler always wants to link msvcrt.dll, so to link with msvcr80 we have to create a directory containing a copy of the mingw/cygwin distribution's msvcr80.a library renamed to msvcrt.a, and then specify this directory as a library path when we link.

Wouldn't it be simpler if the distribution came set up that way?

October 01, 2006

Who Maintains the Peace in Utopia?

It is a difficult quest to arrive at a Utopia of growing, sovereign nations, so maybe it is easier to ask what it would take to maintain such a state of the world, before wondering how to get there.

Consider how a single nation maintains peace within itself; any peaceful modern nation is based on some fundamental ideas - a legal system and some form of representational government, whether secular or religious. The legal system comprises a set of laws that are applied without preference or prejudice to the whole of the population, patrolled by a police force and enforced with by an independent judiciary. The application of the legal system is independent of the political system, even though the later may add to the body of law that is enforced. The political system represents the people in some way, and controls an executive that performs the day to day running of the government. The jurisprudence might by driven by a civil code, case history, or a religious code.

At the supranational level, we can identify similar bodies today. At the continental level the European union provides a functionaing model for co-operating nations, and has fairly well established parliament providing elected representation, a court system, a legislative body, an executive under the high level guidance of the European Council.

On the global scale, we have the United Nations, comprised of a representative body, an executive, a court system, the Security Council responsable for maintaining international peace, and the Economic and Social Council. Independent of the UN, we have the International Criminal Court and Interpol, the World Bank and the International Monetary Fund.

How well are these institutions working, and are they capable of maintaining peace in Utopia?