Verfasst von: Michael | 31/10/2009

Halloween: 14,18km in Nu Shooz

Ab jetzt geht’s hier im Blog auf Deutsch weiter, die Beiträge zum Thema Software-Entwicklung bleiben aber der Einfachheit halber auf Englisch.

Nachdem sich bei meinen letzten Läufen am rechten Fuß üble Blasen gebildet hatten, habe ich heute meine treuen Asics-Laufschuhe eingemottet und habe mir bei Heart & Sole ein neues Paar von Nike besorgt. Nach einer ausführlichen Laufanalyse auf dem “Glas-Spiegel-Würfel” (wie heißt das Ding wirklich ???), auf dem Laufband und einer Runde vor dem Haus habe ich mich in die Neuen verkuckt und sie gleich mitgenommen. Gratis gab’s noch ein Paar Laufsocken oben drauf. Übrigens: wie immer eine klasse Beratung !

Daheim hab ich mich gleich in die Laufklamotten geschmissen und bin meinen Killer-Track mit den neuen Schuhen gelaufen. Erstes Urteil: sehr leicht, angenehm am Fuß und trittsicher.

image

Distanz: 14,18km
Zeit: 1:17:10
Tempo: 5:26
Höhe: +166,8 / -168,0

 

Noch ein Grusel-Tipp für Halloween: das Hörbuch “Der Fall Charles Dexter Ward” von H.P. Lovecraft, gelesen von David Nathan (deutsche Synchron-Stimme von Johnny Depp). Wunderbar altmodische Horrorgeschichte mit unheimlicher Atmosphäre.

image

Verfasst von: Michael | 24/10/2009

Autumn Running

… in the forest around the Bärensee with nice weather & temperature.

imageDistance: 11,90 km
Time: 1:04:25
Pace: 5:25 min/km
Elev: +89,9 / -92,6

Verfasst von: Michael | 18/10/2009

HM in Großbottwar

This morning we had quite a low temperature and on our way to Großbottwar it rained heavily: not the best conditions for running a half marathon. But St. Peter was in good mood and the rain stopped after we arrived in the big smalltown Großbottwar.

The track was more difficult than Lindau because it had some uphill parts which hurt more with every km. Nevertheless I managed to finish with a better time than in Lindau. The 1:50 boundary is not that far away …

imageTime: 1:53:21
Pace: 5:23 min/km
Position (abs / by age): 715 / 126
Elev: +77,5 / -86,4

 image

Verfasst von: Michael | 17/10/2009

One day to 2nd HM

Tomorrow I’ll hopefully top the running season with the finish of the half marathon in Großbottwar. Sadly one of my co-runners (Martin) can’t attend because he has a flu (hopefully not the swine one).

The weather won’t be as nice as in Lindau. Currently we have typical cold autumn weather with rain and wind. Goretex rulez :-)

Let’s RUN for big daddy Martin !

Verfasst von: Michael | 11/10/2009

Dynamic XML-Processing with IronRuby

With C# 4.0 a new keyword will be introduced called "dynamic". Objects of type "dynamic" can be called with any signature. The Dynamic Language Runtime (DLR) in the background converts the calls into valid calls on the target object. E. g. instead of calling xmlElement.GetAttributeNode("Bla") you could call xmlElement.Bla to retrieve the value of the attribute. This way the concepts of dynamic programming enter the world of statically typed C#.

This technique is well-known in the scripting area for a long time (even Smalltalk had such a feature). IronRuby is the Ruby-Implementation on the .NET-CLR so I wanted to experiment a little with its dynamic capabilities.

Let’s start with a small XML document containing data of some addresses:

addressbook = <<addresses
<addressbook>
   <address>
      <name>John Doe</name>
      <street>Somestreet 1</street>
      <city>Somecity</city>
      <phonenumbers>
         <phone kind="home">91829182</phone>
         <phone kind="mobile">7271827</phone>
      </phonenumbers>
   </address>
   <address>
      <name>Jane Doe</name>
      <street>Doestreet 3</street>
      <city>Somecity</city>
   </address>
</addressbook>
addresses

Instead of handling XmlElements, XmlAttributes and all that stuff I want to execute this Ruby code:

doc = XmlDocument.new
doc.load_xml addressbook

doc.addressbook.each_address { |adr|
  puts "%s lives in %s, %s" % [adr.name, adr.street, adr.city]

  if adr.phonenumbers
    adr.phonenumbers.each_phone { |p|
      puts "  Phonenumber %s (%s)" % [p.text, p[:kind]]
    }
  end
}


Quite easy looking, isn’t it ? But how is this possible ? The XmlDocument-Type doesn’t have a member called “addressbook”. Well, here begins the magic of dynamic programming. What happens when Ruby encounters a method that doesn’t exist ? Right, it calls the method_missing-Method which, when not overridden, raises the wellknown exception. Let’s overwrite the method instead by just specifying another XmlDocument class:

