<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Dave Zych]]></title><description><![CDATA[I make developers' lives easier]]></description><link>https://davidzych.com/</link><image><url>https://davidzych.com/favicon.png</url><title>Dave Zych</title><link>https://davidzych.com/</link></image><generator>Ghost 5.26</generator><lastBuildDate>Wed, 22 Apr 2026 03:38:31 GMT</lastBuildDate><atom:link href="https://davidzych.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[A Brief History of QWERTY]]></title><description><![CDATA[Qwerty is the default layout for most keyboards. But where did qwerty come from?]]></description><link>https://davidzych.com/a-brief-history-of-qwerty/</link><guid isPermaLink="false">61ef458c99dc1746fffcb17a</guid><category><![CDATA[qwerty]]></category><category><![CDATA[keyboard]]></category><category><![CDATA[history]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Thu, 16 Apr 2020 23:04:50 GMT</pubDate><media:content url="https://davidzych.com/content/images/2020/04/qwerty.jpeg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2020/04/qwerty.jpeg" alt="A Brief History of QWERTY"><p>Qwerty is the default keyboard layout for most, if not all computers.<a href="#asterisk1">*</a> It&apos;s what is taught in schools, in the workplace and what every computer user knows. But... why Qwerty?</p>
<h2 id="abriefhistoryofthetypingmachine">A brief history of the typing machine</h2>
<h3 id="itallstartedin1829">It all started in 1829...</h3>
<p>Sort of. The <a href="http://www.uspto.gov/">United States Patent Office</a> lists William Austin Burt&apos;s <em>Typographer</em> as</p>
<blockquote>
<p>the actual construction of a type writing machine for the first time in any country</p>
</blockquote>
<p>which probably means</p>
<blockquote>
<p>Mr. Burt paid us money to say he invented the typewriter even though some dudes in Europe made one first</p>
</blockquote>
<p>or something like that but whatever<a href="#asterisk2">**</a>. What he invented (<a href="https://patents.google.com/patent/USX5581">and got a patent for</a>) was this:</p>
<img src="https://davidzych.com/content/images/2015/10/1_Typographer_patent_1829.jpg" width="200" alt="A Brief History of QWERTY">
<p>Yes, this god-awful looking pinball wannabe<a href="#asterisk3">***</a> was the first typing device. It wasn&apos;t even a typewriter in the sense that you could &quot;type&quot; on it. It was operated by turning a crank until the desired letter came up and then pulling a lever to imprint it onto the page. It was actually slower than handwriting the message. But back then it was technology, damnit, and <a href="https://www.youtube.com/watch?v=IDDdZ1VzoxQ">complicated, slow, ridiculous processes are what nerds like us live for.</a></p>
<h3 id="18291864">1829 - 1864</h3>
<p>Some people invented some new versions of the typographer, all of them sucked and none are worth talking about.</p>
<h3 id="allhailthewritingball">All hail the Writing Ball</h3>
<p>In 1865 a man by the name of Rasmus Malling-Hansen invented the <strong>Hansen Writing Ball</strong>. This is the first device that actually <em>increased</em> typing speed and, you know, actually made sense to use.</p>
<img src="https://davidzych.com/content/images/2015/10/2_220px-Skrivekugle_1870.jpg" width="200" alt="A Brief History of QWERTY">
<p>It was also the first commercially produced typewriter, though it never actually took off. The keys were aligned on a brass hemisphere and they were pushed through the ball directly onto the paper which printed the letter. The paper was attached to a cylinder that spun as you typed.</p>
<p>Hansen produced numerous protoypes of his machine out of porcelain to experiment with the location and arrangement of the keys. He ended up placing the most frequently used letters near the fastest writing fingers, and aligned most of the vowels on the left and consonants on the right. It was said that with this configuration and enough practice you could write up to <a href="http://type-writer.org/?p=4081">five times that of ordinary writing.</a> You can see a computer rendering of the functionality here:</p>
<iframe src="https://player.vimeo.com/video/43124993" width="500" height="375" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<h3 id="thehansenwritingballsucksallhailtheremingtonno1">The Hansen Writing Ball sucks, all hail the Remington No. 1</h3>
<p>3 years after Malling-Hansen invented his Writing Ball, a man named Christopher Latham Sholes, along with help from Carlos Glidden and Sam Soule, invented the typewriter in similar fashion to what we know them as today. This machine had a lot of different inventors, constructors and funders, and suffice it to say, the story of it&apos;s invention is complicated, with <a href="https://www.youtube.com/watch?v=Jw36ivnRHRQ">a lot of ins and a lot of outs.</a> It went something like this:</p>
<h4 id="1866creation">1866 - Creation</h4>
<p>Sholes, who was a printer, began creating a machine that printed page numbers in books. He began designing the machine with the help of Sam Soule in a factory in Wisconsin. They met Carlos Glidden, and when he saw what they were working on he said (I&apos;m paraphrasing here) &quot;Well, so, you can print numbers, so, like, why not just add some letters.&quot; My assumption here is that Sholes and Soule probably stood there for a minute with blank expressions on their faces, both feeling like idiots. But again, that&apos;s just an assumption.</p>
<p>They took Glidden&apos;s idea and ran with it and began creating prototypes of alphabet writing machine. The first prototype of the typewriter printed a single letter, &apos;W&apos;, the key for which was taken from a telegraph machine. Sufficiently satisfied that the &apos;W&apos; printing machine was a success, they began working on a prototype with a full alphabet, and by the Fall of 1867 they had a working version of a typewriter.</p>
<p>They used this prototype to compose letters to friends, family and investors to help acquire funds to manufacture the device. How meta of them.</p>
<h4 id="1868patentandmanufacturing">1868 - Patent and manufacturing</h4>
<p>One of the men they sent a letter to was James Densmore, and he immediately purchased a 25% stake in the product having never seeing it in person nor knowing the total cost of his stake. When he did finally see the machine in 1868, he said (again, paraphrasing) &quot;this thing sucks&quot; and urged the 3 of them to iterate on the design.</p>
<p>Apparently Densmore hurt Soule and Glidden&apos;s feelings because they both left the project, leaving only Sholes and Densmore to perfect it.</p>
<h4 id="iterationsandfeedback">Iterations and feedback</h4>
<p>Densmore and Sholes iterated on the design, producing around 30 different variations. Most of these variations were attempts to reduce friction and increase speed. This was a huge concern of theirs because they assumed stenographers would be the main users of this machine.</p>
<p>They started sending prototypes out to stenographers, one of whom was named James Clephane. Clephane was very critical of the device and offered tons of feedback. Whether it was constructive or not depends on who you ask. Sholes was not a fan, and after hearing some of the criticism, he exclaimed</p>
<blockquote>
<p>I am through with Clephane!</p>
</blockquote>
<p>and got very angry. Densmore, however, was level headed, and saw the criticism as an important piece to a good product and told Sholes that</p>
<blockquote>
<p>We had better have it now than after we begin manufacturing.</p>
</blockquote>
<p>It was after Clephane&apos;s feedback that Sholes and Densmore decided to seek an expert mechanic to help them fine tune their design. They invited George Yost to their shop, and Yost thoroughly inspected the machine and offered several changes. After a few more iterations, Yost told Sholes and Densmore that they then needed precision manufacturing; he told them to take their machine to Eliphalet Remington &amp; Sons.</p>
<h4 id="remington">Remington</h4>
<p>Remington at that time was best known for manufacturing firearms. Their shop in New York had the best machines and equipment (well, as good as you could get in the late 1800&apos;s) and had the accuracy to manufacture parts within 1000th of an inch.</p>
<p>In early 1873 Sholes and Densmore took their machine to Remington and pitched it to the company. The Remingtons were so impressed with the machine that they bought the patent from Sholes and Densmore. Sholes took his money in a lump sum of $12,000<a href="#asterisk4">****</a>, whereas Densmore took a royalty; legend has it he made $1.5 million from it. Live and learn I guess.</p>
<p>Remington began manufacturing around September of 1873, and the typewriter went on sale July 1, 1874.</p>
<h4 id="remingtonno2">Remington No. 2</h4>
<img src="https://davidzych.com/content/images/2015/10/SAM_2195_clipped_rev_1-1.png" width="400" alt="A Brief History of QWERTY">
Sales of the Remington No. 1 were rather poor - by December of 1874 only around 400 typewriters had been sold. This is in part because businesses were slow to adopt the machine, but also it was too expensive for a family to purchase.
<p>Remington iterated again and released an improved model, aptly named the Remington No. 2, in 1878.  This machine was the first that had the ability to type upper and lowercase characters via a shift key.</p>
<h4 id="qwerty">QWERTY</h4>
<p>Now seems like a good time to mention how QWERTY came to be. The original key layout that Sholes implemented was laid out like a piano, with 2 rows of keys:</p>
<pre><code> 3 5 7 9 N O P Q R S T U V W X Y Z
2 4 6 8 . A B C D E F G H I J K L M
</code></pre>
<p>The numbers &quot;0&quot; and &quot;1&quot; were not included because &quot;O&quot; and &quot;I&quot; were deemed sufficient. Densmore suggested splitting up commonly used letters in order to improve typing speed and fix an issue they were having related to the keys jamming due to common letters being hit in succession. They iterated on the key layout and came up with the beginnings of what we now call the QWERTY layout:</p>
<pre><code>  2 3 4 5 6 7 8 9 - 
   A E I . ? Y U O ,
B C D F G H J K L M
Z X W V T S R Q P N
</code></pre>
<p>After Remington purchased the manufacturing rights they further iterated on the design, and within a few months came up with the modern QWERTY layout. It is claimed that they finalized this layout due to the fact that you could type <code>TYPE WRITER QUOTE</code> from one keyboard row, which was apparently a sales pitch.</p>
<h4 id="ibm">IBM</h4>
<p>The typewriter, for the most part, stayed the same for the next 80 years or so until IBM introduced the IBM Selectric in 1961. It was an immediate hit, with total orders exceeding 80,000 by the end of the year.</p>
<p>The reason for the success was some smart innovation that drastically increased productivity:</p>
<blockquote>
<p>At the physical heart of the Selectric typewriter&#x2019;s innovation was a golf-ball-shaped type head that replaced the conventional typewriter&#x2019;s basket of type bars. The design eliminated the bane of rapid typing: jammed type bars. And with no bars to jam, typists&#x2019; speed and productivity soared.</p>
</blockquote>
<img src="https://davidzych.com/content/images/2020/04/ibm-selectric-ball.jpg" width="400" alt="A Brief History of QWERTY">
<p>The Selectric was also modified to be one of the first keyboard interface devices to a computer. This modified version, named the IBM 2741 Terminal, plugged into the IBM System/360 and allowed much easier interaction with a computer by a much wider audience.</p>
<p>And that&apos;s how the keyboard was born.</p>
<h2 id="themoraleofthisstoryis">The morale of this story is</h2>
<p>we use qwerty because some dude back in the late 1800s thought it was cool that you could type <code>TYPE WRITER QUOTE</code> with one hand.</p>
<hr>
<h3 id="notes">Notes</h3>
<p>*<a name="asterisk1"></a> Two big ones are Dvorak and Colemak, <a href="https://en.wikipedia.org/wiki/Keyboard_layout">among others.</a> <a href="javascript:history.back()">&#x21B0;</a><br>
**<a name="asterisk2"></a> A man named Pellegrino Turri made one in Italy in 1808 which is why the patent is sort of lying. <a href="javascript:history.back()">&#x21B0;</a><br>
***<a name="asterisk3"></a> I imagine it with a Jurassic Park skin. <a href="javascript:history.back()">&#x21B0;</a><br>
****<a name="asterisk4"></a> Probably went straight to Vegas. <a href="javascript:history.back()">&#x21B0;</a></p>
<h3 id="references">References</h3>
<p>[1] <a href="https://archive.org/details/leadingamericani00ilesrich/page/n375/mode/2up">https://archive.org/details/leadingamericani00ilesrich/page/n375/mode/2up</a><br>
[3] <a href="https://en.wikipedia.org/wiki/Christopher_Latham_Sholes">https://en.wikipedia.org/wiki/Christopher_Latham_Sholes</a><br>
[4] <a href="https://en.wikipedia.org/wiki/QWERTY">https://en.wikipedia.org/wiki/QWERTY</a><br>
[5] <a href="https://en.wikipedia.org/wiki/Typewriter">https://en.wikipedia.org/wiki/Typewriter</a><br>
[6] <a href="https://www.ibm.com/ibm/history/ibm100/us/en/icons/selectric/">https://www.ibm.com/ibm/history/ibm100/us/en/icons/selectric/</a><br>
[7] <a href="https://en.wikipedia.org/wiki/IBM_2741">https://en.wikipedia.org/wiki/IBM_2741</a><br>
[8] <a href="https://books.google.com/books?id=WCuSUufRewoC&amp;pg=PA222&amp;dq=pellegrino+turri+typewriter&amp;hl=en&amp;sa=X&amp;ei=84OvU4ztE8m-uATm5oCYDw&amp;redir_esc=y#v=onepage&amp;q=pellegrino%20turri%20typewriter&amp;f=false">https://books.google.com/books?id=WCuSUufRewoC&amp;pg=PA222&amp;dq=pellegrino+turri+typewriter&amp;hl=en&amp;sa=X&amp;ei=84OvU4ztE8m-uATm5oCYDw&amp;redir_esc=y#v=onepage&amp;q=pellegrino turri typewriter&amp;f=false</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Science is always better if you work together]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>If you read my previous post, <a href="https://davidzych.com/introducing-shience-what-it-is-and-how-to-use-it/">Introducing Shience: What it is and how to use it</a>, you&apos;ll know that I was working on a C# port of Github&apos;s <a href="https://github.com/github/scientist">Scientist</a> library.</p>
<p>It turns out <a href="http://haacked.com/">Phil Haack</a> of Github/Microsoft/Blogging fame is <a href="https://github.com/Haacked/Scientist.net">working on a port as</a></p>]]></description><link>https://davidzych.com/science-is-always-better-if-you-work-together/</link><guid isPermaLink="false">61ef458c99dc1746fffcb181</guid><category><![CDATA[github]]></category><category><![CDATA[Shience]]></category><category><![CDATA[Scientist]]></category><category><![CDATA[Scientist.Net]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Wed, 16 Mar 2016 17:36:41 GMT</pubDate><media:content url="https://davidzych.com/content/images/2016/03/super-science-friends.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2016/03/super-science-friends.jpg" alt="Science is always better if you work together"><p>If you read my previous post, <a href="https://davidzych.com/introducing-shience-what-it-is-and-how-to-use-it/">Introducing Shience: What it is and how to use it</a>, you&apos;ll know that I was working on a C# port of Github&apos;s <a href="https://github.com/github/scientist">Scientist</a> library.</p>
<p>It turns out <a href="http://haacked.com/">Phil Haack</a> of Github/Microsoft/Blogging fame is <a href="https://github.com/Haacked/Scientist.net">working on a port as well</a>, which will become the official Github port once it&apos;s sufficiently implemented.</p>
<p>After some thought, and a <a href="http://haacked.com/archive/2016/01/20/scientist/#comment-2518294972">brief discussion with Phil</a>, I decided to deprecate my library and migrate my efforts over to Phil&apos;s <a href="https://github.com/Haacked/Scientist.net">Scientist.Net</a> port. I didn&apos;t see a need to maintain two separate libraries that performed, for the most part, the exact same function.</p>
<p>So, if you&apos;re interested in performing science, or contributing to the effort, head over to <a href="https://github.com/Haacked/Scientist.net">https://github.com/Haacked/Scientist.net</a>.</p>
<p>RIP Shience.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Introducing Shience: What it is and how to use it]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Shience is a .NET library for carefully refactoring critical paths. It is built on .NET Core, currently targets .NET 4.5.1 and DNX Core 5.0, and is available on <a href="https://github.com/davezych/shience">Github</a> and <a href="https://www.nuget.org/packages/shience/">Nuget</a>.</p>
<p>Keep in mind that it&apos;s early, and the API is subject to change.</p>
<h1 id="whatisacriticalpath">What</h1>]]></description><link>https://davidzych.com/introducing-shience-what-it-is-and-how-to-use-it/</link><guid isPermaLink="false">61ef458c99dc1746fffcb180</guid><category><![CDATA[github]]></category><category><![CDATA[Shience]]></category><category><![CDATA[Scientist]]></category><category><![CDATA[refactor]]></category><category><![CDATA[critical path]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Mon, 22 Feb 2016 19:35:24 GMT</pubDate><media:content url="https://davidzych.com/content/images/2016/02/microscope.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2016/02/microscope.png" alt="Introducing Shience: What it is and how to use it"><p>Shience is a .NET library for carefully refactoring critical paths. It is built on .NET Core, currently targets .NET 4.5.1 and DNX Core 5.0, and is available on <a href="https://github.com/davezych/shience">Github</a> and <a href="https://www.nuget.org/packages/shience/">Nuget</a>.</p>
<p>Keep in mind that it&apos;s early, and the API is subject to change.</p>
<h1 id="whatisacriticalpath">What is a critical path?</h1>
<p>A critical path is a section of code that is not only important, but critically important to the functionality of your application. Good examples are  permission checking, transactions in bank software, or <a href="http://githubengineering.com/move-fast/">pull request merges at Github.</a></p>
<p>These sections of code are often the code that gets ignored. Not because they&apos;re not important, but rather that they&apos;re <em>too</em> important. If you&apos;re maintaining an application for bank transactions, you want to be absolutely sure the code that deducts money from an account calculates the deduction accurately and consistenly - no rounding errors, no overflows, no issues. The code is so critical that developers are often afraid to touch it. If no one touches it, no performance enhancements can be implemented and any previous technical debt will never be never paid off.</p>
<h1 id="whyisshienceneeded">Why is Shience needed?</h1>
<p>Development testing and QA are good first steps towards ensuring quality of your code, but as all developers know bugs can easily fall through. This is why unit tests are created.</p>
<p>And unit tests are great. They help drive the develoment process and find bugs, and help in refactorings, but they don&apos;t cover all test cases. They <em>can&apos;t</em> cover all test cases. And when refactoring critical code, you need to make sure there are no regressions. But how do you do that if you can&apos;t cover all test cases?</p>
<p>What if you could run the code side by side and compare the results? This is what Shience does, and it does it, in production, on real world data.</p>
<p>The Github post I linked above is a great case study on why this can be so helpful. They wanted to refactor pull request merges, but it is physically impossible to not only write enough tests to cover all cases, but test it on enough repositories to ensure no regressions were added. The ability to run both merges together, in production, on real repositories, on <em>all</em> requests allowed them to be 100% confident in their refactor. Which, on an application with millions of users, is a huge, huge deal.</p>
<h1 id="howdoiuseit">How do I use it?</h1>
<p>Grab the latest on <a href="https://www.nuget.org/packages/shience/">Nuget</a>, of course. The latest version is <code>0.0.1-beta5</code>, but we are releasing rather quickly so by the time anyone reads this it might be out of date.</p>
<p>The <a href="https://github.com/davezych/shience/blob/master/readme.md">readme</a> has plenty of examples, but here&apos;s a quick starter.</p>
<pre><code>var experiment = Science.New&lt;bool&gt;(&quot;my-test-code&quot;);
var result = experiment.Test(() =&gt; FirstMethod(),
                             () =&gt; SecondMethod())
                       .PublishTo((e) =&gt; Console.WriteLine(e.Matched))
                       .Execute();
