<?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: Amitav Roy</title>
    <description>The latest articles on DEV Community by Amitav Roy (@amitavroy7).</description>
    <link>https://dev.to/amitavroy7</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%2F382380%2F693e2bda-6ef8-46d2-9c6b-71791a074f53.jpg</url>
      <title>DEV Community: Amitav Roy</title>
      <link>https://dev.to/amitavroy7</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amitavroy7"/>
    <language>en</language>
    <item>
      <title>Understanding the secret of secrets</title>
      <dc:creator>Amitav Roy</dc:creator>
      <pubDate>Mon, 16 Aug 2021 03:46:17 +0000</pubDate>
      <link>https://dev.to/amitavroy7/understanding-the-secret-of-secrets-5a05</link>
      <guid>https://dev.to/amitavroy7/understanding-the-secret-of-secrets-5a05</guid>
      <description>&lt;p&gt;Any application that you create will have some secrets. Even a todo application which is storing information into a database has secrets. The credentials that you use to connect to the database is a secret for that application, isn’t it? But, many developers don’t pay enough attention to this part. &lt;/p&gt;

&lt;p&gt;I have worked on many projects as a consultant. I would advise people on how to improve their applications. Sometimes, these improvements include code level improvements, architecture changes to infrastructure level changes.&lt;/p&gt;

&lt;p&gt;I have seen secrets inside codebase which are actually used in production many times. These things scare me a lot. It's dangerous to commit and push these values inside the codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  Dot env files
&lt;/h2&gt;

&lt;p&gt;Most of the modern frameworks allow you keep the environment variables out of github. Laravel for example uses .env files to load up secrets. And, although there is a .env.example file which should be a replica of the actual .env file minus the values. The idea is that if a developer clones a repository, he/she needs to copy the .env.example file and name it .env. And, the values which should go into the .env file. Some common ones will be the app key, database credentials etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configs should have defaults
&lt;/h2&gt;

&lt;p&gt;Laravel allows developers to use config variables which will pick up values from the .env file. But, if that value is not present, it will pick up a default value. For example the default port of MySQL database is 3306. Now, the database.php configuration file already has this. What that means is, if you have not changed the default, you don’t need to define it at all.&lt;/p&gt;

&lt;p&gt;It allows the developer to get started quickly and define only the things which are beyond the default configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Private repositories are not enough
&lt;/h2&gt;

&lt;p&gt;If you feel that making a repository private will take care of security, I beg to differ. A private repository means that the code is not available in public. But, it doesn’t mean the secrets are secure. Sometimes, we want to share the codebase with developers. Let's say he will add a new feature. But, do you want them to actually get access to the credentials which are being used on production? Will you be comfortable with the fact that the developer has access to the live email sending service?&lt;/p&gt;

&lt;p&gt;Also, you need to understand that deleting the secret code from the code doesn’t mean it no longer exists. A user can always revert to a particular commit and see the keys in history. This basically means, once a key gets committed even by mistake there is no way to get rid of it. You have to start a fresh repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Secrets are lying around
&lt;/h2&gt;

&lt;p&gt;Believe it or not, secrets in codebase are a huge problem. Github has scanners which scans your code for such potential problems and warn you as well. Even then, if you go to Github and search for “removed aws keys” and filter the search by commits everything will be clear.&lt;/p&gt;

&lt;p&gt;So, I hope I was able to make you understand the gravity of this problem and how you can work towards solving this problem. Most frameworks already have the basic checks in place so that the user doesn’t make some of the common mistakes. However, that doesn’t mean they can stop you from all the other possibilities. And hence, as a developer it’s your responsibility to keep these things in mind. &lt;/p&gt;

