<?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: Chris L</title>
    <description>The latest articles on DEV Community by Chris L (@lubekpl).</description>
    <link>https://dev.to/lubekpl</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%2F7366%2F36d08712-aa61-43d6-a2d6-d0b6c592398b.jpg</url>
      <title>DEV Community: Chris L</title>
      <link>https://dev.to/lubekpl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lubekpl"/>
    <language>en</language>
    <item>
      <title>Switch context faster with git worktree</title>
      <dc:creator>Chris L</dc:creator>
      <pubDate>Fri, 25 Oct 2019 14:57:28 +0000</pubDate>
      <link>https://dev.to/lubekpl/switch-context-faster-with-git-worktree-3jil</link>
      <guid>https://dev.to/lubekpl/switch-context-faster-with-git-worktree-3jil</guid>
      <description>&lt;p&gt;Working with git has made lives of many developers in the world a lot easier but it also brought some quirks, especially for those who work in fast paced environments. Having multiple branches and working on many things at once is a normal thing nowadays.&lt;/p&gt;

&lt;p&gt;So, what do you do when you're working on a feature, you're deep down the rabbit hole, and suddenly, you have to switch and work on something else like a hotfix?&lt;/p&gt;

&lt;p&gt;For me, personally, it meant that I'd stash my changes, fetch master, create a new branch and restart my editor to not have cluster of opened files. That also meant that when I finished working on the hotfix and when I got back to the original feature my reaction was somewhat like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3orfk8d0ogifcevs0lu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl3orfk8d0ogifcevs0lu.gif" alt="confused" width="240" height="172"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's introduce &lt;code&gt;git worktree&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A git repository can support multiple working trees, allowing you to check out more than one branch at a time&lt;br&gt;
&lt;a href="https://git-scm.com/docs/git-worktree" rel="noopener noreferrer"&gt;https://git-scm.com/docs/git-worktree&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  But what does it mean?
&lt;/h3&gt;

&lt;p&gt;Using &lt;code&gt;worktree&lt;/code&gt; you can easily create a local copy of your desired branch outside your main repo, work on it like you'd normally would, without having to stash anything!&lt;/p&gt;

&lt;h3&gt;
  
  
  Enough talk, show me the code!
&lt;/h3&gt;

&lt;p&gt;In your main repo dir do&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git worktree add -b super_important_hotfix ../super_important_hotfix origin/master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a new directory with an exact copy of your repository (at &lt;code&gt;origin/master&lt;/code&gt;) and switch to a new branch called &lt;code&gt;super_important_hotfix&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;You can now work on your super important hotfix without polluting the main dir.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch super_important_hotfix.txt
git add super_important_hotfix.txt
git commit -m 'Fixed bug'
git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go back to your main repo dir and eveything is exactly the same you left it!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk98apbqi2xcx2gjanlg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyk98apbqi2xcx2gjanlg.gif" alt="tada" width="480" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you're done with you hotfix you can remove the dir we created for it and run &lt;code&gt;git worktree prune&lt;/code&gt; from the original directory to cleanup references to it.&lt;/p&gt;

&lt;p&gt;You can have a more in depth look at &lt;code&gt;git worktree&lt;/code&gt; &lt;a href="https://git-scm.com/docs/git-worktree" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

&lt;p&gt;Love Ruby, new tech, and working remotely? Check out &lt;a href="https://leadfeeder.com/jobs" rel="noopener noreferrer"&gt;https://leadfeeder.com/jobs&lt;/a&gt; and don't forget to mention my name!&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>workflow</category>
    </item>
    <item>
      <title>How to quickly search all your repos at once</title>
      <dc:creator>Chris L</dc:creator>
      <pubDate>Wed, 06 Mar 2019 11:29:21 +0000</pubDate>
      <link>https://dev.to/lubekpl/how-to-quickly-search-all-your-repos-at-once-2j6g</link>
      <guid>https://dev.to/lubekpl/how-to-quickly-search-all-your-repos-at-once-2j6g</guid>
      <description>&lt;p&gt;Working with microservices can be a pain, especially when one change can require multiple places to update. You have to check various repositories for occurrences of the piece of code you need to change. What can you do in that situation?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open all your repos in your favourite editor at once&lt;/li&gt;
