<?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: Robus Gauli</title>
    <description>The latest articles on DEV Community by Robus Gauli (@robusgauli).</description>
    <link>https://dev.to/robusgauli</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%2F499402%2Feafb59c1-30f2-406f-b879-39a7a61b0dbb.jpeg</url>
      <title>DEV Community: Robus Gauli</title>
      <link>https://dev.to/robusgauli</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/robusgauli"/>
    <language>en</language>
    <item>
      <title>Essence of Terraform</title>
      <dc:creator>Robus Gauli</dc:creator>
      <pubDate>Thu, 19 Nov 2020 15:51:01 +0000</pubDate>
      <link>https://dev.to/robusgauli/essence-of-terraform-4fb0</link>
      <guid>https://dev.to/robusgauli/essence-of-terraform-4fb0</guid>
      <description>&lt;p&gt;This blog post is more on the fundamental principle of Terraform and hopefully should provide you a framework and a perspective to understand the &lt;strong&gt;Essence of Terraform&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If anyone of you who is going through this does not have a basic understanding of Terraform, I highly encourage you to go through the basics and get back to this blog post. &lt;/p&gt;

&lt;p&gt;Having worked with Terraform since its early inception and professionally migrated and provisioned around seven infrastructures, I do feel like I am somewhat qualified to comment on a few aspects of Terraform. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;The Essence&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. &lt;em&gt;-- From Official Terraform Documentation&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The above definition of Terraform simply means it is a tool that allows us to write syntactically structured configuration describing infrastructure resources. It is also responsible for managing the lifecycle of resources throughout different stages such as provisioning, changes, versioning, and destruction.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: Resources could be your S3 Bucket, AKS cluster, EKS cluster, ECR, EC2 instance, Azure blob, etc. You get the idea.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But if we think about it, &lt;strong&gt;Terraform is the best possible documentation you could have of your infrastructure that actively mirrors your live infrastructure.&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The advantage here is that Terraform can understand your documentation and augment it with runtime. This runtime will then "ideally" try to reflect your updated documentation with actual infrastructure in your Cloud. For instance, if your documentation mentions 3 EC2 instances and your current infrastructure has 2 instances, it will spawn one extra instance to match your documentation. Similarly, it will remove 2 instances if your documentation mentions 1 instance and your actual infrastructure has 3 instances running.&lt;/p&gt;

&lt;p&gt;The only job of Terraform is to match whatever you have documented in the form of configuration against your live infrastructure. And during this process of trying to converge to the desired state from the actual state, it does all sorts of trickery such as deletion of resources, an in-place update of resources, and creation of resources. &lt;/p&gt;

&lt;p&gt;It will "magically" figure out the dependency graph of all your resources and comes up with the action plans in order to reach that desired state. This action plan that it comes up with in order to reach the desired state from the actual state is captured by the command called &lt;code&gt;terraform plan&lt;/code&gt;. This command will provide you with a series of actions such as create, delete, or update that it will execute to converge to the desired state.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4gde4fb11kcxckurura4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F4gde4fb11kcxckurura4.png" title="Terraform lifecycle of resources" alt="Terraform Lifecycle"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, you will run &lt;code&gt;terraform apply&lt;/code&gt; if you think the proposed action plans generated by &lt;code&gt;terraform plan&lt;/code&gt; are what you actually intended for. After successful completion of &lt;code&gt;terraform apply&lt;/code&gt;, you will have your live infrastructure that exactly matches your documentation.&lt;/p&gt;

&lt;p&gt;I believe this is everything you need to know in order to understand the very &lt;strong&gt;Essence of Terraform&lt;/strong&gt; and the rest is implementation details.&lt;/p&gt;

&lt;p&gt;P.S. The word "documentation" for writing those configurations is called &lt;strong&gt;&lt;a href="https://github.com/hashicorp/hcl" rel="noopener noreferrer"&gt;HCL&lt;/a&gt;&lt;/strong&gt; which stands for &lt;strong&gt;Hashicorp Configuration Language&lt;/strong&gt;. This is JSON compatible and allows us to declare those infrastructure resources which is then interpreted by Terraform. They like to call it "Human Readable", but I am not sure if I agree 100% with that claim.&lt;/p&gt;

