<?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>Forem: Dineshkumar Gnanaprakasam</title>
    <description>The latest articles on Forem by Dineshkumar Gnanaprakasam (@theloneking).</description>
    <link>https://forem.com/theloneking</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%2F393819%2Fcbfb08ff-3008-48dd-b0b7-ed47a9241248.png</url>
      <title>Forem: Dineshkumar Gnanaprakasam</title>
      <link>https://forem.com/theloneking</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/theloneking"/>
    <language>en</language>
    <item>
      <title>Distraction free reading in Dev.to</title>
      <dc:creator>Dineshkumar Gnanaprakasam</dc:creator>
      <pubDate>Wed, 27 May 2020 02:56:40 +0000</pubDate>
      <link>https://forem.com/theloneking/distraction-free-reading-in-dev-to-360o</link>
      <guid>https://forem.com/theloneking/distraction-free-reading-in-dev-to-360o</guid>
      <description>&lt;p&gt;Today, I learned that you can enter into / exit out of &lt;em&gt;distraction free reading mode&lt;/em&gt; in dev.to, by hitting &lt;code&gt;0&lt;/code&gt; on the keyboard!&lt;/p&gt;

</description>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Deploy a node app to heroku using Travis CI</title>
      <dc:creator>Dineshkumar Gnanaprakasam</dc:creator>
      <pubDate>Mon, 25 May 2020 04:53:15 +0000</pubDate>
      <link>https://forem.com/theloneking/deploy-a-node-app-to-heroku-using-travis-ci-37bh</link>
      <guid>https://forem.com/theloneking/deploy-a-node-app-to-heroku-using-travis-ci-37bh</guid>
      <description>&lt;p&gt;You have written an exciting application and now you want to deploy it somewhere, preferably on the cloud. Heroku is one of the notable cloud platforms that allows developers to deploy and run their apps. If your app is a simple hobby project, you may even be able to deploy your app for free.&lt;/p&gt;

&lt;p&gt;Once you have your app in your github repository, Heroku allows you to deploy your app using either Heroku CLI or by connecting connecting your Heroku app to the github repository or by using their Container Registry mechanism (which also uses Heroku CLI). However, we are going to explore another way of deploying your app to Heroku, using Travis CI.&lt;/p&gt;

&lt;h1&gt;
  
  
  What is Travis CI?
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;“Travis CI is a hosted, distributed continuous integration service used to build and test software projects...” — &lt;a href="https://en.wikipedia.org/wiki/Travis_CI"&gt;Wikipedia&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Travis CI is a continuous integration tool that lets you build, test and deploy (among other things) your code from github. Its services are free for public repositories. So you do not have to pay anything for using Travis CI in your hobby project if you make your github repository public.&lt;/p&gt;

&lt;h1&gt;
  
  
  Create a Heroku app
&lt;/h1&gt;

&lt;p&gt;First step, we have to create a Heroku account. Once we have that, we can create a new app in our Heroku account by just typing the app name and the region where we want to deploy it. In our case, we need to give our Heroku app the same name as our github repository. If the Heroku app name is different from our github repo’s name, Travis CI cannot find which app to deploy to.&lt;/p&gt;

&lt;p&gt;Once created, our new app will appear in the dashboard. If the app needs any environment variables / config variables, now is a good time to add them to our Heroku app. Look for the Config Vars section under the Settings tab of the app.&lt;/p&gt;

&lt;p&gt;Once the app is setup, note down the Heroku account’s API Key. This will be available in the Account detail page (Account Settings menu under the user profile icon). Remember that this is a &lt;em&gt;secret key&lt;/em&gt;; do not share it with anyone.&lt;/p&gt;

&lt;h1&gt;
  
  
  Configuring Travis CI
&lt;/h1&gt;