&lt;p&gt;Do share your experiences on this particular issue. What you have seen, how you have solved the problem, anything. You can find me on &lt;a href="https://twitter.com/amitavroy7"&gt;twitter&lt;/a&gt; or on the &lt;a href="https://discord.gg/X6rGuShX"&gt;Discord Bitfumes community&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Banner photo by &lt;a href="https://unsplash.com/@lazycreekimages?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Michael Dziedzic&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/secret?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>devops</category>
      <category>laravel</category>
    </item>
    <item>
      <title>Power of estimation for developers</title>
      <dc:creator>Amitav Roy</dc:creator>
      <pubDate>Sun, 08 Aug 2021 15:46:33 +0000</pubDate>
      <link>https://dev.to/amitavroy7/power-of-estimation-for-developers-3h7a</link>
      <guid>https://dev.to/amitavroy7/power-of-estimation-for-developers-3h7a</guid>
      <description>&lt;p&gt;I have been working software developer and a Technical project manager at Focalworks for more than 10 years now. Over the years, I have realised the importance of accurate estimates. Accurate estimates are important for projects to be productive and profitable. It doesn't matter whether it's a fixed price project or a retainer model. Accurate estimates ensure that work is getting delivered on time.&lt;/p&gt;

&lt;p&gt;Over the years I have worked on a lot of projects. In some my role was that of a developer and in some projects, I played the role of a project manager. With experience I have realised the importance of estimates. and some things which we should keep in mind while doing that.&lt;/p&gt;

&lt;p&gt;In this post, I am sharing some points which you should consider while doing estimates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do estimates?
&lt;/h2&gt;

&lt;p&gt;While estimates can feel like a need more from the non-dev stakeholders of a project. But, it's important for the developers as well. Estimates helps in better timelines and release management.&lt;/p&gt;

&lt;p&gt;And, it also helps in gaging failure very early in the project. If the sum of all the estimates is going beyond the actual timeline, you know there is a problem. This helps you decide whether you need more resources or we need to shift the timelines.&lt;/p&gt;

&lt;p&gt;Developers will feel more responsible about the timeline when they estimate their work. It's almost like a buy in from them about how much time it should take for them to complete the task.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips while estimating work
&lt;/h2&gt;

&lt;p&gt;Although there is no magic rule that you can follow for accurate estimates. There are certain things a developer should keep in mind for better accuracy. And remember, estimation is a skill, the more you do the better you get at it. So, here are a few things which you should keep in mind while doing estimates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Understand the scope of work
&lt;/h3&gt;

&lt;p&gt;While estimating work, you should have a very clear picture of the work. If the scope is not clear then, as a developer you should do the analysis. Ask questions, and get those answers before you commit to anything. Your estimate should be against something which is clear and well documented. If things are not clear, it's quite possible what you deliver will not be adding much value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Writedown the acceptance criterias
&lt;/h3&gt;

&lt;p&gt;To have a clear scope of work it's a good idea to write acceptance criteria. Sometimes, certain tickets can have a lot of edge cases. A clear list of acceptance criteria brings clarity to the developer. And, it also helps the person who is allocating you the work plan better. You can refer to &lt;a href="https://agileforgrowth.com/blog/acceptance-criteria-checklist/"&gt;this article&lt;/a&gt; on how to write good acceptance criteria.&lt;/p&gt;

&lt;h3&gt;
  
  
  Break down big items into smaller logical chunks
&lt;/h3&gt;

&lt;p&gt;Break down the stories or tickets into smaller chunks for estimation. Any ticket which is more than 3 to 4 days of work should be further divided into smaller ones. This not only allows more accuracy in estimate but also it shows continuous progress. Imagine you working on just one ticket for a week vs 4 smaller tickets completed in a week. Which one sounds better as progress? But yes, that doesn't mean you start breaking down the task without any logic or reason.&lt;/p&gt;

&lt;h3&gt;
  
  
  Discuss with your peer while estimating
&lt;/h3&gt;

&lt;p&gt;It's always a good idea to discuss and take a second opinion during the analysis of the task before committing to an estimate. Sometimes, one might miss certain details / critical aspects of a task. Discuss with your team members about the task. It will help you doing better estimation. And, it will also mean others are aware of the functionality that you are working on.&lt;/p&gt;