&lt;p&gt;Do follow me on &lt;a href="https://github.com/RobusGauli" rel="noopener noreferrer"&gt;github&lt;/a&gt;, &lt;a href="https://twitter.com/robusgauli1" rel="noopener noreferrer"&gt;twitter&lt;/a&gt; and &lt;a href="https://robusgauli.medium.com" rel="noopener noreferrer"&gt;medium&lt;/a&gt;. Thanks a lot.&lt;/p&gt;

</description>
      <category>terraform</category>
      <category>infrastructure</category>
      <category>devops</category>
      <category>sre</category>
    </item>
    <item>
      <title>5 things I wish I knew before adding a variable in .env</title>
      <dc:creator>Robus Gauli</dc:creator>
      <pubDate>Wed, 18 Nov 2020 15:31:44 +0000</pubDate>
      <link>https://dev.to/robusgauli/5-things-i-wish-i-knew-before-adding-a-variable-in-env-4op3</link>
      <guid>https://dev.to/robusgauli/5-things-i-wish-i-knew-before-adding-a-variable-in-env-4op3</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FzAT9y8m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimgur.com%2FzAT9y8m.png" alt=".envimage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TLDR:&lt;/strong&gt; Configuration management is hard. Fix it before digging a deeper hole.&lt;/p&gt;

&lt;p&gt;Below is the sample .env file that looks pretty standard and innocent. This does not necessarily map to a real-world configuration where you could expect this file to contain way more environment variables.This is pretty standard in projects and we used to roll with it until I started to deal with configurations over the years in regards to managing, provisioning, rotations, policy enforcement, and secrets management.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
 
&lt;h2&gt;
  
  
  &lt;strong&gt;1. Explicit over Implicit&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Never allow optional/default value for a configurable variable. How many times you have seen &lt;em&gt;localhost&lt;/em&gt; in your staging/QA environments? How many times you are not able to connect to the database because it used a default value such as &lt;em&gt;Postgres&lt;/em&gt; or &lt;em&gt;Testuser&lt;/em&gt; because you missed configuring the database in the foo environment? &lt;/p&gt;

&lt;p&gt;This gets even difficult when you have to hand off your project you are working on to the Dev ops engineer and they have to deal with your default values for the configurable variable. The next day, your deployed application redirects to &lt;em&gt;localhost:5000/callback?…&lt;/em&gt; when the user is authenticated. &lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;REMEDY&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Crash your application and scream with giant and ugly stack trace until configuration variables are explicitly jotted or provisioned. &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;2. Separation of Build and Run time Configuration&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I often see running applications that are deployed in the cloud have environment variables such as &lt;em&gt;ECR_REPO_URL&lt;/em&gt;, &lt;em&gt;AWS_ACCESS_KEY&lt;/em&gt;, etc. I immediately smell the situation where developers are polluting their &lt;strong&gt;run time&lt;/strong&gt; environment variables with &lt;strong&gt;build-time&lt;/strong&gt; environment variables. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;ECR_REPO_URL&lt;/em&gt; was used to push the application's OCI image to a remote repository and &lt;em&gt;AWS_ACCESS_KEY&lt;/em&gt; was used to authenticate against AWS to upload artifacts to s3. These variables were clearly used to package the application and not used during the application's runtime. And yet we still put those build-time environment variables in our classic &lt;em&gt;.env&lt;/em&gt; file all the time which are supposed to be used for runtime.&lt;/p&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;REMEDY&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Separate your environment variables explicitly for different stages in your development and deployment pipelines.&lt;br&gt;
 &lt;br&gt;
For instance, you could use &lt;em&gt;.env.build&lt;/em&gt; for build and &lt;em&gt;.env.run&lt;/em&gt; for runtime configuration. Over time, you have to manage configurations for integration tests, documentation, etc but hope you got the idea.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;3. Mode is better than Prefixed Variable name&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the above &lt;em&gt;.env&lt;/em&gt; file, you could see that it is &lt;em&gt;TEST_APP_HOST&lt;/em&gt; for the test environment and &lt;em&gt;APP_HOST&lt;/em&gt; for the production environment. &lt;em&gt;TEST&lt;/em&gt; is prefixed to signify that the &lt;em&gt;TEST_APP_HOST&lt;/em&gt; variable is used for the app host in the test environment. This is just a horrible idea in the first place.&lt;/p&gt;

