<?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>Philosophy, Technology and Math</title>
	<atom:link href="http://www.mrrives.com/Technology/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.mrrives.com/Technology</link>
	<description>Software and Papers Related to Game Theory, Math and Philosophy</description>
	<lastBuildDate>Mon, 17 Jun 2013 13:14:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>The Halving Algorithm and the Guessing Game for the TI-83/TI-84</title>
		<link>http://www.mrrives.com/Technology/?p=1118</link>
		<comments>http://www.mrrives.com/Technology/?p=1118#comments</comments>
		<pubDate>Sat, 16 Mar 2013 20:47:47 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[Ti-83]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=1118</guid>
		<description><![CDATA[The first task for each student is to write a program where the computer thinks of a number, and the student gets to guess the number (and the program says if the guess is too high, too low, or just &#8230; <a href="http://www.mrrives.com/Technology/?p=1118">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><strong>The first task </strong>for each student is to write a program where the computer thinks of a number, and the student gets to guess the number (and the program says if the guess is too high, too low, or just right).  The program keeps soliciting the user for a guess until the correct answer has been provided.  On the TI-83, to have the computer pick a number from 1 to 1000, you use the random number generator under Math->Prb->randInt.  The following line of code is how the Ti-83 picks a number from 1 to 1000, and stores it into the variable A:</p>
<blockquote><p>randInt(1,1000) -> A</p></blockquote>
<p>I will leave the rest of the program writing to you. You&#8217;ll use Lbl, if, Input, math tests (>, <) and Disp.</p>
<p>I originally got the idea for a number guessing program when I was 12.  I got it from the book, <em>Basic Computer Games</em>. This book made quite an impression upon me, so it is a pleasure to pass along a snippet (click on the image below to see page 75):</p>
<p><a href="http://www.mrrives.com/Technology/?attachment_id=1119" rel="attachment wp-att-1119"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2013/03/guess-207x300.png" alt="guess" width="207" height="300" class="aligncenter size-medium wp-image-1119" /></a></p>
<p><strong>The second task </strong>for the student is to think of the best way to guess numbers.  For example, consider that I am thinking of a number from 1 to 1000, and I ask you to guess that number (and I will tell you if you are too high or too low).  Two bad ways to go about guessing would be to begin at one and count up to 1000 till you got it, or to begin and 1000 and count down.  There must be a better way.  Find that way.  And then come up with a statement that will tell me the most number of guesses it would take for a person to figure out the secret number.</p>
<p>Do the same thing as if the number to be guessed is between 1 and 10.</p>
<p>Then do it again for a number between 1 and 100.  Then 1 and 1000.  Can you find a general pattern that will tell you the maximum number of guesses it would take to find the hidden number for any range?</p>
<p><strong>Bonus Assignment</strong>: This following line of thinking was not covered in our last class.  But consider what it would be like to play the game of Guess in reverse&#8230; bear with me, and I&#8217;ll try to explain.  Imagine that instead of randomly picking a number, the computer randomly picks &#8220;too high&#8221; or &#8220;too low&#8221; at each guess.  That is, the computer itself does not know the secret number, but discovers it with the guesser.  Can any number be written as a sequence of &#8220;too high&#8221; and &#8220;too low&#8221; statements?  Don&#8217;t worry if this <em>Bonus Assignment</em> makes no sense. But if you follow the gist, have fun thinking about it.  And welcome to the world of open-ended questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=1118</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crypt Program</title>
		<link>http://www.mrrives.com/Technology/?p=995</link>
		<comments>http://www.mrrives.com/Technology/?p=995#comments</comments>
		<pubDate>Wed, 27 Jun 2012 18:54:29 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=995</guid>
		<description><![CDATA[In my last post, I talked about an encryption scheme to add to a Twitter custom app. That&#8217;s great if you can write a custom app. If not, here is an EXE program that uses those functions. For the source &#8230; <a href="http://www.mrrives.com/Technology/?p=995">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In my last post, I talked about an encryption scheme to add to a Twitter custom app. That&#8217;s great if you can write a custom app.  If not, here is <a href="http://www.mrrives.com/crypt/crypt.exe">an EXE program</a> that uses those functions. </p>
<p>For the source code, <a href="http://www.mrrives.com/crypt/crypt.cs">click here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=995</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Encrypting My Thoughts by Encrypting Twitter Messages</title>
		<link>http://www.mrrives.com/Technology/?p=956</link>
		<comments>http://www.mrrives.com/Technology/?p=956#comments</comments>
		<pubDate>Tue, 26 Jun 2012 01:25:57 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=956</guid>
		<description><![CDATA[Twitter has become a kind of extension to my brain. And now, like a brain, my Twitter messages are only accessible to me. But it didn&#8217;t start this way. In the beginning, what I wrote on Twitter was a simple &#8230; <a href="http://www.mrrives.com/Technology/?p=956">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/digital-brain.jpg"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/digital-brain-300x179.jpg" alt="" title="digital-brain" width="300" height="179" class="alignleft size-medium wp-image-961" /></a>Twitter has become a kind of extension to my brain. And now, like a brain, my Twitter messages are only accessible to me. But it didn&#8217;t start this way. </p>
<p>In the beginning, what I wrote on Twitter was a simple index into my latest thoughts.  To the outside observer (and especially to the unsympathetic reader) the appearance of my thoughts appeared thoughtless.  I was accused of thoughtless thinking.  But I imagine that <em>thinking</em>, for many of us, would externally appear to be an undirected or thoughtless activity, and maybe my thinking is. Regardless, thinking is a mostly private affair, and when it was opened up to the world around me, it came off as a collection of unrelated and even crass ciphers. As I began to spread my thoughts, the offense spread.</p>
<p>I never thought that my Twitter account was just for me.  But I acted like it was, and so my thoughts were escaping my brain and making it into the wild, but I was thinking like they were still in my head.  </p>
<p>My rational was simple. I was writing sentences for the benefit of wanting to recall them later &#8212; they were for me to remember (and I still want that Twitter-benefit). But now I am using Twitter as my memories according to this new dictum: Not everything I want to remember do I want to share.  </p>
<p>Twitter has evolved for me.  First it was a noteworthy little place on the web, and I had an account.  Then I tied it to my cell phone and I could easily send messages and track ideas.  Then I tied it to my Facebook and I could update my Facebook from my cell phone. I had lots of friends and social media was good to me.  But then I wrote more things.  And then Twitter was not so good.  Soon, my social media was antisocial. So I deleted my Facebook, kicked everyone off of my Twitter account, pulled everything back, and made all my ideas hidden and private. </p>
<p>My Twitter-Cards are now held close; every madly-scribbled thought is a note to me, or a memo to myself.  These sentences live in my auxiliary storage&#8211;Twitter is an extension of my memory. But Twitter is different than normal memories; I can search these auxiliary sentences and go back to my thoughts and deliberately pick up where I left off in my thinking. My Twitter account is not just an index into my latest thoughts, but is a placeholder for a whole history of thoughts.</p>
<p>My previous mistake was that I was thinking too loudly.  </p>
<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/homer_brain.jpg"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/homer_brain.jpg" alt="" title="homer_brain" width="327" height="469" class="alignright size-full wp-image-959" /></a>Now I am thinking quietly.  I am not claiming to be profound (probably I need to encrypt my thoughts just to spare the world).  In fact, just as my thoughts are locked up behind my skull, my Twitter-Thoughts now live behind a mathematical barrier I thought up.</p>
<p>That&#8217;s the setup for the cryptography code I am about to show you.  Now that my Twitter is closed, I thought: What if some of these thoughts escape?  I write some pretty intense things that aren&#8217;t safe to share.  I still want to use up my 140 character space, but I want some encryption.  </p>
<p>I can now encrypt my Twitter comments. I wrote a simple encryption, nothing fancy, just enough to block the casual observer (especially if I leave my Twitter account up on a computer). </p>
<p>Here is the code for that (I had to sacrifice one character to pull this off &#8212; my encrypted tweets are thus limited to 139 characters, with one character marking the fact that it is encrypted):</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">
<span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// pw is optional.  If not supplied, we just return the plain text passed in.</span>
    <span class="rem">/// Encrypt the plain text, then add a "*" to the end of the string (indicating a encrypted string)</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="rem">/// &lt;param name="plain"&gt;&lt;/param&gt;</span>
    <span class="rem">/// &lt;param name="pw"&gt;&lt;/param&gt;</span>
    <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> enc(<span class="kwrd">string</span> plain, <span class="kwrd">string</span> pw)
    {
        <span class="kwrd">const</span> <span class="kwrd">byte</span> space = 32;
        <span class="kwrd">const</span> <span class="kwrd">int</span> elements = 126 - space;
        <span class="kwrd">string</span> res = plain;
        <span class="kwrd">if</span> (pw != <span class="kwrd">null</span> &amp;&amp; pw != <span class="kwrd">string</span>.Empty)
        {
            <span class="kwrd">byte</span>[] key = Encoding.ASCII.GetBytes(pw);
            <span class="kwrd">byte</span>[] data = Encoding.ASCII.GetBytes(plain);

            <span class="kwrd">int</span> k = 0;
            <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; data.Length; i++)
            {
                <span class="kwrd">int</span> e = data[i] - space;
                e = (e + key[k]) % elements;
                data[i] = Convert.ToByte(e);
                data[i] += space;
                k++;
                <span class="kwrd">if</span> (k &gt;= key.Length)
                    k = 0;
            }

            res = Encoding.ASCII.GetString(data) + <span class="str">"*"</span>;
        }
        <span class="kwrd">return</span> res;
    }
    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// Any string that ends in '*' is treated as encrypted.</span>
    <span class="rem">/// But we only decrypt it if you pass in a password (and, FYI, the '*' is not part of the encryption).</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="rem">/// &lt;param name="enc"&gt;&lt;/param&gt;</span>
    <span class="rem">/// &lt;param name="pw"&gt;&lt;/param&gt;</span>
    <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">string</span> dec(<span class="kwrd">string</span> enc, <span class="kwrd">string</span> pw)
    {
        <span class="kwrd">const</span> <span class="kwrd">byte</span> space = 32;
        <span class="kwrd">const</span> <span class="kwrd">int</span> elements = 126 - space;
        <span class="kwrd">string</span> res = enc;
        <span class="kwrd">if</span> (pw != <span class="kwrd">null</span> &amp;&amp; pw != <span class="kwrd">string</span>.Empty)
        {
            <span class="kwrd">if</span> (enc[enc.Length - 1] == <span class="str">'*'</span>)
            {
                <span class="kwrd">byte</span>[] key = Encoding.ASCII.GetBytes(pw);
                <span class="kwrd">byte</span>[] data = Encoding.ASCII.GetBytes(enc.Substring(0, enc.Length - 1));
                <span class="kwrd">int</span> k = 0;
                <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; data.Length; i++)
                {
                    <span class="kwrd">int</span> d = data[i] - space;
                    d = d - key[k];
                    while (d &lt; 0)
                        d += elements;
                    d = d % elements;
                    d += space;
                    data[i] = (<span class="kwrd">byte</span>)d;
                    k++;
                    <span class="kwrd">if</span> (k &gt;= key.Length)
                        k = 0;
                }
                res = Encoding.UTF8.GetString(data);
            }
        }
        <span class="kwrd">return</span> res;
    }
</pre>
<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/Twitter.png"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/Twitter-300x166.png" alt="" title="Twitter" width="300" height="166" class="alignleft size-medium wp-image-969" /></a>And here you see how these Twitter messages look when encoded. I map everything to the ASCII printable character set.  That&#8217;s important to know.  I don&#8217;t have to worry about hitting those reserved Twitter characters.  I also have it so that the encrypted text is as long as the plain text. Except for the one character that I sacrifice in order to notate that a message is encrypted (which I don&#8217;t have to do, but I have my reasons), I get to keep using Twitter as normal. </p>
<p>If you got this far, you may want to use this encryption for yourself.  In that case, you have some options.  The fastest and easiest option is to use my stand-alone crypt program [see my later article for <a href="http://www.mrrives.com/Technology/?p=995">download instructions</a>]. </p>
<p>Optionally, I have my own Twitter program I wrote. To use the encryption code I have offered here, you need to use this or some other custom Twitter software.  You can write your own (and add the above code to it), or you can use my free MicroSpeak140.  Click the following link to read more about <a href="http://www.mrrives.com/Technology/?p=824">MicroSpeak140</a> (where you can also get all the code).</p>
<p>Now think. And with encrypted Twitter, you can think quietly like you have always done.</p>
<p><strong>About the Method and the Encryption Strength</strong><br />
Someone who is acquainted with cryptographic methods may detect a weakness of what I have implemented. I will address that below, and I will give a fairly substantial defense. Yet, even if my defense is weak and my method is poor, let me set the context: I&#8217;m not trying to protect Fort Knox. My brain is not a vault of treasures.  I am not trying to encrypt government secrets. I just want a little bit of bone structure to encase some sensitive tissues.  My encryption scheme fits the bill. </p>
<p>Mine is a <a href="http://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher">Vigenere Cipher</a> (which, as you will read, is a improvement upon the older Caesar Cipher). The Vigenere method meets my five chief requirements: 1. Most obviously, I want to change the plain text (that is, I want to obscure the original message), 2. I want to use a password scheme so that each use gets different results based on the password, 3. I want to be able to use the same password to recover the plain text, 4. I want to obscure the frequencies of the English letters in the plain text, and finally, 5. As important as items 1 through 4, I want the encrypted text length to be the same or less than the length of the plain text (some encryption schemes yield an encrypted text that is longer than the plain text).</p>
<p>Now, we know that a Viegenre cipher is mathematically breakable if the key length is known and if your attacker is the NSA (or is a sufficiently motivated geek who is extremely patient and determined).  That is, someone would have to want your memories to try to crack them, and it would require some good effort on their part (the Twitter equivalent to being captured and interrogated).</p>
<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/cipherjpg.jpg"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/06/cipherjpg.jpg" alt="" title="cipherjpg" width="276" height="183" class="alignleft size-full wp-image-991" /></a>Ah, but, you can use a password that is the same length as the message you are encoding! After all, with Twitter, we are talking about messages not more than 140 characters long; we have a reasonable shot at picking memorable sentences as pass-phrases.  Furthermore, you can use any number of sentences as pass-phrases. That is, you don&#8217;t have to use the same password (or pass-phrase) for every single Tweet. And, at this point, using passwords that run the length of your message (which you could database), you have a nearly unbreakable cipher.</p>
<p>But that means if you forget your passwords, you lose your memories (the Twitter equivalent to Alzheimer&#8217;s).</p>
<p>If you still want something stronger, you can try an AES and encrypt a string so that it comes out equal length &#8212; for more on this subject, look <a href="http://www.codeproject.com/Articles/7546/A-CBC-Stream-Cipher-in-C-With-wrappers-for-two-ope">here</a>.  I did not take that route as I wasn&#8217;t that interested (nor sufficiently motivated), but with OpenSSL, these sorts of things are not so hard.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=956</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remote copy a file across an intranet that times-out</title>
		<link>http://www.mrrives.com/Technology/?p=953</link>
		<comments>http://www.mrrives.com/Technology/?p=953#comments</comments>
		<pubDate>Fri, 22 Jun 2012 01:39:19 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=953</guid>
		<description><![CDATA[If you have an intranet that times out part way through file copies, this program may be of use to you. This program keeps track of where it was in a file copy and will pick up where it left &#8230; <a href="http://www.mrrives.com/Technology/?p=953">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you have an intranet that times out part way through file copies, this program may be of use to you.  This program keeps track of where it was in a file copy and will pick up where it left off.</p>
<p><!-- code formatted by http://manoli.net/csharpformat/ --></p>
<pre class="csharpcode">
<span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> System.Linq;
<span class="kwrd">using</span> System.Text;
<span class="kwrd">using</span> System.IO;

<span class="kwrd">namespace</span> RCopy
{
    <span class="rem">/// &lt;summary&gt;</span>
    <span class="rem">/// Remote Copy a file on an IntraNet.</span>
    <span class="rem">/// &lt;/summary&gt;</span>
    <span class="kwrd">class</span> RCopy
    {
        <span class="rem">/// &lt;summary&gt;</span>
        <span class="rem">/// Copy a file starting at position.</span>
        <span class="rem">/// &lt;/summary&gt;</span>
        <span class="rem">/// &lt;param name="fname"&gt;&lt;/param&gt;</span>
        <span class="rem">/// &lt;param name="pos"&gt;Where to start copying,&lt;/param&gt;</span>
        <span class="rem">/// &lt;returns&gt;&lt;/returns&gt;</span>
        <span class="kwrd">static</span> <span class="kwrd">bool</span> Copy(FileStream fs, FileStream destination, <span class="kwrd">long</span> start, <span class="kwrd">out</span> <span class="kwrd">long</span> howFarWeMadeIt)
        {
            <span class="kwrd">bool</span> ret = <span class="kwrd">true</span>;
            howFarWeMadeIt = start;
            <span class="kwrd">try</span>
            {
                BinaryWriter w = <span class="kwrd">new</span> BinaryWriter(destination);
                BinaryReader r = <span class="kwrd">new</span> BinaryReader(fs);
                <span class="kwrd">long</span> length = r.BaseStream.Length;
                <span class="kwrd">if</span> (length &gt; start)
                {
                    r.BaseStream.Seek(start, SeekOrigin.Begin);
                    Console.WriteLine(<span class="str">"rem Starting at "</span> + start + <span class="str">" and going to "</span> + length);
                    while (howFarWeMadeIt &lt; length)
                    {
                        <span class="kwrd">byte</span>[] buffer = <span class="kwrd">new</span> <span class="kwrd">byte</span>[] { 0 };
                        r.BaseStream.Read(buffer, 0, 1);
                        w.BaseStream.Write(buffer, 0, 1);
                        howFarWeMadeIt++;
                    }
                }
                r.Close();
            }
            <span class="kwrd">catch</span>
            {
                ret = <span class="kwrd">false</span>;
            }

            <span class="kwrd">if</span> (fs != <span class="kwrd">null</span>)
                fs.Close();
            <span class="kwrd">return</span> ret;
        }
        <span class="kwrd">static</span> <span class="kwrd">int</span> Main(<span class="kwrd">string</span>[] args)
        {
            <span class="kwrd">if</span> (args.Length &lt; 2 || args.Length &gt; 3)
            {
                Console.WriteLine(<span class="str">"rem Usage: RCopy &lt;source&gt; &lt;destination&gt; [pos]"</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem        Remote Copy a source file off an intranet."</span>);
                Console.WriteLine(<span class="str">"rem               If your connection times-out while copying, you can call this program many times."</span>);
                Console.WriteLine(<span class="str">"rem               This program will pick up copying from the last position."</span>);
                Console.WriteLine(<span class="str">"rem               Pass in the position for how far the file copy got before it timed out."</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem        &lt;destination&gt; will be appended if [pos] is zero or not passed in."</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem        [pos] is a positive integer to start copying at the given offset"</span>);
                Console.WriteLine(<span class="str">"rem              Default value is zero."</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem        This program sets RCOPY to -1 if the copy failed;"</span>);
                Console.WriteLine(<span class="str">"rem        This program sets RCOPY to 0 if it has success;"</span>);
                Console.WriteLine(<span class="str">"rem        This program sets RCOPY to a positive number if got partially done."</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem        This program returns an errorlevel as well."</span>);
                Console.WriteLine(<span class="str">"rem             errorlevel 0 means the program is done or will not work."</span>);
                Console.WriteLine(<span class="str">"rem             errorlevel 1 means the program worked and has more work to do."</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine(<span class="str">"rem        This is slow program. It copies one byte at a time. It is not meant for speed."</span>);
                Console.WriteLine(<span class="str">"rem        It is meant to work on an unreliable network."</span>);
                Console.WriteLine(<span class="str">"rem"</span>);
                Console.WriteLine();
                Console.WriteLine(<span class="str">"set RCOPY=-1"</span>);
                <span class="kwrd">return</span> -1;
            }
            <span class="kwrd">long</span> start = 0;

            <span class="kwrd">if</span> (args.Length == 3)
            {
                <span class="kwrd">try</span>
                {
                    start = Convert.ToInt64(args[2]);
                }
                <span class="kwrd">catch</span>
                {
                    Console.WriteLine(<span class="str">"rem Invalid integer value: "</span> + args[2]);
                    Console.WriteLine(<span class="str">"set RCOPY=-1"</span>);
                    <span class="kwrd">return</span> 0;
                }
            }


            FileStream dest = <span class="kwrd">null</span>;
            <span class="kwrd">try</span>
            {
                <span class="kwrd">if</span> (start == 0)
                    dest = File.Open(args[1], FileMode.Create);
                <span class="kwrd">else</span>
                    dest = File.Open(args[1], FileMode.Append);
            }
            <span class="kwrd">catch</span>
            {
                Console.WriteLine(<span class="str">"rem Error: Could not write to "</span> + args[1]);
                Console.WriteLine(<span class="str">"set RCOPY=-1"</span>);
                <span class="kwrd">return</span> 0;
            }

            FileStream source = <span class="kwrd">null</span>;
            Console.WriteLine(<span class="str">"rem Reading "</span> + args[0] + <span class="str">" starting at "</span> + start);
            <span class="kwrd">try</span>
            {
                source = File.Open(args[0], FileMode.Open);
            }
            <span class="kwrd">catch</span>
            {
                Console.WriteLine(<span class="str">"rem Could not open "</span> + args[0]);
                Console.WriteLine(<span class="str">"set RCOPY=-1"</span>);
            }

            <span class="kwrd">long</span> pos = 0;
            while (!Copy(source, dest, start, <span class="kwrd">out</span> pos))
            {
                start = pos;
                <span class="kwrd">bool</span> bail = <span class="kwrd">false</span>;
                <span class="kwrd">try</span>
                {
                    source.Close();
                    source = File.Open(args[0], FileMode.Open);
                }
                <span class="kwrd">catch</span>
                {
                    bail = <span class="kwrd">true</span>;
                }
                <span class="kwrd">if</span> (bail)
                {
                    Console.WriteLine(<span class="str">"rem Call this program again: rcopy "</span> + args[0] + <span class="str">" %RCOPY% "</span>);
                    Console.WriteLine(<span class="str">"set RCOPY="</span> + start);
                    dest.Close();
                    <span class="kwrd">return</span> 1;
                }
            }
            <span class="kwrd">try</span>
            {
                source.Close();
                dest.Close();
            }
            <span class="kwrd">catch</span>
            {
                Console.WriteLine(<span class="str">"rem Closed files."</span>);
            }
            Console.WriteLine(<span class="str">"rem Success"</span>);
            Console.WriteLine(<span class="str">"set RCOPY=0"</span>);

            <span class="kwrd">return</span> 0;
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=953</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chris Keck, d. March 22, 2012</title>
		<link>http://www.mrrives.com/Technology/?p=932</link>
		<comments>http://www.mrrives.com/Technology/?p=932#comments</comments>
		<pubDate>Thu, 22 Mar 2012 19:50:23 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[Philosophy]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=932</guid>
		<description><![CDATA[KANSAS CITY, Kan. &#8211; A wrong-way crash killed one man during morning rush hour in Kansas City, Kan. The Kansas Highway Patrol identified the victim as Christopher T. Keck, 45, of Gardner, Kan. The crash occurred about 8:45 a.m. in &#8230; <a href="http://www.mrrives.com/Technology/?p=932">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/ChrisKeck.png"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/ChrisKeck.png" alt="" title="ChrisKeck" width="320" height="180" class="alignleft size-full wp-image-933" /></a> <strong>KANSAS CITY, Kan.</strong> &#8211; A wrong-way crash killed one man during morning rush hour in Kansas City, Kan.</p>
<p>The Kansas Highway Patrol identified the victim as Christopher T. Keck, 45, of Gardner, Kan.</p>
<p>The crash occurred about 8:45 a.m. in a northbound lane of Interstate 635 just north of Interstate 70.</p>
<p>Keck was traveling north when his car was hit head-on by a vehicle headed the wrong way on the interstate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=932</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t be an Anode. Protect your Cathode.</title>
		<link>http://www.mrrives.com/Technology/?p=924</link>
		<comments>http://www.mrrives.com/Technology/?p=924#comments</comments>
		<pubDate>Wed, 14 Mar 2012 21:02:50 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=924</guid>
		<description><![CDATA[A good rule of thumb if you are a pipe, &#8220;Don&#8217;t be an anode when you can be the cathode.&#8221; Three useful articles on Cathodic Protection: http://www.npl.co.uk/upload/pdf/cathodic_protection.pdf http://www.sescocp.com/tutorial.php http://www.corrosionsource.com/%28S%28cylzjm45pkvkle45ywzhvn55%29%29/FreeContent/1/Cathodic+Protection]]></description>
				<content:encoded><![CDATA[<p>A good rule of thumb if you are a pipe, &#8220;Don&#8217;t be an anode when you can be the cathode.&#8221;</p>
<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/anode.gif"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/anode.gif" alt="" title="anode" width="498" height="372" class="aligncenter size-full wp-image-927" /></a></p>
<p>Three useful articles on <em>Cathodic Protection</em>:</p>
<p><a href="http://www.npl.co.uk/upload/pdf/cathodic_protection.pdf">http://www.npl.co.uk/upload/pdf/cathodic_protection.pdf</a><br />
<a href="http://www.sescocp.com/tutorial.php">http://www.sescocp.com/tutorial.php</a><br />
<a href="http://www.corrosionsource.com/%28S%28cylzjm45pkvkle45ywzhvn55%29%29/FreeContent/1/Cathodic+Protection">http://www.corrosionsource.com/%28S%28cylzjm45pkvkle45ywzhvn55%29%29/FreeContent/1/Cathodic+Protection</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=924</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to deploy a new MVC 4 or MVC 5 app to and older IIS 6 server</title>
		<link>http://www.mrrives.com/Technology/?p=909</link>
		<comments>http://www.mrrives.com/Technology/?p=909#comments</comments>
		<pubDate>Sat, 10 Mar 2012 04:39:04 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=909</guid>
		<description><![CDATA[You can install newer MVC apps on an older Windows 2003 server (it can be done very easily). You must simply configure your Web.Config with a few settings (as shown below) and you may need to go into the Windows &#8230; <a href="http://www.mrrives.com/Technology/?p=909">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>You can install newer MVC apps on an older Windows 2003 server (it can be done very easily). You must simply configure your Web.Config with a few settings (as shown below) and you may need to go into the Windows file explorer and grant the correct rights to your web user for the path you install to.  Ignore the bit about the ASP.NET user (that&#8217;s for something unrelated to what I am showing you here):</p>
<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/WebConfig.gif"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/WebConfig.gif" alt="" title="WebConfig" width="621" height="331" class="aligncenter size-full wp-image-910" /></a></p>
<p>Notice I added customErrors with the value, mode=&#8221;Off&#8221; and I added a whole section called system.codedom section.</p>
<p>You will also need to configure your project by right clicking on your project, and selecting &#8220;Add Deployable Dependencies&#8230;&#8221; and then check all the boxes in the dialog that follows.</p>
<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/AddDeploy.gif"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2012/03/AddDeploy.gif" alt="" title="AddDeploy" width="329" height="783" class="aligncenter size-full wp-image-911" /></a></p>
<p>Then, highlight and select all the references in your new _bin_deployableAssemblies and set the properties for all of the to either &#8220;Copy always&#8221; or &#8220;Copy if newer&#8221;</p>
<p>Finally, make sure that Global.asax is added to the list of files you can access.  This is done under IIS under the Virtual directory you care about (where you installed your web site) or under the web site itself. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=909</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming by existence</title>
		<link>http://www.mrrives.com/Technology/?p=874</link>
		<comments>http://www.mrrives.com/Technology/?p=874#comments</comments>
		<pubDate>Fri, 02 Mar 2012 14:24:05 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=874</guid>
		<description><![CDATA[If something is there, it has existence. In C# this makes all the difference. I realized this morning that I don&#8217;t wire-up relationships, but the C# MVC system works on the basis of mere existence. If a filename with a &#8230; <a href="http://www.mrrives.com/Technology/?p=874">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If something is there, it has existence.</p>
<p>In C# this makes all the difference. I realized this morning that I don&#8217;t wire-up relationships, but the C# MVC system works on the basis of mere existence.  </p>
<p>If a filename with a certain name exists, it is accessed by a controller.  In the Data Entity Model, the existence of a table name is mapped to a class name.  By existence. I don&#8217;t tell the C# system what to associate with what.  I just create the item, and its existence makes it alive.</p>
<p>C# MVC programming is programming by existence. </p>
<p>It is also programming by name.  When something exists, it must be named (a file name, a class name, a property name, etc.).  If it exists, its name is how it relates to the system.</p>
<p>C# MVC programming is programming by existence with right naming.</p>
<p>This is eloquent.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=874</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VS 2010 Intellisense for JQuery in C# Razor (cshtml) Files not working</title>
		<link>http://www.mrrives.com/Technology/?p=868</link>
		<comments>http://www.mrrives.com/Technology/?p=868#comments</comments>
		<pubDate>Fri, 17 Feb 2012 21:15:45 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=868</guid>
		<description><![CDATA[If you know what the title of this blog means, then you are looking for this: @if (false) {&#60;script type="text/javascript" src="../../Scripts/jquery-1.6.2-vsdoc.js"&#62;&#60;/script&#62;} Put this before your jquery include.]]></description>
				<content:encoded><![CDATA[<p>If you know what the title of this blog means, then you are looking for this:</p>
<pre>
@if (false) {&lt;script type="text/javascript" src="../../Scripts/jquery-1.6.2-vsdoc.js"&gt;&lt;/script&gt;}
</pre>
<p>Put this before your jquery include.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=868</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Edit .CMD files with Visual Studio Editor</title>
		<link>http://www.mrrives.com/Technology/?p=856</link>
		<comments>http://www.mrrives.com/Technology/?p=856#comments</comments>
		<pubDate>Tue, 29 Nov 2011 17:00:58 +0000</pubDate>
		<dc:creator>Steve Rives</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.mrrives.com/Technology/?p=856</guid>
		<description><![CDATA[Do you use Visual Studio to edit Windows batch files? Do you want these .bat or .cmd files to show up with all the colors you see in your C# files? If this is what you seek, then let me &#8230; <a href="http://www.mrrives.com/Technology/?p=856">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Do you use Visual Studio to edit Windows batch files? Do you want these .bat or .cmd files to show up with all the colors you see in your C# files?</p>
<p><a href="http://www.mrrives.com/Technology/wp-content/uploads/2011/11/Cmd.jpg"><img src="http://www.mrrives.com/Technology/wp-content/uploads/2011/11/Cmd.jpg" alt="" title="Cmd in Visual Studio" width="700" height="456" class="aligncenter size-full wp-image-857" /></a></p>
<p>If this is what you seek, then let me point you to the TextHighlighterExtensionSetup by Frederic Torres (you can use Visual Studio, Tools->Extension Manager to obtain it, or do the following steps).</p>
<p><strong>Step 1:</strong> Install the Iron Python 2.6 or greater (for .NET 4). It was a one or two click install, I didn&#8217;t change any settings, it just worked. Try this link: <a href="http://ironpython.codeplex.com/releases/view/41236#DownloadId=159515">http://ironpython.codeplex.com/releases/view/41236#DownloadId=159515</a> or get 2.7 here:<a href="http://ironpython.codeplex.com/releases/view/62475"> http://ironpython.codeplex.com/releases/view/62475</a>.  If the link is no good, just go to <a href="http://ironpython.codeplex.com/">Iron Python</a>, click on the Download menu, and get the latest download.</p>
<p><strong>Step 2:</strong> Get and install the .CMD extension itself: <a href="http://visualstudiogallery.msdn.microsoft.com/6706b602-6f10-4fd1-8e14-75840f855569">http://visualstudiogallery.msdn.microsoft.com/6706b602-6f10-4fd1-8e14-75840f855569</a>  If this link dos not work, go to the <a href="http://visualstudiogallery.msdn.microsoft.com/">Visual Studio Gallery</a> and search for TextHighlighterExtensionSetup (note, there are a few search boxes, make sure to use the one that searches the extensions). </p>
<p>For another useful extension, see also Spell Checker which adds the little red underline to misspelled words in comments. Very nice.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mrrives.com/Technology/?feed=rss2&#038;p=856</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