&lt;h3&gt;
  
  
  Keep some buffer
&lt;/h3&gt;

&lt;p&gt;As a developer, there are times when things don't work as you expect. To be honest, I feel surprised if my code works in the first attempt. And hence, it's a good idea to keep some buffer. If you feel you can develop a feature within 8 hours time, keep about 2 hours as buffer. This time should help you do some testing, code review etc. This will help you deliver better code quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As a developer, once you get better at estimates you will realise that you have acquired certain traits which help you mature as a developer. You will be able to work towards very specific targets and hence you will be able to plan your work better. You will get better at analysis of the task. A good developer is not the one who can just do bug free development but rather one who is able to develop the proper solution for a requirement.&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Performance improvement &amp; a silly mistake on my blog and how I fixed them</title>
      <dc:creator>Amitav Roy</dc:creator>
      <pubDate>Mon, 04 Jan 2021 23:25:47 +0000</pubDate>
      <link>https://dev.to/amitavroy7/performance-improvement-a-silly-mistake-on-my-blog-and-how-i-fixed-them-2k64</link>
      <guid>https://dev.to/amitavroy7/performance-improvement-a-silly-mistake-on-my-blog-and-how-i-fixed-them-2k64</guid>
      <description>&lt;p&gt;Recently I was working on performance improvement on my blog post. It all started when I was writing the article &lt;a href="https://my-lnk.com/r/2861564525"&gt;Mobile-first Google Indexing - Are you ready with your website for this change&lt;/a&gt;. During the Lighthouse scan one thing which was glaring to me was the size of the JavaScript file. And, that’s when I realized that I have made such a silly mistake. In this article, I am going to talk you through some of the important changes that I made to my blog. And, how they had a significant impact on the performance of my blog.&lt;/p&gt;

&lt;p&gt;We all know performance is a very important thing when it comes to your website’s acceptance to the end user. Tons of research has confirmed that you get only a few seconds of the user before they move away from your website. I recently did a Page Speed audit of my website, and I was alarmed by the low score that I got for the mobile version. The desktop was around 91 which is great. But, the score on mobile was only 31. Can you imagine? The same URL on two different devices had such a huge difference. I had to do something about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Page speed and it’s recommendations
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://developers.google.com/speed/pagespeed/insights/"&gt;Page speed&lt;/a&gt; report is a great starting point to work on the improvements. It’s always a good idea to look for the line items which are easy to fix and give you a good increase in the percentage. And, you know what I could see was one of the items in red was a JavaScript file size issue. It was a shocker for me as my blog has hardly any JavaScript behaviour. The only thing I recently added was the scroll indicator.&lt;/p&gt;

&lt;p&gt;Digging a little deeper I understood the blunder that I had made. For getting the document ready event, I used the jQuery document ready event. And, that meant I was loading the entire jQuery library. And, that contributed to the huge file size. So, this was the first item which I had to fix. Upon Googling around, I could find a small NPM package “&lt;a href="https://github.com/bendrucker/document-ready"&gt;document ready&lt;/a&gt;” which would give me the same event. As I was very particular about the file size, I even went into the source code of the plugin and saw it will add a few lines of code only. This is why I decided to use it instead of writing my own.&lt;/p&gt;

&lt;p&gt;After making this change, the app.js file size reduced from around 251 KB to less than 2 KB. And, this is why I said that I made a silly mistake. But anyways, the learning is that it’s very important to have a strong checklist while deploying your code to production.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D3NyZsQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/upyfqokbnn2jgo96msxd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D3NyZsQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/upyfqokbnn2jgo96msxd.jpg" alt="Javascript file size before and after"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reducing first byte time using Redis Cache
&lt;/h2&gt;