&lt;p&gt;This should remind your code that looks something like this&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;It becomes exponentially difficult to maintain environment variables based on the environment as a number of environments such as staging, QA, pre-production, etc are introduced. And the worst part is, your unit and integration tests in your development won't ensure the full coverage as you won't be testing the code that branches off when you configure it to production.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;REMEDY&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Use mode to signify the environment and keep the rest of the environment variables without any prefixes.The below code example should give you the idea where we branch off using mode and keep the rest of the statements the same across environments. &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The above code example uses &lt;a href="https://golang.org/" rel="noopener noreferrer"&gt;Golang&lt;/a&gt; as a programming language but should be fairly simple. We enabled tracer and disabled debugging in production and kept the same variable name APP_HOST and APP_PORT irrespective of different environments.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;4. Synchronize .env and .env.example files&lt;/strong&gt;
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Hey, could you pass me your .env file?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's admit it, your &lt;em&gt;.env.example&lt;/em&gt; file always looks "short and sweet" over time while your &lt;em&gt;.env&lt;/em&gt; file includes variables that were added during development which does not exist in the .env.example file. You have to copy-paste your environment files to your team member while they are bootstrapping their project because he/she could not run the project as few environment variables were missing which was not included in the &lt;em&gt;.env.example&lt;/em&gt; file.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;REMEDY&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;Make &lt;em&gt;.env.example&lt;/em&gt; part of your program and crash your app with the ugly exception (if your language has one) if there is a deviation between your &lt;em&gt;.env&lt;/em&gt; and &lt;em&gt;.env.example&lt;/em&gt;. This will ensure that your &lt;em&gt;.env&lt;/em&gt; and &lt;em&gt;.env.example&lt;/em&gt; are in sync and no one in the team has to guess what is missing. You could use tools such as &lt;a href="https://github.com/codeshifu/sync-dotenv" rel="noopener noreferrer"&gt;sync-dotenv&lt;/a&gt; to enforce this.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;5. Handle Secrets secretly&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We tend to manage our secrets similar to how we manage other environment variables such as &lt;em&gt;DB_USER&lt;/em&gt;, &lt;em&gt;DB_HOST&lt;/em&gt;. &lt;em&gt;DB_PASSWORD&lt;/em&gt; is a secret and requires way more policies around it such as rotations, leasing, revoking auditing, and much more. These secrets are usually dynamic i.e changes over time. Since these secrets require more bookkeeping than the rest of the environment variables, it's best to use tools that are best fit for managing such complexities. &lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;REMEDY&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;It really depends on the deployment platform. If you are using Kubernetes, you could use a Config map object to store your configuration and a Secrets object to store your sensitive information. You could also opt for &lt;a href="https://www.hashicorp.com/products/vault/secrets-management" rel="noopener noreferrer"&gt;Vault&lt;/a&gt; by Hashicorp which manages complexities around secrets. If you don't want to manage the Vault Cluster, you could go for services such as &lt;a href="https://secrethub.io/" rel="noopener noreferrer"&gt;Secret Hub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>configuration</category>
      <category>env</category>
      <category>environment</category>
      <category>variables</category>
    </item>
    <item>
      <title>Types of programmers using Fibonacci series</title>
      <dc:creator>Robus Gauli</dc:creator>
      <pubDate>Tue, 27 Oct 2020 06:25:26 +0000</pubDate>
      <link>https://dev.to/robusgauli/types-of-programmers-using-fibonacci-series-35g1</link>
      <guid>https://dev.to/robusgauli/types-of-programmers-using-fibonacci-series-35g1</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Warning: Not recommended for fainted ❤️  Enjoy 🤘&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Functional prodigy&lt;/li&gt;