&lt;li&gt;Use GitHub's search&lt;/li&gt;
&lt;li&gt;Open each and every one of your repos and search manually&lt;/li&gt;
&lt;li&gt;Follow instructions below and start using &lt;a href="https://github.com/etsy/hound" rel="noopener noreferrer"&gt;Hound&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  What is Hound and how to set it up locally?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Hound is an extremely fast source code search engine. The core is based on this article (and code) from Russ Cox: Regular Expression Matching with a Trigram Index. Hound itself is a static React frontend that talks to a Go backend. The backend keeps an up-to-date index for each repository and answers searches through a minimal API.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;from &lt;a href="https://github.com/etsy/hound" rel="noopener noreferrer"&gt;https://github.com/etsy/hound&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;And here's how it works!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs6f6egzt2wfezpmf0i6w.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs6f6egzt2wfezpmf0i6w.gif" alt="preview" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's what you do:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go to the folder you want to keep the configs for Hound, for me it was &lt;code&gt;~/code/hound&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;config.json&lt;/code&gt; file, that points to your local repositories, like this
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;docker run -d -p 6080:6080 --name hound -v $(pwd):/data -v ~/code:/code etsy/hound&lt;/code&gt;.
Please remember that if the folder you keep your repos at is named differently, you have to adjust it in the &lt;code&gt;config.json&lt;/code&gt; and in the docker command, specifically &lt;code&gt;-v ~/code:/code&lt;/code&gt; part!&lt;/li&gt;
&lt;li&gt;Go to &lt;code&gt;localhost:6080&lt;/code&gt; &amp;amp; enjoy your quick search!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Bonus: Hound has integrations with Sublime, Vim, Emacs &amp;amp; Visual Studio code so you don't have to leave your favorite editor!&lt;/p&gt;

&lt;p&gt;Shout out to &lt;a href="https://twitter.com/kmossco" rel="noopener noreferrer"&gt;https://twitter.com/kmossco&lt;/a&gt; and &lt;a href="https://twitter.com/balazs_kutil" rel="noopener noreferrer"&gt;https://twitter.com/balazs_kutil&lt;/a&gt; for showing me Hound 🙇&lt;/p&gt;

&lt;p&gt;Don't forget to check out my other posts at &lt;a href="https://dev.to/lubekpl"&gt;here&lt;/a&gt;.&lt;br&gt;
Love Ruby, new tech, and working remotely? Check out &lt;a href="https://leadfeeder.com/jobs" rel="noopener noreferrer"&gt;https://leadfeeder.com/jobs&lt;/a&gt; and don't forget to mention my name!&lt;/p&gt;