&lt;p&gt;After the file size improvement, I was looking for some way to reduce the first byte time. This is one of the most important aspects in reducing the waiting time for the user. This hardly took me an hour to implement across all the pages on my blog. But, it gave me a much better score on Page Speed and &lt;a href="https://webpagetest.org/"&gt;Web page test&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Redis is an in memory cache. To explain in simple terms, you are storing information in RAM of your server as a cached object. And, because RAM is much faster than hard disk IO speed, your data retrieval time reduces by a huge margin . I have a 2 GB server and I configured Redis to take up to 200 MB of RAM. Now, I know my entire website data won’t even take 20 to 30 MB. I have around 80 articles and that amount of text doesn’t eat up too much space right.&lt;/p&gt;

&lt;p&gt;And, the implementation of the caching on Laravel is just a piece of cake. Whatever is your query result should be cached. And, before fetching the data from the database you just need to confirm whether you have that data in your cache or not. This means, now on page loads I am not at all hitting the database. The data is being served from in-memory cache which is way faster than establishing a connection to the database, query and getting the results. Below is a screenshot of the code which I have on the home page to fetch posts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PNO1EB9c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/63ibfog01l5fwggbwsvi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PNO1EB9c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/63ibfog01l5fwggbwsvi.png" alt="Cache post inside redis code"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the difference between non cached page vs cached page can be seen in the screenshot below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NTxTf9jU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b4wockpilvoi9v57tg8h.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NTxTf9jU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b4wockpilvoi9v57tg8h.jpg" alt="Webpage test first byte time"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So, from these above screenshots you can see that having a strong checklist is important. Along with that you should have a good tool set which you can use to get useful insights. With a quick deployment process, it is very easy to miss out on these aspects. Hence, a checklist is a good way to ensure that we are not making any big mistakes with the new code update (for example my jQuery file size issue). If I had checked the file size after the code update, I would have caught this.&lt;/p&gt;

&lt;p&gt;Let me know what you think about having a checklist? Do you already have one, if yes how do you use it? You can get in touch with me through Twitter &lt;a class="comment-mentioned-user" href="https://dev.to/amitavroy7"&gt;@amitavroy7&lt;/a&gt;
.&lt;/p&gt;

&lt;p&gt;Banner image from &lt;a href="https://unsplash.com/photos/NqOInJ-ttqM"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>performance</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Amazon (AWS) NLP Service - Comprehend and Twitter API</title>
      <dc:creator>Amitav Roy</dc:creator>
      <pubDate>Sun, 21 Jun 2020 15:11:34 +0000</pubDate>
      <link>https://dev.to/amitavroy7/amazon-aws-nlp-service-comprehend-and-twitter-api-1jh</link>
      <guid>https://dev.to/amitavroy7/amazon-aws-nlp-service-comprehend-and-twitter-api-1jh</guid>
      <description>&lt;p&gt;In today's world data is everywhere. And, so analysing data and coming up with insights from that data is a very important thing. &lt;/p&gt;

&lt;p&gt;Recently, I was involved in a project where an automotive company wanted to get some insights about the sentiment of the users who were posting on their twitter handle and also on their other social mediums. &lt;/p&gt;

&lt;p&gt;Now a days, using API we can fetch information from Facebook pages, Tweeter handles etc. And hence, it is possible to fetch that data, run them through Natural Language Processing (NLP) and get some idea about the content which is posted. &lt;/p&gt;

&lt;p&gt;For example, as a social media manager I would like to know what is the sentiment of a user who has written anything about my company on Facebook or Twitter. If there is something positive written about my company, I would like to highlight that. If someone has written something negative, then we have an unhappy customer and I would like to know what was a problem and try to solve that problem.&lt;/p&gt;

&lt;p&gt;Now, it is difficult to read through all these mediums and come up with analytics. And hence, services like AWS Comprehend can really help. Yes, there are a lot of services available who can do these stuff. But, I found AWS to be very easy, vast and cheap as well. &lt;/p&gt;

&lt;p&gt;So, in this video I am going to show you how we can use the Amazon Comprehend service to fetch data from Twitter API using the Twitter streaming API and then send them to AWS Comprehend and get some sentiment analysis done on that tweet, extract some keywords and do other stuff. &lt;/p&gt;