&lt;li&gt;Meta functional expert&lt;/li&gt;
&lt;li&gt;One liner wizard&lt;/li&gt;
&lt;li&gt;The Librarian&lt;/li&gt;
&lt;li&gt;Classy theorist&lt;/li&gt;
&lt;li&gt;Closure fanatic&lt;/li&gt;
&lt;li&gt;Lazy idealist&lt;/li&gt;
&lt;li&gt;OO based lazy conservative&lt;/li&gt;
&lt;li&gt;Generator magician&lt;/li&gt;
&lt;li&gt;Iterator maniac&lt;/li&gt;
&lt;li&gt;Rob Pike&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Functional prodigy
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Meta Functional Expert
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nth&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;nth&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;series&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;series&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  One Liner Wizard
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# f and not fib because functional laws
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  The Librarian
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install &lt;/span&gt;fibonacci
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;fibonacci&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;fibo&lt;/span&gt;

&lt;span class="n"&gt;series&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;fibo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;series&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Classy Theorist
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Fibonacci&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nth&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nth&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;
              &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;
              &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Fibonacci&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# God bless getters
&lt;/span&gt;    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Closure Fanatic
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;functools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;wraps&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;closo_fibo_stream&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="c1"&gt;# precious closures
&lt;/span&gt;    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="o"&gt;@&lt;/span&gt;&lt;span class="n"&gt;wraps&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;wrapper&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;kwargs&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;nonlocal&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
        &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;wrapper&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;streamer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;closo_fibo_stream&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;series&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;streamer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;series&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Lazy Idealist
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;lazy_fibo&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
        &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;itertools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;islice&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;islice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lazy_fibo&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# i feel good
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  OO based Lazy conservative
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# refactored into class coz why not??
&lt;/span&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LazyFibo&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__iter__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;itertools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;islice&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;islice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LazyFibo&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Generator Magician
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fib_magico&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;fib_magico&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;itertools&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;islice&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;islice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fib_magico&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Iterator Maniac
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;fib_iter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__next__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nb"&gt;StopIteration&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"don't care anymore"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__iter__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fib_iter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Rob Pike
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fib&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
    &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4&gt;
  
  
  Thanks!! Checkout the repo below
&lt;/h4&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/RobusGauli"&gt;
        RobusGauli
      &lt;/a&gt; / &lt;a href="https://github.com/RobusGauli/n-ways-to-fibonacci-series"&gt;
        n-ways-to-fibonacci-series
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      But why?
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;
  &lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#"&gt;
    &lt;img src="https://camo.githubusercontent.com/18c2929eb5579c9ab244099ff96f02d4ccb95a8f40dcc52801b8e71b6a6393e0/687474703a2f2f7777772e657073696c6f6e65732e636f6d2f6d6174657269616c2f61727465732f3032372d6669626f6e616363692d706973612e6a7067" alt="statue" width="72" height="72"&gt;
  &lt;/a&gt;
  &lt;/p&gt;
&lt;h3&gt;
11 ways to Fibonacci series&lt;/h3&gt;
  &lt;p&gt;
    because I'm bored and software are broken. Don't believe me
    &lt;br&gt;
  &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Warning: Not recommended for fainted ❤️  Enjoy 🤘&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
