<?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>Cory Hardman&#039;s Blog &#187; Development</title>
	<atom:link href="http://www.coryhardman.com/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coryhardman.com</link>
	<description></description>
	<lastBuildDate>Mon, 07 Nov 2011 04:51:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Repo Command Missing</title>
		<link>http://www.coryhardman.com/2011/06/repo-command-missing/</link>
		<comments>http://www.coryhardman.com/2011/06/repo-command-missing/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 01:32:35 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=363</guid>
		<description><![CDATA[I was recently following along to a tutorial to download the ChromeOS source, when it told me to use the command repo to use sync up the source to my computer. Well I couldn't seem to find the repo command anywhere on my machine, turns out that repo is a tool available on Google Code to facilitate [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently following along to a tutorial to download the <a href="http://www.chromium.org/chromium-os/developer-guide#TOC-Create-a-chroot">ChromeOS source</a>, when it told me to use the command <em>repo </em>to use sync up the source to my computer. Well I couldn't seem to find the <em>repo</em> command anywhere on my machine, turns out that <em>repo</em> is a tool available on <a href="http://code.google.com/p/git-repo/">Google Code</a> to facilitate using GIT. So you can download the command with the following commands:</p>
<blockquote>
<pre>curl https://android.git.kernel.org/repo &gt;~/bin/repo
chmod a+x repo</pre>
</blockquote>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2011/06/repo-command-missing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Quest: Sort 100 Million Integers With OpenMP</title>
		<link>http://www.coryhardman.com/2011/04/my-quest-sort-100-million-integers-with-openmp/</link>
		<comments>http://www.coryhardman.com/2011/04/my-quest-sort-100-million-integers-with-openmp/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 05:40:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=347</guid>
		<description><![CDATA[Over the past couple of weeks I have been teaching myself OpenMP. I wonted to see how much faster I could make my previous Quick Sort with Insertion Sort implementation. What is so great about OpenMP is it allows you to transform a single threaded code bit into a multi-threaded one with just a few [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past couple of weeks I have been teaching myself OpenMP. I wonted to see how much faster I could make my previous Quick Sort with Insertion Sort implementation. What is so great about OpenMP is it allows you to transform a single threaded code bit into a multi-threaded one with just a few lines of code. Here is my implementation:</p>
<pre class="cpp">&nbsp;
<span style="color: #0000ff;">void</span> QuickSortImpl::<span style="color: #00eeff;">Sort</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">int</span> numProcs = omp_get_num_procs<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
    omp_set_num_threads<span style="color: #000000;">&#40;</span>numProcs<span style="color: #000000;">&#41;</span>;
    <span style="color: #339900;">#pragma omp parallel</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #339900;">#pragma omp single nowait</span>
        Sort_h<span style="color: #000000;">&#40;</span>start, end<span style="color: #0000dd;">-1</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> QuickSortImpl::<span style="color: #00eeff;">Sort_h</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>start &lt; end<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>end - start &lt; <span style="color: #0000dd;">20</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            InsertionSort<span style="color: #000000;">&#40;</span>start, end<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0000ff;">else</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0000ff;">int</span> q = Partition<span style="color: #000000;">&#40;</span>start, end<span style="color: #000000;">&#41;</span>;
            <span style="color: #339900;">#pragma omp task</span>
            <span style="color: #000000;">&#123;</span>
                Sort_h<span style="color: #000000;">&#40;</span>start, start + <span style="color: #000000;">&#40;</span>q - <span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
            <span style="color: #000000;">&#125;</span>
            Sort_h<span style="color: #000000;">&#40;</span>start + <span style="color: #000000;">&#40;</span>q + <span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span>, end<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> QuickSortImpl::<span style="color: #00eeff;">Partition</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">int</span> partitionIndex =  <span style="color: #000000;">&#40;</span>end - start<span style="color: #000000;">&#41;</span>/<span style="color: #0000dd;">2</span>;
    <span style="color: #0000ff;">int</span> privotValue = start<span style="color: #000000;">&#91;</span>partitionIndex<span style="color: #000000;">&#93;</span>;
    <span style="color: #0000ff;">int</span> tmp = start<span style="color: #000000;">&#91;</span>partitionIndex<span style="color: #000000;">&#93;</span>;
    start<span style="color: #000000;">&#91;</span>partitionIndex<span style="color: #000000;">&#93;</span> = *end;
    *end = tmp;
    <span style="color: #0000ff;">int</span> swapIndex = <span style="color: #0000dd;">0</span>;
    <span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> i = <span style="color: #0000dd;">0</span>; i &lt; end - start; i++<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> &lt;= privotValue<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            tmp = start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span>;
            start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span> = start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
            start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = tmp;
            swapIndex++;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    tmp = start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span>;
    start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span> = *end;
    *end = tmp;
    <span style="color: #0000ff;">return</span> swapIndex;
<span style="color: #000000;">&#125;</span>
<span style="color: #0000ff;">void</span> QuickSortImpl::<span style="color: #00eeff;">InsertionSort</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">for</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> j = <span style="color: #0000dd;">1</span>; j &lt; = end - start; j++<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0000ff;">int</span> key = start<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>;
        <span style="color: #0000ff;">int</span> i = j - <span style="color: #0000dd;">1</span>;
        <span style="color: #0000ff;">while</span><span style="color: #000000;">&#40;</span>i &gt;= <span style="color: #0000dd;">0</span> &amp;&amp; start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> &gt; key<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            start<span style="color: #000000;">&#91;</span>i<span style="color: #0000dd;">+1</span><span style="color: #000000;">&#93;</span> = start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
            i = i - <span style="color: #0000dd;">1</span>;
        <span style="color: #000000;">&#125;</span>
        start<span style="color: #000000;">&#91;</span>i<span style="color: #0000dd;">+1</span><span style="color: #000000;">&#93;</span> = key;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
<p>I chose to only task off one of my recursive calls in the sort_h routine. This is because there is a small overhead associated with sending off a task to the queue of waiting threads to execute. The actual improvement to performance was fairly minimal at about 0.2-0.3 seconds. This trick would have been more noticeable if there was more iterations of sort_h.</p>
<p>This implementation sorted my random list of integers in roughly 5.5 seconds. That means it is roughly a factor of three speed up over the single threaded version. It also better utilizes my desktop's CPUs but spiking all four cores for a few seconds to complete the operation. </p>
<p>Besides the pretty impressive speed up, what strikes me the most interesting is how little code changed from my previous implementation. Literally 4 additional lines of code was required to turn a single threaded Quick Sort into a parallel Quick Sort that scales pretty well with the number of CPU's you have (on most desktops). This just goes to show you the power of OpenMP. I highly recommend anyone needing to write multi-threaded c++ code to look at OpenMP.</p>
<p>Download: <a href='http://www.coryhardman.com/wp-content/uploads/2011/04/OpenMPQuickSort.zip'>OpenMPQuickSort</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2011/04/my-quest-sort-100-million-integers-with-openmp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Quest: Sort 100 Million Integers</title>
		<link>http://www.coryhardman.com/2011/03/my-quest-sort-100-million-integers/</link>
		<comments>http://www.coryhardman.com/2011/03/my-quest-sort-100-million-integers/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 04:33:59 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=300</guid>
		<description><![CDATA[I have decided to do some research into sorting algorithms to see how fast I can sort a random list of 100 million integers. I picked 100 million integers because is big enough that the gnu c++ implementation of sort took over 15 seconds to sort on my desktop and it fits pretty easily in [...]]]></description>
			<content:encoded><![CDATA[<p>I have decided to do some research into sorting algorithms to see how fast I can sort a random list of 100 million integers. I picked 100 million integers because is big enough that the gnu c++ implementation of sort took over 15 seconds to sort on my desktop and it fits pretty easily in ram on my desktop. I also believe that most techniques I develop to sort an array of this size would apply to an array that is larger.</p>
<p>As I started doing research I realized there actually a lot more to it than figuring out which sorting algorithm is the fastest. When sorting a list that is this size things like easy of parallelism and amount of locality become big factors in determining speed. Over the coming weeks I will be posting updates to this quest with improvements to my algorithm. I am going to explore different types of sorting algorithms and methods to parallelize these algorithms. My parallelism adventures will likely stick to OpenMP and CUDA.</p>
<p>My method of timing will not be perfect. Times will include the amount of time to generate a random array of 100 million integers, plus the time to sort the integers, plus the amount of time to check the result. I will run all tests on my desktop, which is a Core i5 (4 cores) with 8 GB of ram. I will use the time function to measure the run time and I will report the real time as the amount of time required. As this is just me experimenting, there is no requirement to have accurate measures of the actual algorithms. Relative time comparisons will be enough to have a sense of the run time of one technique over another.</p>
<p>To kick it off, I have implemented a Quick Sort that uses Insertion Sort once what we are sorting a small enough list. I apologize if there are any mistakes in the below code. I had to fight with the editor to get this to format correctly. Please see attached files for actual code and header files.</p>
<pre class="cpp"><span style="color: #0000ff;">void</span> QuickSortImpl::<span style="color: #00eeff;">Sort</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    Sort_h<span style="color: #000000;">&#40;</span>start, end<span style="color: #0000dd;">-1</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
<span style="color: #0000ff;">void</span> QuickSortImpl::<span style="color: #00eeff;">Sort_h</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>start &lt; end<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>end - start &gt; <span style="color: #0000dd;">15</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            InsertionSort<span style="color: #000000;">&#40;</span>start, end<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
        <span style="color: #0000ff;">else</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #0000ff;">int</span> size = end - start;
            <span style="color: #0000ff;">int</span> q = Partition<span style="color: #000000;">&#40;</span>start, end<span style="color: #000000;">&#41;</span>;
            Sort_h<span style="color: #000000;">&#40;</span>start, start + <span style="color: #000000;">&#40;</span>q - <span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
            Sort_h<span style="color: #000000;">&#40;</span>start + <span style="color: #000000;">&#40;</span>q + <span style="color: #0000dd;">1</span><span style="color: #000000;">&#41;</span>, end<span style="color: #000000;">&#41;</span>;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
<span style="color: #0000ff;">int</span> QuickSortImpl::<span style="color: #00eeff;">Partition</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">int</span> partitionIndex =  <span style="color: #000000;">&#40;</span>end - start<span style="color: #000000;">&#41;</span>/<span style="color: #0000dd;">2</span>;
    <span style="color: #0000ff;">int</span> privotValue = start<span style="color: #000000;">&#91;</span>partitionIndex<span style="color: #000000;">&#93;</span>;
    <span style="color: #0000ff;">int</span> tmp = start<span style="color: #000000;">&#91;</span>partitionIndex<span style="color: #000000;">&#93;</span>;
    start<span style="color: #000000;">&#91;</span>partitionIndex<span style="color: #000000;">&#93;</span> = *end;
    *end = tmp;
&nbsp;
    <span style="color: #0000ff;">int</span> swapIndex = <span style="color: #0000dd;">0</span>;
    <span style="color: #0000ff;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> i = <span style="color: #0000dd;">0</span>; i &lt; end - start; i++<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0000ff;">if</span><span style="color: #000000;">&#40;</span>start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> &lt;= privotValue<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            tmp = start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span>;
            start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span> = start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
            start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = tmp;
            swapIndex++;
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
    tmp = start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span>;
    start<span style="color: #000000;">&#91;</span>swapIndex<span style="color: #000000;">&#93;</span> = *end;
    *end = tmp;
    <span style="color: #0000ff;">return</span> swapIndex;
<span style="color: #000000;">&#125;</span>
<span style="color: #0000ff;">void</span> QuickSortImpl::<span style="color: #00eeff;">InsertionSort</span><span style="color: #000000;">&#40;</span>vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> start, vector&lt; <span style="color: #0000ff;">int</span> &gt;::<span style="color: #00eeff;">iterator</span> end<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">for</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff;">int</span> j = <span style="color: #0000dd;">1</span>; j &lt; = end - start; j++<span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
         <span style="color: #0000ff;">int</span> key = start<span style="color: #000000;">&#91;</span>j<span style="color: #000000;">&#93;</span>;
         <span style="color: #0000ff;">int</span> i = j - <span style="color: #0000dd;">1</span>;
         <span style="color: #0000ff;">while</span><span style="color: #000000;">&#40;</span>i &gt;= <span style="color: #0000dd;">0</span> &amp;&amp; start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> &gt; key<span style="color: #000000;">&#41;</span>
         <span style="color: #000000;">&#123;</span>
              start<span style="color: #000000;">&#91;</span>i<span style="color: #0000dd;">+1</span><span style="color: #000000;">&#93;</span> = start<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span>;
              i = i - <span style="color: #0000dd;">1</span>;
         <span style="color: #000000;">&#125;</span>
         start<span style="color: #000000;">&#91;</span>i<span style="color: #0000dd;">+1</span><span style="color: #000000;">&#93;</span> = key;
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre>
<p>These are pretty common implementations of Quick Sort and Insert Sort. There are however a few notable things. The partition method uses the middle number instead of a random index. This is because my list to be sorted was already randomized, calling rand() again would have just been overhead. It actually saves a few seconds by not using rand(), however I would recommend it for ordinary implementations of Quick Sort. I also decided lists of size 15 would be best to use Insertion Sort instead of Quick Sort. This number was more experimentally derived. It appeared to give the best results.</p>
<p>This implementation to sort my 100 million integers performed rather well, taking on average 15 seconds to complete. Lets see how much better we can make this, more to come.</p>
<p>Download File: <a href="http://www.coryhardman.com/wp-content/uploads/2011/03/QuickSort.zip">QuickSort.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2011/03/my-quest-sort-100-million-integers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Finding Median in (Almost) Linear Time</title>
		<link>http://www.coryhardman.com/2011/03/finding-median-in-almost-linear-time/</link>
		<comments>http://www.coryhardman.com/2011/03/finding-median-in-almost-linear-time/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 01:52:12 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=272</guid>
		<description><![CDATA[I sometimes find myself needing to find the median of a set of numbers. What I would do was sort the list of numbers and then take the value in the middle index, something like(in Java): public static int FindMedian&#40;List &#38;lt;Integer&#38;gt; nums&#41; &#123; Collections.sort&#40;nums&#41;; if&#40;nums.size&#40;&#41; % 2 == 0&#41; &#123; return &#40;nums.get&#40;nums.size&#40;&#41; / 2&#41; + [...]]]></description>
			<content:encoded><![CDATA[<p>I sometimes find myself needing to find the median of a set of numbers. What I would do was sort the list of numbers and then take the value in the middle index, something like(in Java):</p>
<pre class="java">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #993333;">int</span> FindMedian<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AList+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">List</span></a> &amp;lt;Integer&amp;gt; nums<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ACollections+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Collections</span></a>.<span style="color: #006600;">sort</span><span style="color: #66cc66;">&#40;</span>nums<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>nums.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> % <span style="color: #cc66cc;">2</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
             <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #66cc66;">&#40;</span>nums.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>nums.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> + nums.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>nums.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">2</span>;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> nums.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>nums.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> / <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span></pre>
<p>This solution is on the order of O(n lg n) where n is the number of elements. A faster method would be use a modified <a href="http://en.wikipedia.org/wiki/Quicksort">quick sort</a>. The idea being that after each partition we gain some knowledge about how many numbers are less than or equal to a given number in the list. So we can be smart and only iterate on the side of the list where we know the selected number is. Here is my implementation of QuickSelect in Java:</p>
<pre class="java">&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> QuickSelect <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> &lt; T <span style="color: #000000; font-weight: bold;">extends</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AComparable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Comparable</span></a> &lt;? <span style="color: #000000; font-weight: bold;">super</span> T&gt;&gt; T quickSelect<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AList+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">List</span></a> &lt; T &gt; values, <span style="color: #993333;">int</span> k<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #993333;">int</span> left = <span style="color: #cc66cc;">0</span>;
        <span style="color: #993333;">int</span> right = values.<span style="color: #006600;">size</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> - <span style="color: #cc66cc;">1</span>;
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARandom+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Random</span></a> rand = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARandom+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Random</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #993333;">int</span> partionIndex = rand.<span style="color: #006600;">nextInt</span><span style="color: #66cc66;">&#40;</span>right - left + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> + left;
            <span style="color: #993333;">int</span> newIndex = partition<span style="color: #66cc66;">&#40;</span>values, left, right, partionIndex<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #993333;">int</span> q = newIndex - left + <span style="color: #cc66cc;">1</span>;
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>k == q<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>newIndex<span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>k &lt; q<span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
                right = newIndex - <span style="color: #cc66cc;">1</span>;
            <span style="color: #66cc66;">&#125;</span>
            <span style="color: #b1b100;">else</span>
            <span style="color: #66cc66;">&#123;</span>
                k -= q;
                left = newIndex + <span style="color: #cc66cc;">1</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
    <span style="color: #66cc66;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> &lt; T <span style="color: #000000; font-weight: bold;">extends</span> Comparable&lt;? <span style="color: #000000; font-weight: bold;">super</span> T&gt;&gt; <span style="color: #993333;">int</span> partition<span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AList+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">List</span></a> &lt; T &gt; values, <span style="color: #993333;">int</span> left, <span style="color: #993333;">int</span> right, <span style="color: #993333;">int</span> partitionIndex<span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        T partionValue = values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>partitionIndex<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #993333;">int</span> newIndex = left;
        T temp = values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>partitionIndex<span style="color: #66cc66;">&#41;</span>;
        values.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span>partitionIndex, values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>right<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        values.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span>right, temp<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">int</span> i = left; i &lt; right; i++<span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
            <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">compareTo</span><span style="color: #66cc66;">&#40;</span>partionValue<span style="color: #66cc66;">&#41;</span> &lt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
            <span style="color: #66cc66;">&#123;</span>
                temp = values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
                values.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span>i, values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>newIndex<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                values.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span>newIndex, temp<span style="color: #66cc66;">&#41;</span>;
                newIndex++;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        temp = values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>right<span style="color: #66cc66;">&#41;</span>;
        values.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span>right, values.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span>newIndex<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
        values.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span>newIndex, temp<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #000000; font-weight: bold;">return</span> newIndex;
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
<p>From here implementing FindMedian should be pretty straight forward. The nice thing about this algorithm is that it can find any kth largest number in a set. Plus on average this will run in O(n) with a worst case of O(n lg n). Enjoy!</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2011/03/finding-median-in-almost-linear-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>in_addr to string(char*)</title>
		<link>http://www.coryhardman.com/2010/12/in_addr-to-stringchar/</link>
		<comments>http://www.coryhardman.com/2010/12/in_addr-to-stringchar/#comments</comments>
		<pubDate>Sat, 04 Dec 2010 23:56:39 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=217</guid>
		<description><![CDATA[The other day I needed to turn a IPv4 address to a string in C. I figured some others would find it useful: &#160; char* hexToCharIP&#40;struct in_addr addrIP&#41; &#123; char* ip; unsigned int intIP; memcpy&#40;&#38;intIP, &#38;addrIP,sizeof&#40;unsigned int&#41;&#41;; int a = &#40;intIP &#62;&#62; 24&#41; &#38; 0xFF; int b = &#40;intIP &#62;&#62; 16&#41; &#38; 0xFF; int c [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I needed to turn a IPv4 address to a string in C. I figured some others would find it useful:</p>
<pre class="c">&nbsp;
<span style="color: #993333;">char</span>* hexToCharIP<span style="color: #66cc66;">&#40;</span><span style="color: #993333;">struct</span> in_addr addrIP<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #993333;">char</span>* ip;
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> intIP;
  memcpy<span style="color: #66cc66;">&#40;</span>&amp;intIP, &amp;addrIP,<span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #993333;">int</span> a = <span style="color: #66cc66;">&#40;</span>intIP &gt;&gt; <span style="color: #cc66cc;">24</span><span style="color: #66cc66;">&#41;</span> &amp; 0xFF;
  <span style="color: #993333;">int</span> b = <span style="color: #66cc66;">&#40;</span>intIP &gt;&gt; <span style="color: #cc66cc;">16</span><span style="color: #66cc66;">&#41;</span> &amp; 0xFF;
  <span style="color: #993333;">int</span> c = <span style="color: #66cc66;">&#40;</span>intIP &gt;&gt; &lt;img src=<span style="color: #ff0000;">'http://www.coryhardman.com/wp-includes/images/smilies/icon_cool.gif'</span> alt=<span style="color: #ff0000;">'8)'</span> class=<span style="color: #ff0000;">'wp-smiley'</span> /&gt; &amp; 0xFF;
  <span style="color: #993333;">int</span> d = intIP &amp; 0xFF;
  <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>ip = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span>*<span style="color: #66cc66;">&#41;</span>malloc<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">16</span>*<span style="color: #993333;">sizeof</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> == <span style="color: #000000; font-weight: bold;">NULL</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">NULL</span>;
  <span style="color: #66cc66;">&#125;</span>
  sprintf<span style="color: #66cc66;">&#40;</span>ip, <span style="color: #ff0000;">&quot;%d.%d.%d.%d&quot;</span>, d,c,b,a<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">return</span> ip;
<span style="color: #66cc66;">&#125;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2010/12/in_addr-to-stringchar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>P != NP</title>
		<link>http://www.coryhardman.com/2010/08/p-np/</link>
		<comments>http://www.coryhardman.com/2010/08/p-np/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 03:01:44 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Security]]></category>
		<category><![CDATA[Links]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=179</guid>
		<description><![CDATA[Dr. Vinay Deolalikar of HP Labs has written a paper proving that P != NP. This has been at the center of theoretical computer science for almost as long as computers have been envisioned. This is good news for cryptography but bad news for optimization of some useful problems, like traveling sales man. The paper has not been [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hpl.hp.com/personal/Vinay_Deolalikar/">Dr. Vinay Deolalikar</a> of <a href="http://www.hpl.hp.com/">HP Labs</a> has written a <a href="http://www.scribd.com/doc/35539144/pnp12pt">paper</a> proving that <a href="http://en.wikipedia.org/wiki/P_versus_NP_problem">P != NP</a>. This has been at the center of theoretical computer science for almost as long as computers have been envisioned. This is good news for cryptography but bad news for optimization of some useful problems, like traveling sales man.</p>
<p>The paper has not been peer reviewed, so the jury is still out on whether he is correct.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2010/08/p-np/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Microsoft&#8217;s 2019 &#8211; Where are the developers?</title>
		<link>http://www.coryhardman.com/2010/08/microsofts-2019-where-are-the-developers/</link>
		<comments>http://www.coryhardman.com/2010/08/microsofts-2019-where-are-the-developers/#comments</comments>
		<pubDate>Fri, 06 Aug 2010 03:48:48 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=166</guid>
		<description><![CDATA[A little known fact is that Microsoft invests heavily into developing technologies for the future. Every now and then these researchers look to the future and into how to turn what is being developed as pure research into reality. Nearly a year ago Microsoft released this video of how productivity will be in year 2019 [...]]]></description>
			<content:encoded><![CDATA[<p>A little known fact is that Microsoft invests heavily into developing technologies for the future. Every now and then these researchers look to the future and into how to turn what is being developed as pure research into reality. Nearly a year ago Microsoft released this video of how productivity will be in year 2019 (ten years after the video was released). I just recently saw the video for the first time, if you have not seen it you should check it out here:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/gHNBS5NJxHk" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/gHNBS5NJxHk"></embed></object></p>
<p>After I watched the video I was left with a few thoughts, which I'm sure was the true purpose of the video. The over arching theme in the video was that productivity will shift from application based to task based. By this I mean instead of thinking I need to open up Word to work on some research paper, I will instead have a research task that has a word document associated with it along with all of my research references and my collected data. At first glance it isn't that big of a change, users already associate related files/material together by creating folders or some naming scheme. You need to look a bit deeper, instead of the user associating files together with some type of organization, the computer will automatically discover context and associate the correct material together. It is a very cool idea and one that I am sure will come true some day. The question I think is how do developers get involved?</p>
<p>Since the world is not slowing at producing computer scientist, they will need jobs in year 2019 just like they need them now. So if we assume that a lot of these things come true, especially the task based productivity, what do these computer scientist do? Well clearly, a lot of the computer scientist will help develop the software that is capable of detecting the correct context and making sure this stuff stays secure. These are the developers that work for companies like Microsoft and other top software companies. What about the rest of the developers? Like the ones that do open source, developers for hire, or work for a small software company. What will they provide to an end user?</p>
<p>Cloud services are featured all over the place in this video. Data is everywhere you are. How does an open source developer be part of this type of world? I think it will be a lot like it is today. Protocols will be open enough to allow anyone to interface with the cloud. In order to make this possible, these protocols we will need to move from today's free services that are paid for by ads to paid for services. This will happen due to privacy concerns and cloud services will have trouble placing ads so the user will be interested in them. Interfaces to the cloud will be what open source developers are creating. Microsoft and other propitiatory software will still exist along side open source software, like it is today.</p>
<p>Well these other developers could not write custom applications anymore. This is because applications no longer exists. So they must provide a task environment. Now the question becomes, what does it mean to provide a task environment? This is a difficult question because we have never seen one yet. I would expect a task will resemble a rule set, where developers tell the host system in which context input should be handled by the developer's task. Then host system will provide the windowing environment and placement of the data in the user interface.</p>
<p>What are your thoughts?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2010/08/microsofts-2019-where-are-the-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Usable Security</title>
		<link>http://www.coryhardman.com/2010/07/usable-security/</link>
		<comments>http://www.coryhardman.com/2010/07/usable-security/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 06:30:55 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Information Security]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=161</guid>
		<description><![CDATA[There has been a big push over the last few years to develop what has been coined as "usable security". Things like drawing patterns on Android devices instead of typing in a 4 digit pin or identifying particular things in an image instead of typing a password have been developed. The biggest problem with these usable security [...]]]></description>
			<content:encoded><![CDATA[<p>There has been a big push over the last few years to develop what has been coined as "usable security". Things like drawing patterns on Android devices instead of typing in a 4 digit pin or identifying particular things in an image instead of typing a password have been developed. The biggest problem with these usable security mechanisms is that they often take longer to use than the alternatives.</p>
<p>Imagine if you had to take your mouse and click at 10 particular spots in an image every time you wanted to unlock your screen at work. Doing this would take several more seconds at every sign on and would add up quickly. Often for systems that are used often keying in a password is still the fastest method.</p>
<p>Well Microsoft has developed a new <a href="http://www.technologyreview.com/computing/25826/">solution</a>. Instead of having password requirements that are visible to the user, like minimum length, they want to let users use anything as a password. Even simple passwords like "love" would be accepted. However there is a catch, only a small number of users will be allowed to use a particular password.</p>
<p>Complex password requirements were introduced to combat spraying and braying attacks. A spray and bray attack is when an attacker tries to use one particular password on a large number of accounts. This way bypassing lock out procedures. This solution by Microsoft will fix this by only allowing a small number of accounts to be compromised and thus reduce the benefits of the spray and pray attack while keeping passwords simple and easy to remember.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2010/07/usable-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Reviews, the Lost Art</title>
		<link>http://www.coryhardman.com/2010/07/code-reviews-the-lost-art/</link>
		<comments>http://www.coryhardman.com/2010/07/code-reviews-the-lost-art/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 04:45:25 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=154</guid>
		<description><![CDATA[Most matured developers tend to like the idea of code reviews but given the choice, on there next commit they would likely opt to not send their code for code review. The reason why is simple, code reviews can delay the forward progress of the software and they take time. ]]></description>
			<content:encoded><![CDATA[<p>Nearly every software development shop worth its salt has some form of what is known as a code review and nearly every developer dislikes them.  Most matured developers tend to like the idea of code reviews but given the choice, on there next commit they would likely opt to not send their code for code review. The reason why is simple, code reviews can delay the forward progress of the software and they take time. When you have other developers needing access to the library you just wrote it is hard to say we need to take a few hours to a week of our time to look over my code. I think we should be able to make code reviews better and into something everyone wants to do.</p>
<p>After a code review I often finding myself wondering was what was found worth my time and the reviewers time? Most of the code reviews that I have been apart of have had minor suggestions or more commonly code standards compliance problems. When you rummage through several hundred or a few thousand lines of code during a code review and all that is found is that you have a few extra blank lines or should change the name of a variable, it does seem like a bit of a wast.</p>
<p>I'm not saying that we should not care about those extra lines or any code standard for that matter. I'm a big fan of code standards, I think they help in the readability of code. I'm saying that there is a cost to code reviews, we have to weigh those costs against the rewards. When a reviewer only finds a few compliance issues, things that could be fixed by anyone that is reading through the code, it was not worth the time the reviewer spent reviewing.</p>
<p>So how do we make code reviews worth everyone's time? Simple, we change the intent of a code review back to what the actual intent was. Code reviews are put into place to find bugs. Bugs that would show up to an end user or other developers that are trying to use the code.</p>
<p>You may say, “well Cory that is what every code reviewer is doing, they are looking for bugs.” However that is not true, sure they are looking for obvious bugs like unassigned variables being referenced, but they are not looking for deep bugs. One of the most common bugs comes from input validation, and yet it is a bug that is often over looked in code reviews. This is because it is often difficult to tell exactly where input to a function is coming from and how much it should be trusted. Detecting  multi-level bugs requires a reviewer to see how the multiple levels interact and the path of the code in correct and error states. This kind of review takes a lot of time and drastically increases the complexity of a code review. The sharp increase is due to the fact that we are moving a code review from a mostly passive practice to a very active process.</p>
<p>Obviously code reviews could not detect all bugs and there will be times when a code review will not find any bugs. From this active process of a code review you get a new found level of confidence. Bug counts will be decrease and actual development should increase. This confidence is how a code review pay for themselves.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2010/07/code-reviews-the-lost-art/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>OpenVPN in Windows 7</title>
		<link>http://www.coryhardman.com/2010/07/openvpn-in-windows-7/</link>
		<comments>http://www.coryhardman.com/2010/07/openvpn-in-windows-7/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 06:13:39 +0000</pubDate>
		<dc:creator>Cory Hardman</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://www.coryhardman.com/?p=150</guid>
		<description><![CDATA[I often need to work remotely from work, luckily my work has a VPN server that allows me to get access to the companies internal resources. I have been using OpenVPN in Windows XP for a long time to do this, through the use of OpenVPN GUI. Well when I got a new laptop it [...]]]></description>
			<content:encoded><![CDATA[<p>I often need to work remotely from work, luckily my work has a VPN server that allows me to get access to the companies internal resources. I have been using <a href="http://openvpn.net/">OpenVPN</a> in Windows XP for a long time to do this, through the use of <a href="http://openvpn.se/">OpenVPN GUI</a>. Well when I got a new laptop it came with Windows 7 installed. So one of the first things I did was set up my development environment which required me to get into some of the file shares inside of my companies network. I thought it wouldn't be a problem at all to do, I installed OpenVPN GUI and just copied over my configuration and key files. When I went to connect I got quite an interesting error:</p>
<blockquote>
<div id="_mcePaste">Thu Jul 08 23:05:33 2010 ROUTE: route addition failed using CreateIpForwardEntry: One or more arguments are not correct.   [if_index=16]</div>
</blockquote>
<div>It turns out to be very simple to fix. In Windows 7 and I believe in Vista you need to do a few extra steps to get OpenVPN GUI to work with Windows 7. First you need to go C:\Program Files\OpenVPN\Bin and make sure openvpn-gui.exe is always started as Administrator (in the compatibility menu of the file properties). Then you will need to edit your configuration file and add two lines after the line that describes your cipher:</div>
<blockquote>
<div>
<div>route-method exe</div>
<div>route-delay 2</div>
</div>
</blockquote>
<div>That should do it. Let me know if you have any questions.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.coryhardman.com/2010/07/openvpn-in-windows-7/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