</code></pre>
<p>Shience will run both the Test methods (the first is the control, the second is the candidate) in a random order. It will record the results in an <code>ExperimentResult</code> and provide that to you in the <code>PublishTo</code> method, and will then return the result of the control method.</p>
<h1 id="whenis10">When is 1.0?</h1>
<p>I don&apos;t know, but we&apos;re moving fast. We should get to 1.0 by the time Episode 8 is out at least.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Setting up SSL with Lets Encrypt on Ubuntu and Nginx]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Let&apos;s Encrypt entered public beta recently. What is <a href="https://letsencrypt.org/">Let&apos;s Encrypt</a>?</p>
<blockquote>
<p>Let&#x2019;s Encrypt is a free, automated, and open certificate authority (CA), run for the public&#x2019;s benefit. Let&#x2019;s Encrypt is a service provided by the Internet Security Research Group (ISRG).</p>
</blockquote>
<p>So,</p>]]></description><link>https://davidzych.com/setting-up-ssl-with-lets-encrypt-on-ubuntu-and-nginx/</link><guid isPermaLink="false">61ef458c99dc1746fffcb17f</guid><category><![CDATA[ubuntu]]></category><category><![CDATA[ghost]]></category><category><![CDATA[nginx]]></category><category><![CDATA[letsencrypt]]></category><category><![CDATA[ssl]]></category><category><![CDATA[digital ocean]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Thu, 10 Dec 2015 20:37:40 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/12/letsencrypt.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/12/letsencrypt.png" alt="Setting up SSL with Lets Encrypt on Ubuntu and Nginx"><p>Let&apos;s Encrypt entered public beta recently. What is <a href="https://letsencrypt.org/">Let&apos;s Encrypt</a>?</p>
<blockquote>
<p>Let&#x2019;s Encrypt is a free, automated, and open certificate authority (CA), run for the public&#x2019;s benefit. Let&#x2019;s Encrypt is a service provided by the Internet Security Research Group (ISRG).</p>
</blockquote>
<p>So, basically, free https. Yay! &#x1F64C;</p>
<p>Here&apos;s how to set it up on Nginx.</p>
<h2 id="clonetherepository">Clone the repository</h2>
<pre><code>git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
</code></pre>
<p>If you don&apos;t have <code>git</code> installed, <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git#Installing-on-Linux">get it using <code>apt-get</code></a>.</p>
<h2 id="obtainthecertificate">Obtain the certificate</h2>
<h4 id="stopnginx">Stop Nginx</h4>
<pre><code>sudo service nginx stop
</code></pre>
<h4 id="runtheautoconfigurationmanually">Run the auto configuration manually</h4>
<p>The auto configuration utility for Nginx isn&apos;t set up yet (<a href="https://letsencrypt.readthedocs.org/en/latest/using.html#nginx">but should be soon!</a>) so you can&apos;t just run <code>letsencrypt-auto</code>, which is a bit of a bummer, but really the current steps aren&apos;t very hard. Run this:</p>
<pre><code>./letsencrypt-auto --agree-dev-preview --server https://acme-v01.api.letsencrypt.org/directory auth
</code></pre>
<p>This starts the pretty interface that tells you to read the terms and other obligatory junk. Accept that and enter your domain(s) when it tells you to. Specify with and without <code>www</code> if you want to.</p>
<p>After completion, it will tell you where your certs are stored, which should be:</p>
<pre><code>/etc/letsencrypt/live/www.yourdomain.com/
</code></pre>
<p>Within that directory should live some files, the 2 important ones being <code>fullchain.pem</code> and <code>privkey.pem</code> which will be used below.</p>
<h2 id="setupthecertsinnginx">Set up the certs in Nginx</h2>
<p>Now edit your nginx config to tell it to use SSL and where the certs are. Your nginx config should either be in <code>/etc/nginx/nginx.conf</code> or in an external file in <code>/etc/nginx/sites-enabled/</code>. Mine was in <code>sites-enabled</code> in a file named <code>ghost</code> (e.g. <code>/etc/nginx/sites-enabled/ghost</code>).</p>
<h4 id="tellittouseport443">Tell it to use port 443</h4>
<p>Within the <code>server</code> block for your site, set it up to listen on port 443:</p>
<pre><code>server {
    listen 443 default_server; #Used to be port 80
    listen [::]:443 default_server ipv6only=on;

    #other things
}
</code></pre>
<p>The ipv6 binding is optional.</p>
<h4 id="turnonssl">Turn on SSL</h4>
<p>Turn on SSL and tell it where your certs are located. Place this anywhere within the <code>server</code> block:</p>
<pre><code>server {
    listen 443 default_server;
    listen [::]:443 default_server ipv6only=on;

    ssl on;
    ssl_certificate /etc/letsencrypt/live/www.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/www.yourdomain.com/privkey.pem;

    #other things
}
</code></pre>
<h4 id="setuparedirectfrom80to443">Set up a redirect from 80 to 443</h4>
<p>This is optional (but totally recommended). Ensure that all users that navigate to <code>http</code> get thrown over to <code>https</code>. Set up another server block (outside of your site&apos;s server block) that listens on port 80 and redirects to 443:</p>
<pre><code>server {
    #your existing server block stuff
}