</description>
      <category>git</category>
      <category>tutorial</category>
      <category>productivity</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>General ideas/guidelines for fresh developers</title>
      <dc:creator>Chris L</dc:creator>
      <pubDate>Tue, 05 Jun 2018 21:31:19 +0000</pubDate>
      <link>https://dev.to/lubekpl/general-ideasguidelines-for-fresh-developers-1ej3</link>
      <guid>https://dev.to/lubekpl/general-ideasguidelines-for-fresh-developers-1ej3</guid>
      <description>&lt;p&gt;This is a very general guide for less experienced software developers. It took me some time to realize these over the years and I think it would be a great help to me back when I started with coding.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Your code should be readable. Why? This great quote will explain it all.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Indeed, the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. ...[Therefore,] making it easy to read makes it easier to write&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Robert C. Martin&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tests... Some clients/project managers believe that spending money on testing is a waste. You don't need that kind of negativity in your life. Tests are very useful for a bunch of reasons! First of all, they check if your code actually does what it's supposed to do. Second, refactoring - have you ever tried to refactor a class and &lt;em&gt;hoped&lt;/em&gt; that each method returns the same result as before? Tests are also a type of documentation that helps new teammates understand what how and why.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Even though code never lies and comments sometimes do, it's generally a good idea to comment your code. Try to shy away from comments that explain your complicated code (see point 1) and use comments as a way to explain the business logic. Why this piece of code does what it does.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;As a developer, it's your responsibility to take care of your &lt;del&gt;child&lt;/del&gt; code. You think that a refactoring is in place? Get your client or project manager and explain to them why refactoring is a good idea and is needed. Technical debt always comes back.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ever wonder what's with all the rubber ducks around developers? When you're stuck on a piece of code you can try explaining it to a rubber duck. This method is called &lt;a href="https://en.wikipedia.org/wiki/Rubber_duck_debugging" rel="noopener noreferrer"&gt;rubber duck debugging&lt;/a&gt; and it's a very powerful weapon in a developer's arsenal. Talking about your code and trying to explain it to somebody will help you get unstuck and think differently about your code.&lt;br&gt;
Sometimes even a duck won't help. Talk to other people, preferably other developers ;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have you heard of Agile? There's this idea of a daily meeting where the team talks to each other and shares problems or issues. Give that a try, it's easier to share ideas and ask for help when everyone knows what you're doing.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Documentation. Even more dreaded then tests. Tell me this, how would you use your favorite API or 3rd party service without their docs? Keep your teammates and other teams happy when working with them and document public-facing things.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remeber the principles of software development (&lt;a href="https://en.wikipedia.org/wiki/Don't_repeat_yourself" rel="noopener noreferrer"&gt;DRY&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/KISS_principle" rel="noopener noreferrer"&gt;KISS&lt;/a&gt;, &lt;a href="https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)" rel="noopener noreferrer"&gt;SOLID&lt;/a&gt;, and &lt;a href="https://en.wikipedia.org/wiki/You_aren't_gonna_need_it" rel="noopener noreferrer"&gt;YAGNI&lt;/a&gt;) and try to use them on a daily basis, e.g. extracting a class or a module (DRY) will help to keep your code maintainable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sometimes when you read through the code you can find some oddities or simply a bad piece of code. Sure it works, but if you can improve it easily then why not? It's called the boy scout rule - "Always leave the campground cleaner than you found it".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;"Measure twice, cut once" - it's always better to think about (or write down) things before doing actual development.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It may come as a surprise to you, but you're human. Everybody makes mistakes. &lt;em&gt;You&lt;/em&gt; make mistakes. Get it over with. Making mistakes is a part of the job, I'd say. Try to make the most of it and when you make a mistake, try to learn from it as much as possible.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Don't hesitate to ask questions and oppose ideas. Questions can spark a discussion on why this feature is needed, how we should implement it, and what are the risks of this implementation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Be eager to learn and to spread your knowledge. Books, blog posts, RSS feeds, conferences, podcasts, local user group meetings. Those are great to learn new things and to talk about your experiences.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Always keep an eye out for new libraries and new versions of frameworks/libraries that you use. Newer versions bring new and exciting features!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use your workflow to your advantage. You're using vim? Great. Atom? Nice. Sublime? Yay. Write down your code on pieces of paper and then scan them? Whatever floats your boat. You want to know which editor/ide is the best? The best is the one that makes you feel comfortable. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Try to be professional. Don't use phrases like "we'll see" and "hopefully". How would you feel if you took your car to a mechanic and he'd tell you that hopefully, he'll fix it?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Never be afraid to ask. If you don't know something or are not sure, for the love of god, ASK.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;PS. Oh, and take &lt;a href="https://xkcd.com/323/" rel="noopener noreferrer"&gt;Ballmer Peak&lt;/a&gt; into consideration! ;)&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
  </channel>
</rss>