&lt;p&gt;So, if this requirement interests you, then dive into the journey where I show you how we can do this.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/LHlHPrFe-6M"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>amazon</category>
      <category>twitter</category>
      <category>nlp</category>
    </item>
    <item>
      <title>Setting up husky &amp; lint-staged for code format and unit tests before git push</title>
      <dc:creator>Amitav Roy</dc:creator>
      <pubDate>Sat, 30 May 2020 18:36:01 +0000</pubDate>
      <link>https://dev.to/amitavroy7/setting-up-husky-lint-staged-for-code-format-and-unit-tests-before-git-push-3kif</link>
      <guid>https://dev.to/amitavroy7/setting-up-husky-lint-staged-for-code-format-and-unit-tests-before-git-push-3kif</guid>
      <description>&lt;p&gt;Having an automated code formatting and php unit runner is a great addition to your automation. &lt;/p&gt;

&lt;p&gt;I work in a team where different developers have different habit when it comes to code formatting. Yes, they are small things I know. But, I spend a lot of time in code review. And, reading other's code is always difficult if the formatting is different. And hence, I want to ensure that the code formatting, structure etc are as much similar as possible. It reduces a lot of load from the code review process and speeds up things.&lt;/p&gt;

&lt;p&gt;Plus, the aspect of automatically running the unit tests before every code commit is one check enforced for the developer to ensure that his new code is not breaking something which is running properly right now and was working before he / she made any code changes. &lt;/p&gt;

&lt;p&gt;And, hence I looked at different options and this combination of husky to hook into the git hooks and lint-staged to get the context of the files which are staged are really helpful.&lt;/p&gt;

&lt;p&gt;In this article, I will explain how I did the setup of these two npm modules to ensure code formatting and running php unit before every git push.&lt;/p&gt;

&lt;p&gt;Hope you like it, and feel free to leave comments about your views.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.amitavroy.com/justread/content/articles/setting-up-husky-lint-staged-for-code-format-and-unit-tests-before-git-push"&gt;https://www.amitavroy.com/justread/content/articles/setting-up-husky-lint-staged-for-code-format-and-unit-tests-before-git-push&lt;/a&gt;&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>git</category>
    </item>
    <item>
      <title>Working with Laravel Livewire is fun</title>
      <dc:creator>Amitav Roy</dc:creator>
      <pubDate>Sat, 09 May 2020 16:55:45 +0000</pubDate>
      <link>https://dev.to/amitavroy7/working-with-laravel-livewire-is-fun-1ah3</link>
      <guid>https://dev.to/amitavroy7/working-with-laravel-livewire-is-fun-1ah3</guid>
      <description>&lt;p&gt;Development with Laravel is always fun. The more I spend time with Laravel, I enjoy the Test Driven Approach.&lt;/p&gt;

&lt;p&gt;Now, when any frontend development comes into picture, there is an entire range of things to do. Browser testing, Unit tests, Mock servers to test your services and APIs and what not. &lt;/p&gt;

&lt;p&gt;However, if you develop your frontend in Livewire, then even your front end code is in PHP. Which means, even your tests are in PHP. Plus, without writing any Javascript, you can create a complete SPA type application.&lt;/p&gt;

&lt;p&gt;Under the hood, it doesn't return back JSON responses but rather HTML which is something even big giants like Github is also doing. And using smart dom diff, the new HTML is added to the dom and hence you get updates from the server based on user interactions.&lt;/p&gt;

&lt;p&gt;It allows you to play will component lifecycle hooks as well which means, you can add behaviours based on change in state of the component and a lot more.&lt;/p&gt;

&lt;p&gt;This in itself is a great thing. And, in this video I show you how you can get started with Livewire and start doing frontend development in PHP. Hope you like it.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/2Lzn-VCpxD4"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>livewire</category>
      <category>php</category>
    </item>
  </channel>
</rss>