By professionals&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#functional-prodigy"&gt;Functional prodigy&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#meta-functional-expert"&gt;Meta functional expert&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#one-liner-wizard"&gt;One liner wizard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#the-librarian"&gt;The Librarian&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#classy-theorist"&gt;Classy theorist&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#closure-fanatic"&gt;Closure fanatic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#lazy-idealist"&gt;Lazy idealist&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#OO-based-lazy-conservative"&gt;OO based lazy conservative&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#generator-maniac"&gt;Generator magician&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#iterator-maniac"&gt;Iterator maniac&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://raw.githubusercontent.com/RobusGauli/n-ways-to-fibonacci-series/master/#abandoned"&gt;Abandoned&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Functional prodigy&lt;/h2&gt;
&lt;div class="highlight highlight-source-python js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;fib&lt;/span&gt;(&lt;span class="pl-s1"&gt;n&lt;/span&gt;)
    &lt;span class="pl-k"&gt;if&lt;/span&gt; &lt;span class="pl-s1"&gt;n&lt;/span&gt; &lt;span class="pl-c1"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="pl-c1"&gt;1&lt;/span&gt;:
        &lt;span class="pl-k"&gt;return&lt;/span&gt; &lt;span class="pl-s1"&gt;n&lt;/span&gt;
    &lt;span class="pl-k"&gt;return&lt;/span&gt; &lt;span class="pl-en"&gt;fib&lt;/span&gt;(&lt;span class="pl-s1"&gt;n&lt;/span&gt;&lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;1&lt;/span&gt;) &lt;span class="pl-c1"&gt;+&lt;/span&gt; &lt;span class="pl-en"&gt;fib&lt;/span&gt;(&lt;span class="pl-s1"&gt;n&lt;/span&gt;&lt;span class="pl-c1"&gt;-&lt;/span&gt;&lt;span class="pl-c1"&gt;2&lt;/span&gt;)&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
Meta Functional Expert&lt;/h2&gt;
&lt;div class="highlight highlight-source-python js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-k"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;fib&lt;/span&gt;(&lt;span class="pl-s1"&gt;a&lt;/span&gt;, &lt;span class="pl-s1"&gt;b&lt;/span&gt;, &lt;span class="pl-s1"&gt;nth&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;0&lt;/span&gt;, &lt;span class="pl-s1"&gt;current&lt;/span&gt;&lt;span class="pl-c1"&gt;=&lt;/span&gt;&lt;span class="pl-c1"&gt;0&lt;/span&gt;):
    &lt;span class="pl-k"&gt;if&lt;/span&gt; &lt;span class="pl-s1"&gt;nth&lt;/span&gt; &lt;span class="pl-c1"&gt;==&lt;/span&gt; &lt;span class="pl-s1"&gt;current&lt;/span&gt;:
        &lt;span class="pl-k"&gt;return&lt;/span&gt; &lt;span class="pl-s1"&gt;a&lt;/span&gt;
    &lt;span class="pl-k"&gt;return&lt;/span&gt; &lt;span class="pl-en"&gt;fib&lt;/span&gt;(&lt;span class="pl-s1"&gt;b&lt;/span&gt;, &lt;span class="pl-s1"&gt;a&lt;/span&gt; &lt;span class="pl-c1"&gt;+&lt;/span&gt; &lt;span class="pl-s1"&gt;b&lt;/span&gt;, &lt;span class="pl-s1"&gt;nth&lt;/span&gt;, &lt;span class="pl-s1"&gt;current&lt;/span&gt;&lt;span class="pl-c1"&gt;+&lt;/span&gt;&lt;span class="pl-c1"&gt;1&lt;/span&gt;)

&lt;span class="pl-k"&gt;def&lt;/span&gt; &lt;span class="pl-en"&gt;main&lt;/span&gt;():
    &lt;span class="pl-s1"&gt;series&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; [&lt;span class="pl-en"&gt;fib&lt;/span&gt;(&lt;span class="pl-c1"&gt;0&lt;/span&gt;,&lt;span class="pl-c1"&gt;1&lt;/span&gt;,&lt;span class="pl-s1"&gt;n&lt;/span&gt;) &lt;span class="pl-k"&gt;for&lt;/span&gt; &lt;span class="pl-s1"&gt;n&lt;/span&gt; &lt;span class="pl-c1"&gt;in&lt;/span&gt; &lt;span class="pl-en"&gt;range&lt;/span&gt;(&lt;span class="pl-c1"&gt;50&lt;/span&gt;)]
    &lt;span class="pl-en"&gt;print&lt;/span&gt;(&lt;span class="pl-s1"&gt;series&lt;/span&gt;)&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
One Liner Wizard&lt;/h2&gt;
&lt;div class="highlight highlight-source-python js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-s1"&gt;f&lt;/span&gt; &lt;span class="pl-c1"&gt;=&lt;/span&gt; &lt;span class="pl-k"&gt;lambda&lt;/span&gt; &lt;span class="pl-s1"&gt;n&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/RobusGauli/n-ways-to-fibonacci-series"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;



