<?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: Anshul Gupta</title>
    <description>The latest articles on Forem by Anshul Gupta (@anshul_gupta).</description>
    <link>https://forem.com/anshul_gupta</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%2F404078%2F42bf94a1-a07b-48df-bc8b-59303f3637ac.png</url>
      <title>Forem: Anshul Gupta</title>
      <link>https://forem.com/anshul_gupta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/anshul_gupta"/>
    <language>en</language>
    <item>
      <title>How to write Netlify lambda function?</title>
      <dc:creator>Anshul Gupta</dc:creator>
      <pubDate>Tue, 21 Jul 2020 16:13:49 +0000</pubDate>
      <link>https://forem.com/anshul_gupta/how-to-write-netlify-lambda-function-4m25</link>
      <guid>https://forem.com/anshul_gupta/how-to-write-netlify-lambda-function-4m25</guid>
      <description>&lt;p&gt;&lt;a href="https://www.blog.guidefather.in/2020/07/how-to-publish-website-on-netlify.html"&gt;Netlify&lt;/a&gt; is an awesome service that offers Webhosting, Analytics, Free SSL, Netlify lambda functions, etc.&lt;br&gt;
Today I will demonstrate Netlify lambda functions. &lt;a href="https://www.blog.guidefather.in/2020/07/how-to-publish-website-on-netlify.html"&gt;Netlify lambda functions&lt;/a&gt; is a serverless backend service which can be used to perform any serverside task. Under the hood, it uses AWS lambda functions, but Netlify removes all the complexity and gives an easy to use interface and the best part it has a great free tier.&lt;br&gt;
Before proceeding, I assume that you know how to deploy your website in Netlify, If not check out my article &lt;a href="https://www.blog.guidefather.in/2020/07/how-to-publish-website-on-netlify.html"&gt;How to use Netlify&lt;/a&gt; on &lt;a href="https://www.blog.guidefather.in"&gt;GuideFather&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Steps to write Netlify lambda functions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To create a lambda function create a folder with any name you want (I am using API), inside that folder create a JS file( I am creating getJoke.js). keep in mind that the folder and file name will be the URL.&lt;/li&gt;
&lt;li&gt;Add the following code to the JS file (getJoke.js)
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;netlify.toml&lt;/strong&gt; file and add the following code. This file will indicate which one is the function directory and what command to run
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Commit and push the code to GitHub, If the continuous integration is activated then your functions will be automatically deployed. You can verify the functions in the functions tab
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TasZsDHh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w9k0cjd73t0xbzz2yfzx.png" alt="Function URL"&gt;
Netlify will provide you an URL from which you can access the code
For more info check my &lt;a href="https://www.blog.guidefather.in/2020/07/how-to-publish-website-on-netlify.html"&gt;article&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Thank you for reading&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>api</category>
      <category>javascript</category>
      <category>devops</category>
    </item>
    <item>
      <title>Create a desktop application from your website in 10 minutes</title>
      <dc:creator>Anshul Gupta</dc:creator>
      <pubDate>Tue, 30 Jun 2020 18:35:48 +0000</pubDate>
      <link>https://forem.com/anshul_gupta/create-a-desktop-application-from-your-website-in-10-minutes-234a</link>
      <guid>https://forem.com/anshul_gupta/create-a-desktop-application-from-your-website-in-10-minutes-234a</guid>
      <description>&lt;p&gt;If you have ever tried to build a desktop application in a traditional way i.e. in C, JAVA, .Net then you will agree it no only time consuming but costly.&lt;br&gt;
Using a cross-platform framework helps you to reduce the cost and time to build a production-ready application.&lt;br&gt;
&lt;strong&gt;Electron&lt;/strong&gt; is one of the most famous frameworks to build a cross-platform application. Many famous Softwares like VS Code, Atom, Slack are build using Electron.&lt;br&gt;
I would suggest to give it a try, it will hardly take 10 min.&lt;br&gt;
I've built a small application to get you started where you can create a desktop application from your website and maintain a history of your navigation.&lt;br&gt;
I've explained it in detail in my blog &lt;strong&gt;&lt;a href="https://www.blog.guidefather.in/2020/06/how-to-create-desktop-app-from-website.html"&gt;how to create a desktop app&lt;/a&gt;&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GRA256n2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ybnfznu16ziwkep9xtqk.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GRA256n2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ybnfznu16ziwkep9xtqk.gif" alt="App preview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What is electronJs
&lt;/h1&gt;

&lt;p&gt;With the help of ElectronJs one can build cross-platform desktop applications with HTML, JavaScript, and CSS. It was introduced in 2013 to make cross-platform text-editors, later its scope was extended to build other utility apps. Electron has chromium in it.&lt;br&gt;
Electron has two processes &lt;br&gt;
&lt;strong&gt;Main Process:&lt;/strong&gt; It manages the bootstrapping the application and lifecycle events like starting, quitting, etc. This main process is responsible for interacting with the native GUI of the Operating System. It creates the GUI of your application.&lt;br&gt;
&lt;strong&gt;Rendering Process:&lt;/strong&gt; It is created by the main process and its main purpose is to render the UI.&lt;/p&gt;