server {
    listen 80;
    server_name yourdomain.com;

    location / {
        rewrite ^(.*)$ https://yourdomain.com$1 permanent;
    }
}
</code></pre>
<p>Save the file and exit.</p>
<h4 id="testtheconfiguration">Test the configuration</h4>
<p>Unless you&apos;re 100% confident in your typing abilities (I never am) it&apos;s best to run the following command that tells Nginx to load the configuration and test it to ensure it&apos;s valid. If it&apos;s not, it will tell you why:</p>
<pre><code>nginx -c /etc/nginx/nginx.conf -t
</code></pre>
<p>I had a missing <code>;</code> so this saved me 37 seconds of trouble.</p>
<h2 id="restartnginx">Restart Nginx</h2>
<pre><code>sudo service nginx start
</code></pre>
<h2 id="testyoursite">Test your site</h2>
<p>Navigate to <code>https://yourdomain.com</code> and enjoy your new security.</p>
<h2 id="questions">Questions?</h2>
<p>Leave a comment!</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Abusing Emoji in Windows]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Inspired by <a href="http://zachholman.com/posts/abusing-emoji/">this post by Zach Holman</a>, let&apos;s see what Windows 10 will allow us to use emoji for.</p>
<h1 id="firstsomehistory">First... some history</h1>
<h4 id="unicode">Unicode</h4>
<p>Most computer systems today (e.g. Windows, OSX, Android, iOS) use a thing called Unicode to represent text. Since computers work in binary, there needs</p>]]></description><link>https://davidzych.com/abusing-emoji-in-windows/</link><guid isPermaLink="false">61ef458c99dc1746fffcb17d</guid><category><![CDATA[windows 10]]></category><category><![CDATA[emoji]]></category><category><![CDATA[abuse]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Mon, 19 Oct 2015 16:06:03 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/10/post_image.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/10/post_image.png" alt="Abusing Emoji in Windows"><p>Inspired by <a href="http://zachholman.com/posts/abusing-emoji/">this post by Zach Holman</a>, let&apos;s see what Windows 10 will allow us to use emoji for.</p>
<h1 id="firstsomehistory">First... some history</h1>
<h4 id="unicode">Unicode</h4>
<p>Most computer systems today (e.g. Windows, OSX, Android, iOS) use a thing called Unicode to represent text. Since computers work in binary, there needs to be a way to take a string of binary and convert it to letters and numbers to display on the screen. Unicode is one way to do that, and any system that uses Unicode knows that  <code>01000001</code> is the capital letter <code>A</code>.</p>
<h4 id="emoji">Emoji</h4>
<p><a href="https://www.google.com/webhp?sourceid=chrome-instant&amp;ion=1&amp;espv=2&amp;ie=UTF-8#q=define%3Aemoji">An emoji is:</a></p>
<blockquote>
<p>a small digital image or icon used to express an idea, emotion, etc., in electronic communication.</p>
</blockquote>
<p>So basically these:</p>
<blockquote>
<p>&#x1F454; &#x1F4AA; &#x1F476; &#x1F385; &#x1F4A3; &#x1F354; &#x1F682; &#x1F3B0;</p>
</blockquote>
<p>A few years ago some people were trying to send messages to each other and one of them was like (keep in mind I&apos;m totally guessing here, but I&apos;m 99% sure this is exactly how it happened)</p>
<blockquote>
<p>Hey, I&apos;m tired of typing lol. I wish I could send someone a picture of a laughing head</p>
</blockquote>
<p>And so they came up with emoji. Then some more people* were like</p>
<blockquote>
<p>We need to standardize this shit</p>
</blockquote>
<p>and so they made a whole unicode character set just for emoji. And now anytime you&apos;re on Tinder and talking to a chick you can just send over the character <code>U+1F4AA</code> which is</p>
<blockquote>
<p>&#x1F4AA;</p>
</blockquote>
<p>and she&apos;ll clearly be all over you because not only do you have ripped biceps but you also know how to make proper use of emoji and that&apos;s a major turn on.</p>
<p>Anyway...</p>
<p>Since all of these emoji are part of the Unicode standard it means that emoji is essentially text, and it can be typed into anywhere normal text can be typed into, which means we can now put them in lots of funny places.</p>
<p>The easiest way to enter emoji in Windows is to enable the <a href="http://www.hanselman.com/blog/HowToEnterAndUseEmojiOnWindows81.aspx">Touch Keyboard</a>. Alternatively, you could also copy the emoji text straight from the <a href="http://unicode.org/emoji/charts/full-emoji-list.html">full emoji list straight from Unicode.org</a></p>
<h1 id="letshavesomefun">Let&apos;s have some fun</h1>
<h5 id="files">Files</h5>
<p>The NTFS file system that Windows uses <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd317748(v=vs.85).aspx">stores file names in Unicode.</a> That means we can save a file named the <a href="http://unicode.org/emoji/charts/full-emoji-list.html#270c">victory hand</a> (&#x270C;&#xFE0F;):</p>
<p><img src="https://davidzych.com/content/images/2015/10/1_victoryfingers.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>But file extensions are <em>also</em> unicode, so we can also save a file with 2 <a href="http://unicode.org/emoji/charts/full-emoji-list.html#270b">hands high fiving</a> each other over the dot:</p>
<p><img src="https://davidzych.com/content/images/2015/10/2_highfive.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<h5 id="shortcuts">Shortcuts</h5>
<p>Shortcuts to programs can also be emoji, so you can name your recycle bin the literal recycle symbol &#x267B;&#xFE0F;:</p>
<p><img src="https://davidzych.com/content/images/2015/10/8_recyclebin.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>Or you can name it an octopus &#x1F419; which is fitting because those things are disgusting and should be thrown out.</p>
<p><img src="https://davidzych.com/content/images/2015/10/11_octopi.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<h5 id="applications">Applications</h5>
<p>I renamed my notepad++ app to &#x1F366;. Now if it crashes I can yell &quot;oh shit, my ice cream is melting!&quot;</p>
<p><img src="https://davidzych.com/content/images/2015/10/10_icecreampad.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<h5 id="startmenu">Start menu</h5>
<p>You can also name a group on the start menu with emoji. I named my group &quot;cool &#x1F4A9;&quot;:</p>
<p><img src="https://davidzych.com/content/images/2015/10/9_coolshit.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<h5 id="useraccounts">User Accounts</h5>
<p>Windows user accounts also accept emoji. Which means your account name can be the <a href="https://en.wikipedia.org/wiki/Three_wise_monkeys">see no evil hear no evil speak no evil monkeys</a>:</p>
<p><img src="https://davidzych.com/content/images/2015/10/3_hearnospeaknoseeno.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>and every time you sign in you get to see your cute little monkeys:</p>
<p><img src="https://davidzych.com/content/images/2015/10/4_login.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>Surprisingly, Windows couldn&apos;t care less that your account name is a picture of 3 monkeys. It even shows it as your home directory:</p>
<p><img src="https://davidzych.com/content/images/2015/10/13_homedir.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<h5 id="passwords">Passwords</h5>
<p>You can <em>also</em> set your password using emoji. You can set it to something like this firework symbol so you can literally login with a bang:</p>
<p><img src="https://davidzych.com/content/images/2015/10/5_loginwithabang.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>But just like in OSX, it&apos;s almost impossible to enter emoji at the login screen so sadly you can&apos;t sign in with that password. My monkey account is now lost forever. &#x1F64D;</p>
<h5 id="time">Time</h5>
<p>You can change the time settings to use emoji. I set AM to show as &#x1F369; and PM to show as &#x1F37B;.</p>
<p><img src="https://davidzych.com/content/images/2015/10/12_time.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>Now I&apos;ll always know whether it&apos;s socially acceptable to eat donuts or drink beer.</p>
<h5 id="computername">Computer Name</h5>
<p>You can set your computer name using emoji. I set mine to a castle:</p>
<p><img src="https://davidzych.com/content/images/2015/10/6_castlecomputer.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>Now when you want to share things with your friends, you can proclaim &quot;<em>welcome to my kingdom</em>&quot;:</p>
<p><img src="https://davidzych.com/content/images/2015/10/7_castlenetwork.png" alt="Abusing Emoji in Windows" loading="lazy"></p>
<p>You could also set up strict firewall rules and make moat jokes if you prefer. &#x1F30A;</p>
<h3 id>&#x1F4A1;</h3>
<p>As you can see, Windows allows us to make use of emoji pretty much everywhere and it doesn&apos;t care. Have fun with this newfound knowledge.</p>
<hr>
<p>* Those people were the <a href="http://unicode.org/">Unicode Consortium</a>. They decide what goes into Unicode, so thank them for all your emoji.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[View compilation in ASP.NET 5 with the RazorPreCompileModule]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>In MVC versions up to and include version 5, you could compile your Razor views by adding the <code>&lt;MvcBuildViews&gt;</code> attribute in the <code>csproj</code> file. But in ASP.NET 5 there is no more csproj file, so how we compile views for MVC 6?</p>
<h2 id="why">Why?</h2>
<p>If you&apos;ve</p>]]></description><link>https://davidzych.com/view-compilation-in-aspnet-5-with-the-razorprecompilemodule/</link><guid isPermaLink="false">61ef458c99dc1746fffcb17c</guid><category><![CDATA[asp.net 5]]></category><category><![CDATA[roslyn]]></category><category><![CDATA[mvc 6]]></category><category><![CDATA[razor]]></category><category><![CDATA[view]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Wed, 14 Oct 2015 20:58:03 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/10/DSCN1797.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/10/DSCN1797.jpg" alt="View compilation in ASP.NET 5 with the RazorPreCompileModule"><p>In MVC versions up to and include version 5, you could compile your Razor views by adding the <code>&lt;MvcBuildViews&gt;</code> attribute in the <code>csproj</code> file. But in ASP.NET 5 there is no more csproj file, so how we compile views for MVC 6?</p>
<h2 id="why">Why?</h2>
<p>If you&apos;ve never compiled views and are wondering why you would, the reason is that it gets you compile-time checking. This means if you change your view model, you&apos;ll know if you broke the bindings in your view during compilation of your project. The alternative is waiting until run-time and until you view the page which could easily be overlooked. Sooner is always better.*</p>
<h2 id="how">How?</h2>
<p>The short answer is: Create a class that inherits from <code>RazorPreCompileModule</code> and place it in the <code>{root}\compiler\preprocess</code>** folder of your application.</p>
<pre><code>namespace RazorPrecompileTest.compiler.preprocess
{
    public class RazorPreCompilation : RazorPreCompileModule
    {
    }
}
</code></pre>
<p>And that&apos;s it! Whenever you build your application your razor views will also be compiled and you&apos;ll get compile time checking on them. If you want to know how it works, read on...</p>
<h2 id="sohowdoesitwork">So... how does it work?</h2>
<h4 id="razorprecompilemodule">RazorPreCompileModule</h4>
<p><a href="https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNet.Mvc.Razor/Precompilation/RazorPreCompileModule.cs"><code>RazorPreCompileModule</code></a> is an abstract class that implements the <a href="https://davidzych.com/what-is-an-assembly-neutral-interface-and-why-do-we-need-it/">assembly neutral interface</a> <code>ICompileModule</code>.</p>
<pre><code>public abstract class RazorPreCompileModule : ICompileModule 
</code></pre>
<h4 id="icompilemodule">ICompileModule</h4>
<pre><code>public interface ICompileModule
{
    void BeforeCompile(BeforeCompileContext context);
    void AfterCompile(AfterCompileContext context);
}
</code></pre>
<p><a href="https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Compilation.CSharp.Abstractions/ICompileModule.cs"><code>ICompileModule</code></a> is an interface that <a href="https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Compilation.CSharp.Abstractions/ICompileModule.cs#L7"><em>&quot;allows plugging into the compilation pipeline&quot;</em></a>. During compilation of your project, dnx will use <a href="https://davidzych.com/microsoft-releases-a-preview-of-the-net-compiler-platform-codenamed-roslyn/">Roslyn</a>  to build up an <a href="https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Compilation.CSharp/RoslynCompiler.cs#L230">in memory assembly appended with <code>!preprocess</code></a> with the same references as your project. It will use that to <a href="https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Compilation.CSharp/RoslynCompiler.cs#L234">look for any and all classes that implement <code>ICompileModule</code></a> and will run the <code>BeforeCompile</code> and <code>AfterCompile</code> methods for each class, before and after compilation, respectively.</p>
<hr>
<p>*<a href="http://www.urbandictionary.com/define.php?term=minute+man">Well, most of the time</a></p>
<p>**<a href="https://github.com/aspnet/dnx/blob/dev/src/Microsoft.Dnx.Runtime/ProjectFilesCollection.cs#L16">It <strong>must</strong> be put in that directory!</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Unit Testing Entity Framework 7 with the In Memory Data Store]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p><a href="https://github.com/aspnet/EntityFramework">Entity Framework 7</a> includes a new <a href="https://github.com/aspnet/EntityFramework/tree/dev/src/EntityFramework.InMemory"><code>InMemory</code></a> store which is fantastic for unit testing. No more mocking <code>DbContext</code> or doing other dumb things!</p>
<h3 id="hereshow">Here&apos;s how</h3>
<p>Start by creating a new class library project using the <code>Class Library (package)</code> template:</p>
<p><img src="https://davidzych.com/content/images/2015/10/1_NewProjectPage.png" alt loading="lazy"></p>
<p>Next, add the appropriate Entity Framework dependencies to your</p>]]></description><link>https://davidzych.com/unit-testing-entity-framework-7-with-the-in-memory-data-store/</link><guid isPermaLink="false">61ef458c99dc1746fffcb17b</guid><category><![CDATA[asp.net 5]]></category><category><![CDATA[entity framework]]></category><category><![CDATA[InMemory]]></category><category><![CDATA[UseInMemoryDatabase]]></category><category><![CDATA[dnx]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Thu, 08 Oct 2015 22:08:03 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/10/ship-back.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/10/ship-back.png" alt="Unit Testing Entity Framework 7 with the In Memory Data Store"><p><a href="https://github.com/aspnet/EntityFramework">Entity Framework 7</a> includes a new <a href="https://github.com/aspnet/EntityFramework/tree/dev/src/EntityFramework.InMemory"><code>InMemory</code></a> store which is fantastic for unit testing. No more mocking <code>DbContext</code> or doing other dumb things!</p>
<h3 id="hereshow">Here&apos;s how</h3>
<p>Start by creating a new class library project using the <code>Class Library (package)</code> template:</p>
<p><img src="https://davidzych.com/content/images/2015/10/1_NewProjectPage.png" alt="Unit Testing Entity Framework 7 with the In Memory Data Store" loading="lazy"></p>
<p>Next, add the appropriate Entity Framework dependencies to your <code>project.json</code>:</p>
<pre><code>&quot;dependencies&quot;: {
    &quot;EntityFramework.Core&quot;: &quot;7.0.0-beta7&quot;,
    &quot;EntityFramework.Commands&quot;: &quot;7.0.0-beta7&quot;,
    &quot;EntityFramework.InMemory&quot;: &quot;7.0.0-beta7&quot;
},
</code></pre>
<p>and dependencies to the latest <a href="https://xunit.github.io/docs/getting-started-dnx.html">xUnit runner</a>:</p>
<pre><code>&quot;xunit&quot;: &quot;2.1.0-rc2-build3176&quot;,
&quot;xunit.runner.dnx&quot;: &quot;2.1.0-beta5-build169&quot;
</code></pre>
<p>and finally, add a command to your <code>project.json</code> for the xUnit runner:</p>
<pre><code>&quot;commands&quot;: {
    &quot;test&quot;: &quot;xunit.runner.dnx&quot;
}
</code></pre>
<p>Because we&apos;re awesome (seriously, don&apos;t do this in a real app, I&apos;m just doing it here because it&apos;s easy) we&apos;re going to create a <code>DbContext</code> inside of this test project with a <code>Foo</code> entity:</p>
<pre><code>public class MyContext : DbContext
{
    public MyContext()
    {
    }

    public MyContext(DbContextOptions options) : base(options)
    {            
    }

    public DbSet&lt;Foo&gt; Foos { get; set; }
}