</description>
      <category>python</category>
      <category>functional</category>
      <category>go</category>
    </item>
    <item>
      <title>How do I work on multiple projects simultaneously without losing my mind</title>
      <dc:creator>Robus Gauli</dc:creator>
      <pubDate>Tue, 27 Oct 2020 02:33:43 +0000</pubDate>
      <link>https://dev.to/robusgauli/how-do-i-work-on-multiple-projects-simultaneously-without-losing-my-mind-5h3o</link>
      <guid>https://dev.to/robusgauli/how-do-i-work-on-multiple-projects-simultaneously-without-losing-my-mind-5h3o</guid>
      <description>&lt;p&gt;When you work for a company that has multiple projects running at the same time and your job is to constantly context switch between projects, it becomes nearly impossible to wrap your head around given the project and problem at hand to work on.&lt;/p&gt;

&lt;p&gt;Sometimes I am writing K8s ingress configuration for Azure managed Ingress controller where I am required to open up the terminal with Kubectl client configured with the appropriate context, setup VPN connection, open up K8s dashboard to tail logs and sometimes I am writing Dagster pipeline in Python where I am required to set up Redis instance, Celery worker, Rabbitmq, Python’s Virtualenv required, etc etc etc.&lt;/p&gt;

&lt;p&gt;I have to sometimes work on 4 to 5 projects in a day and switching between these projects was becoming a pain in my brain. And the worst thing was, it sometimes took me half an hour to switch to project and set up bells and whistles and finally 3 minutes to fix a bug/issue at hand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia1.tenor.com%2Fimages%2F3454aa74f6f3b89aba749a28b93932c1%2Ftenor.gif%3Fitemid%3D7212027" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia1.tenor.com%2Fimages%2F3454aa74f6f3b89aba749a28b93932c1%2Ftenor.gif%3Fitemid%3D7212027" alt="frustation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I knew it was getting out of my hand and I had to do something about it. I knew one open-source tool called &lt;a href="https://github.com/tmux/tmux" rel="noopener noreferrer"&gt;&lt;strong&gt;TMUX&lt;/strong&gt;&lt;/a&gt; that could potentially solve my issues, but I had not given serious thoughts. I started playing with Tmux once again, it gave me a way to create multiple terminal windows, split a single window into multiple child terminals (also known as panes), switch between multiple terminal windows, and a lot more. It also gave me a way to manage multiple projects simultaneously by allowing me to create multiple tmux sessions. I was super pleased with what it had to offer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1000%2F1%2AwNISmAmDIWRh939jbBEB7A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1000%2F1%2AwNISmAmDIWRh939jbBEB7A.png" alt="sample-screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above image shows my setup where I have three windows setup for a single project. They are called &lt;strong&gt;function&lt;/strong&gt;, &lt;strong&gt;api&lt;/strong&gt;, and &lt;strong&gt;database&lt;/strong&gt;. I typically name a window based on what they are intended for. If I need to write/debug SQL queries, I would quickly switch to the &lt;strong&gt;database&lt;/strong&gt; window and I would switch to &lt;strong&gt;api&lt;/strong&gt; if I need to work on the API side of the project. If you look closely, the API window consists of 3 child terminals called panes where I keep Neovim(code editor), Virtualenv activated terminal and Postman process running.&lt;/p&gt;