&lt;p&gt;Clone the project from my &lt;a href="https://github.com/guide-father/desktop-app-in-minutes"&gt;Github Repo&lt;/a&gt; and change my website URL &lt;a href="https://www.blog.guidefather.in"&gt;www.blog.guidefather.in&lt;/a&gt; to your website URL and if you are interested then you can check out my blog &lt;strong&gt;&lt;a href="https://www.blog.guidefather.in/2020/06/how-to-create-desktop-app-from-website.html"&gt;how to create a desktop app&lt;/a&gt;&lt;/strong&gt; to learn more.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>desktopapplication</category>
      <category>node</category>
    </item>
    <item>
      <title>How to check the browser is offline?</title>
      <dc:creator>Anshul Gupta</dc:creator>
      <pubDate>Sat, 20 Jun 2020 03:59:59 +0000</pubDate>
      <link>https://forem.com/anshul_gupta/how-to-check-the-browser-is-offline-ecm</link>
      <guid>https://forem.com/anshul_gupta/how-to-check-the-browser-is-offline-ecm</guid>
      <description>&lt;p&gt;Let the user know that he/she is offline is not only a good feature but it helps developers to avoid unexpected conditions and handle errors gracefully. By detecting the client has gone offline you can perform all the security measures to ensure the security of your applications.&lt;br&gt;
I have identified four ways to detect browser is offline which are briefly discussed in my article &lt;a href="https://www.blog.guidefather.in/2020/06/how-to-detect-browser-is-online-or.html"&gt;How to detect Browser is online or offline?&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S209hBjX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w0lgf01fk3j1k4ofi945.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S209hBjX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/w0lgf01fk3j1k4ofi945.gif" alt="four ways to detect browser internet connection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As mentioned in this there are two categories &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Client-Side Approaches &lt;/li&gt;
&lt;li&gt;Server-Side Approaches &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can't rely on client-side approaches to check that the user has internet or not because the browser checks that the system is connected to a network or not which means the user may be connected to a local network that doesn't have access to the internet so I will discuss Sockets approach which is nice and easy to implement if you already using sockets in your project&lt;/p&gt;

&lt;p&gt;&lt;code&gt;let interVal=null; &lt;br&gt;
    const socket=io()&lt;br&gt;
    socket.on("connect",function(){&lt;br&gt;
        updateIfRequire("online");&lt;br&gt;
        clearInterval(interVal)&lt;br&gt;
    })&lt;br&gt;
    socket.on("disconnect",function(){&lt;br&gt;
        interVal=setTimeout(() =&amp;gt; {&lt;br&gt;
            updateIfRequire("offline")&lt;br&gt;
        }, 100);&lt;br&gt;
    })&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You may be wondering, why setTimeout and clearInterval? &lt;br&gt;
Because Sockets are very fast and in real live projects, small errors can occur any time which may interrupt the socket connection, however, sockets will try to reconnect and establish the connection within few milliseconds that's why I have used setTimeout to update the state after 100ms, meanwhile, if the sockets get connected just clear the setTimeout to stop code from updating the state.&lt;br&gt;
You Can get the complete code from &lt;a href="https://github.com/guide-father/no-internet-detection"&gt;here&lt;/a&gt;&lt;br&gt;
Check the &lt;a href="https://www.blog.guidefather.in/2020/06/how-to-detect-browser-is-online-or.html"&gt;article&lt;/a&gt; more info&lt;/p&gt;

&lt;p&gt;Please let me know if you have a better approach.&lt;/p&gt;

&lt;p&gt;t̷h̷a̷n̷k̷ y̷o̷u̷ f̷o̷r̷ r̷e̷a̷d̷i̷n̷g̷&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>internet</category>
      <category>socket</category>
    </item>
    <item>
      <title>Serve Website/Api from your own system</title>
      <dc:creator>Anshul Gupta</dc:creator>
      <pubDate>Wed, 10 Jun 2020 03:05:08 +0000</pubDate>
      <link>https://forem.com/anshul_gupta/serve-website-api-from-your-own-system-4ke</link>
      <guid>https://forem.com/anshul_gupta/serve-website-api-from-your-own-system-4ke</guid>
      <description>&lt;p&gt;Have you ever seen a condition when you need to change your design or API frequently to meet the demand?&lt;br&gt;
I did, a few days back. Because of lockdown, My colleagues and I were working on a project from home. We are not in the same local network, so to connect backend and frontend I had to push to code to server then my colleagues start working.&lt;br&gt;
Then I found a service called &lt;a href="https://ngrok.com/" rel="noopener noreferrer"&gt;NGROK&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.blog.guidefather.in/2020/06/host-websiteapi-from-local-system-ngrok.html#how-ngrok-work" rel="noopener noreferrer"&gt;&lt;strong&gt;Ngrok is a cross-platform service that enables you to expose your local development server to the internet.&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use NGROK
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go to their &lt;a href="https://ngrok.com/download" rel="noopener noreferrer"&gt;website&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Download setup for your OS and exact it.&lt;/li&gt;
&lt;li&gt;Open terminal in the same folder and type&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;./ngrok http port_to_map&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;example ./ngrok http 3000&lt;br&gt;
Ngrok will provide you an URL. Using which you can access your api/website publically.&lt;br&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%2Ftmuma76gb6hrnk2kk0dl.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%2Ftmuma76gb6hrnk2kk0dl.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
If you want to know more you can check this link &lt;a href="https://www.blog.guidefather.in/2020/06/host-websiteapi-from-local-system-ngrok.html" rel="noopener noreferrer"&gt;Host website from local system&lt;/a&gt;.&lt;br&gt;
I believe using NGROK is more easy than reading this article.&lt;br&gt;
If you have a better alternative or solution, please let me know. I would love to explore.&lt;/p&gt;

&lt;p&gt;▀█▀ █░█ ▄▀█ █▄░█ █▄▀   █▄█ █▀█ █░█&lt;br&gt;
░█░ █▀█ █▀█ █░▀█ █░█   ░█░ █▄█ █▄█&lt;/p&gt;

</description>
      <category>api</category>
      <category>hosting</category>
      <category>agile</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
