15 September 2012

Interpreting the Bible

Today I got asked "Is it possible to accurately channel the bible, given that there are so many different interpretations available? Genuine question, not flamebait." Thought I'd repost the reply here.

Sure, fair question. Assuming it isn't about translations or source of text. (But if it is, these are built on evidence-based processes using thousands of historical manuscripts, etc. Be suspicious of anyone says that only 'their' translation is correct). Different translations often serve different purpose (e.g. with varying tradeoffs between readability vs more literal translation of original text, which have less readable grammatical structures)

Facetiously, there are so many different interpretations because people try to interpret it, rather than just read it. Reading the Bible is a comprehension exercise, like reading the paper, and for the most part it's pretty clear what it says. Unclear parts often become clear once more context is read; or when historical customs/geography/sayings are uncovered (often in the footnotes). Some parts are just plain unclear, but these tend not to be about topics that catch the public eye. Given it's a book to be understood by all people in all times, I wonder if some parts just aren't meant for us now.

Unsurprising, not everyone who presents an 'interpretation' is doing so with honest intentions. Many try to use the Bible in the same way politicians use statistics: for support, rather than illumination. Reasons include:

  • to deceive others
  • to deceive themselves
  • to self promote by trying to value-add

Some ways that people arrive at the wrong meaning include:

  1. like most documents, it's pretty easy to make it say the exact opposite of what it clearly says by quoting out of context; and you see a fair bit of that.
  2. interpreting descriptive text as prescriptive text. (e.g. Abraham did this or that, but that doesn't mean that he was right to do it, let alone that we should do it).
  3. trying to apply Old Testament rules to modern times. The Bible is clear that most don't apply now, along with why they did then, but don't after Jesus.
  4. claiming it says something on a topic that it is silent on. (e.g. should children be baptised? some say yes, some say no, the Bible doesn't really say at all).
  5. try to interpret text that is clearly poetry, parable, dream or metaphore, as literal. With a bit of context it's usually pretty easy to tell which is which.

Watching someone put a clearly wrong interpretation with a clear agenda is about as frustrating as watching people get up and say that climate change isn't happening. :)

p.s. I can't remember where I heard some of these analogies, but felt should at least say they're not original.

3 May 2012

MSBuild Task to generate hash of files

Here's a handy inline MSBuild task to take a bunch of files and generate a hash. I used it to generate a hash of source files in order to determine if an exe has really been changed (given that exe's compile to distinct files each time even if the source hasn't changed).

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<UsingTask TaskName="GenerateHash" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<InputFiles ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<OutputFile ParameterType="System.String" Required="true" />
<Using Namespace="System.IO" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Security.Cryptography" />
<Code Type="Fragment" Language="cs"><![CDATA[
using (var ms = new MemoryStream())
using (var md5 = MD5.Create())
foreach (var item in InputFiles)
string path = item.ItemSpec;
using (FileStream stream = new FileStream(path, FileMode.Open))
var fileHash = md5.ComputeHash(stream);
ms.Write(fileHash, 0, fileHash.Length);
ms.Position = 0;
var dirHash = md5.ComputeHash(ms);
using (TextWriter w = new StreamWriter(OutputFile, false))
w.WriteLine(string.Join("", dirHash.Select(b => b.ToString("x2"))));

<Target Name="Demo">
<GenerateHash InputFiles="@(SomeFiles)" OutputFile="res.txt" />

11 March 2012

GoDaddy Joomla on Windows: fail

Hi GoDaddy Support,

I recently installed the Joomla application. I deployed two instances to: URIs omitted

They are both running extremely slowly. (Between 4 and 10 seconds to respond - way to slow for a web site). I haven't even set up any content on them yet. Can you please help? Why are they running so slowly?

Thanks in advance.

Support Staff Response

Dear Peter,

Thank you for contacting Online Support. I understand you installed Joomla to a Windows hosting plan. This would be why the sites are resolving slowly. If you do not have ASP elements or any other windows only content, I would recommend switching to a Linux hosting plan as these run Joomla much better. You can change your hosting Operating System by following the instructions below.

If you find that you need to switch the operating system of your hosting account, you can do so at any time.

To Switch Your Hosting Account Operating System

  • Log in to your Account Manager.Click Web Hosting.
  • Click Options next to the account you want to use.
  • Go to the Customize tab.
  • From the Plan menu, select a new hosting plan. NOTE: If you do not see the Plan menu, contact customer support.
  • Click Save Changes or Checkout, and then complete your purchase.

This change may make take up to 72 hours depending on the size of the site, the number of databases and other factors that may increase the complexity of the migration. We recommend that you do not try to FTP to your hosting account during the migration. You will receive an email message when we complete your upgrade.

NOTE: If your website contains certain advanced features, such as ASP, ASP.NET, CGI, or PHP applications and you select a hosting plan that does not support those advanced features, your website may no longer function properly after the plan change. Please make sure your website does not contain advanced features BEFORE moving to a plan that may not support them or be prepared to modify your Web content accordingly.

NOTE: If you created databases that are incompatible with the new operating system, you must delete them before proceeding. Data existing in compatible databases will be preserved.

Please let us know if we can assist you in any other way.


Mike P.

Online Support


9 February 2012

Universal Turing Snake

Random thought for the day: How hard would it be to make a mechanical Universal Turing Machine that used an arbitrarily long Rubik's snake as the tape? ...out of Lego... Hmm...


Sometimes features are staring at you in the face, all you need to do is read the docs. Other times it really feels like things are hidden. Thanks Con for pointing me to ShouldSerializePropertyName - I did a careful look through the MSDN serialization docs in hope of finding this very feature, but didn't have any luck.

What does it do? For any given property, create a bool ShouldSerializePropertyName() method to decide if it should be included in serialization. A bit magical, but does the trick.

Why do I want this? I want to serialize an object graph to XML. But I don't want to render a container element for any empty collections. I think I'm becoming a bit of a pedent when it comes to XML.

Docs (in as much as I could be find any) are over here under Windows Form Controls.

31 January 2012

SQL Optimisation article

Thanks to Martin for pointing me to this Microsoft article on SQL optimization: Best Practices for Semantic Data Modeling for Performance and Scalability. A tightly packed and in depth look at various SQL Server optimisation techniques.

24 January 2012

The Grand Design

I've just finished "The Grand Design": Stephen Hawking's explanation of how the universe came to be. Chapter 7, 'The apparent miracle', addresses the problem of fine-tuning whereby many fundamental constants of the universe appear to be fine-tuned for life. This appearance of fine-tuning is a fairly widely accepted phenomena and demands explanation. But his explanation still leaves me wanting.
As most do, Hawking appeals to the anthropic principle, which for our purposes can be read as "of course it looks suitable for life, because if it didn't then we wouldn't be here asking questions". Now this only works if there are many universes. If there are countless universes with different parameters, then it seems reasonable that some might fluke the right parameters, and those are the ones that would have curious life forms. However if there is only one universe, then the incredible odds-against suggest that chance alone could not given us the right parameters. By analogy, it is not surprising that people win Lotto sometimes, given the number of games and people being played. But if in all of history there had only been a single player playing a single game of Lotto, then a jackpot result would have to be viewed with suspicion.
In chapter 7 he gives us the succinct: "We saw in Chapter 5 that our universe seems to be one of many, each with different laws.". Yet chapter 5 seems to do nothing of the sort. The closest we get is "The laws of M-theory therefore allow for different universes". In my mind it is a fairly substantial and unwarranted leap of logic from 'the universe could have different constants' to 'there exists oodles of universes with different constants'.
Typically, the home for all these universes is the multiverse. But there does not seem to be any good reason to think we can ever test for or prove the existence of a multiverse (and suggestions to the contrary are fairly hand-wavy), as it is by definition outside the realm of our observable universe. It seems that the usual motivation for invoking a multiverse is in order to enable the anthropic principle, thereby providing a naturalistic explanation for the apparent design we see in our universe. For example, Wikipedia gives us:
The concept of other universes has been proposed to explain why our universe seems to be fine-tuned for conscious life as we experience it.
However this is circular reasoning: in order to demonstrate that the universe has naturalistic causes, we had to invoke an untestable extra-natural multiverse that we only invented to solve the problems with a naturalistic causes.
Hawkins believes he escapes the problem of a multiverse by instead packing all of these universes as different possible histories of our own universe, in the freaky quantum 'everything possible history is happening at once' kind of sense (i.e. Feynman's sum of histories). The universe then collapses onto life-sustaining constants because we're observing it. But this still seems to suffer the same kind of problem: declaring that the universe could have had different constants and laws is very different to declaring that there are different histories that would take on all these possible combinations. I'd love to hear from someone who understands the physics better whether there is any valid explanation to bridge this gap.

15 January 2012

XmlSerializer inheritance woes

OK, this just drove me crazy for about an hour. I'm using the XmlSerializer, and my object graph has derived types.

I was using the XmlInclude attribute in the correct manner, but I still kept getting:

The type Child was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.

It didn't work when I passed the extraTypes parameter to the XmlSerializer constructor either.

In the end it turns out that the 'Namespace' declaration was the problem. Adding an identical namepsace to the Child class fixed the problem. Strange because up until using inheritance things have worked fine only specifying it on the root class.

[XmlRoot(Namespace = "somenamespace")]
public class Root
public Parent Field { get; set; }

public class Parent
public string Data { get; set; }

public class Child : Parent

Root r = new Root();
r.Field = new Child();

4 January 2012

Markov analysis of Beetle

Having young kids, we seem to have a lot of games around the house at the moment. The geek in me starts looking at them as maths challenges. Beetle, by Milton Bradley, is a variant on the classic dice game. I was curious to use Markov chains to figure out the average game length, and which positions were closer to victory.

Basic rules:

  • Take turns spinning the spinner to build a piece of the beetle
  • 1/6 chance of getting the body
  • 1/6 chance of getting the head
  • 1/6 chance of getting one of two eyes
  • 1/6 chance of getting one of two antenna
  • 2/6 chance of getting one of six legs
  • Must get the body before getting anything else
  • Must get the head before the antenna or eyes

This allows for 71 states as depicted in the diagram below:

The 71x71 matrix is basically formed from the above diagram. There are three regions:

  • no body
  • body, but no head
  • body and head

Within each region there are various combinations of legs or other pieces, as permitted. E.g. state 'A' has no pieces; state 'B' has a body, no head, and five legs; state C has a head and body, one antenna, two eyes and one leg; state 'D' is a completed beetle. Each successful spin moves either to the right or down (or 'out') to an adjacent state.

Result: 31.498 spins on average.

The following table shows the average number of moves remaining to victory from each position, sorted by moves remaining (hopefully the notation is self explanatory):

CombinationAverage turns to victory
b h e2 a2 l60.00000
b h e2 a2 l53.00000
b h e1 a2 l66.00000
b h e2 a1 l66.00000
b h e2 a2 l46.00000
b h e1 a2 l57.00000
b h e2 a1 l57.00000
b h e1 a2 l48.66667
b h e2 a1 l48.66667
b h e1 a1 l69.00000
b h e2 a2 l39.00000
b h e1 a1 l59.50000
b h e1 a1 l410.58333
b h e1 a2 l310.77778
b h e2 a1 l310.77778
b h a2 l612.00000
b h e2 l612.00000
b h e2 a2 l212.00000
b h e1 a1 l312.18056
b h a2 l512.33333
b h e2 l512.33333
b h a2 l413.11111
b h e2 l413.11111
b h e1 a2 l213.18519
b h e2 a1 l213.18519
b h a1 l613.50000
b h e1 l613.50000
b h a1 l513.70833
b h e1 l513.70833
b h e1 a1 l214.18287
b h a1 l414.27778
b h e1 l414.27778
b h a2 l314.33333
b h e2 l314.33333
b h e2 a2 l115.00000
b h a1 l315.26736
b h e1 l315.26736
b h e1 a2 l115.79012
b h e2 a1 l115.79012
b h a2 l215.95062
b h e2 l215.95062
b h e1 a1 l116.48650
b h l616.50000
b h l516.60417
b h a1 l216.66705
b h e1 l216.66705
b h l416.94097
b h l317.60417
b h a2 l117.89712
b h e2 l117.89712
b h e2 a218.00000
b h a1 l118.42943
b h e1 l118.42943
b h e1 a218.52675
b h e2 a118.52675
b h l218.63561
b h e1 a119.00662
b h l120.03252
b h a220.10700
b h e220.10700
b h a120.49312
b h e120.49312
b h21.76282
b l622.50000
b l522.53472
b l422.67014
b l322.98148
b l223.53286
b l124.36608