&lt;p&gt;Tmux was a game-changer for me. It gets even better if your primary code editor is Vim. Vim + Tmux simply deserves its Own blog. If I were to put it in one sentence, its nothing but &lt;strong&gt;Match made in heaven ❤&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Okay, now I was able to manage multiple projects using sessions and create multiple terminal windows using Tmux’s windows and panes, you might be wondering if there is anything left to polish. And the answer is &lt;strong&gt;YES&lt;/strong&gt; and here are the reasons below:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The way to create sessions and windows was using its command line program called tmux . For example, to create a new window, you had to run &lt;code&gt;tmux new-window -c /home/mojo/jojo -n database -t project:1&lt;/code&gt; to split a window into panes, you had to run &lt;code&gt;tmux split-window -c /home/mojo/jojo...&lt;/code&gt; . You get the idea. It was pretty verbose and imperative.&lt;/li&gt;
&lt;li&gt;I had to remember all those commands every time I restart my laptop or kill the Tmux server.&lt;/li&gt;
&lt;li&gt;When your project is relatively complex, you had to run 30/40 of these commands and hope you didn’t mess up. Imagine doing this for 4 to 5 projects. It quickly gets unmanageable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Therefore, I wanted something that was more declarative. I wanted something where I could just declare What I wanted instead of How I wanted. I present to you &lt;a href="https://github.com/robusgauli/mx.sh" rel="noopener noreferrer"&gt;&lt;strong&gt;mx.sh&lt;/strong&gt;&lt;/a&gt; a tool that I wrote for managing Tmux sessions using the declarative configuration file.&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/RobusGauli" rel="noopener noreferrer"&gt;
        RobusGauli
      &lt;/a&gt; / &lt;a href="https://github.com/RobusGauli/mx.sh" rel="noopener noreferrer"&gt;
        mx.sh
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Lean and opinionated tmux session manager. 
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/cdbe8f5d2eca1a33c5c9ef562c8090fb924360f9d7fbb42c54d9ba255760456f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666c61742d737175617265"&gt;&lt;img src="https://camo.githubusercontent.com/cdbe8f5d2eca1a33c5c9ef562c8090fb924360f9d7fbb42c54d9ba255760456f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666c61742d737175617265" alt="MIT License"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;br&gt;
&lt;p&gt;
  &lt;a href="https://github.com/othneildrew/Best-README-Template" rel="noopener noreferrer"&gt;
    &lt;img src="https://camo.githubusercontent.com/d5e7279a62c02943e5cc59404dddf54c78e1ca251f00770c2c3ea6a26a06a54e/68747470733a2f2f692e696d6775722e636f6d2f55684a516237782e706e67" alt="Logo" width="80" height="80"&gt;
  &lt;/a&gt;
  &lt;/p&gt;
&lt;p&gt;
    Manage tmux sessions with simple configuration. Lean and  opinionated
    &lt;br&gt;
  &lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/0622e3d5ad839166b1cf4cf750aa932ebde16ce551666825144afb34aac26f26/68747470733a2f2f696d6775722e636f6d2f72396f544161612e676966"&gt;&lt;img src="https://camo.githubusercontent.com/0622e3d5ad839166b1cf4cf750aa932ebde16ce551666825144afb34aac26f26/68747470733a2f2f696d6775722e636f6d2f72396f544161612e676966" alt="mx.sh"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Why another tmux session manager?&lt;/h3&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;It has to work out of box without any bloats.&lt;/li&gt;
&lt;li&gt;Because, I didn't want runtime dependency such as Ruby interpreter just to manage my tmux sessions.&lt;/li&gt;
&lt;li&gt;Shell scripting is free and native, lets do more of that.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Requirements&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;bash &amp;gt;= 4.x&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Installation&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;Copy paste this in your terminal&lt;/p&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;curl https://raw.githubusercontent.com/RobusGauli/mx.sh/v0.6.1-alpha/install.sh &lt;span class="pl-k"&gt;|&lt;/span&gt; bash&lt;/pre&gt;

&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;This will install &lt;code&gt;mx&lt;/code&gt;  script in your path. Run &lt;code&gt;mx&lt;/code&gt; to verify the installation.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Getting Started&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;Below steps assumes that you have a working knowledge of tmux and you understand the concepts of windows, panes and sessions in tmux. Also, you are able to attach and detach to tmux session. If you think you are rusty around these topics, you could reach out to &lt;a href="https://man7.org/linux/man-pages/man1/tmux.1.html" rel="nofollow noopener noreferrer"&gt;man&lt;/a&gt; page or this awesome quick tour &lt;a href="https://danielmiessler.com/study/tmux/" rel="nofollow noopener noreferrer"&gt;blog&lt;/a&gt;.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h4 class="heading-element"&gt;1. Generate configuration template&lt;/h4&gt;