public class Foo
{
    public int Id { get; set; }
    public string Name { get; set; }
}
</code></pre>
<p>Now create a test class:</p>
<pre><code>public class MyTestClass
{
    private readonly MyContext _context;

    [Fact]
    public void FoosIsEmpty()
    {
        var foos = _context.Foos;

        Assert.Empty(foos);
    }
}
</code></pre>
<p>In order to set up entity framework for each test, we&apos;re going to make use of the fact that xUnit creates a <a href="https://xunit.github.io/docs/shared-context.html#constructor">new instance of a test class <em>for each test run</em>.</a> This means we can use the constructor to get a clean <code>MyContext</code> for every single test.</p>
<pre><code>public class MyTestClass
{
    public MyTestClass()
    {
        var db = new DbContextOptionsBuilder();
         db.UseInMemoryDatabase();
        _context = new MyContext(db.Options);
    }
    
    //Tests
}
</code></pre>
<p>The <code>UseInMemoryDatabase</code> call is the fun part. EF will enforce all constraints and validations, however it won&apos;t persist anything to a real database and instead hold everything in memory. Which means it&apos;s fast and disposable.</p>
<p>You can also, if you&apos;re so inclined, set up a seed class to populate the in memory store with test data to use for each test. &#x1F44D;</p>
<p><strong>Update</strong>: The in memory store no longer supports constraints. (Embarrassingly, it didn&apos;t at time of this writing either, I was mistaken.) This is because constraints are solely a relational thing, and other types of stores don&apos;t enforce them. This is discussed in <a href="https://github.com/aspnet/EntityFramework/issues/2166">this Github issue</a>, specifically <a href="https://github.com/aspnet/EntityFramework/issues/2166#issuecomment-101824412">this comment. </a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Programmers and sleep]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>For most programmers, sleep is an afterthought. It gets in the way of coding. Of inspiration. Of progress. But sleep is an important part of your mental and physical health and is essential in keeping your body running smoothly.</p>
<p>Most programmers I know have some trouble sleeping, a disorder or</p>]]></description><link>https://davidzych.com/programmers-and-sleep/</link><guid isPermaLink="false">61ef458c99dc1746fffcb179</guid><category><![CDATA[sleep]]></category><category><![CDATA[programmers]]></category><category><![CDATA[Chernobyl]]></category><category><![CDATA[Challenger Accident]]></category><category><![CDATA[Circadian Rythym]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Fri, 10 Jul 2015 20:03:00 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/07/Keyboard.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/07/Keyboard.jpg" alt="Programmers and sleep"><p>For most programmers, sleep is an afterthought. It gets in the way of coding. Of inspiration. Of progress. But sleep is an important part of your mental and physical health and is essential in keeping your body running smoothly.</p>
<p>Most programmers I know have some trouble sleeping, a disorder or otherwise. It stems from our obsessive nature and our drive to always be productive. We have to always be doing something. We have to finish that one last unit test. We have to finish that one last level in the new video game.*</p>
<p>Although it can be fun and can have a semblance of productivity, it&apos;s usually not effective, especially after doing it for a few days in a row.</p>
<h2 id="werenotrobots">We&apos;re not robots</h2>
<p>No matter what we tell ourselves, we can&apos;t work effectively on little sleep. There have been numerous studies done on the effects of sleep deprivation on decision making, and a number of catastrophes have been attributed to lack of sleep, most alarmingly the Chernobyl disaster and the Challenger Accident. The National Center for Biotechnology Information published a manuscript reviewing the &quot;role of human sleep and brain clocks (time-of-day variation in physiology and alertness) in the occurrence of medical and human error catastrophes&quot;. They found that sleep deprivation <a href="http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2517096/">played a key role in the Challenger Accident</a>:</p>
<blockquote>
<p>...the recent report of the Presidential Commission on the Space Shuttle Challenger Accident did cite the contribution of human error and poor judgement related to sleep loss and shiftwork during the early morning hours. ... <strong>Certain key managers had obtained &lt;2 h sleep the night before and had been on duty since 1:00 a.m. that morning.</strong> The report noted that &quot;time pressure, particularly that caused by launch scrubs and turnarounds, increased the potential for sleep loss and judgment errors&quot; and that <strong>working &quot;excessive hours, while admirable, raises serious questions when it jeopardizes job performance, particularly when critical management decisions are at stake&quot;.</strong></p>
</blockquote>
<p>The Journal of Experimental Physchology: Applied backs this up in their article <a href="http://psycnet.apa.org/journals/xap/6/3/236/"><em>The impact of sleep deprivation on decision making: A review</em></a>:</p>
<blockquote>
<p>It is perhaps just a coincidence that some of the most renowned man-made disasters or near disasters concerning nuclear power plants, such as Chernobyl, Three Mile Island, Davis-Beese (Ohio), and Rancho Seco (Sacramento), all occurred in the early morning and involved human error in failing to contain otherwise controllable but unexpected and unusual mechanical or control room malfunctions. With all four, experienced control room managers misdiagnosed and failed to appreciate the extent of the fault and then embarked on courses of action that were inappropriate and continued to persevere in this way in spite of clear indications that their original assessment was wrong. Of course, it is difficult to say how much of this could have been due to SD effects on decision making and not to stress and panic. However, SD certainly played a crucial role in the fateful dawn decision to launch the Space Shuttle Challenger.</p>
</blockquote>
<h2 id="whatcanwedoaboutit">What can we do about it</h2>
<p>So, sleep is important. Great. But how do you ensure you get enough sleep? Here are a few tips:</p>
<h4 id="sticktoasleepschedule">Stick to a sleep schedule</h4>
<p>I think this is the single most important thing you can do to ensure quality sleep which is why I listed it first. Pick a bed time and a wake up time and stick to them as closely as you can. This helps regulate your body&apos;s internal clock (your <a href="https://en.wikipedia.org/wiki/Circadian_rhythm">Circadian rythym</a>), which will help you fall asleep each night and wake up easier each morning.</p>
<p>Of course, life will get in the way of this sometimes, and you shouldn&apos;t tell your friends you can&apos;t grab a drink because it will <em>throw off your circadian rythym</em>. They&apos;ll probably look at you like you&apos;re standing on the corner of Senile Old Man St. and Crazy Lady Way. But try to avoid breaking the schedule continuously. Try to at least stick to your schedule on weekdays, which shouldn&apos;t be too hard, because, well, you have a job, right?</p>
<h4 id="shutoffyourelectronicdevices">Shut off your electronic devices</h4>
<p>Screens are bright and mimic daylight, and they cause our body to think we&apos;re not ready for bed. Sleep.org says <a href="https://sleep.org/articles/how-technology-changing-the-way-we-sleep/">using certain technology is bad immediately before bed</a>:</p>
<blockquote>
<p>Reading a work email at 9:30pm can keep you up with stress, the blue light from the screens mimics daylight and stimulates you, and you can wake up feeling tired, anxious, and depressed. That&#x2019;s why you should power down devices at least 30 minutes before bedtime.</p>
</blockquote>
<p>Reading email on a smartphone, watching TV or watching a movie on a tablet all stimulate us and can make it harder to fall asleep. Sleep.org recommends not using any sort of technology 30 minutes before bed, and instead to read a magazine or book. If you don&apos;t like paper copies of things, reading a book on a tablet is okay (make sure you set it to white on black instead of black on white to limit the brightness), reading on a Kindle E-Ink reader would be better.</p>
<h4 id="getexercise">Get exercise</h4>
<p>It&apos;s rather common knowledge that indoor enthusiasts such as ourselves don&apos;t get enough exercise. We&apos;re not the most coordinated bunch, and a lot of times the sun burns. Exercise is another crucial component to sleep, though. As little as 10 minutes of exercise per day can improve sleep, because it reduces stress and tires you out.</p>
<p>Besides, exercise isn&apos;t just important to sleep, it&apos;s incredibly important in overall health <a href="http://www.betterhealth.vic.gov.au/bhcv2/bhcarticles.nsf/pages/physical_activity_its_important?open">for many reasons</a>. It&apos;s imperative we all get up, start moving and keep moving.</p>
<h4 id="eatmorehealthily">Eat more healthily</h4>
<p>Researchers from the Perelman School of Medicine at the University of Pennsylvania <a href="http://www.cnn.com/2013/02/07/health/time-diet-sleep/">looked at how diet affects sleep</a> and they found there is a correlation between length of sleep, calories consumed and variety in your diet. Those that slept a &quot;normal&quot; amount of time, defined as 7-8 hours, consumed an average number of calories. But more importantly they ate a large variety of foods:</p>
<blockquote>
<p>Normal sleepers, however, showed the highest food variety in their diets, and very short sleepers had the least variation in what they ate. A varied diet tends to be a marker for good health since it includes multiple sources of nutrients.</p>
</blockquote>
<p>Make sure you eat a well balanced diet, that includes some grains, some meat, and some fruits and veggies.</p>
<p><img src="https://davidzych.com/content/images/2015/07/2000px-MyPyramidFood-svg-1.png" alt="Programmers and sleep" loading="lazy"></p>
<p>And make sure you lay off the Funyuns.</p>
<h4 id="havechildren">Have children</h4>
<p>I&apos;m only half joking with this one. It&apos;s well known by everyone that a newborn actually causes less sleep (I have 2 children, it&apos;s definitely true), however once they get to be 6 months or so (a year if you&apos;re unlucky) they&apos;ll start sleeping better. And what happens is they become a natural alarm - children have this incredible knack for waking up at the same time each morning, regardless of when they went to bed. So, if they always get up at 6:30am, and you, in turn, then always get up at 6:30am, then all you need to do is figure out your bed time and bam, you have your sleep schedule.</p>
<h4 id="takeasleepaid">Take a sleep aid</h4>
<p>This is something I would recommend avoiding because sleeping pills can cause drowsiness, rebound insomnia, dependency and abuse. However some people truly have insomnia and need help sleeping. If this is you, you can talk to your doctor about sleeping pills, or get an OTC aid like ZzzQuil, or get a sleep <em>supplement</em> such as melatonin.</p>
<h2 id="soputdownthekeyboardandsleep">So put down the keyboard and sleep</h2>
<p>Rest your eyes, rest your body, rest your mind. You <strong>need</strong> to recharge yourself, and there&apos;s no better way to do that than sleep.</p>
<hr>
<p>* A friend and I once tried to beat Halo on Legendary in one sitting. It took 16 hours with a few quick pee and food breaks. We finally finished at 6AM and subsequently passed out for the next 10 hours.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[The SOLID design principles applied to an actual Swiss Army Knife]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>The term <em>swiss army knife</em> is thrown around a lot when discussing the SOLID principles. <em>Dave, that class looks like a swiss army knife. We need to refactor that shit.</em> Yeah. Whatever. You know what, how about we see how a real swiss army knife stands up against the SOLID</p>]]></description><link>https://davidzych.com/the-solid-design-principles-applied-to-an-actual-swiss-army-knife/</link><guid isPermaLink="false">61ef458c99dc1746fffcb178</guid><category><![CDATA[SOLID]]></category><category><![CDATA[OOP]]></category><category><![CDATA[swiss army knife]]></category><category><![CDATA[object oriented programming]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Fri, 15 May 2015 20:26:00 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/05/swissarmyknife.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/05/swissarmyknife.jpg" alt="The SOLID design principles applied to an actual Swiss Army Knife"><p>The term <em>swiss army knife</em> is thrown around a lot when discussing the SOLID principles. <em>Dave, that class looks like a swiss army knife. We need to refactor that shit.</em> Yeah. Whatever. You know what, how about we see how a real swiss army knife stands up against the SOLID principles, huh?! Then we&apos;ll see who needs refactoring.</p>
<h2 id="singleresponsibilityprinciple">Single Responsibility Principle</h2>
<p>The Single Responsibility Principle states:</p>
<blockquote>
<p>Every object should have a single responsibility, i.e. a single reason to change</p>
</blockquote>
<p>When looked at in terms of software, this means that a class should only do one thing - log errors, or send email, or determine if a person&apos;s name is funny. A class that finds any irreverence in a person&apos;s name should not be worried about sending email - it should delegate that off to an email service, which will email anyone who thinks that the name <em>Wang Liqin</em> is funny.*</p>
<p>But what about the swiss army knife? Let&apos;s count it&apos;s responsibilities:</p>
<ul>
<li>Knife</li>
<li>Flat head screwdriver</li>
<li>Philips head screwdriver</li>
<li>Can opener</li>
<li>Nail filer</li>
<li>Bottle opener**</li>
<li>Scissors</li>
<li>A relatively hefty item that can be used as a projectile</li>
</ul>
<p>Look at all of those responsibilities! A screwdriver and scissors <em>in one device??</em> Madness. The swiss army knife clearly violates the SRP.</p>
<table><tr><th>Principles</th><th>Swiss Army Knife</th></tr><tr><td>SRP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/redno.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>OCP</td><td></td></tr><tr><td>LSP</td><td></td></tr><tr><td>ISP</td><td></td></tr><tr><td>DIP</td><td></td></tr></table>
<h2 id="openclosedprinciple">Open-Closed Principle</h2>
<p>The Open-Closed Principle states:</p>
<blockquote>
<p>Objects should be open for extension, but closed for modification</p>
</blockquote>
<p>In OOP, once a class is finalized it should not be changed (except for bug fixes, of course). The reason behind this is to ensure that existing functionality does not break when maintaining/adding to the codebase. Further functionality should be implemented using inheritance.</p>
<p>Let&apos;s apply the OCP to a Swiss Army Knife.</p>
<h5 id="closedformodification">Closed for modification</h5>
<p>There are no visible ways to open or take apart a swiss army knife. There are no screws or notches to pop open the case. It&apos;s definitely closed for modification. (Unless you hit it with a rock, but I think that&apos;s circumventing the rules.)</p>
<h5 id="openforextension">Open for extension</h5>
<p>Well, we determined that there are no screws or any way visible to take apart a swiss army knife. There are no ports or cables either. But there is often a keyring on it, so you can, like, hang a spatula from it? Sure.</p>
<table><tr><th>Principles</th><th>Swiss Army Knife</th></tr><tr><td>SRP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/redno.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>OCP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>LSP</td><td></td></tr><tr><td>ISP</td><td></td></tr><tr><td>DIP</td><td></td></tr></table>
<h2 id="liskovsubstitutionprinciple">Liskov-Substitution Principle</h2>
<p>The Liskov-Substitution Principle states:</p>
<blockquote>
<p>You should be able to use any derived class in place of a parent class and it should behave in the same manner with no modification.</p>
</blockquote>
<p>In software, this means there should be no custom code required when using a child class in place of the parent class.</p>
<p>Does the swiss army knife violate the LSP? Well, if we think of the swiss army knife as the child, it would have parents of a knife, a pair of scissors, a screwdriver, etc. You can use the swiss army knife in place of each of the parents with no modification. It might just take you a bit longer to slice that turkey with your 3 inch blade.</p>
<table><tr><th>Principles</th><th>Swiss Army Knife</th></tr><tr><td>SRP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/redno.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>OCP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>LSP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>ISP</td><td></td></tr><tr><td>DIP</td><td></td></tr></table>
<h2 id="interfacesegregationprinciple">Interface Segregation Principle</h2>
<p>The Interface Segregation Principle states:</p>
<blockquote>
<p>Clients should not be forced to depend on interfaces they do not use</p>
</blockquote>
<p>If you create an interface, the interface should have clearly defined functionality, and any classes implementing that interface should implement all properties/methods without any <code>NotImplementedExceptions</code> or fake return values. The goal is to get rid of monster interfaces and create interfaces with directly related functionality.</p>
<p>The swiss army knife does not implement any interfaces (it&apos;s a freakin knife, yoh).</p>
<table><tr><th>Principles</th><th>Swiss Army Knife</th></tr><tr><td>SRP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/redno.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>OCP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>LSP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>ISP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/redno.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>DIP</td><td></td></tr></table>
<h2 id="dependencyinversionprinciple">Dependency Inversion Principle</h2>
<p>The Dependency Inversion Principle states:</p>
<blockquote>
<p>Classes should depend on abstractions for their dependencies</p>
</blockquote>
<p>Common terms used when discussing the DIP are <strong>Dependency Injection</strong> and <strong>Inversion of Control</strong>. Basically, they say that classes should rely on interfaces or abstract classes for any outside dependencies they need, and not instantiate concrete objects themselves.</p>
<p>What dependencies does a swiss army knife have? Well, two main ones are an operator and a sharpener.</p>
<p>It definitely does not instantiate it&apos;s own operator, and it definitely relies on abstractions because it doesn&apos;t care of a person or a dog or a tree is using it. It also doesn&apos;t care if it&apos;s being sharpened with a $1,000 wet stone or on a rock you grabbed out of the river.</p>
<table><tr><th>Principles</th><th>Swiss Army Knife</th></tr><tr><td>SRP</td><td><img src="https://davidzych.com/content/images/2015/05/redno.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>OCP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>LSP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>ISP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/redno.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr><tr><td>DIP</td><td>
    <img src="https://davidzych.com/content/images/2015/05/greencheck.png" alt="The SOLID design principles applied to an actual Swiss Army Knife">
