Monday, 17 November 2008
Dealing with snake bite
A kind colleague lent me a very old and rare book recently, that has a great story on the above title. The book, From Cape to Cairo, by Ewan Scott Grogan, tells of the first traverse of Africa from South to North.
The next time you have a bite of some description, be glad the treatment isn't what follows:
"During lunch a native rushed in, saying that he had been bitten by a night-adder (one of the most deadly snakes in Africa). I promptly collared him by the arm, stopped the circulation with some string, slit his finger crosswise with my pocket-knife, exploded some gunpowder in the cut, while Dodson administered repeated subcutaneous injections of permanganate of potash. Meanwhile the arm, chest, and left side swelled to the most appalling proportions. Cavendish then appeared on the scene with a bottle of whisky, three parts of which we poured down his throat. Then we told off three strong men to run the patient round the camp till he subsided like a log into a drunken stupor. The following morning he was still alive, but the swelling was enormous, and the colour of his nails indicated gangrene. Not knowing what else to do, we put a pot on the fire, and made a very strong solution of the permanganate which we kept gently simmering, while six stalwart natives forced the unfortunate's hand in and out. His yells were fearful, but the cure was complete. The swelling rapidly subsided, the nails resumed their normal colour, and the following morning, with the exception of the loss of the skin on his hand, he was comparatively well."
Wednesday, 29 October 2008
Help - the Storm Troopers have got me
Basil and teddy
Five years of nagging, and we finally do it!
Yes, we've got a dog (the one on the right). The kids agreed to give up Christmas presents in exchange for having a dog. He's a Border Collie and is ten weeks old in this picture. Named Basil, after Basil the Brush (the one on the left).
House training is going well so far!
Tuesday, 14 October 2008
Serialising, streams and strings
Enjoy!
using (MemoryStream stream = new MemoryStream())
{
DataContractSerializer serializer = new DataContractSerializer(typeof(SomeClass));
serializer.WriteObject(stream, instanceOfSomeClass);
// Serialisation defaults to UTF8Encoding when used with a stream.
// See Simple Serialization at http://msdn.microsoft.com/en-us/library/ms731073.aspx
string data = Encoding.UTF8.GetString(stream.ToArray());
// Do something useful with the data.
}
Filtering log4net messages
The solution is to use a LoggerMatchFilter. The code below can be inserted into any appender definition:
<filter type="log4net.Filter.LoggerMatchFilter">
<loggertomatch value="NHibernate.Loader.Loader"/>
<acceptonmatch value="false"/>
</filter>
Tuesday, 7 October 2008
Love is ... unconditional (really, truely)
A quote from the book that particularly struck me was this:
"If the gospel isn't good news for everybody, then it isn't good news for anybody.
And this is because the most powerful things happen when the church surrenders its desire to convert people and convince them to join. It is when the church gives itself away in radical acts of service and compassion, expecting nothing in return, that the way of Jesus is most vividly put on display. ... We have to surrender our agendas. ... I have learned that when I toss out my agenda and simply love as Jesus teaches me to, I often end up learning more about God than I could have imagined."
Mind blowing stuff. The exciting part is living it.
Wednesday, 3 September 2008
Redundancy, L=V+E and being a great leader
- The team grow to be able to do all that I do, but without me.
- I can focus on higher-level goals.
It then goes on to list these seasons/steps (as modelled by a great leader 2000 years ago):
- State a clear vision.
- Adopt a "I do, you watch" approach ...
- Followed by "I do, you help" ...
- Followed by "You do, I help" ...
- Followed by "You do, I watch".
Leadership = Vision + Empowerment
- Low vision + low empowerment = dead
- High vision + low empowerment = burnt-out
- Low vision + high empowerment = cosy
- High vision + high empowerment = dynamic
Accountability in life
The following points stayed with me about being accountable to each other (in a small faith group, or equally at work). Several references were made to the John Wesley Class-meeting System, which would also be worth researching.
- p83. "Relational, rather than institutional accountability is entirely different ... the relationship is indispensable."
- p81. Accountability questions:
- "What do you want to see changed in your life?"
- "What do you sense God is challenging you on?"
Effective evangelism requires ...
Effective evangelism requires:
- Self-denial - personal sacrifice for the good of others.
- A broken heart for the lost.
- Demonstrative love: "evangelism is an outward demonstration of all other gifts".
- Consistency in:
- Friendly contact.
- Meaningful connections.
- Significant content.
- Creating a climate of pleasant surprise, instead of disappointment.
- Embracing ultimate joy - anticipation of the good to come.
Thursday, 14 August 2008
SQL errors don't cause exceptions if nocount is off
The cause was traced to incorrect database permissions, i.e.
Server: Msg 229, Level 14, State 5, Procedure xyz, Line 123
SELECT permission denied on object 'abc', database 'pqr', owner 'dbo'.
The question was, why did this not cause an exception? A possible cause is our use of SqlDataReader, but I was unhappy with the suggested fix. The underlying cause however was that nocount was set to off (its default setting). This caused the row count messages to mask the error, and thus no exception was raised.
Lesson learned: always set nocount on at the start and off at the end of each stored procedure, e.g.
create procedure xyz
as
begin
set nocount on
-- SP SQL
set nocount off
end
go
Tuesday, 12 August 2008
God sees you now as one day we could be
A truly inspirational speaker.
Thursday, 17 July 2008
Deciding between ref and out
When to use neither
ref and out are used for methods that pass back two or more values to the caller. This is often a code smell indicative of the need for a new encapsulating struct or class. As a rule of thumb, where three or more ref’s or out’s are required, use a struct or class to encapsulate them into a single parameter instead.When to use 'out'
Use out when the method’s focus is to provide two or more new return values, some of which may be null/empty.In the following example, the firstName and lastName parameter values are only of interest after the call to SplitName. Neither the callee nor the caller require knowledge of their initial value, and its valid that either or both remain null/empty.
class OutExample
{
static void SplitName(string fullName, out string firstName, out string lastName)
{
// NOTE: firstName and lastName have not been assigned to yet. Their values cannot be used.
int spaceIndex = fullName.IndexOf(' ');
firstName = fullName.Substring(0, spaceIndex).Trim();
lastName = fullName.Substring(spaceIndex).Trim();
}
static void Main()
{
string fullName = "Yuan Sha";
string firstName;
string lastName;
// NOTE: firstName and lastName have not been assigned yet. Their values may not be used.
SplitName(fullName, out firstName, out lastName);
// NOTE: firstName and lastName have been assigned, because the out parameter passing mode guarantees it.
System.Console.WriteLine("First Name '{0}'. Last Name '{1}'", firstName, lastName);
}
}
When to use 'ref'
Use ref when the method’s focus is to return a value and make use of and potentially update a second value.In the following example, the index parameter’s value is of interest before and after the call to FindNext. Both the callee and the caller require knowledge of its initial value, and its valid that it may be modified by the call to FindNext.
class RefExample
{
static object FindNext(object value, object[] data, ref int index)
{
// NOTE: index can be used here because it is a ref parameter
while (index < data.Length)
{
if (data[index].Equals(value))
{
return data[index];
}
index += 1;
}
return null;
}
static void Main()
{
object[] data = new object[] {1,2,3,4,2,3,4,5,3};
int index = 0;
// NOTE: must assign to index before passing it as a ref parameter
while (FindNext(3, data, ref index) != null)
{
// NOTE: that FindNext may have modified the value of index
System.Console.WriteLine("Found at index {0}", index);
index += 1;
}
System.Console.WriteLine("Done Find");
}
}
Friday, 13 June 2008
URL rewriting with multiple websites
I recently consolidated a number of websites onto a single Windows 2003 server. One such site (dokuwiki) used url-rewriting via ISAPI Rewrite to present user-friendly URLs. Unfortunately our original rewriting configuration broke the other websites as it tried to re-write their url's also!
Although I'm happy to pay the $99 for the full version of ISAPI Rewrite, I was pleased that we could solve the problem with the Lite one by using the RewriteCond directive, e.g.:
RewriteCond %{HTTP:Host} =ourWikiHostName
RewriteRule ^/_media/(.*)\?(.*)$ /lib/exe/fetch.php?media=$1&$2 [L]
RewriteCond %{HTTP:Host} =ourWikiHostName
RewriteRule ^/_detail/(.*)\?(.*)$ /lib/exe/detail.php?media=$1&$2 [L]
The same technique will also prove useful in hosting multiple .Net 3.5 web services on the same server, e.g.:
RewriteCond %{HTTP:Host} =webServiceHostName RewriteRule RewriteRule ^/(.*)$ /service.svc/$1 [L]
Sunday, 18 May 2008
You know you're in Africa when ... (Kotido, Kachiri, Kaabong)
I hope the following gives a taste of what we've seen and done....
You know you're in Africa when ...
10:30 am actually means 12pm, or maybe 1 or 2 pm.
It rains for less than an hour and everywhere is flooded. But the people are over-joyed.
The local church is just a tin roof.
You have four armed police men guarding you at night.
Almost one-hundred people meet under a tree, and will listen to three locals and three Muzungu's talk about God.
Only English men use umbrella's when it rains.
Children have swollen bellies because there is no food.
Young and old have eye problems that are a minor operation in the West. Yet when they look at you, you also see their love and gratitude for meeting you.
You borrow a local's bike, only to discover it has no brakes.
Your vehicle gets stuck in a dry river bed, and you and half a village dig, push and pull it out.
People who have nothing give you their fatest goat and chicken as a leaving gift. Some passengers (me) seem to worry about travelling with them though!
Planting a hedge is blister-making, back-breaking work (if you're a Muzungu, that is).
Going to the toilet (long-drop) at night may mean being shot (by a sleepy policeman, or whoever they're guarding us from).
A game of hop-scotch attracts half the village.
People play football barefoot, despite inch-long thorns.
A three-hour church service is short. It (plus free lunch) attracts 720 people and ends with 102 people becoming Christians.
Sunday, 11 May 2008
Arriving in Kotido
Arriving in Kotido was very exciting. To finally be here after seven months of planning was a great feeling. It was mid-thirties, so we found the nearest bit of share to wait for our pickup.
After a fantastic welcome ("you are most welcome" was a phrase we would hear a lot from then on), we got to work. More on that next post. Our accomodation was basic, but suficient. We were just very glad for the mosquito nets!
Thursday, 8 May 2008
First impressions of Uganda
We've done a fair bit of driving around Kampala today, what with needing to buy some wireless routers to take to Karamoja, plus visiting various sights and markets. When I say driving, I fortunately mean "being driven", as for a Westerner, the traffic is a nightmare! From what the others say though, Kampala is fairly typical of a large, 3rd-world city: busy, noisy, smelly and lots and lots of bikes and scooters. The only rule road-users seem to follow is keep to the left, though this does not stop over/under-taking at any opportunity!
What's surprised me about my visit so far is how normal everything seems. I was expecting to feel huge culture shock, both from being an ethnic minority and also due to the poverty. Both are very, very present, and the poverty saddens me, but I think I have yet to see it at its worst. I think that this has been tempered also by the seemingly even spread of poverty across the city: everywhere we go, we see people begging, selling things or otherwise impoverished, and yet right next to them will be someone in a suit, or a smart car, or even a private tennis court!
We were also treated to a view of Uganda's Prime Minister today! His convoy of a pickup, loaded with bored, but armed soldiers, followed by his chauffeur-driven Merc honked past us. We decided not to take any pictures though, having been warned by a traffic police-woman earlier in the day that taking photos without prior permission was not allowed (even from a car)!
Flying up to Karamoja tomorrow. Need to be up at 6 am :-(
Flickr photo stream of Uganda trip
- Flickr slide show
- Flickr image list
First post from Kampala
I'm here with nine other Christians from Church of the Good Shepherd, Four Marks, as part of its Mission 2008 program. The basic idea is that we're celebrating the church's 100th anniversary by sending out 100 "blessings" to others, across the room, across the street and across the world. Our team are here to serve the church in Karamoja, an impoverished region of Uganda that is linked with the Winchester diocese.
Tomorrow morning we'll be flying to Karamoja on a MAF flight that will take six of the team to Moroto, in South Karamoja, and three of the team (including myself) to Kotido, in the more rural North Karamoja. One of my functions in the team is to install two laptops in the diocesan office in Kotido, and provide training in their use. The team will also be visiting local schools and manyatta's and speaking in local churches (Christ Church, Kotido on the first Sunday and St Peter's Church, Kabong on the second Sunday).
We'll be living with the locals, possibly in a manyatta like the one below!
Wednesday, 20 February 2008
Test run initialisation code
After much puzzling and googling, I finally found the answer: SetupFixture. The NUnit documentation says it all.
Hurrah!
Wednesday, 16 January 2008
Browser shortcuts
- Alt+D - address bar
- Ctrl+E - search box
- Alt+Enter (with cursor in address bar or search box) - open item in new tab
- Middle mouse click - open/close a tab
Thursday, 10 January 2008
message.IsEmpty fixed by .Net 3.0 SP1
Tests on the pre-production environment showed up a defect that seems to be present in .Net 3.0 but fixed in .Net 3.0 SP1. I've not located the release notes for the Service Pack so can not confirm this for sure.
The Defect
The provider web service returns an empty message in certain legitimate situations. The Windows Service therefore avoids processing a message's body if message.IsEmpty was true.On my development PC all was good, but the pre-production environment gave exceptions whenever an empty message was processed.
Installing .Net 3.0 SP1 fixed the defect. If you know why, please leave a comment!