&lt;p&gt;To use Travis CI in our project, we first have to create a file named &lt;code&gt;.travis.yml&lt;/code&gt;. This file has to be in the root directory of our application. This files servers as the configuration file for all the things that we want Travis CI to do with our code. Let us assume that we have written a node.js app that we now want to deploy to Heroku. In that case we would need to tell Travis CI what kind of app we have, where to deploy it, when to deploy it and we also have to give it the secret API key from our Heroku account (after encrypting it, of course).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q8O0LCNB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ua8zmpcnyw0jn8q732pc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q8O0LCNB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ua8zmpcnyw0jn8q732pc.png" alt="Sample .travis.yml" title="Sammple .travis.yml"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To encrypt your heroku account key, we can use travis cli as explained in the travis documentation &lt;a href="https://docs.travis-ci.com/user/encryption-keys/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The .travis.yml file configures how our project is deployed. The first three lines the file mentions that our project is a node.js project and that Travis CI should use node.js environment with version 8.11.3 to build the project.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;deploy.on&lt;/code&gt; section has two fields &lt;code&gt;tags&lt;/code&gt; and &lt;code&gt;all_branches&lt;/code&gt;. If they both are set to true, Travis CI will fire the deployment whenever a new tag is created in our github repository. So, all we have to do to deploy our app is just create a new tag.&lt;/p&gt;

&lt;h1&gt;
  
  
  Create a new tag
&lt;/h1&gt;

&lt;p&gt;We can create a new tag in the repo of our node.js app just by bumping the version of our app by using the &lt;code&gt;npm-version&lt;/code&gt; command. For example, if we choose to bump the patch version of our app, just run the command &lt;code&gt;npm version patch&lt;/code&gt; in your terminal. It will automatically create a commit and tag with the new version. Push those changes to the remote github repo.&lt;/p&gt;

&lt;p&gt;Once pushed, we can sit back and relax! Travis will automatically kick-off the deployment of our app from the newly created tag to our heroku app.&lt;/p&gt;

</description>
      <category>heroku</category>
      <category>travisci</category>
      <category>github</category>
    </item>
    <item>
      <title>Make bat, not exe</title>
      <dc:creator>Dineshkumar Gnanaprakasam</dc:creator>
      <pubDate>Sat, 23 May 2020 22:44:25 +0000</pubDate>
      <link>https://forem.com/theloneking/make-bat-not-exe-2j57</link>
      <guid>https://forem.com/theloneking/make-bat-not-exe-2j57</guid>
      <description>&lt;p&gt;Yesterday, I was banging my head against the internet to find a way to convert a batch file that I have written to an executable file. Why did I want to convert my batch file into an exe file? Here is the story…&lt;/p&gt;

&lt;p&gt;At my job, I was using a CLI tool to build and deploy my app to the server. Every time I made a change to the code and wanted to deploy the latest code, I had to execute five commands to build and deploy my app.&lt;/p&gt;

&lt;p&gt;I am not that person who gets everything right at the first shot. When I test the app after deploying, more often than not, I would find that I missed something. Again I had to execute those five commands. And again… and again… and again…&lt;/p&gt;

&lt;p&gt;I am super lazy and me having to execute five commands again and again drove me crazy. So I decided to write a batch script where I would automate running these commands. I wrote the script and tested it. It worked just the way I wanted.&lt;/p&gt;

&lt;p&gt;But then, I had this crazy idea, or… maybe a wish. The CLI tool that I was already using was packaged as an exe file. So when I used this CLI tool, I would say &lt;code&gt;cli arg1 arg2&lt;/code&gt;. Mine was a batch file. So each time I executed the batch script, I had to say &lt;code&gt;mybatch.bat arg1 agr2&lt;/code&gt;. I did not like having to type .bat when I executed the script.&lt;/p&gt;

&lt;p&gt;So, I wanted to convert my batch script into an exe file, so that I can execute it without having to type .bat every time. I searched the internet, downloaded a few batch to exe converter tools. I even tried the IExpress tool that comes bundled with Windows which supposedly does the batch to exe conversion.&lt;/p&gt;

&lt;p&gt;Either the downloaded tool was blocked by my company’s security software or they simply did not work for me. Frustrated, I gave up. I decided to live with having to type .bat in my command. After a few minutes, the &lt;em&gt;Eureka&lt;/em&gt; moment happened.&lt;/p&gt;

&lt;p&gt;Out of carelessness, my hands typed &lt;code&gt;mybatch arg1 arg2&lt;/code&gt; and the command started running! I blinked in excitement. So, I did not have to type .bat to execute a batch file?&lt;/p&gt;

&lt;p&gt;Well, that day I learnt that in order to execute a .bat file Windows, you did not have to type .bat with the filename.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