</td></tr></table>
<h2 id="conclusion">Conclusion</h2>
<p>The swiss army knife did pretty well, scoring a 3/5. Think twice before calling my classes swiss army knifes, because I call that a passing grade.</p>
<hr>
<p>* Which should be everyone.</p>
<p>** The most important, if you ask me.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[The Internet, text encodings and making an ass out of you and me]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>HTML, by it&apos;s design, is incredibly liberal in what it accepts. Which is kind of cool, but sometimes it&apos;s definitely not and it bites you. And it can bite you in many ways, including the character encoding used on a page. (I.e. ascii vs unicode</p>]]></description><link>https://davidzych.com/the-internet-text-encodings-and-making-an-ass-out-of-you-and-me/</link><guid isPermaLink="false">61ef458c99dc1746fffcb177</guid><category><![CDATA[powershell]]></category><category><![CDATA[unicode]]></category><category><![CDATA[text encoding]]></category><category><![CDATA[utf-8]]></category><category><![CDATA[internet]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Fri, 06 Mar 2015 22:22:06 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/03/p065.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/03/p065.png" alt="The Internet, text encodings and making an ass out of you and me"><p>HTML, by it&apos;s design, is incredibly liberal in what it accepts. Which is kind of cool, but sometimes it&apos;s definitely not and it bites you. And it can bite you in many ways, including the character encoding used on a page. (I.e. ascii vs unicode vs whatever. <a href="http://www.joelonsoftware.com/articles/Unicode.html">Read this</a> if you want to learn more (and you should)).</p>
<p>There are a few ways to declare the encoding of a web page, <a href="http://www.w3.org/TR/html4/charset.html#spec-char-encoding">as specified by the w3c:</a></p>
<blockquote>
<p>To sum up, conforming user agents must observe the following priorities when determining a document&apos;s character encoding (from highest priority to lowest):</p>
</blockquote>
<blockquote>
<ol>
<li>An HTTP &quot;charset&quot; parameter in a &quot;Content-Type&quot; field.</li>
</ol>
</blockquote>
<ol start="2">
<li>A META declaration with &quot;http-equiv&quot; set to &quot;Content-Type&quot; and a value set for &quot;charset&quot;.</li>
<li>The charset attribute set on an element that designates an external resource.</li>
</ol>
<blockquote>
<p>In addition to this list of priorities, the user agent may use heuristics and user settings. For example, many user agents use a heuristic to distinguish the various encodings used for Japanese text. Also, user agents typically have a user-definable, local default character encoding which they apply in the absence of other indicators.</p>
</blockquote>
<p>That last paragraph is the fun part. If no encoding is specified in any of the 3 ways listed, the user agent (Chrome, IE, etc) can attempt to figure it out itself.</p>
<h4 id="waitsohowcanthisbiteyou">Wait, so how can this bite you?</h4>
<p>I ran into an interesting situation earlier. Powershell uses <code>UTF-16</code> internally (it&apos;s based on .NET, you know, and .NET uses <code>UTF-16</code> on its strings), and when you pipe output to a file, it defaults to that encoding:</p>
<pre><code>&quot;&lt;html&gt;&lt;body&gt;&lt;div&gt;Here&apos;s a div&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;&quot; &gt; index.html #I&apos;m UTF-16!
</code></pre>
<p>Hey look, we created a webpage. When opening that file in the browser, the browser doesn&apos;t see a charset header or a META declaration so it decides to determine the encoding itself and it figures out that, <em>hey, this is utf-16</em>. You can see this by opening the browser developer tools and running:</p>
<pre><code>&gt; document.characterSet
    &quot;UTF-16LE&quot;
