 Saturday, September 30, 2006
Part 2 - More IronPython and delegates…
So we have briefly covererd strongly typed delegates and event
handlers... But they make the assumption that we know what our
arguments are at compile time, what if we dont?
Say for instance you're expression engine has a bag of contextual values being passed around in a dictionary, like this:
Dictionary<string, object> context = new Dictionary<string, object>();
context.Add("user", "alex");
context.Add("age", 26);
What if we want to use python to evaluate expressions against that
context?... Say something like writing out “my name is alex and my age
is 25" - the expression in python is easy enough, we can go:
‘my name is’ + name + ‘ and my age is ‘ + str(age)
But how do we marry all these together... lets start exploring... ever noticed that delegates have a DynamicInvoke method with a signature like this?
object
DynamicInvoke(params object[] parameters)
Perhaps we can try and use this to our advantage... lets see shall we?
First Attempt
[Test]
[ExpectedException(typeof (ArgumentException), "T must be a concrete delegate, not MulticastDelegate or Delegate")]
public void LooseDelegateAndDynamicInvoke()
{
PythonEngine engine = new PythonEngine();
List<string> parameters = new List<string>(new string[] {"name", "age"});
Delegate func =
engine.CreateMethod<Delegate>("return ‘my name is’ + name + ‘ and my age is ‘ + str(age)", parameters);
string result = (string) func.DynamicInvoke("alex", 26);
Assert.AreEqual("my name is alex and my age is 25", result);
}
Sadly this doesn’t work so well, seems the PythonEngine is looking for
a concrete delegate... we could try giving it void delegate,
but it does type checking on the number of parameters and their type,
so we're a little stuck.
At this point I think the best answer is to actually build some code
which generates the apropriate delegate type, based on the supplied
dictionary, and then passing that onto the python engine, but there is
another way… it’s a little less elegant, but it’s at least amusing:
Round 2
First of let’s build a little helper method...
private static string GenerateFunction(string functionName, string[] parameters, string statements)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat("def {0}(", functionName);
for (int i = 0; i < parameters.Length; i++)
{
if (i > 0) builder.AppendFormat(", ");
builder.AppendFormat(parameters[i]);
}
builder.AppendFormat("):\r\n ");
builder.AppendFormat(statements.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n "));
return builder.ToString();
}
You can no doubt see where this is going – so given a statement like this:
GenerateFunction("func", new string[] { "user", "age" }, "return user + ' is ' + str(age) + ' years old'")
We’d end up with a string like this:
def func(user, age):
return user + ' is ' + str(age) + ' years old'
And, moving on from there we build a test…
[Test]
public void GeneratingPythonFunction()
{
Dictionary<string, object> context = new Dictionary<string, object>();
context.Add("user", "alex");
context.Add("age", 26);
List<string> parameters = new List<string>(context.Keys);
List<object> values = new List<object>(context.Values);
PythonEngine engine = new PythonEngine();
engine.Execute(
GenerateFunction("func", parameters.ToArray(), "return user + ' is ' + str(age) + ' years old'"));
PythonFunction func1 = engine.EvaluateAs<PythonFunction>("func");
engine.Execute(
GenerateFunction("func", parameters.ToArray(),
"return user + ' is ' + str(age+1) + ' years old next year'"));
PythonFunction func2 = engine.EvaluateAs<PythonFunction>("func");
object result1 = func1.Call(values.ToArray());
Assert.AreEqual("alex is 26 years old", result1);
object result2 = func2.Call(values.ToArray());
Assert.AreEqual("alex is 27 years old next year", result2);
}
Are there problems with this?… well there’s a few, unsurprisingly!
• PythonFunction’s are not delegates.
• String manipulation is a bit clunky
• Because these are named functions, you probably
want to lock against some object when generating the function, to avoid
cross-threading issues…
Back to delegates
Aside from the problems it works alright, but what we really want is a
delegate… those PythonFunctions don’t give you the flexibility to
substitute IronRuby in the future now do they?
So first off, lets
declare a delegate suitable for our purposes.
[ThereBeDragons("Only use as a last resort")]
public delegate object UntypedDelegate(params object[] parameters);
Aint she a beauty ;o) - full credit for the ThereBeDragons attribute goes to Ayende,
though it's probably not really warranted in this situation - now,
let’s rework the last test to use a delegate instead, a simple
anonymous delegate will do the dirty work:
[Test]
public void UntypedDelegateForPythonFunction()
{
Dictionary<string, object> context = new Dictionary<string, object>();
context.Add("user", "alex");
context.Add("age", 26);
List<string> parameters = new List<string>(context.Keys);
List<object> values = new List<object>(context.Values);
PythonEngine engine = new PythonEngine();
engine.Execute(GenerateFunction("func",parameters.ToArray(),"return user + ' is ' + str(age) + ' years old'"));
PythonFunction func1 = engine.EvaluateAs<PythonFunction>("func");
UntypedDelegate func1Delegate = delegate(object[] param)
{
return func1.Call(param);
};
object result1 = func1Delegate(values.ToArray());
Assert.AreEqual("alex is 26 years old", result1);
}
It’s certainly better then passing around PythonFunction instances –
though you need to be a little careful… there’s a little quirk here, if
we were to use:
object result1 = func1Delegate.DynamicInvoke(values.ToArray());
It’s going to fail because the wrong number of arguments were supplied
(it expects only 1, an array), so our delegate doesn’t really behave
like it has multiple parameters.. so to dynamically invoke this
delegate we’d need to take special care, promoting the arguments into a
second array like so:
object result1 = func1Delegate.DynamicInvoke(new object[] { values.ToArray()});
Next Time
When I get bored I'll write a version which doesn't require the clunky generator and post it up...
Next time I'll talk about writing classes which are python-friendly, riveting stuff eh? As you were.
I felt like posting some code snippets… so I was looking around and
thought
perhaps some IronPython might be interesting…. Some of you may find
this useful, possibly not. I tend to explore functionality using
unit tests, so all my code will be test cases – I might make this part
of a small series on looking at python code with a view to integrating
it into an existing system as a scripting engine. Lets call the
series "IronPython is your friend"... because it really is.
Part 1 - IronPython and delegates….
So you have downloaded the IronPython runtime dll's, and you would like
to start integrating it into some project your working on… first off
lets create a python engine, and make sure it goes….
[Test]
public void GetGoing()
{
PythonEngine engine = new PythonEngine();
engine.Execute("myString = 'hello'");
Assert.AreEqual("hello reader", engine.Evaluate("myString + ' reader'"));
}
That was pretty easy; we executed some python code to assign the value
hello to myString, and then evaluated the expression – sweet you might
say – no effort required.
Now, you could write your scripting engine so that it passed the
strings to the engine for evaluation every time you wanted to evaluate
them – but this strings malarkey isn’t very pleasant… what we really
want is a decent god fearing .Net delegate, so we can call this without
having to think about the python engine…. Lets check out our first
destination, method delegates.
Method Delegates
Given a converter delegate like this:
Converter<int, string>
(Which by the way, if you haven’t stumbled across the generic
Converter<TInput,TOutput> delegate yet, effectively you end up
with a delegate method of the definition“TOutput Converter(TInput)” – pretty handy
actually)
We could do this:
[Test]
public void StatementsToStronglyTypedDelegate()
{
PythonEngine engine = new PythonEngine();
List<string> parameters = new List<string>(new string[] {"age"});
Converter<int, string> converter =
engine.CreateMethod<Converter<int, string>>("return str(age+1)", parameters);
Assert.AreEqual("11", converter(10));
}
Using a strongly typed overload for the engine's CreateMethod method,
we’re able to evaluate statements using our new delegate, which in turn
uses our IronPython method we created earlier… looks promising!
Events
Now delegates are cool, but it’s only half the story for
scripting in an application – depending on your model, you may be
aiming to produce results similar to a microsoft’s VBA in applications like Excel or Word – and for this
we need to be able to assign python code to events on our own classes…
we can do this using delegates of course, or we could let the python (user code)
do this itself, and save some time…. So lets have a look at the latter:
[Test]
public void HookingToEvents()
{
PythonEngine engine = new PythonEngine();
ManualResetEvent waitHandle = new ManualResetEvent(false);
WebClient client = new WebClient();
List<string> results = new List<string>();
engine.Globals["client"] = client;
engine.Globals["results"] = results;
engine.Execute(
@"def storeResult(sender, e):
results.Add(e.Result)
e.UserState.Set()
# assign out storeResult function as an event handler for the client class
client.DownloadStringCompleted += storeResult
");
client.DownloadStringAsync(
new Uri(
"http://api.feedburner.com/awareness/1.0/GetFeedData?uri=http://feeds.feedburner.com/BitterCoder"),
waitHandle);
Assert.IsTrue(waitHandle.WaitOne(10000, false), "timeout occured after 10 seconds");
Assert.AreEqual(1, results.Count);
Assert.IsTrue(results[0].StartsWith("<?xml"));
}
This test is a bit clunky, but you get the idea… we are:
- Creating a web client, for downloading some xml from a web site.
- Set the client as a global variable for the default module in the python engine.
- Execute some python, which creates a function, and assigns that
function as a handle for the web client's DownloadStringCompleted event
(take note at how concise the code is, this would be a lot uglier in C#)
- start the async download
- Make sure we got a response, and that the python code did what it should.
All in all, with a little finesse you can recreate a model similar to
VBA, driving your extension points from events – and this certainly has
some merit – obviously you want to create the code in their own
modules, as opposed to using the default module for the python engine
as we are.
We haven't quite finished with delegates yet though, I'll leave that for part 2 - which I'll post shortly.
 Wednesday, September 27, 2006
It seems like batching is a data access "theme" at the moment (much
like Castle, IOC & IronPython are all themes in the NZ Blogspace at the
moment... even though none of them could be considered new, I've
been using Castle IoC container for 1 & 1/2 years now!) - no
sooner do I discover the batching support in the Rhino.Commons
library, it appears NHibernate now supports it in the latest beta drop and it's a planned feature for the upcoming version 3 of the enterprise library ... It's interesting that this support never made it's way into the framework itself for version 2.0, it's all but there.
On the flip side, for NHibernate at least, the performance boons of
batching are impressive (see below for an image from Ayende's blog
where he's done some profiling), I haven't checked Base4.net out in
a while, but I wonder if Alex James has had a chance to implement
batching support yet? - maybe I should make that my task for the
weekend (checking out base4.net again that is heh... not implementing
support ;o)
Over the past couple of days I've been working on using
DirectShow and DES (DirectShow Editing Services) for re-encoding mobile
video content suitable for posting on the web... With the goal of
including video editing into our unified "media engine" which the Syzmk
line of products makes use of... as an off-shoot of that work I decided
to refactor the rather ugly code we had for working with DES over the
weekend into something a little less ugly, that hid most of the details
away, say hello to:
(sorry, couldn't resist the lame web 2.0 logo ;o)
A simple little library for doing most of the useful things in DES, the project is hosted here up on Codeplex.
It's currently in an alpha state, at version 0.9.0.0 - and should get
feature drops every week or so until I think it can go into beta.
To give an idea of what I'm up to, it's basically just wrapping up the
various DES components and removing alot of the unpleasantness (ie. you
get to deal with human-friendly units of time like seconds) .. and
seperating the concerns of the timeline, and rendering that timeline
into something useful like audio or video container (currently that's
just WAV, AVI & Windows Media formats). It's fully
functional, but the interfaces at this point it isn't very stable as
I'm likely to refactor the various interfaces mercilessly till I get it
working how I want, so if you build something with the library now,
it's likely to break in the future (but probably not in major way, it
is after all mirroring the functionality available in DES).
The added bonus of developing a set of rich wrappers for a lot of this
stuff is that I can mock away the requirement on DES altogether, which
is always a bonus considering how long the units tests currently take
to run for the Syzmk RMP product.
When I get a chance, I'll put up some code examples to demonstrate how
you might use it... At any rate it'll be going through some dog fooding
in the next month or so while I integrate it with the Syzmk product, so
you'll probably here a little more about in the future.
After a long hiatus from Blogging, I've returned... hopefully
with a vengence, but more likely with a small "vurrrrp" sound... like
hot air bubbling up through porridge.
Lets start off with a recap... Spectacles, testacles, wallet and all that jazz.
My name is Alex Henderson, 26 years young, living in Auckland, New
Zealand. I've been working on code since I was knee high, cut my
teeth in GW Basic while in primary school, and C++ a few years after
that... Now days I tend to spend my hours working in C# code, and my
spare time in either .Net and ruby or python when I feel like a change.
For the last year and a half I've been working for a start up company called Seismic Technologies which works in a rather ill-defined space, which I'll probably talk about in posts to come.
The main product I've been working on for Syzmk is the " Rich Media
Processor" - it's a message clearing house, geared towards taking
messages with rich content, transforming them, and then distributing
them... The messages might be files on a network share, emails, SMS or
MMS messages from a phone etc. It's all about rich content, so a
large part of the product deals with transforming the content before
furnishing it to line of business systems - we have been working with
companies like XSOL who use our product to use messages from mobile devices to extend their business processes outside of the host organisation.
Before I was working for the Seismic, I was travelling around Asia for
4 months... which was a lot of fun, I hope to visit europe next... Then
maybe Japan, Egypt and South America.
 Wednesday, April 05, 2006
With the first release of our COM interop SDK for the Syzmk Rich
Media Processor (yes, we have clients who want to integrate with the Rich Media Processor from legacy apps) suite coming out last week, I felt it necessary to put
some documentation together... internally we've been using FlexWiki
sporadically to document what's happening development-wise, iteration
feature sets etc. So It made sense to release our documentation on the
platform, and offer our clients that ability to augment the
documentation where appropriate.
Mixed Reactions
Wiki's get mixed reactions from a lot of developers - some love
them, others loathe them. I think it's generally related to two
problems:
- Lack of refactoring
- Ignoring beautification
A wiki is a living document, its structure should develop in-line
with your understanding on the topics - this includes revisiting old
topics, pulling content and moving it into new topics etc. If it
attempts to document a product then it must be aligned with releases,
otherwise you will forever be chasing your tale... If you can't get
commitment to this time allocation from management, just don't even
bother.
Stale documentation is often worse then no documentation.
Second to that, if the wiki is clunky, poorly formatted,
disorganised and generally lacking in beauty... Then it's not a
compelling resource for consumers - getting a wiki clean, well
organised and aligned with the rest of your web branding seems to go a
long way towards encouraging use.
Goodbye FlexWiki
We've been using FlexWiki partly through a loyalty to the .Net
platform (http://www.flexwiki.com/) and because internally it's what we
feel most comfortable with when it comes to have to modify or extend
products but the project has stalled for now and just doesn't reach
our needs for a commercially capable collaboration tool... (for
instance it doesn't support attachments) ... so I decided to go find a
new wiki... of which there are many... to many you might say!
WikiMatrix to the rescue
At which point I discovered wikimatrix: http://www.wikimatrix.org/ -
What a great little site! Especially there new Wiki Choice Wizard.. In
about 5 minutes I managed to narrow down what I was looking for, and
eventually selected TWiki (http://www.twiki.org/) as our prime
candidate (Confluence also looked very good, but the entry cost didn't
seem justifiable at this point).
Hello TWiki
TWiki does have some pitfalls for a Microsoft-focused house, mainly
that hosting it on windows is possible but going to cause tears before
bed time... luckily they have a debian vmware installation... so we
have avoided all the grief involved with windows, and gained a tasty
performance bonus over running it on windows (Because the project would
have required the cygwin tools & apache for windows... not
necessarily a high-performance combination)
The second best thing since sliced bread
VMWare server being free has to be probably the best thing since
sliced bread (Though I guess unbundling supersedes that for most IT
people in NZ of late) - as we're seeing a host of Linux based products
being released as pre-configured VM's - suitable as drop in "software
appliances" - with a lot less support problems then the normal process
of installing Linux onto a virtual machine and setting up the software
itself... and Often the memory foot print of the Linux distro + product
is half that of an empty windows 2003 standard install, before you've
deployed any applications onto it.
So within 15 minutes I had downloaded the 220mb virtual image,
booted it up and started editing wiki documents... It's not all quite
that easy though, you still need to get your hands dirty doing a little
shell based configuration if you want to securely host it on the web -
but it's all pretty painless especially if youve dabbled with Linux
in the past.
As for TWiki itself - so far it seems very very good, my only
dislike is some of the wiki-text conventions it uses, such as the
elaborate header mark-up... though FlexWiki was no better - why they
couldn't use the Confluence style mark-up of "h1. " through "h6." I'll
never know still the wysiwyg editor takes away most of the mark-up
pain for new users.
I've managed to avoid doing any Kriss Kross "wickety whack" references for the whole post too - be grateful ;o)
 Sunday, June 19, 2005
Well I’m back in New Zealand… after roughly 26 hours of flying and
stop overs (Hanoi -> Bangkok -> Sydney -> Auckland) I landed
back home… to be greeted by a selection of my family (Parents, Brother,
Nieces and grand parents no less) – which was all good.
My last few days in Hanoi were great – didn’t really do much sight
seeing... just enjoyed the good food and beverages on offer in Hanoi
and generally relaxed as well as I could – was lots of fun – and put me
in a good frame of mind to head home.
The trip out to the airport in Hanoi was also pretty cool – there’s
a funky bridge you have to travel over... wish I’d got some pictures of
it, pretty impressive.
And now that I’m home… well I’ve got the winter blues a little – to
come from 36 degrees and doing whatever I pleased all day long…
to 16 degrees, GST and income tax waiting in the wings and a town full
of generally unfriendly and distant people (in comparison to most parts
of Asia I visited).. It did/has left me in a bit of a daze – though
only temporary I’m sure.
Oh, and for the curious... If I was to list my favourite countries, it would be in this order:
- China
- Vietnam
- Laos
- Thailand
- Cambodia
Which isn't to say I hated any of them... but I did definitely loved
China just that little bit more then the others... if there was a place
I'd head back to for another visit (or to work...hmmm)... probably
Beijing or Hangzhou for a city.
Oh and as for some myths dispelled... I remember at first thinking
that woman were wearing masks perhaps because of fears of bird flu or
SARS... and I think Nikolai commented that it was probably because of
air pollution? Well we were both wrong, it was because the woman wanted
to hide from the sun and keep their faces as white as possible... they
even have shirts with extra long sleeves that button up/down (makeshift
gloves) and attached bonnets and face masks that look like giant
collars - just to hide from the sun when riding around on bikes.
Asian woman want to be white with big breasts (loads of adverts for
breast enlarging "cream" on the local TV)... Western woman want
tan's... cest la vie.
Another thing that puzzled me at first was the Cambodian kid I saw
with what looked like lash marks and scars on his back (who's family I
got a ride with over the Laos/Cambodia border)... It was actually
just a bad reaction to a big dose of tiger balm "stripes" - which they
normally apply when someone has a dose of the flu - saw loads of people
like this in Vietnam and Cambodia, that and people covered in lots of
black/purple round spots where they've been using vacuum "therapy" to
suck the "poisons" out of their blood... fun stuff.
Guess my next blog post will probably be a technical one – should make for a change!
 Saturday, June 11, 2005
Well I survived the 4 hour ride in Ninh Binh... it's a pretty flat town :) so it's not exactly taxing... though "Buck" (Clint, but we call him buck.. as he's a respected elder) did somehow cause his back tire to explode...
At any rate, after Ninh Binh I headed out to halong bay... went out overnight on a "chinese junk" like ship... which is pretty damn slow... hardly surprising for a 60 foot 3 story boat that only has a 4 litre nissan diesel motor pushing it along - Sadly it was overcast all day, so my pictures probably dont do it credit at all.. but this place is stunningly beautiful (and even hauntingly so when it's raining)... basically it's Yangshou/Guilin in China, but reproduced in the middle of the ocean - i.e. thousands of limestone peaks of various sizes that are amazingly steep and jagged.
After going for a bit of a swim in the sea.. and a kayak around some islands (even went through a cave and popped out in a completely enclosed lagoon in the middle of an island... stunning).. oh and visiting "surprising" cave.. which is surprising, in that ships ram each other for a chance to unload passengers on the island (bloody funny to watch) .. and that the cave from the outside looks "tasteful" - yet inside it's like some kind of really repetative disneyland.. coloured lights.. the odd sound effect... oh la la!
That evening I got myself a tad laquered... wine.. beer.. "hanoi" vodka.. and even some scotch.. needless to say it was an amusing evening.. and ended up spending a good four hours cloud watching with Helen out on deck and discussing the why's and where for's of being "barren" *snigger*... It's funny that because you generally bump into people with very diverse backgrounds and interests that inevitably discussions always end up going back to "people" and "relationships" as opposed to things - which, though it passes the time, slowly liquifies my brain... I can't wait to get back into some coding.
The following day we departed from Halong bay and headed up to Hanoi... ye olde capital of Vietnam - which is where I am now (sitting in the old quarter thinking how I really need some bia hoi and a shower).. for the ummm... 2nd day?
At any rate - I've been binging on western "treats" for the last 2 days... Tastey bbq ribs at Al'frescos last night... tastey lunch at Koto's (Koto stands for Know one, teach one... which is a restaurant started by an australian dude who trains street kids).. Halida beer - which only seems available up here in the north - and tastes pretty good... and I even sat down and watched a DVD this afternoon (the life and death of peter sellers... not that bad actually) while eating a take away "caramel cream" and some "tizzarisu" from the bakery down the street.. (poorly spelt tirramisu I suspect it was, damn tasty).
All in all, hanoi is treating me pretty damn well.. though being overcast here seems to make absoloutely no difference to this sodding heat and the humidity is sky high - so I just spend all day with my shirt soaking wet with sweat... I hope it's bloody miserable and freezing cold when I get home - that first kiss of cool eye should be brilliant!
On the cultural side of things... I've been to see Uncle Ho this morning.. so I can scratch another dead preserved communist/socialist leaders body of the list... it's actually pretty good, I think the setup and surrounding buildings and museum are a lot "nicer" then the tacky shit they try to sell as you depart from chairman Mao's mousaleum.. that probably only leaves Lenin? Unless I've forgotten someone else.
At any rate, couple more days and I'll be flying home.. for the curious I'm expecting to touch down at around 12:30pm on the 16th of June... And I figure that friday I'll probably head out for some drinks or a meal somewhere if anyone in the Auckland region is keen.
Oh and tomorrow night in Hanoi, the Culi Cafe is opening there downstairs italian cafe... and it's free beer and wine for all... if you can make it, I'll see you there!
 Wednesday, June 08, 2005
Leaving Hoi An
Well I left for Hue from Hoi An around 2pm - the drive took us past
the Marble mountains and china beach.. pretty much a non-event other
then there being a lot of domestic tourists... and then the bus crawled
it's way up the gorgeous Hoi van pass - if I was to start a love affair
with Vietnam, this would be the place to initiate it.
At this point I should probably
make a note about vehicles in vietnam ... the speed limit is generally
50 km/h (rumour has it it's 60km/h for bikes?) on the open road and
30km/h in the city limits. Needless to say road trips can take
longer then you would initially think! But after having driven on
the roads around here I hope they never change that limitation, because
it would just be a death sentence for so many more drivers... it's hard
enough at 30km/h and I've already had to duck through peoples car ports
to avoid hitting cars and performing various other cunning slow-speed
manouvers ;o)
The current statistics suggest
that for the 80+ million population there is about 44 million
registered bikes... remove the elderly and kids and you have a huuuge
vehicle owning population (not to mention all the non-registered bikes
out in the countryside). And whats even better is that a number
of the bikes are being "riced" up... I've seen spinners on the wheels,
respray jobs and neon underlighting... though no one seems interested
in squeezing additional performance out of those 110 cc engines.
Arriving at Hue
I got to Hue about 6pm.. and ended up going out to dinner at a
french vietnamese restaurant and then drinks at the DMZ bar - which is
a mix of locals and expats... met a couple of expat friends of Marks,
Darra and Jim...Jim has the honour of being a 3rd place winner in the
"Minsk olympics" of vietnam... basically making him an expert at drunk
russian motorbike piloting, as far as I could tell.
In fact I think the club has a website (http://www.minskclubvietnam.com/) for the curious... it seems to be the popular choice of vehicle if you want to tour through Vietnam.
I actually ended up getting a lift home on his "Minky"... they're a
pretty funny old beast... smokey...heavy... gutless... a perfect
example of russian 1950's engineering - and the expats can't seem to
get enough of them in vietnam, it seems to offer them a bit of identity
in a country which could no doubt do your head in after a few years -
the fact that the vietnamese hate them because they're "old" and
"uncool" only seems to reinforce the appeal - like most expats, they
dont so much want to integrate (or can't, it's easier said then done)..
as create a niche for themselves to inhabit.
The following day I went on a motorbike tour with crazy Mr Than, a
martial arts master (of some vietnamese variant of karate?) who is
also a keen photographer... I think he stopped to take more photos then
we did... but it was a great morning of exploring Hue's back roads...
even visited some chanting monks (and chanted with them... because it
seemed the right thing to do) and a nunnery.. I have a soft spot
for Buddhist nun's - they're always a little cheaky - and often get
inducted from a very young age.. so other then the odd tourist to
giggle with, there lives can be quite sterile from an outsiders
perspective - I can't imagine being 10 years old and seeing your entire
life pre-planned for you... They cooked an awesome vegetarian meal for
us as well... perhaps the best vegetarian meal I've ever had in fact...
mmmmm
Some other stuff happened.. blah blah blah... then that evening I
attempted to go see a motorbike stunt show... however I was a little
too late, as they had already oversold the show and a small riot of a
thousand or so people was starting up outside as the security tried to
pull the doors shut :) absoloute chaos, so it was worth the effort just
to see that... but still a little dissapointing.. The reports from some
attendees was that they played about an hours music (mostly vietnamese
battle hymns.. heheh) and then had a michael jackson "impressionistic"
act followed by half an hour or so of motorbike stunts... with half of
them done on the little 110cc scooters, which must've been funny to see.
The following day I visited the Citadel... basically a walled in
fort with an inner forbidden purple city (ah la Beijings
"forbidden city") where the emperor lived... a huge amount of this site
is completely obliterated by various conflicts (French, American and
allies ..and of course the north vietnamese themselves who during the
"good times" of communism took it upon themselves to burn all the
ancient texts in the libraries here).
None the less, it's a beautiful spot and well worth a look around ..
especially if you haven't been to China (the further north we go, the
more chinese influence I keep seeing).
The D.M.Z
After Hue we headed to Dong Ha and spent the night there so we could
leave early to explore the DMZ that seperated north and south vietnam
"back in the day"... while around the DMZ I visited the Vinh Moc
Tunnels, the old and new bridges across the river that seperated north
and south plus some other random nearby sights...very cool, then
tunnels were inhabited by about 300 people and are situated near the
coast.. I think they were formed around 1965/1966 during the height of
war time... the deepest tunnels are about 23 metres below the surface,
and alot of the network survived repeated carpet bombing from the
U.S. The text on the entry ticket reads:
"Visiting Vinh Moc today, you will feel as you lived back in
the glorious time with the historical heroes who made these exploits"
heh... "keep living the dream" springs to mind.
Also visited the Phong Nha Cave(s) later in the afternoon... this is
a boat trip for half an hour, followed by looking at some caves lit
with red, green and blue flourescent lights... the best bit is the
english guide they supply you for free.. who's obsessed with seeing
things in the deposits... of course, because he's asian they all
happen to be either a dragon, water buffalo, elephant, tiger or
turtle... but at times he seemed melancholoy if you didn't see it too
(which was often) - I kept having flash backs to the "cave guy" in the
League of gentleman series... "child killed in cave tragedy, local
man blamed..".. at any rate, it's probably not a reference many people
will get... so, moving right along.
Had a good hot pot for dinner in Dong Hoi (squid, prawns, meat and
fish...) that though expensive (about $6 NZ) .. was enough food to feed
four people, though I had a good go at eating it all myself... That
evening we jumped a night train (after stopping briefly at Bia Hoi,
which had sadly "run dry"...Bia Hoi [beer hoy! sounds like a piratical drinkery nyarr]
is locally brewed beer... about 120,000 dong for a 22 litre keg (about
$8 US dollars)... I'm definitely keen to give it a lash - its what most
expats hit if they're planning to drink alot.
The overnight train was surprisingly comfy... I'd heard that hard
sleepers on this route weren't that shit hot (ie. no padding) .. but
these 6 bunk cabins even had a door you could pull shut... we hit the
"Lum Noi" (basically vietnamese vodka) .. which goes down ok with a bit
of Da/Nook Da (ice) and Soda Chang (soda water and fresh lime) and
cranked out some rather tragic guns and roses to listen too.
Today I'm in "Ninh Binh" .. basically it's another 200,000
population viet town, like all the rest... I've wandered through the
market this mornin' to have one of my last "fills" of open air
butcheries... this afternoon I'm gonna jump a bicycle and have a cruise
round the town.. apparently there's a quite good 24km ride around this
area - though the clouds are lifiting so it's probably going to end up
being bloody 38 or 40 degrees again.. bleh, tomorrow I'm off to Halong
bay... which I'm looking forward too, boats are my preferred way to
travel :)
 Saturday, June 04, 2005
Nah Trang
Ok, well we arrived in Nah Trang at about 6:30am, got to the hotel and just crashed.. slept till about 12:30 then went for a walk up the beach.. this was back on the 27th of may.. interesting walk.
Nah Trang seems to have dual personalities.. one a cute fishing village/town, the other a beach resort "hell on earth" (to my way of thinking...) - think deck chairs, fat men getting massaged and half the beach being "private" so that a stroll ends up with you being chased off... heh - oh and I did I forget to mention the couple of syringes I almost stepped on up the far end of the beach.. woot ;o)
At 2pm I headed up to some local Cham era ruins which are amazingly well preserved (compared to other Cham ruins I've seen) and then onto the local "attraction" - some medicinal mud baths - which was nice, so I soaked in hot mineral water, mud baths, steam rooms and got an hour of full body massage all for the princely sum of around $10 US. If your in Nah Trang it's well worth it, and the one thing we all noticed was how good your hair feels afterwards...mmm
That night we hit some of the local iconic spots.. drinks at the sailing club (nice view, hugely overpriced beers) - then hit the best little seafood restaurant in town for a 100,000 dong bbq... which included 4 lobsters, scallops, mussels, squid (which was gorgeous), fish... the list goes on, it was a truely huge ammount of food.. and the fun thing is that it's just an outdoor restuarant that sets itself up in a bus stop on a road corner - classy!
Later that night I made myself "comfortable" in the Red Sun bar.. had 3 "zombie" buckets made with the local rice rum.. each bucket is about a litre... kinda catches up with you after an hour though.. like any cheap spirits I guess.
The following day we went for a "cruise" on the harbour with dodgy old Papa Langs "second best island tour" - visited an Island that was half fishing village, half "super" aquarium.. shaped like a giant gallion made from coral.. it was truely awe inspiringly tacky... I loved it... played with some turtles... watched kids tormenting the turtles... (Vietnamese aren't too clued up on animal cruelty) and went on our merry way.
That afternoon we did some swimming/snorkeling over some reefs... had a nice lunch that the crew of the boat prepared "on the fly" with a little gas cooker (more squid, honestly the squid in vietnam is the best I've ever had... mmmm) - and then got dropped off on an island beach (Mimi?) that was deserted.. so I lay around listening to music while watching the world go by, and interspersed it with cooling off in the sea. Pretty damn sweet.
Burgers and beer for dinner... *bliss*... yes it's not traditional vietnamese fair, but to be honest .. most vietnamese food is pretty boring and bland compared to their surrounding cousins (other then the seafood).
Off to the Central Highlands
Grabbed a bus to the central highlands.. Dropped our big packs at Buon Ma Thuot to drove out into the country side... originally there was going to be a 1km walk to a local E-de minority peoples village, but there's a big hydro dam project taking place thats ripped all the roads to shit (and though providing work for the local tribes people is probably going to displace them all once it's complete) - this is the difference between vietnam and it's neighbours (excluding china obviously)... it's just a buzz with industrial projects - the entire country is like one giant roadworks project.
So... the big hydro project meant big bulldozers on muddy roads.. which also meant our bus wasn't going to get very close to the village... so we ended up walking about 3 km's through the hydro project (which I quite enjoyed) before we finally got to the village/farm stay. The E-de village was an interesting spot... the people weren't particularly engaging.. I didn't mind but some of my fellow travellers thought they were rude and unfriendly people (the fact that they didn't attempt to engage them and of course that all these people had just worked 16 hour days didn't really enter there minds I suspect...) - though it was a lovely spot and I got to play with some pigs - the next day we had an 18km trek up through vietnamese jungle to a M'nong village called Buon Triet.. This was a nice walk, though about half way through it we suddenly entered leach country... A new experience for me - and not that pleasant.. the little fuckers get into everything... climb up your shoes, and can even slide through alot of fabricks weaves ie. socks - I had to keep nocking them off every 5 or so minutes for about 3 hours, and still ended up with 8 of them attached to me...
..a couple got really big before I finally got rid of them (wish I'd taken a picture) - at which point you look like you've been mortally wounded because your blood wont clot (due to the anti-coagulent they secrete) - kinda creepy, but pretty harmless in small doses.
That afternoon/night I got on the piss with the locals... After my experiences in Lao I'm pretty "ok" with rice wine... we did it the "traditional" way where by you do shots and have some cooked meet and greenery to chew on in between - I love drinking with locals, even though of course I get far too loud (A drunk Henderson is a loud person, even to the vietnamese ;o) but it was loads of fun and the older and more respected men of the M'nong villages (ie. Buck's and up.. me being just a lowly "em") are hilarious to watch.
The next day we got up and walked out to where a bus should've been to pick us up.. on the way we got to see a motorbike accident and get some first hand experience as to east meets west first aid..
The accident
this kid came hooning down past us, then turned sharply into a narrow driveway at about 40kms and missed it completely running into the deep ditch next to it. He was nocked unconcious and may have sustained spinal injuries... so (probably incorrectly) two of our fellow travellers first on the scene helped pull him out of the ditch and lay him on the ground... Then mark (our guide at the time) turned up and attempted to assess the situation... but at about this point an argument ensued with the local family that had come out because they believed he needed to be rushed to hospital... on the back of a motorbike... at this point as a westerner there's really nothing you can do accept close your eyes and let it take it's course... but they proceeded to lift the unconcious guy up (without supporting his head which flopped back and assumed a rather sickening angle) and then sandwiched him in between two other people on a motorbike as he flopped around... they then started to take off and after a couple of metres noticed his feet were dragging on the ground and decided it might be a good idea to pick them up... erk...
After the incident Mark talked about a sweedish guy who had hit a logging truck while on a bike in vietnam... he survived (amazingly).. and woke up in a sweedish hospital with massive facial reconstruction and most toes missing from either foot... ground off on his rushed trip from the scene of the accident to hospital on the back of a bike... hmmm... the moral of the story is dont get injured in these countries if at all possible.
At any rate.. after that our trip to the bus continued.. but it had broken down, so we hung around with some local kids playing "photographer" and then eventually got some "local" transport to the next town where our bus was. Local transport consisted of an old jeep that had no clutch and no brakes... needless to say the trip was pretty amusing (they'd start then thing in first gear and god help you when you needed to stop!)
After all the mornings activities I had a lazy afternoon as I borrowed Helens portable DVD player (will have to take one of these next time I travel ;o) and watched a couple of random things... Love Actually and Eternal sunshine of the spotless mind... I kinda enjoyed the later, though that could just be because I like girls with blue hair that wear hoodies.
Hoi Ain Ho!
On the 1st I flew to Hoi An (Well to Danang from Buon Ma Thuot, then took a bus to Hoi An) - the flight was short (just under an hour) .. and it's the first time I've been in a turbo prop aircraft... there a little bumpier, which is fun. Hoi An is a unesco protected world heritage sight.. with a lovely "old town" sector, a nearby beach, rivers and some good eating spots - all in all it's a lovely spot to chill out for a couple of days.
After arriving in the early afternoon I went for a cycle round town.. had lunch in the cargo room (lamb rack...mmmm...) then retired back to my room for a brief nap, swim and then headed out to Tam Tam's for dinner and drinks... being Low season most of the night spots aren't exactly going "off" - but personally I think that makes it better... I'm into just chilling out at the moment and squeezing as much relaxation as possible into my last few weeks of tripping around.
The following morning I decided to go see woman slapping eachother with fish in the local fish market... which is pretty funny as the old ladies get fairly heated in their negotiations :) ... bought myself a vietnamese coffee dripper and some coffee (they do gooood coffee in vietnam...).. Walked around the old town, hilight being the Fujian Assembly hall which is a very cool old building. Did a little shopping and had a quiet'ish night of drinking, eating and savouring the delights of a local patisserie ;o)
On my 3rd day in Hoi An I took a motorbike out for a bit of a ride (with roger on the back) and visited a local orphanage and got shown around by a volunteer coordinator (Nicole Woods, a laywer from Australia) who's been there since october last year.. it's interesting to get the "low down" on the rather depressing circumstances that result in kids getting shipped off from home - often they aren't so much orphans in the traditional sense but the refuse from a widowed wife, who upon remarrying, the new husband doesn't want the children - either because of financial reasons, or that it might discourage the woman from wanting to have children to him - sometimes the parents just cant afford to keep the children, this is especially common with the subsistance fisherman in the near by Cham islands.
The kids in the orphanage are currently being fed on about 5000 dong a day per child... $0.33 US cents a day :( - and these aren't small kids, they range from 7 to 20 years of age. Even in the local market I could only buy a small bottle of water and baguette with animal parts pate' for that... hardly 3 square meals - needless to say they eat a lot of plain rice.
That night I'd arranged to do a cooking class with Mr Hai... Mr Hai is umm... interesting :) he was completely sozzled at 6am before he'd even started to do our 2 hour cooking class... very very funny - I'm not sure what I learnt about vietnamese cooking ;o) but I had a good laugh - and ended up drinking with him for a few hours afterwards - he definitely seems like a bit of institution in Hoi An, and until the 11th of this month he was one of Vietnams oldest (and dodgiest) bachelors.. but alas no more, as he's marrying a woman who doesn't look good but smells great... or something to that effect, I couldn't really understand him alot of the time. Finished off the night drinking Majitos in the "Then an Now" - probably the mintiest one I've ever had.
And today (the 4th) I'm leaving Hoi An for my next destination in an hour or so... Hue.. should be interesting... Though the heat in Vietnam is pretty nasty at the moment, seems to be averaging a very uncomfortable 40 degrees... the real problem though is the humidity.. as your sweat just doesn't evaporate... fun and games, ugh!
© Copyright 2008 Alex Henderson
Theme design by Bryan Bell
newtelligence dasBlog 1.9.6264.0  | Page rendered at Thursday, November 20, 2008 12:18:16 AM (New Zealand Daylight Time, UTC+13:00)
|
Search
FeedCount
Tags...
Who am I?

|
Alex Henderson
Auckland, New Zealand
Managing Director at Dev|Defined Limited
"Self Confessed Coding Junky for 15 years"
|
 |
| |
| Mobile: |
+64-21-402-969 |
| Email: |
bittercoder 'at' gmail 'dot' com |
| MSN: |
bittercoder_nz@hotmail |
| Skype: |
alex.devdefined |
Navigation
On this page....
Blogs I read by New Zealanders...
|