class XmlDocument
  def method_missing(method)
    if document_element.name == method.to_s
      document_element
    end
  end
end


We don’t replace the XmlDocument class here, we just add a little bit of code for our needs: we just check if the name provided by the missing method equals the name of the Root-Element and return this. When I run this code

doc = XmlDocument.new
doc.load_xml addressbook
puts doc.addressbook


I get the output System::Xml::XmlElement which is actually the type of the document_element-Member. Works, great.

OK, that was easy, but what about these each-Methods and the other accessors. This is a little bit more difficult. Here is the complete code of the XmlElement-Class:

class XmlElement
  alias_method :the_old_name, :name

  def method_missing(method, *args, &block)
    each_index = method.to_s.index("each_")

    if each_index == 0
      examine_each(method, &block)
    else
      examine_child(method)
    end
  end

  def [](attr_name)
    attr = get_attribute_node(attr_name)
    return attr.value if attr
  end

  def name
    child = examine_child(:name)
    return child ? child : the_old_name
  end

  def text
    inner_text
  end

private
  def examine_each(each_method, &block)
    child_name = each_method.to_s[5..-1]
    select_nodes(child_name).each { |child|
      block.call child
    }
  end

  def examine_child(child_name)
    child = select_single_node(child_name)

    if child.class == XmlElement and
      not child.child_nodes.any? { |c| c.class != XmlText }
      child.inner_text
    else
      child
    end
  end
end


Some explanations:

  • By using alias_method I can remember the original implementation of the replaced “name”-Member
  • As you can see the method_missing-Method doesn’t only get a method name but also the args and the code block that was provided. Therefore I can forward the block to the examine_each-Method which yields the block for each matching child
  • The string “each_” is used to identify if the user wants to iterate over child nodes or access the child directly.
  • The []-Operator is replaced to read attribute values
  • The examine_child-Method uses the assumption that a node that doesn’t have any child nodes with an XmlText can be considered as Text-Nodes.

When I run the program from above I’ll get the desired output:

John Doe lives in Somestreet 1, Somecity

  Phonenumber 91829182 (home)

  Phonenumber 7271827 (mobile)

Jane Doe lives in Doestreet 3, Somecity

I think this small example shows the power of dynamic programming. I’m curious if C# will get the same treatment as IronRuby and have a concept like the method_missing-Callback.

Verfasst von: Michael | 08/10/2009

9,49km

Time: 51:38
Pace: 5:26 min/km

image

Verfasst von: Michael | 04/10/2009

inudge – Music For Absolute Beginners

I just found this nice website where you can create small pieces of music with a simple matrix control. Really cool, what do you think of my composition ?

Verfasst von: Michael | 04/10/2009

First Time Finisher

This morning at 6 o’clock the four crazy ones (J.M.M.G.) started their trip to Lindau to run the JAKO-Halbmarathon. We arrived at 8:00 in Lindau to get our starting documents. Fortunately I checked my champion-chip ID: there was a mistake in the last letter (actually it was the letter B instead of the digit 8).

SNV80874

Then we drove to Bregenz were we changed clothes for the run and got on a ship which brought us back to Lindau where the start was (nobody said that the whole setup is understandable at first sight). There we dumped our clothing bags in trucks and waited another hour for the start at 11:11. Weather was great !

The crowd was quite big, so after the start there was a lot of sidestepping. J+M were out of sight very soon as they ran at a higher speed. G ran a little bit slower so most of the time I was on my own. Everything went fine (as usual) up to 14km. There was a nice panoramic view on Lake Constance and the mountains behind, and a lot of cheering people (thank you folks !). At one point we passed the Seebühne in Bregenz were we ran right below the tribune.

imageAfter 16km I faced the well-known problem of dropping energy. I used every waypoint where drinks and food were provided so I could still hold the speed of 5:30 min/km most of the time. After 21km I entered the stadium of Bregenz where the finish waited for me. Exhausted but still alive I immediately got my medal. J+M were already there since 7 minutes, G finished 4 minutes after me (hats down to all of you).

My official results:
Time: 1:54:53
Pace: 5:27 min/km
Elevation: +64,7 / -52,4
Absolute position: 1116
Position in my age group (M-35): 157

SNV80878Four Finishers: the person with hair on the head is the girl ;-)

 

 

 

 

 

SNV80881

The Reward

Verfasst von: Michael | 04/10/2009

Final Post

After a short night I got up at 4:30h. One coffee, some bread, a shower, that’s it. Now meeting J.M.G. at M. then heading down to Lindau.

This is Linkey, hopefully finisher of The Lindau HM, signing off …

Verfasst von: Michael | 03/10/2009

One Day To Go

Yesterday I moved a washing machine + a big bedroom cupboard from IKEA together with my sister and brother. I came home at 11 o’clock quite tired so I have to relax today because TOMORROW IS DA DAY !

My starter number in Lindau is: 4237

In 24 hours I’ll be on the road right beside Lake Constance

Ältere Artikel »

Kategorien