</code></pre>
<p>Neat. And the page displays correctly and all is well.</p>
<p>But let&apos;s say we want to add an external script because we like javascript and <em>we&apos;re good programmers, damnit, so we separate our concerns and don&apos;t add inline scripts</em>. So we edit our <code>index.html</code> file and add a script tag, specifically getting RequireJS from a <a href="http://en.wikipedia.org/wiki/Content_delivery_network">CDN:</a></p>
<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.16/require.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div&gt;
        Here&apos;s a div
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>And now we have RequireJs! Wait. What? We don&apos;t?</p>
<p>If you open the index file now, you&apos;ll see <code>Here&apos;s a div</code> but if you open the dev tools, you&apos;ll get a</p>
<blockquote>
<p>Uncaught SyntaxError: Unexpected token ILLEGAL</p>
</blockquote>
<p>error. And if you open the requireJs file, you&apos;ll see a bunch of chinese characters.</p>
<h4 id="whyyyyyyyy">Whyyyyyyyy</h4>
<p>The RequireJs file, from the CDN, is encoded in <a href="http://en.wikipedia.org/wiki/Windows-1252"><code>windows-1252</code></a>. But since we didn&apos;t specify a charset for the script file, the browser assumed it was the same as the html file, and brought it in as <code>UTF-16</code>. It interpreted all of the bytes as <code>UTF-16</code> and you get all of those crazy characters. Specifying a charset fixes the problem, because the browser knows how to interpret the incoming file:</p>
<pre><code>&lt;script charset=&quot;windows-1252&quot; src=&quot;https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.16/require.min.js&quot;&gt;&lt;/script&gt;
</code></pre>
<h4 id="doicare">Do I care?</h4>
<p>In most cases, this won&apos;t be a problem. Most everywhere uses UTF-8 now, and in the HTML5 spec, <a href="http://www.w3.org/TR/html5/document-metadata.html#charset">the w3c says:</a></p>
<blockquote>
<p>Authors should use UTF-8.</p>
</blockquote>
<blockquote>
<p>Authoring tools should default to using UTF-8 for newly-created documents.</p>
</blockquote>
<p>In other cases (which should be few and far between) set a charset and be on your way.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Migrating from Wordpress to Ghost: 301'ing some urls]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>I just migrated from Wordpress to Ghost, for probably the same reason as most people - I got tired of the mass of crazy that Wordpress has become. I just want to write shit, and Wordpress was almost getting in the way of that.</p>
<p>The migration process was ridiculously easy</p>]]></description><link>https://davidzych.com/migrating-from-wordpress-to-ghost-301-urls/</link><guid isPermaLink="false">61ef458c99dc1746fffcb176</guid><category><![CDATA[wordpress]]></category><category><![CDATA[ghost]]></category><category><![CDATA[nginx]]></category><category><![CDATA[301]]></category><category><![CDATA[rewrite]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Thu, 19 Feb 2015 18:55:18 GMT</pubDate><media:content url="https://davidzych.com/content/images/2015/02/ghost404.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><img src="https://davidzych.com/content/images/2015/02/ghost404.png" alt="Migrating from Wordpress to Ghost: 301&apos;ing some urls"><p>I just migrated from Wordpress to Ghost, for probably the same reason as most people - I got tired of the mass of crazy that Wordpress has become. I just want to write shit, and Wordpress was almost getting in the way of that.</p>
<p>The migration process was ridiculously easy thanks to both <a href="http://tryghost.com">Ghost</a> and <a href="http://digitalocean.com">Digital Ocean</a> - I clicked a few buttons, waited 50 seconds and had a new Ghost installation. I exported my posts from Wordpress, imported them into Ghost and, boom, done.</p>
<p>Well, basically.</p>
<h4 id="thosedangslugs">Those dang slugs</h4>
<p>Wordpress, by default, sets up URLs in the form of <code>http://yourblog.com/yyyy/MM/dd/kinda-nice-post-title</code>. Ghost, by default, uses the form <code>http://yourblog.com/kinda-nice-post-title</code>. I like the Ghost way better, but that meant all links to my posts would be broken.</p>
<h4 id="letswritesomerewrites">Let&apos;s write some rewrites</h4>
<p>The best way to get around this is to set up <a href="http://en.wikipedia.org/wiki/HTTP_301">301 redirects </a>, so that not only do the old links automatically get redirected to the new links, search engines like Google know it&apos;s a permanent redirect and therefore forget the old url and use the new one.</p>
<p>Most instances of Ghost are running under <a href="http://nginx.org/">nginx</a>, which is an open source web host, and it has a rewrite module (<code>ngx_http_rewrite_module</code>) installed by default that helps us here.</p>
<h4 id="configurationfiles">Configuration files</h4>
<p>Nginx uses json formatted <code>.conf</code> files for it&apos;s configuration settings. There are 2 files we&apos;re going to look at: <code>nginx.conf</code> and <code>[your site name]</code> The main file is <code>nginx.conf</code> and it lives in <code>/etc/nginx/</code>. That file has a bunch of settings that apply to all sites. The <code>[your site name]</code> file has settings that apply to only your site, and it lives in <code>/etc/nginx/sites-enabled/</code>*. The <code>nginx.conf</code> file includes this line:</p>
<pre><code>include /etc/nginx/sites-enabled/*;
</code></pre>
<p>that imports the site settings into the main file.</p>
<p>We&apos;ll be editing the <code>[your site name]</code> file, since these rewrites will probably only apply to your site. From here on out, I&apos;ll use <code>ghost</code> instead of <code>[your site name]</code> since that&apos;s what my site is called.</p>
<h4 id="irregularexpressions">(Ir)Regular expressions</h4>
<p>The rewrite module uses regular expressions to match urls, and we&apos;ll use one that matches <code>/yyyy/MM/dd/pretty-url</code> and rewrite it to only <code>/pretty-url</code>. The regex is:</p>
<pre><code>\d{4}/\d{2}/\d{2}/(.*)$
</code></pre>
<p>This basically says &quot;if the url starts with 4 digits, and then has a slash and 2 digits, and then has another slash and 2 other digits, grab everything after that.&quot;</p>
<p>To apply this, edit your site configuration file using vim:</p>
<pre><code>vim /etc/nginx/sites-enabled/ghost
</code></pre>
<p>You&apos;ll see a <code>server</code> node, and inside of that a <code>location</code> node. In the <code>location</code> node, add the following rule:</p>
<pre><code>rewrite &quot;\d{4}/\d{2}/\d{2}/(.*)$&quot; /$1 permanent;
</code></pre>
<p>So your file should look something like this:</p>
<pre><code>server {
    #some stuff
    location / {
        #some stuff
        rewrite &quot;\d{4}/\d{2}/\d{2}/(.*)$&quot; /$1 permanent;
    }
}
</code></pre>
<p>That says &quot;if the url matches this regular expression, rewrite the last bit (the <code>(.*)$</code>) as just <code>/$1</code>, where <code>$1</code> is the capturing group. And do it permanently, as a 301 redirect.</p>
<p>Save the file, and restart nginx:</p>
<pre><code>sudo service nginx restart
</code></pre>
<p>Now hit an old url and watch the magic happen.</p>
<hr>
<p>* Kind of. It actually lives in <code>/etc/nginx/sites-available</code> and is symbolically linked to <code>sites-enabled</code>.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Creating an ASP.NET 5 Class Library with Vim]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>One of the great things about ASP.NET 5 (aka vNext) is that there is no longer a reliance on Visual Studio. I definitely think VS is a great IDE, but it does have it&#x2019;s quirks and people love options; the option of not having to use VS</p>]]></description><link>https://davidzych.com/creating-an-asp-net-5-class-library-with-vim/</link><guid isPermaLink="false">61ef458c99dc1746fffcb175</guid><category><![CDATA[asp.net 5]]></category><category><![CDATA[aspnet50]]></category><category><![CDATA[aspnetcore50]]></category><category><![CDATA[class library]]></category><category><![CDATA[vim]]></category><category><![CDATA[vnext]]></category><category><![CDATA[Yeoman]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Tue, 23 Dec 2014 17:09:10 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>One of the great things about ASP.NET 5 (aka vNext) is that there is no longer a reliance on Visual Studio. I definitely think VS is a great IDE, but it does have it&#x2019;s quirks and people love options; the option of not having to use VS is a very good option. Also, since ASP.NET 5 can be developed and run on OSX and Linux, users of the *nix OS&#x2019;s are able to use whatever editor they want.</p>
<p>One thing you might be wondering is: <em>If I don&#x2019;t have VS, how to I create a project?</em> In current versions of VS/ASP.NET, you open VS and hit File-&gt;New Project, give it a name and VS generates a bunch of junk for you. If you don&#x2019;t have VS, how do you generate that bunch of junk?</p>
<h2 id="beautyinsimplicity">Beauty in simplicity</h2>
<p>One of the design goals of ASP.NET 5 was to simplify the project structure and remove the hell that is the .csproj file. All that is required now for an ASP.NET 5 project is a <code>project.json</code> file. The csproj file (now a .kproj file in VS 2015) is solely a VS thing and is only necessary if you want to use Visual Studio.</p>
<p>You can, obviously, still use VS to generate projects and it will work great and you can be on your way. But what if you don&#x2019;t want to use VS? (or are on *nix?)</p>
<p>You have 2 options, the first being to use another generator. One example of a generator is <a href="https://www.npmjs.com/package/generator-aspnet">generator-aspnet</a>, which uses the popular <a href="http://yeoman.io/">Yeoman</a> scaffolding tool.</p>
<p>The other option, which is way more fun, is to create the project yourself.</p>
<h2 id="creatinganaspnet5projectwithvim">Creating an ASP.NET 5 project with Vim</h2>
<p>We&#x2019;ll create a simple class library to show how stupidly easy it is, and all we&#x2019;ll use is Powershell/Vim.</p>
<p>First, create a directory for your project:</p>
<pre><code>C:\Projects&gt; mkdir ClassLib
C:\Projects&gt; cd ClassLib
</code></pre>
<p>Next, create a project.json file:</p>
<pre><code>C:\Projects\ClassLib&gt; vim project.json
</code></pre>
<p>..and add the following contents (I promise, this is it!):</p>
<pre><code>{

}
</code></pre>
<p>Create a file for a class:</p>
<pre><code>C:\Projects\ClassLib&gt; vim MyClass.cs
</code></pre>
<p>&#x2026; with the following contents:</p>
<pre><code>namespace ClassLib
{
    public class MyClass
    {
        public int Number { get; set; }
    }
}
</code></pre>
<p>And finally, build it:</p>
<pre><code>C:\Projects\ClassLib&gt; kpm build
</code></pre>
<p>This will build the library as a nuget package and place the nupkg and all files in the <code>\bin\Debug</code> path.</p>
<p>That&#x2019;s it! It&#x2019;s worth noting that this is compiling against .NET 4.5 full and is using dependencies from the GAC. You can specify the framework/dependencies in the <code>project.json</code> file if you want to use <code>aspnet50</code> or <code>aspnetcore50</code>. For example, to compile against <code>aspnetcore50</code>, you can specify it like so:</p>
<pre><code>{
    &quot;frameworks&quot;: {
        &quot;aspnetcore50&quot;: {
            &quot;dependencies&quot;: {
                &quot;System.Runtime&quot;: &quot;4.0.20-beta-22231&quot;
            }
        }
    }
}
</code></pre>
<p>You can review the <code>project.json</code> schema here: <a href="https://github.com/aspnet/Home/wiki/Project.json-file">https://github.com/aspnet/Home/wiki/Project.json-file</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Explaining the ASP.NET 5 Configuration Framework]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>ASP.NET 5 (aka vNext) has <a href="https://github.com/aspnet/Configuration">a new configuration system</a> which is designed to be lightweight and to work everywhere. This means no more web.config XML hell! Hooray! (However you <em>can</em> use XML files if you want&#x2026;)</p>
<h2 id="loadingsettings">Loading Settings</h2>
<p>The Configuration class is defined in the <code>Microsoft.Framework.</code></p>]]></description><link>https://davidzych.com/explaining-the-asp-net-5-configuration-framework/</link><guid isPermaLink="false">61ef458c99dc1746fffcb174</guid><category><![CDATA[asp.net 5]]></category><category><![CDATA[configuration]]></category><category><![CDATA[ini]]></category><category><![CDATA[json]]></category><category><![CDATA[vnext]]></category><category><![CDATA[xml]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Sun, 21 Dec 2014 22:29:37 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>ASP.NET 5 (aka vNext) has <a href="https://github.com/aspnet/Configuration">a new configuration system</a> which is designed to be lightweight and to work everywhere. This means no more web.config XML hell! Hooray! (However you <em>can</em> use XML files if you want&#x2026;)</p>
<h2 id="loadingsettings">Loading Settings</h2>
<p>The Configuration class is defined in the <code>Microsoft.Framework.ConfigurationModel</code> namespace. This is included as a dependency if you reference the <code>Microsoft.AspNet.Mvc</code> package so there&#x2019;s no need to explicitly reference the nuget package.</p>
<p>Currently, there are 3 different file types that are supported: Json, Xml and Ini. You can also pull in settings from Environment Variables (like those you&#x2019;d set in Azure). The Ini load method is in the default package, however the Json and Xml load methods are each defined in the <code>Microsoft.Framework.ConfigurationModel.Json</code> and <code>Microsoft.Framework.ConfigurationModel.Xml</code> packages, respectively. This is because the Json and Xml loaders have different dependencies, and the AspNet team wants to ensure you only load and reference what you need.</p>
<p>To load a settings file, you instantiate a new <code>Configuration</code> and use one of the <code>Add...</code> methods:</p>
<pre><code>var config = new Configuration();
config.AddJsonFile(&quot;path/to/file.json&quot;);
config.AddXmlFile(&quot;path/to/file.xml&quot;);
config.AddIniFile(&quot;path/to/file.ini&quot;);
</code></pre>
<h2 id="gettingsettings">Getting Settings</h2>
<p>To get settings out, call the <code>Get</code> method. For example, if you have a Json config like so:</p>
<pre><code>{
     &quot;window&quot;: {
         &quot;background&quot;: {
             &quot;color&quot;: &quot;blue&quot;
         }
     }
}
</code></pre>
<p>You can get the color out with the full &#x201C;namespace&#x201D; (for lack of a better term) of the key:</p>
<pre><code>var backgroundColor = config.Get(&quot;window:background:color&quot;);
</code></pre>
<p>The team looks like they&#x2019;re hitting their goal of a lightweight configuration system that&#x2019;s easy to use. They still have some kinks to work out (like how are arrays going to be handled, if at all?) but the initial impressions are positive.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[What is an Assembly Neutral Interface and why do we need it?]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>If you&#x2019;ve spent any time <a href="https://github.com/aspnet">browsing the source of ASP.NET 5</a> (aka vNext), you&#x2019;ve surely seen the <a href="https://github.com/aspnet/HttpAbstractions/blob/7be9cefc4c7671caba7d8fe538ba6a0ad308fdad/src/Microsoft.AspNet.HttpFeature/AssemblyNeutralAttribute.cs"><code>[AssemblyNeutral]</code></a> attribute floating around. What in the hell is that?</p>
<h2 id="somebackground">Some Background</h2>
<p>Right now, interfaces are tied to an assembly. If you want to implement an interface, you</p>]]></description><link>https://davidzych.com/what-is-an-assembly-neutral-interface-and-why-do-we-need-it/</link><guid isPermaLink="false">61ef458c99dc1746fffcb173</guid><category><![CDATA[asp.net]]></category><category><![CDATA[assembly neutral interfaces]]></category><category><![CDATA[david fowler]]></category><category><![CDATA[interfaces]]></category><category><![CDATA[vnext]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Fri, 19 Dec 2014 17:28:47 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>If you&#x2019;ve spent any time <a href="https://github.com/aspnet">browsing the source of ASP.NET 5</a> (aka vNext), you&#x2019;ve surely seen the <a href="https://github.com/aspnet/HttpAbstractions/blob/7be9cefc4c7671caba7d8fe538ba6a0ad308fdad/src/Microsoft.AspNet.HttpFeature/AssemblyNeutralAttribute.cs"><code>[AssemblyNeutral]</code></a> attribute floating around. What in the hell is that?</p>
<h2 id="somebackground">Some Background</h2>
<p>Right now, interfaces are tied to an assembly. If you want to implement an interface, you have to reference the assembly that the interface is declared in. For instance, let&#x2019;s say I&#x2019;m writing a framework, aptly named <em>ZeeFramework</em> (what it actually does and the implementation both don&#x2019;t matter), and in this framework I have an interface for a logger:</p>
<pre><code>namespace Zee
{
    public interface IZeeLogger
    {
        void DoZeeLogging(); //Ironically sounds like &quot;Doozie Logging&quot;
    }
}
</code></pre>
<p>Now, in your application you&#x2019;re writing, you want to use this amazing ZeeFramework (it&#x2019;s been called framework of a generation, so obviously it&#x2019;s amazing). And with this logging component, you want to use <a href="http://logging.apache.org/log4net/">log4net</a>. You have 2 options:</p>
<ol>
<li>You write an implementation yourself</li>
<li>You contact the creators of log4net and tell them to write an implementation</li>
</ol>
<p>The first one sucks because each and every person who wants to use ZeeFramework has to write their own implementation. The second one sucks because the creators of log4net have to create and maintain a package with an implementation for this logger. And other logging frameworks, like nlog, have to do the same.</p>
<p>Okay. Let&#x2019;s say you convince log4net and nlog to write implementations for everyone to use. Great. Now they both have <em>binary dependencies</em> on ZeeFramework just so they can implement <code>IZeeLogger</code>. And what if you, because you&#x2019;re mean and don&#x2019;t like ZeeFramework, create a framework named <em>WhyFramework</em> with another logging interface:</p>
<pre><code>namespace Why
{
    public interface IWhyLogger
    {
        void WhyLog();
    }
}
</code></pre>
<p>And we run into the same issue &#x2013; either everyone writing an application has to write their own implementation, or the logging frameworks have to each maintain a package with an implementation. The logging interfaces are essentially the same &#x2013; why do we need all of these implementations?</p>
<h2 id="letsallliveinharmony">Let&#x2019;s all live in harmony</h2>
<p>In a perfect world, we&#x2019;d have one logging abstraction &#x2013; <code>ILogger</code> &#x2013; that every framework would use. My ZeeFramework and your WhyFramework would be dependent on that, and log4net and nlog and whatever other loggers there are would each maintain a single implementation of that single interface.</p>
<p>So how would that work? We <em>could</em> have a package whose sole member would be the the <code>ILogger</code> interface, but then we&#x2019;re back to having seemingly unnecessary binary dependencies. And besides, who would maintain that? Who would <em>own</em> it?</p>
<h2 id="theassemblyneutralattribute">The AssemblyNeutral attribute</h2>
<p><a href="https://davidzych.com/wp-content/uploads/2014/12/0009-Duck-Commander-Tradema.png"><img src="https://davidzych.com/wp-content/uploads/2014/12/0009-Duck-Commander-Tradema-150x150.png" alt="Swimming Duck" loading="lazy"></a>That&#x2019;s where the <code>[AssemblyNeutral]</code> attribute comes in. When an interface is decorated with this attribute, it&#x2019;s identity is no longer tied to an assembly. Interfaces are now just contracts, and the code basically says &#x201C;hell, all I need to be able to do is call <code>Log</code> &#x2013; can you log or not?&#x201D;. We&#x2019;re getting down to <a href="http://en.wikipedia.org/wiki/Duck_typing">Duck Typing</a> &#x2013; if it walks like a duck, and talks like a duck, well then it must be a duck which means it can do duck-like things.</p>
<p>This removes the unnecessary binary dependencies that we have today, and allows for more loose coupling, which as developers we strive for.</p>
<p>To do this, anyone who wants to use the assembly neutral interface must define it in their code (it must be <strong>exactly</strong> the same!). For instance, if I defined this in ZeeFramework and log4net defined it in their package, we&#x2019;d be good to go:</p>
<pre><code>[AssemblyNeutral]
public interface ILogger
{
    void Log(string message);
}
</code></pre>
<h2 id="why">Why?</h2>
<p>The goal is to:</p>
<ul>
<li>Allows for loose coupling</li>
<li>Less code duplication</li>
<li>Less dependency hell</li>
<li>More community defined standards</li>
</ul>
<p>The ASP.NET vNext team wants to create a vibrant open source eco-system. Part of that includes allowing the community to decide on standards and contracts. This allows the community to more easily achieve that. The more easily these standards <em>can</em> be adopted the more likely they <em>will</em> be adopted.</p>
<p>You can read more about Assembly Neutral Interfaces on the <a href="https://github.com/aspnet/Home/wiki/Assembly-Neutral-Interfaces">ASP.NET Github Wiki</a> or on <a href="http://davidfowl.com/assembly-neutral-interfaces/">David Fowler&#x2019;s blog</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[I understand why Facebook split Messenger into it's own application]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>A large part of programming (probably the largest part) is refactoring. It&#x2019;s the process of taking existing code and improving it. And part of that is determining when a class, feature, or even an application gets too big and splitting it up. It could mean applying the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single</a></p>]]></description><link>https://davidzych.com/i-understand-why-facebook-split-messenger-into-its-own-application/</link><guid isPermaLink="false">61ef458c99dc1746fffcb172</guid><category><![CDATA[facebook]]></category><category><![CDATA[meetings]]></category><category><![CDATA[messenger]]></category><category><![CDATA[Programming]]></category><category><![CDATA[single responsibility principle]]></category><dc:creator><![CDATA[David Zych]]></dc:creator><pubDate>Tue, 11 Nov 2014 17:45:01 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>A large part of programming (probably the largest part) is refactoring. It&#x2019;s the process of taking existing code and improving it. And part of that is determining when a class, feature, or even an application gets too big and splitting it up. It could mean applying the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle">Single Responsibility Principle</a> and splitting a class into 2 or more classes. Or moving features around in the UI so that the app is more organized.</p>
<p>Or even breaking a feature out into it&#x2019;s own application. <a href="http://www.facebook.com">Facebook</a> recently did just that when it split off the messaging portion of Facebook into it&#x2019;s own application, the aptly named <a href="https://www.facebook.com/mobile/messenger"><em>Messenger</em></a>. <a href="http://mashable.com/2014/07/29/facebook-messenger-switch/">They have received some flak for this,</a> and from a user perspective it&#x2019;s definitely not unwarranted. <em>I have to download a new app? A second one? What happens to the old app? What if I&#x2019;m browsing Facebook and I want to respond to a message? Now I have to switch apps? Are the permissions different on both apps? If I change my password do I have to re-login in both apps? Do I have to have the main Facebook app or can I only use messenger?</em> It adds confusion, and one thing that isn&#x2019;t good is confusing your users.</p>
<p>Mark Zuckerberg <a href="http://www.theverge.com/2014/11/6/7170791/mark-zuckerberg-finally-explains-why-he-forced-you-to-download-the">recently explained the reasoning behind the split himself</a>:</p>
<blockquote>
<p>&#x2026; but if we wanted to focus on serving this [use case] well, we had to build a dedicated and focused experience. We build for the whole community. &#x2026; We realize that we have a lot to earn in terms of trust and proving that this standalone messenger experience will be really good. We have some of our most talented people working on this.</p>
</blockquote>
<p>Although people may be confused, what Facebook is trying to do is enhance the messaging user experience. People may not realize it now, but it was the right move, and especially from a programming perspective. They broke off Messenger so they could decrease the size of the teams working on both Messenger and the main Facebook application.</p>
<h3 id="qualityvsquantity">Quality vs Quantity</h3>
<p>The quality of a product often goes down with the number of hands that touch it. The more programmers there are on a team, the more communication paths there are:</p>
<p><a href="https://davidzych.com/wp-content/uploads/2014/11/quad_paths.jpg"><img src="https://davidzych.com/wp-content/uploads/2014/11/quad_paths-580x387.jpg" alt="quad_paths" loading="lazy"></a></p>
<p>Many programmers know that as the size of teams grow, so does the time it takes to complete a feature. And things get forgotten. And Jerry said this but Ronnie said that. And you end up having 6 person code reviews.</p>
<p>And then there are the meetings. Oh god, the meetings. <em>Let&#x2019;s synchronously get together and talk about doing something instead of actually, you know, doing it.</em></p>
<p><a href="https://davidzych.com/wp-content/uploads/2014/11/main-qimg-8bae3fb44a61990ee7840b736b173f4c.gif"><img src="https://davidzych.com/wp-content/uploads/2014/11/main-qimg-8bae3fb44a61990ee7840b736b173f4c.gif" alt="main-qimg-8bae3fb44a61990ee7840b736b173f4c" loading="lazy"></a></p>
<p>Smaller teams are more focused. They&#x2019;re leaner, meaner and can get things done faster. Leaner, meaner, more focused teams means a better overall product &#x2013; both Messenger and Facebook itself. And a better overall product is, obviously, better for users.</p>
<p>I understand the user blowback from this, but overall this was a smart move. Besides, just like <a href="http://mashable.com/2008/09/16/new-facebook-backlash/">every</a> time Facebook <a href="https://www.change.org/p/facebook-bring-back-the-old-design-or-give-users-the-option-to-keep-the-old-design-the-new-design-is-totally-useless-and-awful">changes</a> their <a href="http://www.change.org/p/mark-zuckerberg-creators-of-facebook-change-facebook-layout-back-to-the-old-way">layout</a>, everyone will get used to it in a matter of weeks.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>