<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: John Horner</title>
    <description>The latest articles on DEV Community by John Horner (@johnhorner).</description>
    <link>https://dev.to/johnhorner</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F126110%2Faca7d8f1-dd22-4456-a598-90ad6591de29.jpg</url>
      <title>DEV Community: John Horner</title>
      <link>https://dev.to/johnhorner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/johnhorner"/>
    <language>en</language>
    <item>
      <title>My password policy</title>
      <dc:creator>John Horner</dc:creator>
      <pubDate>Sat, 27 Jul 2019 04:54:28 +0000</pubDate>
      <link>https://dev.to/johnhorner/my-password-policy-n8j</link>
      <guid>https://dev.to/johnhorner/my-password-policy-n8j</guid>
      <description>&lt;p&gt;[&lt;strong&gt;Note&lt;/strong&gt;: I'm going to give examples of passwords in this post. None of them is or has ever been my password for anything. Also I'm using "password" but "passphrase" is probably better.]&lt;/p&gt;

&lt;p&gt;Like most people in the business, I have to use passwords many times a day.&lt;/p&gt;

&lt;p&gt;Like most people in the business, I have to change those passwords frequently, and they have to match a password policy: uppercase, lowercase, numbers and special characters.&lt;/p&gt;

&lt;p&gt;Here's my system for making it as painless as possible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start with an uppercase word. This way you hold down shift, or use caps lock, all in one unbroken string, then forget about it.&lt;/li&gt;
&lt;li&gt;Use dashes between the different parts of the password. Most  "special character" policies don't require anything more special than "not alphanumeric". And you don't need to hold down a modifier key for dashes.&lt;/li&gt;
&lt;li&gt;Use numbers which match words like 4 for "for" etc. which are easy to remember, and failing that replace letters with numbers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And the final one which makes all the difference:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make it something inspiring or motivational&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Say you're thinking of learning a new language this year. Your password could be &lt;code&gt;LEARN-1-new-language&lt;/code&gt; or &lt;code&gt;LEARN-2-code-in-Perl&lt;/code&gt;. Because you're going to type that thing many times a day, right? Why make it a random string like &lt;code&gt;GH^C6e36y%7w&lt;/code&gt; (thanks LastPass) when it could be &lt;code&gt;DO-100-days-of-code&lt;/code&gt;, or &lt;code&gt;WORK-on-th4t-side-project&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;How about a fitness goal like &lt;code&gt;BENCH-press-50-kilos&lt;/code&gt; or &lt;code&gt;RUN-a-faster-5K&lt;/code&gt;? Or maybe a mindfulness goal like &lt;code&gt;READ-4-books-this-month&lt;/code&gt; or &lt;code&gt;MAKE-time-2-meditate&lt;/code&gt; or a social/political one like &lt;code&gt;GIVE-more-2-charity&lt;/code&gt; or &lt;code&gt;DONATE-to-2020-candidate&lt;/code&gt;?&lt;/p&gt;

&lt;p&gt;You can probably think of better ones for yourself. And of course, vary the rules for extra security. Maybe the uppercase string goes at the end, or you use something other than dashes.&lt;/p&gt;

&lt;p&gt;But we might as well redecorate that little room in our brains, which we have to visit so many times a day, with something which inspires us a little.&lt;/p&gt;

</description>
      <category>passwords</category>
      <category>security</category>
      <category>motivation</category>
    </item>
    <item>
      <title>How I figured out what a git pathspec error is, or "well, there's an hour of my life I'm never getting back"</title>
      <dc:creator>John Horner</dc:creator>
      <pubDate>Sat, 09 Mar 2019 06:54:26 +0000</pubDate>
      <link>https://dev.to/johnhorner/how-i-figure-out-what-a-git-pathspec-error-is-or-well-theres-an-hour-of-my-life-im-never-getting-back-ji4</link>
      <guid>https://dev.to/johnhorner/how-i-figure-out-what-a-git-pathspec-error-is-or-well-theres-an-hour-of-my-life-im-never-getting-back-ji4</guid>
      <description>&lt;p&gt;I recently had to get back an earlier version of a specific file from a git repo.&lt;/p&gt;

