<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ErrorOK</title>
	<atom:link href="http://blog.errorok.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.errorok.com</link>
	<description>A library of useless knowledge</description>
	<lastBuildDate>Mon, 26 Mar 2012 23:04:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Installing VMWare Player on Ubuntu 11.10 Oneiric x86 (32 bit)</title>
		<link>http://blog.errorok.com/2012/03/26/258/</link>
		<comments>http://blog.errorok.com/2012/03/26/258/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 23:04:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[11.10]]></category>
		<category><![CDATA[3.1.5]]></category>
		<category><![CDATA[i386]]></category>
		<category><![CDATA[oneiric]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[vmplayer]]></category>
		<category><![CDATA[vmware]]></category>
		<category><![CDATA[x86]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=258</guid>
		<description><![CDATA[get vmplayer 3.1.5 installed and ready for oneiric x86]]></description>
			<content:encoded><![CDATA[<p>I use a netbook for most of my day to day personal computing, an HP mini 311. While i think this netbook is the best ever, it does have one flaw. It comes with the ION chip, but the caveat is the CPU uses a 32 bit instruction set. This means obviously that i am restricted to 32 bit operating system installs. In the past this hasn&#8217;t really been much of an issue (i have owned this netbook for quite some time now). But recently 32 bit CPU&#8217;s are a bit of a rarity, and support for 32 bit appears to be waning, if not at least with respect to vmware.</p>
<p>I just finished setting a nice new ESXi 5.0.0 U1 server and wanted to start playing around with it. This is when things got complicated. VMWare offers an i386 installer for Player 4.0.2 but contrary to what you&#8217;d think, this installer is not supported on a 32 bit CPU. this installer is available for those who install i386 arch onto a 64 bit CPU. If you, like me, don&#8217;t have a 64 bit CPU then you have to live with 3.1.5 (VMware-Player-3.1.5-491717.i386.bundle at the time of posting, sorry i can&#8217;t find a live link). This installs as you would expect, by running <code>sudo sh VMware-Player-3.1.5-491717.i386.bundle</code> and following the GUI installer. You may remember from earlier vmware installs that you need to compile kernel modules in order for things to work &#8220;smooth&#8221; and this install is no different. Where this install differs is when you are using a 3.x linux kernel, such as the one that comes with Oneiric. For whatever reason, vmware assumes that nobody upgrades their linux kernel regularly and left us to patch the module sources ourselves. Fortunately, someone has done the heavy work for everyone already (my source for this info is here: http://ved-antani.com/2011/10/vmplayer-not-compiling-for-latest-linux-kernel/ ) so that you can quickly build the modules manually.</p>
<p>the instructions at the original source are not quite perfect, so here is what i did to compile my modules.<br />
<code># you need to do this stuff as root<br />
sudo su</p>
<p># make a directory to build the modules and cd to it<br />
mkdir /tmp/vmware-build<br />
cd /tmp/vmware-build</p>
<p># extra the module sources to our build directory<br />
find /usr/lib/vmware/modules/source -name "*.tar" -exec tar xf '{}' \;</p>
<p># get the patch archive and extract it<br />
wget http://weltall.heliohost.org/wordpress/wp-content/uploads/2011/05/vmware2.6.39patchv3.tar.bz2<br />
tar -xf vmware2.6.39patchv3.tar.bz2</p>
<p># update the patch for 3.1.5 (it is designed for 3.1.4)<br />
sed -i -e 's/plreqver=3\.1\.4/plreqver=3.1.5/' patch-modules_2.6.39.sh</p>
<p># patch the source and start the build<br />
./patch-modules_2.6.39.sh</p>
<p># after the build is finished the modules will be installed</code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2012/03/26/258/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Better ArrayAdapter Implementation (Android Development)</title>
		<link>http://blog.errorok.com/2012/02/07/251/</link>
		<comments>http://blog.errorok.com/2012/02/07/251/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 17:59:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[ArrayAdapter]]></category>
		<category><![CDATA[DynamicArrayAdapter]]></category>
		<category><![CDATA[Filter]]></category>
		<category><![CDATA[ListView]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=251</guid>
		<description><![CDATA[I have been doing some Android development these past few days and coming form C#/WPF land, I have noticed that there are a number of design flaws in the android architecture that I feel could be improved. The most annoying thing that I have run into involves the ArrayAdapter. I use lists a lot (as [...]]]></description>
			<content:encoded><![CDATA[<p>I have been doing some Android development these past few days and coming form C#/WPF land, I have noticed that there are a number of design flaws in the android architecture that I feel could be improved. The most annoying thing that I have run into involves the ArrayAdapter. I use lists a lot (as I&#8217;m sure others do to) and having a quick and easy adapter that is generic and extendable is very important. The built in ArrayAdapter has many flaws, the biggest are that you cannot access the backing list (EVER!) and filtering is completely broken.  To solve this, most people just create their backing list outside of the adapter and pass it in, which is no big deal but completely unnecessary. And to solve the filtering issue, everyone basically just rewrites the filter themselves (ugh!). Because of the way filtering works, you must maintain two copies of your list. One copy contains all items, and the other the filtered items. Without having easy access to the backing list, the filtering  ops start to become very inefficient (requirements of copying items back and forth).  ArrayAdapter fixes this by doing it for you but only if your list is of String&#8217;s (WAT?).</p>
<p>So anyways, i got fed up with rewriting nearly all the ArrayAdapter code every time i wanted to have a custom adapter, i decided to just sack up and write a GOOD ArrayAdapter, which I am calling the DynamicArrayAdapter.  This new adapter handles changes much more efficiently and MASSIVELY simplifies any customizations of the adapter.  If you compare it with the original ArrayAdapter, you&#8217;ll see that it is not very different at all, but the differences MAKE THE DIFFERENCE.  So here is some code: <a href="http://pastebin.com/4mxtEC5e">http://pastebin.com/4mxtEC5e</a></p>
<p>Here is a sample implementation (for a sample Bluetooth app I wrote): <a href="http://pastebin.com/Quwsgkbm">http://pastebin.com/Quwsgkbm</a></p>
<p>I fully expect to never use ArrayAdapter again.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2012/02/07/251/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Thoughts on the New 0.05 BAC Limit Drunk Driving in Alberta</title>
		<link>http://blog.errorok.com/2011/12/28/248/</link>
		<comments>http://blog.errorok.com/2011/12/28/248/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 19:31:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[0.05]]></category>
		<category><![CDATA[AB]]></category>
		<category><![CDATA[Alberta]]></category>
		<category><![CDATA[BAC]]></category>
		<category><![CDATA[Bill 26]]></category>
		<category><![CDATA[Check Stops]]></category>
		<category><![CDATA[Drunk Driving]]></category>
		<category><![CDATA[DUI]]></category>
		<category><![CDATA[Impaired Driving]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=248</guid>
		<description><![CDATA[How I think Impaired Driving Should be Targeted.]]></description>
			<content:encoded><![CDATA[<p>This has been on my mind for a while and I am hoping that my writing here can maybe change some minds or at least persuade some additional action on the part of law enforcement, legislators, the entertainment industry, and the taxi industry.</p>
<p>Recently, our province enacted Bill 26, which dropped the legal limit for consuming alcohol and driving your vehicle to 0.05 BAC, from the previous limit of 0.08 BAC.  Proponents claim that the intent of this bill is not to criminalize the public who has a glass of wine with dinner, and furthermore (appear to) harshly criticize those who oppose such action by calling said people supporters of impaired drivers (ugh!).  Let me first make it abundantly clear that I in no way support impaired driving.  With that said, I cannot support the enactment of this bill either.  I recognize the effort and the good intentions that went into this bill, but it has been pushed through for the sole purpose of this government to look like they are getting tough on impaired drivers.  Now for some truths&#8230; Lowering the legal limit does not automatically make you tough on impaired drivers; it only makes it more common for a driver to be impaired.  These are two very different statements, though they do look very similar on the surface.  While statistics may show that &#8220;we are catching more impaired drivers&#8221; they do not show that more dangerously impaired drivers are being caught.  </p>
<p>Let&#8217;s analyze this for a moment.  By lowering the limit we are spreading our law enforcement thinner by having them cast a wider net to target more drivers.  By doing this we are spending more time and resources on dealing with those who before would have been under the limit.  Without proportionally increasing the number of resources to the statistical number of people who are now effectively driving impaired (lowering the limit by 0.03 includes a LOT more people in this problem) our law enforcement cannot spend the necessary time tracking down and removing those truly dangerous impaired drivers on the road.  Now the proponents of this bill will say that everyone gets caught eventually, so it makes no difference, just more people get caught now.  They are correct, partially.  Everyone does get caught eventually, but that &#8220;eventually&#8221; time frame just widened.  So if we have a statistical average number of impaired &#8220;road trips&#8221; before a death is involved, and a statistical average number of days before someone is eventually caught, then we also have a statistical average number of deaths per impaired driver.  By widening that time frame we are actually increasing that number of deaths because more dangerous impaired drivers have more time to cause that statistical death.  Don&#8217;t read too much into the statistics because statistics lie.  But they do offer a window into real life data that is collected, the can inform us of trends and they can help us project.  They cannot, however, tell us the future and guarantee results.  So my very brief analysis above is just to help describe the logic that suggests that lowering the limit could have the opposite effect that is desired.</p>
<p>So you may ask if I don&#8217;t support this bill then what do I suggest we do instead.  Well my suggestion is simple; the status quo was working but was improperly implemented.  Let&#8217;s get something straight, the majority of people do not want to criminalize themselves intentionally.  Some don&#8217;t care enough, but most would do the right thing if given the choice.  The problem right now is that the choice is not very well defined.  &#8220;Do I drive or do I cab?&#8221;  The statement should really be worded as &#8220;My BAC is X, therefore I should Y.&#8221;  Now it is no longer really a choice, all law abiding citizens follow the directive given, and those that don&#8217;t care enough do whatever they want and eventually get caught if they choose poorly too often.  By increasing awareness at the individual level, citizens can now act responsibly with some contextual knowledge.  Without that contextual knowledge, how can we expect everyone to make the right choice?  If I ask you right now is the milk in your fridge expired? You can make an educated guess based on the last time you remember buying milk or looking at the expiry date, but without seeing that date in front of you can can&#8217;t make the right choice every time.  Nobody wants to drink expired milk, so that&#8217;s why the date is included on the container.  Without our BAC given to us prior to making our choice, we can never guarantee making the right choice every time.  So how do we implement this notion?  Well that is truly the most important question, how do we inform everyone at the individual level so that they can make an informed choice.  We need a quick, simple, and cost effective way of informing people in the entertainment districts.  It&#8217;s still a choice, so it should be optional, but easily available to those who want to be informed.  I know that I would never step into a vehicle knowingly over the limit (even our new draconian limit).  I have to imagine that others would feel the same, because who wants to voluntarily criminalize themselves?  To implement this strategy some communication between law enforcement, legislators, and entertainment industry owners must begin.  These three parties are those who can solve this problem in a reasonable manner.</p>
<p>Now that informed choice is solved, we need to solve the second half of the equation.  When the answer to the choice is &#8220;I should not drive&#8221; then we need realistic alternatives.  Catching a taxi from the Jasper Ave entertainment district to my home in Rutherford is absurdly expensive.  A 5 to 10 minute cab ride in Edmonton, at night, with tip is approximately $20 to $25.  The distance to my home is going to be around 40 minutes, and I would expect to shell out at least $60 and probably closer to $80 to get home.  You want to talk about incentives to drive &#8220;impaired&#8221; this is the biggest of incentives.  If someone has two beers over the course of 4 hours (what would be considered social drinking, NOT consuming to be impaired) then could EASILY be over the 0.05 limit.  Do you think someone who was socially drinking would be interested in shelling out $80 to get home, not to mention another $80 to return and get the vehicle!  Now I realize that a cab is not the only method of transportation, in fact I love public transit options and I think that the city made a wonderful choice when they proposed the late night transit service (too bad it keeps getting delayed).  This certainly helps reduces the burden of cost but it isn&#8217;t feasible for the whole city only in concentrated entertainment districts.  All this has me come to the conclusion that we require some more incentive to make the right choice.  If you make the wrong choice (and you are caught making this wrong choice) then you are punished.  But if you make the right choice, while you aren&#8217;t quite punished, you are still severely inconvenienced which almost feels like a punishment.  I would love to see some positive incentives for those who make the right choice.  We need cooperation between taxis, law enforcement, entertainment establishments, and maybe more to help subsidize the cost/burden of making the right choice.  If those who are legally impaired have an incentive to make that right choice and maybe save someone&#8217;s life, then maybe providing that incentive will help solve this problem from a new angle.</p>
<p>Finally, I wanted to touch on the social media &#8220;problem&#8221; that is so viciously discussed these days.  &#8220;Everyone who tweets a check stop is supporting drunk drivers and causing deaths!&#8221;  I can&#8217;t stand it when people oversimplify the twitter issue.  If you&#8217;ve ever been caught in a check stop line (I mean caught as in traffic wise) then you know that it sucks, a lot.  You don&#8217;t complain because you know it&#8217;s for the good of the community but when you get home you silently complain that it took forever to get home because of the check stop.  Now I know that tweeting check stop locations can be used by impaired drivers to circumvent their purpose, but letâ€™s be truly honest here.  Anyone who is dangerously impaired (not necessarily legally impaired) is probably not going to find out.  This isn&#8217;t true for all cases, but in the general case the impaired driver is either not capable (not device to check for them), not motivated (doesn&#8217;t care enough to wade through all the anti check stop tweeting), not cognizant (remembering to check), or even not smart enough (to realize that there is in fact a check stop on the way home). When you consider this, really the only people who benefit from the check stop tweeting are people that probably aren&#8217;t of interest to the police anyway (or shouldn&#8217;t be because they aren&#8217;t actually impaired) thus making the check stop more efficient at finding those who are impaired.  I would also like to bring up the fact that this was never a problem until the new legislation came into effect.  People were more than happy with the 0.08 limit because that meant that 2 drinks over the course of your socializing period was almost certainly under the limit, and for those who were lighter weight one drink was still nothing to worry about.  Now, even one drink may be too much.  Two drinks is almost certainly over the limit for some.  This dramatic shift in what is acceptable and what is not has clearly caused an outrage amongst those who enjoy socializing with a beer or glass of wine.  The outrage has spawned a need determined by a few people to help keep the others informed.  And I know that most people think that tweeting check stops is just as bad as driving impaired yourself, but I believe that it is a social mechanism to counter what many feel is an invalid restriction imposed on us.  I know that in my own case two beers will almost certainly put me over the legal 0.05 limit.  I used to enjoy going to the sports bar to watch hockey.  I no longer engage in this activity because it is simply not worth the risk.  It may sound stupid but I am what would be considered a light weight, my body weight hovers around 140 lbs.  My body is very capable of processing two beers, and while by BAC might read 0.05 or 0.06, my impairment is very likely similar to someone else&#8217;s 0.03 or 0.04.  BAC does not necessary imply impairment (though it is a very good indicator, there are variances).  So while I am quite certainly not impaired, a road side test will probably disagree.  I simply cannot afford to take such risks and therefore I no longer engage in social drinking without prior dedication of a ride home.  The end result is that I far less frequent the sports bars to watch sports and socialize.</p>
<p>So to summarize I want to go over what I have suggested in this (rather long) post.  I am suggesting that the new laws may in fact be causing more harm than good, in the form of too many resources wasted on those who are not truly impaired (or dangerously impaired at least).  I am suggesting that we need to offer those who make the choices contextual information (what their current BAC is at) so that they can make the informed choice, and most likely the responsible choice.  I am suggesting that we need to offer positive incentives to those who make the right choice, help make being responsible something people don&#8217;t have to think twice about.  And finally, I am suggesting we stop caring so much about tweeting check stops because it simply isn&#8217;t informing as many dangerously impaired drivers as you think it might be.  Remember dangerously impaired drivers are the people who are causing the majority (if not all) deaths.  These are the people who making roads dangerous.  These are the people that we don&#8217;t want on our roads.  Letâ€™s focus more energy on removing these people (either through law enforcement or the incentives I have suggested) and less energy on criminalizing law abiding citizens and clogging up our legal system.  I want to make our streets just as safe as all of you Bill 26 proponents do, but we have to focus and target the bigger problems, and we just took a giant step in the wrong direction.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/12/28/248/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simplifying Complicated SQL queries in LINQ</title>
		<link>http://blog.errorok.com/2011/12/01/243/</link>
		<comments>http://blog.errorok.com/2011/12/01/243/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 20:12:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[linq]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=243</guid>
		<description><![CDATA[quick how to on using group by with aggregate function columns in LINQ.]]></description>
			<content:encoded><![CDATA[<p>I have been working pretty heavily in LINQ the past few days and ran into a few problems when dealing with some more complicated queries.  While LINQ is fairly simple and intuitive when working with objects in memory, the LINQ-SQL bridge (or SQLite in my case) is a different machine.  The reason it is different is that your queries must be translated into the appropriate SQL, and this SQL can sometimes turn into brutally inefficient queries.</p>
<p>In my case i was working on a query that inner joined three tables together, then grouped by one of the columns in the joined tables.  Now LINQ can do this no problem with Join/Join/GroupBy.  The difficulty lies in how you project your grouped columns. By default LINQ will just include the whole collection of grouped columns per group row.  While this works great in memory, the SQL bridge butchers your call.  The reason is that SQL (SQLite at least) can&#8217;t do what you asked so the translation is to group by, then do a select all for each group row.  As you can imagine, the computational power required grows exponentially with the data size.  This is quite clearly very bad.</p>
<p>When working in pure SQL, we can only include columns that are in the group key and columns with an aggregation function applied to them.  The aggregation functions are not super obvious on how to use them, so this is what i will be simplifying in this post.  Usually what you want is the Sum, Count, First Row, Last Row, etc&#8230; from your grouped rows.  The main problem is that you can&#8217;t just call the LINQ aggregate functions normally, because it doesn&#8217;t make sense in the context of your group by projection.  I&#8217;ll start off with some sample code and move on from there explaining as i go.</p>
<p>First we join the tables together, and project the join into an anonymous type with both values<br />
<code>var q1 = Table1.Join(Table2, x => x.t2key, x => x.key, (t1, t2) => new { t1, t2 })</code></p>
<p>Now we can group by (say by t1) so that we end up with t1, and an enumerable of t2&#8242;s.<br />
<code>var q2 = q1.GroupBy(x => x.t1.key, x => x.t2, (k, x) => new { k.Name, Timestamp = x.Max(y => y.Timestamp), Value = x.Max(y => y.Value) })</code><br />
so the first lambda tells us what to group on (our parent key), the second lambda describes how to project the grouped data (we will just project the whole t2 table), and the third lambda describes how to project the result set.  The third lambda is where things get interesting, we can include members of the key as is (k.Name), but for members of the grouped data, we must apply the aggregate functions or risk a horribly inefficient query.  In the above example, i am using the Max aggregate function, which (in SQLite land at least, but others as well im sure) will select the last item in the group as determined by the order by clause (which i didn&#8217;t include).  Because i didn&#8217;t include an order by then its just the last item in the grouped data however the grouped data was built.  The order by must appear before the group by in order for it to affect the aggregation functions, so above i would do something like <code>q1 = q1.OrderBy(x => x.t2.Timestamp)</code> in order for the Max function to return the most recent value in the grouped data.  If you specify an order by after the group by, it will order the projected group results, so you could do something like <code>q2 = q2.OrderBy(x => x.Value)</code> in order to show the values in ascending order, without affecting the group by aggregation.  This is executed by a wrapper query, that uses the projected grouped data as input, so you execute a second query, but that&#8217;s it (and this one is generally quite fast)</p>
<p>So the important bits to take a way from this post is that any aggregated columns you want to project must be individually included in your group by result projection, and if you include any enumerations in your projection then they will be converted into subqueries.  While my example may not be all that complicated, it is certainly more complicated than simple a select/join/where/order type of LINQ query, which are far more common.  By understanding the group by projection core concepts, it should be relatively easy to construct much more complicated (AND efficient) LINQ queries.  And remember, when in doubt play around in LINQPad, that program is the best for testing out LINQ queries.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/12/01/243/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some alternative Zip extension methods</title>
		<link>http://blog.errorok.com/2011/08/22/237/</link>
		<comments>http://blog.errorok.com/2011/08/22/237/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 00:07:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[linq]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=237</guid>
		<description><![CDATA[Using Linq's Zip with multiple arrays (enumerables)]]></description>
			<content:encoded><![CDATA[<p>I ran into a small problem today, i had &#8216;n&#8217; arrays of correlated data.  I wanted to effectively &#8220;transpose&#8221; the rows into columns so that i would end up with the same number of arrays but containing the items of the same index of all arrays. to simplify that terrible explanation, here are some visuals:</p>
<p>start : [a0, a1, a2], [b0, b1, b2], [c0, c1, c2] &#8211;&gt; transpose &#8211;&gt; [a0, b0, c0], [a1, b1, c1], [a2, b2, c2]</p>
<p>Now the Zip function in .net4 can do this very easily, but only for TWO enumerables, not any number.  Its basic function is to interleave two enumerables and project the result. I wanted to do something similar but without the silly two enumerable limitation.  It&#8217;s very easy to extend Zip to operate on &gt; 2 enumerables statically, you just need to add more and more params to the extension method, but i wanted to have true dynamic interleaving functionality.  So i wrote two extension methods (really just one, and then a simplification for the standard projection) that would do this.  One consequence to note is that this will be slower than the built-in Zip, quite obviously because we&#8217;re dealing with more enumerables, but also because we can&#8217;t run the same type of optimizations that Zip does (this is due to the dynamic nature of this function).  So here is some code to look at:</p>
<pre>public static IEnumerable&lt;TResult&gt; ZipMany&lt;TItem, TResult&gt;(
    this IEnumerable&lt;IEnumerable&lt;TItem&gt;&gt; source,
    Func&lt;IEnumerable&lt;TItem&gt;, TResult&gt; func)
{
    var iters = source.Select(x =&gt; x.GetEnumerator()).ToArray();
    while (iters.All(x =&gt; x.MoveNext()))
    {
        yield return func(iters.Select(x =&gt; x.Current));
    }
}

public static IEnumerable&lt;List&lt;TItem&gt;&gt; ZipMany&lt;TItem&gt;(
    this IEnumerable&lt;IEnumerable&lt;TItem&gt;&gt; source)
{
    return ZipMany(source, x =&gt; x.ToList());
}</pre>
<p>So the idea is we build an array of enumerators for each of the input source lists.  We have to call ToArray to invoke the execution of the projection, otherwise some strange and undesirable stuff happens.  Then we just iterate each enumerator at the same pace and project the index aligned projection of the results.  It&#8217;s actually pretty simple code for what it is really doing, but it works quite well and i thought i would share it.  The second method is just a helper that simplifies the first by removing the need to project the results, this way you can project the results into any custom type if you want, but the default is to simply project them into a list (which is how i can imaging myself and most others wanting the results returned).</p>
<p>I am curious if anyone can point out any improvements or optimizations on this code.  Mostly just so i can learn from them myself.  Other than that, i am quite happy with how this turned out and it works wonderfully with the application that i wanted to use it with.</p>
<p>This same post is available at the msdn forums if you want to follow the comments there as well: <a href="http://social.msdn.microsoft.com/Forums/eu/linqprojectgeneral/thread/40cc2410-adad-4da6-80cd-1736140e885e">http://social.msdn.microsoft.com/Forums/eu/linqprojectgeneral/thread/40cc2410-adad-4da6-80cd-1736140e885e</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/08/22/237/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Bitcoin Email Alerts on Mt. Gox Price Changes</title>
		<link>http://blog.errorok.com/2011/07/21/234/</link>
		<comments>http://blog.errorok.com/2011/07/21/234/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 16:31:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[bitcoin]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=234</guid>
		<description><![CDATA[configurable email price alerts for price changes on the Mt. Gox exchange.]]></description>
			<content:encoded><![CDATA[<p>I got fed up with watching <a href="http://mtgoxlive.com">mtgoxlive.com</a> all day long so I wrote a simple web service to monitor the Mt. Gox prices for me.  Then I wrote a simple engine to send out email alerts when the price (or volume) goes above or below a specified threshold. The result is <a href="http://btcalerts.errorok.com/">http://btcalerts.errorok.com/</a> which now just tells me when I should pay attention to the exchange, or when my open orders have likely been filled.  The site is designed to eventually track multiple exchanges, but since I do all my trading on Mt. Gox I have only coded its prices in so far.  The site also lacks any flare, but im not one for flare, but rather sustenance.  Anyways, check it out and let me know if you like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/07/21/234/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharing Layout Size Info Between Multiple Grids</title>
		<link>http://blog.errorok.com/2011/01/25/230/</link>
		<comments>http://blog.errorok.com/2011/01/25/230/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 19:11:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[IsSharedSizeScope]]></category>
		<category><![CDATA[SharedSizeGroup]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=230</guid>
		<description><![CDATA[The title should probably be enough, but in case it isn&#8217;t I am talking about multiple grids in a single view that need to share row size or column size. A good example of this would be if you wanted to split grid rows up into groups, then apply each group to an expander, thus [...]]]></description>
			<content:encoded><![CDATA[<p>The title should probably be enough, but in case it isn&#8217;t I am talking about multiple grids in a single view that need to share row size or column size.  A good example of this would be if you wanted to split grid rows up into groups, then apply each group to an expander, thus allowing you to show and collapse the different groups of rows.  However, when everything is expanded, you still want all your columns to line up.  Well, you can use the <strong>Grid.IsSharedSizeScope</strong> attached property for this.  There are some msdn docs on this <a href="http://msdn.microsoft.com/en-us/library/ms751905.aspx">here</a>, but i found them to be somewhat lacking in detail.  So here is is my idiot proof guide (really just the information left out of the msdn article) on how to share grid layout size info.</p>
<p>The most important thing to note is that you only use the attached property to enable (or disable) a scoped region to share size info within.  This is extremely important to understand because scope is not inherited by children if you override it.  For example, if you were to create a grid within a grid and put the attached property on both grid nodes, the second grid would override the scope of the first, and you would NOT get your shared sizing.  You only ever want to put the attached property ONCE for the ENTIRE scope of shared sizing.</p>
<p>With that out of the way, all you need to do now is give your row or column definitions a unique identifier on the SharedSizeGroup property and then all rows or columns that share the same unique identifier will also share the same hight or width respectively.  You should also note that this only works for explicit or Auto sized rows and columns.  If you specify a star on a shared item, it will default it to Auto.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2011/01/25/230/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Quick Lesson On Simple Yet Confusing Depedency Property Issue</title>
		<link>http://blog.errorok.com/2010/12/16/228/</link>
		<comments>http://blog.errorok.com/2010/12/16/228/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 19:13:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[depedency property]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=228</guid>
		<description><![CDATA[This is an issue that I just ran into and was a little confused as to why it was happening, but upon thinking about it for a moment it makes perfect sense. When you are creating your DP&#8217;s, you have the option of specifying a default (initial) value. The problem with this value is that [...]]]></description>
			<content:encoded><![CDATA[<p>This is an issue that I just ran into and was a little confused as to why it was happening, but upon thinking about it for a moment it makes perfect sense.</p>
<p>When you are creating your DP&#8217;s, you have the option of specifying a default (initial) value.  The problem with this value is that it is created and stored statically.  So if you are creating a DP for, say, a collection, and you initialize it statically in the DP definition then your collection reference now exists statically.  So regardless of whether or not you create ten instances of your DO, they will all contain the same initial value because they will all point to the same static reference.</p>
<p>So the conclusion to this quick lesson is that you should never initialize your DP&#8217;s with reference types, always perform this step at instantiation to guarantee unique DP values per object instance (unless of course you want to share the reference).  As for value types it doesn&#8217;t matter nearly as much because the value is copied anyways.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/12/16/228/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anonymous Type Return Value in C# 4.0</title>
		<link>http://blog.errorok.com/2010/12/13/208/</link>
		<comments>http://blog.errorok.com/2010/12/13/208/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 16:59:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=208</guid>
		<description><![CDATA[Ever wanted to return an anonymous type from a method or property, but then find out you can&#8217;t use it because there is no valid return type? Â Well I have, and I will explain how to get around this issue. The solution as you may have guessed is to use dynamic types, which allow you [...]]]></description>
			<content:encoded><![CDATA[<p>Ever wanted to return an anonymous type from a method or property, but then find out you can&#8217;t use it because there is no valid return type? Â Well I have, and I will explain how to get around this issue.</p>
<p>The solution as you may have guessed is to use dynamic types, which allow you to build the type definition at run time and return it. Â Since there is no static compilation type checking, it doesn&#8217;t care that you can&#8217;t define the return type of your method or property. Â This isn&#8217;t something very common, or even recommended in most situations, but it can come in handy in a pinch. Â Here is some totally useless, but good sample code explanation.</p>
<pre>private bool flagValue = false;
private bool isFlagValueSet = false;

private dynamic Flag
{
    get
    {
        return new { Value = flagValue, IsValueSet = isFlagValueSet };
    }
}

public bool Test()
{
    return Flag.IsValueSet ? Flag.Value : false;
}</pre>
<p>All you gotta do is ensure that you reference the Microsoft.CSharp.dll to get access to dynamic types. Â You won&#8217;t get any intellisense on the flag variable, but that&#8217;s because the type information is computed at runtime only.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/12/13/208/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simulating Multi-Source One Way Data Bindings</title>
		<link>http://blog.errorok.com/2010/12/13/223/</link>
		<comments>http://blog.errorok.com/2010/12/13/223/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 16:44:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software Developement]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[wpf]]></category>

		<guid isPermaLink="false">http://blog.errorok.com/?p=223</guid>
		<description><![CDATA[The title is a bit of a mouthful, so here is the quick synopsis. Â We have one to many controls that drive a single view. Â Each control implements the same interface, something that provides the view with its context. Â That way regardless of what control is used, the single view updates appropriately. The problem here [...]]]></description>
			<content:encoded><![CDATA[<p>The title is a bit of a mouthful, so here is the quick synopsis. Â We have one to many controls that drive a single view. Â Each control implements the same interface, something that provides the view with its context. Â That way regardless of what control is used, the single view updates appropriately.</p>
<p>The problem here is that we need to bind the DP of the view&#8217;s context to multiple sources, something which a standard Binding does not allow. Â MultiBinding allows multiple sources, but it would be impossible to know which source was actually &#8220;made active&#8221; most recently, so we could never return the right source accurately (unless we gave context to the sources themselves, which would be poor design).</p>
<p>The solution to this problem is rather simple, we just need to manage that multi-source aspect of the binding manually in the location where the binding is made or where the DP&#8217;s live (this could be the same place if you are doing MVVM). Â First create a read only DP that will act as your view driving DP, it can be initialized to null. Â Now create a standard event handler function to handle the property changed event for the driving DP on each source. Â Hook up the DP value changed events:</p>
<pre>private void ViewContext_PropertyChanged(object sender, EventArgs e)
{
    SetValue(ViewContextPropertyKey, (sender as IViewContextProvider).ViewContext);
}</pre>
<pre>DependencyPropertyDescriptor.FromProperty(Source1ViewModel.ViewContextProperty, typeof(Source1ViewModel))
    .AddValueChanged(m_Source1ViewModel, ViewContext_PropertyChanged);</pre>
<p>In the event handler, we simply update your RO DP and that&#8217;s it!</p>
<p>If the scenario seems a little obscure, think of this situation. Â You want to write a file explorer type of view, the explorer will obviously display files and folders in some sort of list or grid. Â On the left hand side, you have multiple panels that determine the context of the file explorer. Â One panel is your local system, another panel is a local search, another panel is an FTP site, etc&#8230; Â All these left side panels can drive your single view through this RO DP pattern.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.errorok.com/2010/12/13/223/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