&lt;/div&gt;
&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;mx template --json --session euler&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h4 class="heading-element"&gt;2. Start&lt;/h4&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/RobusGauli/mx.sh" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Now you are only required to describe your intent such as the number of windows, the number of panes in a window, command(s) to run on each pane, name of a session, etc and &lt;a href="https://github.com/robusgauli/mx.sh" rel="noopener noreferrer"&gt;&lt;strong&gt;mx.sh&lt;/strong&gt;&lt;/a&gt; will take care of creating a layout that you have described in your configuration file. It will parse your configuration and creates a session with windows, panes, and commands that you have described in your configuration file. Let’s see a sample configuration file below:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
 

&lt;p&gt;The above configuration file manifests the following resources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A new session named mojo. This could be the name of the project you are working on.&lt;/li&gt;
&lt;li&gt;Two windows named &lt;strong&gt;w1&lt;/strong&gt; and &lt;strong&gt;w2&lt;/strong&gt;. In real world, this could be API, database, frontend, etc.&lt;/li&gt;
&lt;li&gt;Window &lt;strong&gt;w1&lt;/strong&gt; with two panes whose current working directory is set to &lt;code&gt;/home/robus&lt;/code&gt; and each pane execute echo command. As you can imagine, your command could &lt;code&gt;source venv/bin/activate&lt;/code&gt; , &lt;code&gt;yarn start&lt;/code&gt; , &lt;code&gt;kubectl config set-context --current --namespace=admin&lt;/code&gt; , etc.&lt;/li&gt;
&lt;li&gt;Window &lt;strong&gt;w2&lt;/strong&gt; with three panes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully, this should give an idea of how you could extend this configuration file to add windows/panes/command to your likes. If you are wondering, how would the above configuration manifest in an actual Tmux session, below is the screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1000%2F1%2AVUyHtni9YIhq6T0gz51Zvw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1000%2F1%2AVUyHtni9YIhq6T0gz51Zvw.png" alt="tmux-sample-screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, the way you spin up the new session that is configured to my likes with all the required dependencies is simply&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mx up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And if I want to delete the session named mojo&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mx down &lt;span class="nt"&gt;--session&lt;/span&gt; mojo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yup, I am serious. Below is the demo where I am spinning up a project that requires the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Neovim editor for Lamda functions repository.&lt;/li&gt;
&lt;li&gt;Terminal where I run Serverless commands.&lt;/li&gt;
&lt;li&gt;Neovim editor with python’s flask source code.&lt;/li&gt;
&lt;li&gt;Virtual environment activated terminal session.&lt;/li&gt;
&lt;li&gt;Postman instance.&lt;/li&gt;
&lt;li&gt;Beekeeper instance as GUI SQL client.&lt;/li&gt;
&lt;li&gt;VPN connection.&lt;/li&gt;
&lt;li&gt;SSH into Bastion host.&lt;/li&gt;
&lt;li&gt;Running ‘alias’ command inside in bastion host.&lt;/li&gt;
&lt;li&gt;Access to auth0 dashboard, Jira and Aws console.&lt;/li&gt;
&lt;li&gt;blah blah …&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All these setup now requires single command and about 7 seconds to roll. Pretty happy now that I can switch between projects in seconds and let &lt;a href="https://github.com/robusgauli/mx.sh" rel="noopener noreferrer"&gt;&lt;strong&gt;mx.sh&lt;/strong&gt;&lt;/a&gt; automate everything from starting my code editor to ssh into a remote machine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1000%2F1%2ARUqaZSzcSF4eCKx6kEkKEg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmiro.medium.com%2Fmax%2F1000%2F1%2ARUqaZSzcSF4eCKx6kEkKEg.gif" alt="demo-mx"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this article is useful for those who are suffering similar symptoms of having to spend most of the time getting that initial setup right. If you find my project useful or think you could make improvements, let's do that too.&lt;/p&gt;

&lt;p&gt;Cheers!!&lt;/p&gt;

</description>
      <category>tmux</category>
      <category>productivity</category>
      <category>automation</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