&lt;p&gt;This is simple as far as git is concerned:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout &amp;lt;commit id&amp;gt; &amp;lt;filename&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;so if you want to get back the version of &lt;code&gt;file.txt&lt;/code&gt; that you had back in commit &lt;code&gt;f6b01b3&lt;/code&gt; you would do&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout f6b01b3 file.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and that's what you'd get.&lt;/p&gt;

&lt;p&gt;But when I did it, I got this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;error: pathspec 'file.txt' did not match any file(s) known to git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;and it took quite a while to figure out what was wrong.&lt;/p&gt;

&lt;p&gt;What had happened is, a folder in the structure above &lt;code&gt;file.txt&lt;/code&gt; had been renamed.&lt;/p&gt;

&lt;p&gt;Here's how to reproduce what happened. Let's create a git repo and a file, inside a folder:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;john$ git init
Initialized empty Git repository in /Users/john/Library/Scripts/gitexample/.git/
john$ mkdir originalfolder
john$ cd originalfolder/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;We make a file, add and commit it. All good.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;john$ echo "this is the initial file" &amp;gt; file.txt
john$ git add file.txt 
john$ git commit file.txt -m "initial"
[master (root-commit) f6b01b3] initial
 1 file changed, 1 insertion(+)
 create mode 100644 originalfolder/file.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;so now, we changed our mind about the name of the folder, we'll rename it (and please note, this is &lt;code&gt;git mv&lt;/code&gt; not just &lt;code&gt;mv&lt;/code&gt;):&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;john$ cd ../
john$ git mv originalfolder/ changedfolder
john$ cd changedfolder/
john$ echo "now I've added a line" &amp;gt;&amp;gt; file.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;we'll commit this new version of the file:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;john$ git commit file.txt -m "second"
[master ab9595b] second
 1 file changed, 2 insertions(+)
 create mode 100644 changedfolder/file.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;no problems there.&lt;/p&gt;

&lt;p&gt;Now we want to get back the version of &lt;code&gt;file.txt&lt;/code&gt; from the original commit.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;john$ git checkout f6b01b3 file.txt 
error: pathspec 'file.txt' did not match any file(s) known to git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;git now says it's got a pathspec error and it can't find &lt;code&gt;file.txt&lt;/code&gt;, which is &lt;em&gt;right there&lt;/em&gt;…&lt;/p&gt;

&lt;p&gt;Obviously, what's wrong is that when commit &lt;code&gt;f6b01b3&lt;/code&gt; was made, it was in a folder, and that folder no longer exists.&lt;/p&gt;

&lt;p&gt;If you want that file back, you'll need to get it back at the original path:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;john$ mkdir ../originalfolder
john$ mkdir cd ../originalfolder/
john$ git checkout f6b01b3 file.txt 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;this goes through with no problem.&lt;/p&gt;

</description>
      <category>git</category>
    </item>
    <item>
      <title>Live Code idea — a weird new way of giving code presentations</title>
      <dc:creator>John Horner</dc:creator>
      <pubDate>Sun, 03 Feb 2019 08:24:22 +0000</pubDate>
      <link>https://dev.to/johnhorner/live-code-idea--a-weird-new-way-of-giving-code-presentations-229h</link>
      <guid>https://dev.to/johnhorner/live-code-idea--a-weird-new-way-of-giving-code-presentations-229h</guid>
      <description>&lt;p&gt;I came up with an interesting way to do presentations/demos involving showing code, and I thought you might be interested, so here's a video.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/5DL3b81xFYI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>code</category>
      <category>perl</category>
      <category>presentation</category>
      <category>git</category>
    </item>
  </channel>
</rss>
