<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Kevin Comba Gatimu on Medium]]></title>
        <description><![CDATA[Stories by Kevin Comba Gatimu on Medium]]></description>
        <link>https://medium.com/@kevin_comba?source=rss-c524afc125b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RsgU2tdpekDgFhw2ZLGZ-Q.png</url>
            <title>Stories by Kevin Comba Gatimu on Medium</title>
            <link>https://medium.com/@kevin_comba?source=rss-c524afc125b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:08:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kevin_comba/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[✨Fixing errors caused by fallback routes for React Static Web Apps on Azure✨]]></title>
            <link>https://medium.com/@kevin_comba/fixing-errors-caused-by-fallback-routes-for-react-static-web-apps-ae75aac5e360?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae75aac5e360</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[azure-static-web-app]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-router-dom]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Fri, 17 Feb 2023 14:23:02 GMT</pubDate>
            <atom:updated>2023-02-17T21:26:54.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*rRgkak_p7BukYUWX5ygclw.png" /></figure><p>Most web applications have multiple pages and routing so that users can move from one page to another. In Azure static web apps, we must explicitly configure fallback routes whenever we refresh the page. This is not the case if you develop the entire application on your local machine because the webpack dev server will handle it. This post will demonstrate how to configure fallback routes in the Azure static web apps service.</p><h3>Prerequisites</h3><p>To understand the Azure Static web apps service, you must first understand a number of prerequisites. To begin, you must create two accounts: one on GitHub to store the source code and one on Microsoft to deploy it using the Azure static web apps service. Let’s get started by clicking the links below. Both are free to begin.</p><ul><li><a href="https://github.com/">Github Account</a></li><li>An <a href="https://learn.microsoft.com/en-us/azure/guides/developer/azure-developer-guide#understanding-accounts-subscriptions-and-billing">Azure subscription</a>: if your a student you can access <a href="https://azure.microsoft.com/en-us/free/students?wt.mc_id=studentamb_225706">Azure for free for students</a> (use your school email to verify your student), else create <a href="https://azure.microsoft.com/en-us/free/?ref=microsoft.com&amp;utm_source=microsoft.com&amp;utm_medium=docs&amp;utm_campaign=visualstudio">a free account</a> if your not a student.</li><li><a href="https://github.com/kelcho-spense/Azure_react-router_project_demo.git">Demo Project</a></li></ul><p>Because we are creating a React application, you must be familiar with the React CLI, node.js. You must first install NodeJS.</p><h3>Demo without Configuration</h3><p>This demo-video shows a simple react app with three pages, a homepage, about page and an error page. The app is deployed to azure static web apps.</p><h4>Routing Scenario</h4><p>Here is the simple routing scenario in which where you click the about page, the web app routes to the about page. When you refresh the page on the about page, we are getting 404 because we didn’t configure fallback routes. If we try to access an invalid route, we get an azure default 404 page instead of our app&#39;s own defined error page. You can check out the video below for the demo of the app.</p><p><a href="https://1drv.ms/v/s!Am3AyfCC3RzEgSx96bVRZiVskqc6?e=PtBudk">App-demo.mp4</a></p><h3>Our problem?</h3><ol><li>We need first to clone this <a href="https://github.com/kelcho-spense/Azure_react-router_project_demo.git">project</a>.</li><li>after forking this project you will find our app has homepage.jsx, app.jsx, About.jsx, Notfound.jsx and headerComponent.jsx. This are the pages we require to showcase the problem.</li><li>code on App.jsx</li></ol><figure><img alt="app.jsx" src="https://cdn-images-1.medium.com/max/1024/1*6X5fE_qgeecOT7kQ5HV-PQ.png" /></figure><p>as you can see we have our react-router-dom with About route, NotFound route and Homepage route.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rtwd5_y1tdoQB-10BIGD-A.png" /><figcaption>Aboutpage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VWoWcGrp0DISgogDAtjIVg.png" /><figcaption>Homepage</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCIWWxMsk49pboMQJyRlIQ.png" /><figcaption>Not found page</figcaption></figure><p>3. You need to deploy this app to Azure static web app from your GitHub.</p><blockquote><a href="https://medium.com/@kevin_comba/hosting-your-student-portfolio-for-free-on-azure-static-web-apps-ecac2b75300c"><strong>I have already done a similar example here so if you have problem with deploying a static web app to refer and come back.</strong></a></blockquote><p>4. You will find your app with the same issue as we saw in this <a href="https://1drv.ms/v/s!Am3AyfCC3RzEgSx96bVRZiVskqc6?e=PtBudk">App-demo.mp4</a> video.</p><h3>Solution: Azure Static Webapps Configuration file</h3><ol><li>on your code in GitHub we need to add some config files.</li><li>With this in place, Whenever we refresh the page it loads the index.html, and the client-side routing kicks in and takes care of the appropriate route. When you build the react project all the static files are served from the static folder that why it’s added to the exclude array</li><li>create a JSON file at the root of your project and name it staticwebapp.config.json. Then add the code below.</li></ol><pre><br>{<br>    &quot;navigationFallback&quot;: {<br>        &quot;rewrite&quot;: &quot;index.html&quot;,<br>        &quot;exclude&quot;: [&quot;/static/images/*.{png,jpg,gif}&quot;, &quot;/static/css/*&quot;]<br>    },<br>    &quot;mimeTypes&quot;: {<br>        &quot;.json&quot;: &quot;text/json&quot;<br>    }<br>}</pre><p>4. Your file should look like this ⬇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgQ6l466ZnAgvF33xVf3Cw.png" /></figure><p>5. Save changes and push to GitHub to trigger the CI/CD actions which will deploy your app to azure static web apps.</p><p>6. test whether the app is working and routing properly.</p><h3>Conclusion</h3><p>This is how we have to configure fallback routes in the Azure static web apps service <strong>staticwebapp.config.json file.</strong></p><p>If you love the content clap for it😊😊😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae75aac5e360" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting your student portfolio for free on Azure static web Apps]]></title>
            <link>https://medium.com/@kevin_comba/hosting-your-student-portfolio-for-free-on-azure-static-web-apps-ecac2b75300c?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecac2b75300c</guid>
            <category><![CDATA[azure-static-web-app]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[studentambassadorprogram]]></category>
            <category><![CDATA[students]]></category>
            <category><![CDATA[github-codespaces]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Fri, 17 Feb 2023 09:12:38 GMT</pubDate>
            <atom:updated>2023-02-17T09:12:38.697Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*kAcvC3bKsel_gR0x3xP9GA.png" /></figure><p>As a student, it can be difficult😒😒 to showcase your work to potential employers, especially when you don’t have a personal website or the means to host one. Creating a personal website can be costly, and many students are unable to pay for hosting services. This can make it challenging for them to effectively showcase their skills and projects to potential employers.</p><blockquote>Azure Static Web Apps provides a free and easy solution for hosting student portfolios. With Azure Static Web Apps, students can create a website for their portfolio using popular front-end frameworks such as React, Angular, Vue, or just HTML, CSS and JavaScript and host their website for free. The platform provides easy integration with GitHub, so students can easily manage their website source code and make updates as needed. Additionally, the platform provides automatic deployment, so students don’t have to worry about setting up servers or configuring DNS records.</blockquote><p>By hosting their portfolios on Azure Static Web Apps, students can have a professional and easily accessible portfolio that they can share with potential employers. This can help them stand out from other applicants and increase their chances of getting hired.</p><h3>On this blog:</h3><p>• Create a portfolio from Microsoft workshop library templates.</p><p>• host a student portfolio to azure static web apps.</p><h4>Requirements:</h4><p>• An <a href="https://learn.microsoft.com/en-us/azure/guides/developer/azure-developer-guide#understanding-accounts-subscriptions-and-billing">Azure subscription</a>: if your a student you can access <a href="https://azure.microsoft.com/en-us/free/students?wt.mc_id=studentamb_225706">Azure for free for students</a> (use your school email to verify your student), else create <a href="https://azure.microsoft.com/en-us/free/?ref=microsoft.com&amp;utm_source=microsoft.com&amp;utm_medium=docs&amp;utm_campaign=visualstudio">a free account</a> if your not a student.</p><p>• A portfolio template. You can make use of this <a href="https://github.com/kelcho-spense/mentorportfolioTemplate.git">sample resume project</a> I created from Microsoft-Peer <a href="https://github.com/microsoft/workshop-library/tree/main/full/build-resume-website">Mentorship workshop-library</a></p><p>• Assuming you have GitHub account if not create it <a href="https://github.com/">here</a>.</p><h3><strong>Creating our portfolio</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAdc9VKGI2xTJGJ7ceosGw.png" /></figure><p>• Folk this <a href="https://github.com/kelcho-spense/mentorportfolioTemplate">repo</a></p><ul><li>Give a name of your choice</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pbgELe98-KUjKiq2w93fjA.png" /></figure><ul><li>This is the view of your project</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pbgELe98-KUjKiq2w93fjA.png" /></figure><p>Press i on you keyboard to go to github.dev mode(GitHub Codespaces).</p><ul><li>After everything is loaded you should see your project in a VSCode mode but on the browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_ufGO88IjoSgU1RwPVGzg.png" /></figure><ul><li>We need to install a codeswing VScode extension for hot reloading.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7cvF8oU7C6uBjhaBk-9GqA.png" /></figure><ul><li>To run our project, type `Ctrl + Shift + P` (on windows) or `Cmd + Shift + P` (on Mac) on your keyboard and then type `CodeSwing : Open Swing` on the input prompt you get.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUdVS53BMaPcsGhtWMfVXg.png" /></figure><p>then and then press ok.</p><ul><li>Your screen will be divided into three screens, one preview screen with Realtime updates and your two coding files one HTML and CSS. On our example were going to use HTML so you can go ahead to minimize or close the CSS file(but feel free to use it to make changes)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eULDUbkIA3qJeumhVqxgsg.png" /></figure><p>• Change all your personal Information according to your profile.</p><p>Before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eULDUbkIA3qJeumhVqxgsg.png" /></figure><p>After:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*83s9sKMMqzzQrzYnLK_nKQ.png" /></figure><ul><li>After you have finished making your changes, we can commit and push our changes to GitHub.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*83s9sKMMqzzQrzYnLK_nKQ.png" /></figure><h3>Creating Azure Static Web App Via Azure Portal</h3><p>We need to provision an Azure service to host our code now that we’ve created our portfolio and stored it on GitHub. Because our web application is static and does not require dynamic data, we will use Azure Static Web Apps. Azure Static Web Apps is an excellent choice for us because it is inexpensive and simple to implement. Provisioning a Azure Static Web Apps involves specifying the configuration options for the Azure Static Web Apps, including the operating system, size, and location.</p><h4>To provision an Azure Static Web App, follow these steps:</h4><ol><li>Visit <a href="https://portal.azure.com/?wt.mc_id=studentamb_225706">Azure Portal</a> and sign in, if you don’t have an account click here to activate <a href="https://azure.microsoft.com/en-us/free/students/?wt.mc_id=studentamb_225706">azure for students</a>.</li></ol><p>2. You should see a page like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*cpUsK9ANGENMq7yEj28B0A.png" /></figure><p>3. Search for static web apps and click to select.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XWAUt3uX8F8z8m2L2VsMSQ.png" /></figure><p>4. Click create to start provisioning your service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vN0cUicKr8UCfcqkhQVEcQ.png" /></figure><p>5.1. By default, your Subscriptions should be Azure for students.</p><p>5.2. Provide the name of the resource group in which the virtual machine will reside or create a new one. Here, we will create a new one named Studentportifolio by clicking on create new button.</p><p>5.3. Give a name to your Static Web App.</p><p>5.4. We are going to use Free plan type because it’s a personal project.</p><p>5.5. Provide the region you want the Static Web App to be deployed to. I have gone with West Europe since it’s the nearest location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8xNtBuC76qbSsUUlKEYu1Q.png" /></figure><p>6.2. Select deployment source to be GitHub since we stored our code there.</p><p>6.3. You have allow Azure to access your GitHub especially the one we have stored our project.</p><p>6.4. Select your GitHub organization.</p><p>6.5. Select the Repository where our code is, mine is MLSAMentorshipPortfolio</p><p>6.6. Select the branch of your repository, mine is master.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RXsLqZxH67NTH1xPgJocpQ.png" /></figure><p>7.3. Since our project doesn’t require external libraries, we are going to go with custom Build Presets.</p><p>7.4. Leave the default since our index.html is on our root folder.</p><p>7.5 leave the default value.</p><p>7.6. Leave the default value.</p><p>7.7 Give a tag of your choice and the value of choice. I’ll go with portfolio and value of 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KrgBDx9cZUvE8g6NNr4Qbg.png" /></figure><p>8.1 Watch the tag and value.</p><p>8.2. Click create to finish the provisioning process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LAhSV22Xl_ySgDzBY9SCGw.png" /></figure><p>9.1. Watch the prompt to show the initializing deployment.</p><p>9.2. All the details of your project i.e. resource group, name, Repository etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Km5gyW29ISWJZLR1ly4KgA.png" /></figure><p>10. Deployment in progress.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZOXYluEtw-8kudTmFvquQ.png" /></figure><p>11. Deployment complete click Go to resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oHefJdn3Xlg1utDk8H0UCA.png" /></figure><p>12. Click on the URL to view your deployed portfolio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cU66n6oAJwmqsgMpBjQ4FQ.png" /></figure><p>13. We completed the task. View our portfolio on a single page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Opipi1tQqUpXwJD38i3UNA.png" /></figure><p>We followed the best practices of GitHub CI/CD, which means that when we make changes to our code in GitHub using GitHub codespaces, those changes are automatically deployed to our Azure Static Web App.</p><p>If you love the content clap for it😊😊😊.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecac2b75300c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an Azure Virtual Machine And running a React website]]></title>
            <link>https://medium.com/@kevin_comba/creating-an-azure-virtual-machine-and-running-a-react-app-4529c27ef422?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4529c27ef422</guid>
            <category><![CDATA[rdp-services]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[azure-virtual-machines]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Thu, 19 Jan 2023 18:05:50 GMT</pubDate>
            <atom:updated>2023-01-19T21:03:30.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Oo3CN-6kjY4P9A12mjwUqw.png" /><figcaption>Azure Virtual Machines</figcaption></figure><p>Azure is a platform and architecture for cloud computing developed by Microsoft for creating, delivering, and managing applications and services through a worldwide network of data centers under Microsoft’s management. A web-based management and monitoring tool for Azure resources, such as virtual machines, web apps, and storage accounts, is called the Azure portal.</p><p>The Azure portal offers information on several solutions, including Azure Virtual Machines (VMs). Azure VMs are virtualized environments that run in the cloud and can be used to host programs and services.</p><p>Azure Virtual machines are software emulations of physical computers.</p><p>✔ Include virtual machine’s operating system, processor, memory (RAM), storage and networking among other hardware and software resources.</p><p>✔ It is categorized as Infrastructure as a Service (IaaS) that provides total control and customization.</p><h3>Creating Azure Virtual Machine Via Azure Portal</h3><p>To create and use an Azure Virtual Machine (VM), you will need to provision a VM in the Azure portal. Provisioning a VM involves specifying the configuration options for the virtual machine, including the operating system, size, and location.</p><blockquote>To provision an Azure virtual machine, follow these steps:</blockquote><ol><li>Sign in to the <a href="https://portal.azure.com/">Azure portal</a>.</li></ol><blockquote>Note if your a student you can access <a href="https://azure.microsoft.com/en-us/free/students?wt.mc_id=studentamb_225706">Azure for free</a></blockquote><p>2. Click the “Create a resource” button in the top left corner of the portal</p><p>3.In the “Search the Marketplace” field, search for “virtual machine”.</p><p>4. Click the “Virtual machine” option that appears in the search results.</p><p>5. In the Virtual machines page, select Create and then Azure virtual machine. The Create a virtual</p><p>machine page opens.</p><p>6. Under Project details :- Select your subscription to manage deployed resources and costs</p><p>7. Under Instance details, enter myVM for the Virtual machine name and choose Windows Server 2019</p><p>Datacenter — Gen 2 for the Image. Leave the other defaults.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nqdqo8ej6PP7gimz6ylT5Q.png" /><figcaption>Instance details</figcaption></figure><p>8. Under Administrator account, provide a username, such as azureuser and a password. The password must be at least 12 characters long and meet the defined complexity requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lbeMAwpJmwgSM2FMwX7jA.png" /></figure><p>9. Under Inbound port rules, choose Allow selected ports and then select RDP (3389) and HTTP (80) from the drop-down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rkMhSF_p9pknzH55q1fmaA.png" /></figure><p>10. Leave the remaining defaults and then select the Review + create button at the bottom of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*yg_jpo8PwZkeDBRgKlcYHQ.png" /></figure><p>11. After validation runs, select the Create button at the bottom of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FADk68_YCESkCRGyaf8Dqg.png" /></figure><p>12. After deployment is complete, select Go to the resource.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*SoF_8dO7Kx7AJwG-2ZdEpg.png" /></figure><p>Under Instance details, enter myVM for the Virtual machine name and choose Windows Server 2019 Datacenter — Gen 2 for the Image. Leave the other defaults.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FADk68_YCESkCRGyaf8Dqg.png" /></figure><blockquote>Note : on step 6 Some users will now see the option to create VMs in multiple zones. To learn more about this new capability, <a href="https://learn.microsoft.com/enus/%20azure/virtual-machines/create-portal-availability-zone?wt.mc_id=studentamb_225706">See Create virtual machines in an availability zone</a>. It may take a few minutes for the virtual machine to be provisioned and become available. Once the VM has been created, you can access it through the Azure portal by clicking on its name in the list of virtual machines. From the virtual machine page, you can start, stop, and restart the VM, as well as view and manage its resources, such as disks, network interfaces, and extensions. Provisioning a VM in Azure allows you to create a virtualized environment in the cloud that you can use to host applications and services. Azure VMs offer a range of options for configuring the hardware and software resources of the virtual machine, giving you the flexibility to create a VM that meets your specific needs. Once the virtual machine has been created, you can connect to it using HTTP (80), HTTPS(443), SSH(22) and Remote Desktop Protocol (RDP).</blockquote><h3>Creating and Running a React -App on Azure Virtual Machine</h3><p>1. Create an Azure virtual machine and connect to it using Remote Desktop Protocol (RDP) or Secure Shell (SSH).</p><p>2. Install Node.js on the virtual machine by following the instructions for your operating system. You can download the latest version of Node.js from the <a href="https://nodejs.org/en/">official website</a> or use a <a href="https://nodejs.org/en/download/package-manager/">package manager </a>like apt or yum to install it.</p><p>3. To create a react app run the following command</p><pre>npx create-react-app my-app</pre><blockquote>Nb you can replace ‘my-app’ with the desired name for your app. This will create a new directory with the same name as your app and generate the files and dependencies needed for a basic React app.</blockquote><p>5. To navigate to the app’s directory:</p><pre>cd my-app</pre><p>Start the development server by running:</p><pre>npm start</pre><p>To access a React app running locally on an Azure virtual machine, you will need to know the public IP address or domain name of the virtual machine and the port on which the app is running. Assuming that the app is running on port 3000 and the virtual machine’s public IP address is 123.456.789.0, you can access the app by navigating to <a href="http://123.456.789.0:3000">http://123.456.789.0:3000</a> in a web browser. If you are accessing the app from a device on the same network as the virtual machine, you can also use the private IP address of the virtual machine. You can find the private IP address by running the ipconfig command in a terminal on the virtual machine. If you want to access the app from a device outside of the virtual machine’s network, you may need to configure the virtual machine’s firewall to allow incoming traffic on the port that the app is running on.</p><p>You can do this through the Azure portal or using the az command-line tool. It’s also possible to use a tool like ngrok to create a secure tunnel to your local development environment, which can make it easier to access the app from external devices.</p><h3>Connecting Azure Virtual machine using Remote Desktop Protocol</h3><p>To connect to an Azure virtual machine using Remote Desktop Protocol (RDP), follow these steps <a href="https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal#connect-to-virtual-machine?wt.mc_id=studentamb_225706">here</a></p><p>Note: If you are using a Windows virtual machine, you will need to enable Remote Desktop connections on the virtual machine before you can connect to it using RDP. To do this, follow these steps:</p><p>1. In the Azure portal, navigate to the virtual machine that you want to connect to.</p><p>2. Under “Settings”, click “Operating system”.</p><p>3. Under “Remote Desktop”, toggle the switch to “On”.</p><p>4. Click “Save” to apply the changes.</p><h3>Testing our Azure Virtual Machine using a Web Server</h3><p>Depending on the operating system of the VM, you may need to install a web server manually. For example, on Windows VMs, you can install web server via windows Powershell. On Linux VMs, you can install Apache or another web server using the package manager. <a href="https://learn.microsoft.com/en-us/azure/virtual-machines/windows/quick-create-portal#install-web-server?wt.mc_id=studentamb_225706">more info here</a></p><h3>Conclusion</h3><p>In conclusion, Azure Virtual Machines (VMs) are a powerful and flexible solution for hosting applications and services in the cloud. They offer a range of options for configuring the hardware and software resources of the virtual machine, including the operating system, CPU, memory, and storage. By using the Azure portal, you can create, configure, and manage Azure VMs with ease. You can use Remote Desktop Protocol (RDP) to connect to the VM and access the operating system, allowing you to install and configure a web server or other applications.</p><p>Azure VMs offer many benefits, including scalability, reliability, and security. They can be used to host a wide range of applications and services, including web servers, databases, and analytics platforms. With Azure VMs, you can take advantage of the power and flexibility of the Azure platform to build and deploy your applications and services in the cloud. So, Azure VMs can be a great solution for many different scenarios.</p><p>Credit to Microsoft Learn Platform For More information <a href="https://learn.microsoft.com/enus/azure/virtual-machines?wt.mc_id=studentamb_225706">read the docs</a>. You can also attend <a href="https://www.microsoft.com/enus/trainingdays/azure">Azure virtual Training day</a> to get an in-depth fundamental of cloud computing concepts. You’ll also learn the basics of infrastructure as a service (IaaS), platform as a service (PaaS), and software as a service (SaaS). This will help you take the <a href="https://learn.microsoft.com/en-us/certifications/azure-fundamentals?wt.mc_id=studentamb_225706">Microsoft Azure Fundamentals certification exam at no cost</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4529c27ef422" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to be a Microsoft Learn Student Ambassador [2023]-Everything you need to know!]]></title>
            <link>https://medium.com/@kevin_comba/how-to-be-a-microsoft-learn-student-ambassador-2023-everything-you-need-to-know-958f5ab0647b?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/958f5ab0647b</guid>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[microsoft-learn]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Sun, 08 Jan 2023 13:10:11 GMT</pubDate>
            <atom:updated>2023-01-19T21:10:09.348Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0GG7MF-Mm-XPvGTgeLIvg.png" /></figure><p>This article involves the following sections:</p><ul><li>Microsoft Learn Student Ambassador Program — about, eligibility, timeline, and everything you need to know</li><li>Why you should apply for this program — the perks and other benefits</li><li>Complete step by step guide to the application process</li></ul><p>So let’s get started.</p><h3>What is Microsoft Learn Student Ambassador Program?</h3><p>Microsoft Learn Student Ambassadors is a global program that empowers students to become leaders in their communities and helps them build valuable skills that will benefit them in their future careers. The ambassadors are exposed to a high learning environment through the Microsoft platform and they might find themselves organizing and mentoring events for the upliftment of technical and career skills for the future thereby increasing the overall employability among communities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O10J2QQUWTQ_69r5ht5sdg.png" /></figure><h3>What are the eligibility criteria?</h3><p>· Be 16 years of age or older.</p><p>· Be enrolled full-time in an accredited academic institution (e.g. College, University) and have at least one academic remaining in the course your taking.</p><ul><li>Be an individual person (not a corporate entity)</li><li>Not be a Microsoft employee or current contractor</li></ul><h3>What are the perks of being an MLSA?</h3><ul><li>Exposure to be in the talented pool all across the world(networking)</li><li>Office 365 subscription()</li><li>Visual Studio Enterprise(license keys for windows,GitHub Enterprise,Azure DevOps (Basic),Visual Studio Professional IDE)</li><li>Azure credits worth $150/month</li><li>Linkedin Learning free subscription</li><li>Invitation to Microsoft regional, national, and sometimes international events including Microsoft Student Summit, Ignite, etc.</li><li>Nomination to the <a href="https://mvp.microsoft.com/">Microsoft Most Valuable Professional (MVP)</a> program</li><li>Host workshops through the <a href="https://developer.microsoft.com/reactor/">Microsoft Reactor</a> and <a href="https://docs.microsoft.com/shows/learn-live/">Microsoft Learn Live Series</a></li><li>Exclusive swags, badges, and accessories from Microsoft</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*07jRNxbXTVNq1Jh4E50juw.jpeg" /><figcaption>My Microsoft Beta Swag kit with amazing goodies</figcaption></figure><ul><li>And the <strong>best part, </strong>you get a personal profile section on the official website to connect with anyone and showcase your portfolio.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IUgEmV68uwSwE__NZ8iQcg.png" /><figcaption>Find my MLSA profile at <a href="https://studentambassadors.microsoft.com/en-US/studentambassadors/profile/b81411c3-fbca-4a78-86c3-e7360f946b7f">Microsoft Learn Student Ambassadors</a></figcaption></figure><h3>How to apply to become a Microsoft Learn Student Ambassador?</h3><h3>Step 1: Log in to the application portal</h3><p>Visit <a href="https://studentambassadors.microsoft.com/en-US/?wt.mc_id=studentamb_225706">studentambassadors.microsoft.com</a> and click on “Apply Now”</p><p>Login with a new or an already existing Microsoft Account to get the application form.</p><h3>Step 2: Fill in the Application Form Details</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JQGC6EhsKFHlWOtaHV-c-A.png" /></figure><p>As shown above, accept the terms and fill in the initial personal and academic details. Now comes the most important section,Now comes the most important section, the <strong>Written Sample,</strong> having three questions to be answered with at least one video response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*344GAUhY05dmoqTZZBfzgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvzRwD5EL4sBGNwWmSroBw.png" /></figure><blockquote><em>Pro tip: Select the question you feel confident or you won’t struggle to answer in a video.</em></blockquote><h3>What’s a good written/video sample?</h3><p>Though it is custom to individuals, try to keep these points in mind:</p><ul><li>Through these three areas(Welcome, Guide, Connect), Microsoft is trying to see <strong>how good and excited you are about what you do</strong>. So, presenting your authentic and fresh ideas would be a plus. Try not to lie.</li><li>Microsoft has no intention of judging you on your video editing skills. So <strong>try not to over-edit</strong> your video with effects and filters pushing the main content(i.e your voice) to the background.</li></ul><blockquote><em>My submission video was just me in front of the camera speaking for 2 mins about what excites me to join this program. I did not edit it at all.</em></blockquote><ul><li>Though you can take references from youtube and other blogs about <em>what applications have been selected, </em>I <strong>do not recommend it in any case</strong> because when you see a sample, you subconsciously start to think in a certain direction which becomes a hindrance to your imagination and hence the responses. It made me fail 2times because of copy-pasting other people’s work.</li><li>Most importantly, within these answers, <strong>try to focus on how you can learn and help communities around you grow</strong> because, in the nutshell, MLSA is all about learning and growing together through communities.</li><li>Fill in the social media and additional information my recommendation is to have a <a href="https://ke.linkedin.com/?wt.mc_id=studentamb_225706">Linkedin</a>, <a href="https://learn.microsoft.com/en-us/training/student-hub/?wt.mc_id=studentamb_225706">Microsoft learn profile</a>, and <a href="https://twitter.com/">Twitter account</a>. Be active with the tech communities. Connect with me <a href="https://linktr.ee/kevincomba">here</a>.</li><li>Microsoft learn profile is important because it will show the recruiter if you have been learning skills on Microsoft&#39;s best learning platform. Doing at least two learning paths will be a plus for you. Examples of beginner learning paths you may check out are</li></ul><ol><li><a href="https://learn.microsoft.com/en-us/training/paths/web-development-101/?wt.mc_id=studentamb_225706">Web development</a> — introduction to programming.</li><li><a href="https://learn.microsoft.com/en-us/training/paths/machine-learning-foundations-using-data-science/?wt.mc_id=studentamb_225706">Foundation of data science for machine learning</a></li><li><a href="https://learn.microsoft.com/en-us/training/paths/az-900-describe-cloud-concepts/?wt.mc_id=studentamb_225706">Cloud Computing With Azure</a></li><li><a href="https://learn.microsoft.com/en-us/training/roles/data-analyst?wt.mc_id=studentamb_225706">Cloud Administrator</a></li><li><a href="https://learn.microsoft.com/en-us/training/roles/data-scientist?wt.mc_id=studentamb_225706">Data Scientist</a></li><li><a href="https://learn.microsoft.com/en-us/training/student-hub/certifications?wt.mc_id=studentamb_225706">Free student Certification(do exams at no cost)</a></li><li><a href="https://azure.microsoft.com/en-us/free/students/?wt.mc_id=studentamb_225706">Azure for Students </a>— build in cloud-free with azure for students.</li><li><a href="https://education.github.com/pack?wt.mc_id=studentamb_225706">GitHub Student Developer Pack</a> -as a student you can get offers and benefits from Github partners.</li></ol><blockquote>Check all green ticks in the upper left corner for successful application and submit when you are fully satisfied with your answers.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*Bx5X_mneaQC9H4KPZzbVHg.png" /></figure><blockquote>Just after submitting the application, you will get a confirmation via email or text message on the mobile you’ve verified in the initial application</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3N7bkZpwMb2AMBKktzSHNQ.png" /><figcaption>A confirmation mail and text messages after submission</figcaption></figure><p>later if you are selected you will receive this email.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAOuVQJvJJIwXmXyrn1zDw.png" /><figcaption>A confirmation mail and text messages after being accepted</figcaption></figure><h3>How does the further selection process work?</h3><p>Each of the submissions will be reviewed manually by the team the candidates will be notified about the acceptance in the next quarter.</p><p>If you’re selected, Congratulations and welcome to the team :)</p><p>If you’re not, don’t worry, you can always go to your application delete it, and reapply for the next cohort.</p><h3>So what’s next after getting selected?</h3><p>If you’ve come this far, huge kudos!</p><h3>MILESTONES</h3><p>Once you are selected for the program, you can achieve the following milestones. Each milestone has it own benefits.</p><p>You will be joining as N<strong>ew MLSA</strong> and later advance to <strong>alpha MLSA</strong> and as you move ahead, you will be unlocking the further milestones of <strong>Beta</strong> and <strong>Gold </strong>according to your performances and commitment.</p><ol><li><strong>Alpha</strong> -Complete a <a href="https://learn.microsoft.com/en-us/training/paths/web-development-101/?wt.mc_id=studentamb_225706">Microsoft Learn</a> path,<a href="https://github.com/microsoft/SATechnicalOnboarding">start your technical onboarding</a> and unlock $150 monthly <a href="https://azure.microsoft.com/">Azure</a> credits and your Visual Studio Enterprise subscription benefit. You’ll also receive free <a href="https://www.linkedin.com/learning/">LinkedIn Learning</a>.</li><li><strong>Beta </strong>— Get loaded with the swag kit. Host an event in your community to unlock event support and resource benefits. This effort could include an invitation to join our annual Microsoft Learn Student Ambassadors Summit.</li><li><strong>Gold </strong>— Get invited to the Gold milestone when you’ve gone above and beyond in earning your badges and serving your local community. You’ll become a Student Ambassadors Regional Leader, gain access to special events, and may be invited to become a Microsoft <a href="https://mvp.microsoft.com/">Most Valuable Professional</a> (MVP).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*ofHD92FAvrc0hpkiyf7AZA.png" /></figure><h3>LEAGUES</h3><p>Leagues are designed to allow you to engage in topics you are passionate about while enabling you to develop skills, share knowledge with your communities and get professional mentorship.<br>You can join any two leagues, including one technical and one social impact league.</p><h3>Technical Leagues</h3><ul><li>AI and Machine Learning</li><li>Data and Analytics</li><li>Emerging Technologies</li><li>Internet of Things</li><li>Mobile and Development</li><li>Low Code Development</li></ul><h3>Social Impact Leagues</h3><ul><li>Digital Accessibility</li><li>Education</li><li>Green Tech</li><li>Healthcare</li></ul><p>Personally, I have been part of many campus ambassador programs but this, by far is the most productive one in terms of learning opportunities and networking. If you’re a student, you should definitely give it a shot.</p><p>I hope this article has helped you. Feel free to reach out on <a href="https://www.linkedin.com/in/kevin-comba-gatimu/">Linkedin</a> or <a href="https://twitter.com/_kevincomba">Twitter</a> for any other queries. Good luck and clap for this article 🤩🤩🤩</p><p></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=958f5ab0647b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started With C# Part 1[Overview & Control Flow]]]></title>
            <link>https://medium.com/@kevin_comba/getting-started-with-c-part-1-overview-control-flow-3c590f0b52ee?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c590f0b52ee</guid>
            <category><![CDATA[dot-net-developers]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Wed, 23 Nov 2022 20:49:22 GMT</pubDate>
            <atom:updated>2022-11-27T22:34:06.553Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*57j81M60MP_GDtVeWrmPpQ.png" /><figcaption>C# basics[overview &amp; control flow]</figcaption></figure><h3><strong>Session 1: Types, Keywords, and Operators with C#</strong></h3><p>In this first session, we’re going to start learning about object-oriented programming with C#. We’ll touch on the very basics around variable types, language keywords, and how we can use operators to make variables work together for us.</p><h3><strong>Get C# to run locally</strong></h3><p>You can get all of the tools to build with C# locally on your Mac or PC by installing <a href="https://code.visualstudio.com/?wt.mc_id=studentamb_225706">Visual Studio or Visual Studio for Mac</a>. You can also install just the build tools for Windows, Mac, or Linux by following the instructions at <a href="https://dotnet.microsoft.com/en-us/download/dotnet/7.0?wt.mc_id=studentamb_225706">dot.net</a> For most of my streams to start, we will be writing code using <a href="https://github.com/dotnet/interactive?wt.mc_id=studentamb_225706"><em>Jupyter Notebooks and .NET Interactive.</em></a></p><h3><strong>⌛What is C# ?</strong></h3><p>C# is a statically-typed, compiled, object-oriented language used with the .NET frameworks and runtimes. The official Microsoft C# language reference can be found on <a href="https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp?wt.mc_id=studentamb_225706">docs.microsoft.com</a>. Similar to Java in syntax and structure, C# programs are compiled and executed against a .NET runtime running on a computer. The output of compiling C# code can be called a ‘.NET program’.</p><p>A .NET Runtime is a collection of commands native to the computer operating system that instruct the computer how to interpret and run a .NET program</p><p>There are several different .NET runtimes available that give C# flexibility to run in many different locations.</p><p>➡️.NET Framework — runs on Windows and support desktop user-interface, console, and server development</p><p>➡️.NET Core — runs on Windows, Mac, and Linux with support for desktop userinterface, console, and server development</p><p>➡️.NET Core — runs on Windows, Mac, and Linux with support for desktop userinterface, console, and server development</p><p>➡️Unity — runs on Windows, Mac, Linux, iOS, and Android devices with support for game development using the Unity3D tools</p><p>➡️Mono — runs on Windows, Mac, Linux, and Web Assembly</p><p>A .NET Framework is a collection of programming instructions and tools that help you write a program of a specific type. Examples of .NET Frameworks include <a href="https://learn.microsoft.com/en-us/dotnet/desktop/winforms/?view=netdesktop-6.0&amp;wt.mc_id=studentamb_225706">Windows Forms</a>, <a href="https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps?wt.mc_id=studentamb_225706">ASP.NET</a>, <a href="https://dotnet.microsoft.com/en-us/apps/xamarin?wt.mc_id=studentamb_225706">Xamarin iOS</a>, and <a href="https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor?wt.mc_id=studentamb_225706">Blazor</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*De7rSnCg-aNcS4rEWBurCw.png" /></figure><p>C# requires a .NET runtime and frameworks for the appropriate program type to run. The definition of the framework and runtime for a C# program are stored in a .csproj file. We’ll learn more about this file and structure in a future lesson. For now, know that the .NET tools will help construct and manage this file for you when you specify what type of program you want to create.</p><p><strong><em>All C# files carry a .cs file extension by default</em></strong></p><h3>⭐<strong>Syntax 101⭐</strong></h3><p>Here are the basics of C# code syntax that you should know as we get started.</p><p>⭐C# uses a semi-colon to denote the end of a statement.</p><p>This is a hard and fast rule, and you’ll get used to it quickly. Every statement in C# needs to end with a semi-colon ; This allows us to also have very flexible spacing in how we structure our code.</p><p>⭐C# is NOT space sensitive</p><p>You can place as many spaces, tabs, or blank lines around your code as you would like.</p><p>⭐C# IS case sensitive</p><p>C# is case-sensitive. All variables, objects, and their interactions must be referenced with the proper casing.</p><p>⭐Comment Syntax</p><p>You can write comments by using the two forward-slash characters to indicate everything after them is a comment.</p><pre>// This is a comment<br>Console.WriteLine(&quot;Heey kevin&quot;);<br>output⬇️<br>Heey kevin </pre><p>You can create comments that span multiple lines by using slash asterisk fencing like the following:</p><pre>/* This is a multi-line comment <br>sdgdfhdfhdfghdfghdfhdfhdfhd and <br>this is still commented out */</pre><h4><strong>Everything in C# is an object</strong></h4><p>As C# is an object oriented language, everything we want to work with is an object. Objects can be declared of various TYPES and then interacted with. The simplest types in C# are called <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-types?wt.mc_id=studentamb_225706">Built-In Types</a> We can define variables, in-memory storage for a type by preceeding the name of the variable we would like to create with the type of the variable we are creating.</p><pre>int i;<br>double j;<br>char c;<br>Console.WriteLine(c);</pre><p>That’s not very exciting, but we created a 32-bit integer named i. We can initialize a variable with an = assignment at the time of declaration</p><p><strong>The var keyword</strong></p><p>Sometimes, its a little cumbersome to declare a variable, assign a value, and have to specify the type before it. C# has built-in type inference and you can use the var keyword to force the compiler to detect the actual type being created and set the variable to the type of the value being assigned.</p><pre>var i = 10;<br>var someReallyLongVariableName = 9;<br>var foo = &quot;Something&quot;;<br>Console.WriteLine(someReallyLongVariableName);<br>var c = &#39;C&#39;;<br>Console.WriteLine(c);</pre><h3>🕹️Basic Data Types:</h3><p>➡️1. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types?wt.mc_id=studentamb_225706">int</a> 4 bytes Stores whole numbers from -2,147,483,648 to 2,147,483,647 ➡️ 2. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types?wt.mc_id=studentamb_225706">long</a> 8 bytes Stores whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807</p><p>➡️3. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types?wt.mc_id=studentamb_225706">float</a> 4 bytes Stores fractional numbers. Sufficient for storing 6 to 7 decimal digits</p><p>➡️4. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types?wt.mc_id=studentamb_225706">double</a> 8 bytes Stores fractional numbers. Sufficient for storing 15 decimal digits.</p><p>➡️5. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types?wt.mc_id=studentamb_225706">bool</a> 1 bit Stores true or false values</p><p>➡️6. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types?wt.mc_id=studentamb_225706">char</a> 2 bytes Stores a single character/letter, surrounded by single quotes</p><p>➡️7. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/integral-numeric-types?wt.mc_id=studentamb_225706">string</a> 2 bytes per character Stores a sequence of characters, surrounded by ➡️ ➡️ double quotes</p><pre>// Declare some basic value type variables<br>int i = 10;<br>float f = 2.5f;<br>decimal d = 10.0m;<br>bool b = true; //or false<br>char c = &#39;c&#39;;<br>// Declare a string - it&#39;s a collection of characters<br>string str = &quot;this is my name&quot;;<br>// Declare an implicit variable<br>var x = 10;<br>var z = &quot;Hello!&quot;;<br>// Declare an array of values<br>int[] vals = new int[5];<br>string[] strs = { &quot;one&quot;, &quot;two&quot;, &quot;three&quot; };<br><br>// Print the values using a Formatting String<br>Console.WriteLine(&quot;{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}&quot;, i, c, b,<br>str, f, d, x, z);<br>// &quot;null&quot; means &quot;no value&quot;<br>object obj = null;<br>string john = null;<br>Console.WriteLine(john);<br>// Implicit conversion between types<br>long bignum;<br>bignum = i;<br>// Explicit conversions<br>float i_to_f = (float)i;<br>Console.WriteLine(&quot;{0}&quot;, i_to_f);<br>int f_to_i = (int)f;<br>Console.WriteLine(&quot;{0}&quot;, f_to_i);</pre><h3>🕹️Operators:</h3><p>Now that we have some basic types and can create variables, it would sure be nice to have them interact with each other. <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators?wt.mc_id=studentamb_225706">Operators</a> can be used to interact with our variables. Let’s start by declaring two variables, apples and oranges and interact with them using <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators?wt.mc_id=studentamb_225706">different operators</a>. Try changing some of the values and tinkering with the operators in the following code snippets.</p><pre>//Basic arithmetic operators and assignment are available:<br>var apples = 100m; // Decimal value<br>var oranges = 30m; // Decimal value<br>Console.WriteLine(apples + oranges);<br>Console.WriteLine(apples - oranges);<br>Console.WriteLine(apples * oranges);<br>Console.WriteLine((int)apples / 7m);</pre><p>You can use the equals character = to assign values, and prefix it with an <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/arithmetic-operators?wt.mc_id=studentamb_225706">arithmetic</a> operator to modify and <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/comparison-operators?wt.mc_id=studentamb_225706">assign</a> the resultant value.</p><pre>var apples = 100m;<br>Console.WriteLine(apples += 10); //apples = apples + 10<br>Console.WriteLine(apples -= 10); //apples = apples - 10<br>Console.WriteLine(apples *= 10); //apples = apples * 10<br>Console.WriteLine(apples /= 3m); //apples = apples / 3<br>Console.WriteLine(30.0d == 30);</pre><p>C# makes the <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/comparison-operators?wt.mc_id=studentamb_225706">inequality operators</a> available as well, and a test for equality using ==</p><pre>Console.WriteLine(apples &gt; oranges);  //greator than<br>Console.WriteLine(apples &gt;= oranges); //greaterthan or equal to<br>Console.WriteLine(apples &lt; oranges);  //less than<br>Console.WriteLine(apples &lt;= oranges); //less than or equal to<br>Console.WriteLine(apples == oranges); //equal to<br>Console.WriteLine(apples != oranges); //The not-equals operator</pre><p>😎😎 Declare some variables to excercise the operators</p><pre>int x=10, y=5;<br>string a=&quot;abcd&quot;, b=&quot;efgh&quot;;<br>// Basic math operators are +, -, /, *<br>Console.WriteLine(&quot;----- Basic Math -----&quot;);<br>Console.WriteLine((x / y) * x);<br>Console.WriteLine(a + b);<br>// Increment / decrement operators<br>Console.WriteLine(&quot;----- Shorthand -----&quot;);<br>// x++;<br>// y--;<br>Console.WriteLine(x);<br>Console.WriteLine(y);<br>// Operators can be shorthand: a = a + b<br>a += b;<br>Console.WriteLine(a);<br>// Logical operators &amp;&amp;, ||<br>Console.WriteLine(&quot;----- Logic Operators -----&quot;);<br>Console.WriteLine(x &gt; y &amp;&amp; y &gt;= 5); //true<br>Console.WriteLine(x &lt; y || y &gt; 5); // false<br>// null-coalescing operators<br>string str = null;<br>// the ?? operator uses left operand if not null, or right one if it <br>is<br>Console.WriteLine(str ?? &quot;Unknown string&quot;);<br>// the ??= operator assigns the right operand if the left one is null<br>// it replaces the code:⬇️<br>// if (variable is null) {<br>// variable = somevalue;<br>// }<br>str ??= &quot;New string&quot;;<br>Console.WriteLine(str);</pre><h3>🕹️Data Types : Date</h3><p>Dates are a more complex data type that you can interact with by using the DateTime type. We can assign a new Date and time with a new statement to construct the DateTime type. Complete documentation of the DateTime type is available at docs.microsoft.com</p><pre>DateTime today = new DateTime(2020, 8, 1, 9, 15, 30); /* Create a <br>date for August 1, 2020 at 9:00am */<br>Console.WriteLine(today);<br>Console.WriteLine(today.Hour); /* We can reference parts of the DateTime as <br>properties on the variable */<br>Console.WriteLine(today.Minute);<br>Console.WriteLine(today.Second);</pre><p>There are several properties on the DateTime object that allow us to interact with the variable type itself:</p><pre>Console.WriteLine(DateTime.Now); // Display the current local time<br>Console.WriteLine(DateTime.MaxValue); // Display the maximum date value<br>Console.WriteLine(DateTime.MinValue); // Display the maximum date value</pre><p>We can also add durations to our date like days and hours. The TimeSpan type is available to define a time duration that we can interact with</p><pre>Console.WriteLine(today.AddDays(7)); // Add a week to November 1<br>TimeSpan ThreeHours = TimeSpan.FromHours(3); // Define a TimeSpan of 3 hours<br>Console.WriteLine(ThreeHours); // Show 3 hours as a string<br>Console.WriteLine(today.Add(ThreeHours)); // Add 3 hours to &#39;today&#39; and display the result</pre><h3>🕹️Data Types : Tuples</h3><p><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/value-tuples?wt.mc_id=studentamb_225706">A Tuple</a> can be used to group together related data elements in a lightweight structure. Use parenthesis with the value-types to combine:</p><pre>(int, int) point = (24, 35);<br>Console.WriteLine(point);</pre><p>You can access the items in the Tuple with the Item# properties of the Tuple instance:</p><pre>Console.WriteLine(point.Item1);<br>Console.WriteLine(point.Item2);</pre><p>Tuples can have names assigned to the properties as well:</p><pre>(decimal Latitude, decimal Longitude) Philadelphia = (39.95233m, -<br>75.16379m);<br>Console.WriteLine(Philadelphia);<br>Console.WriteLine(Philadelphia.Latitude);<br>Console.WriteLine(Philadelphia.Longitude);</pre><h3>⭐Program Flow⭐</h3><p>Are recipes which have a particular start spots and special rules on how the computer follows them. In general, a program will start at some “main” routine and continue “downward” one line at a time until the end of the function is reached</p><p>C# supports the usual logical conditions from mathematics:</p><p>➡️ Less than: a &lt; b</p><p>➡️ Greater than or equal to: a &gt;= b</p><p>➡️Equal to a == b</p><p>➡️ Not Equal to: a != b</p><p>You can use these conditions to perform different actions for different decisions. C# has the following conditional statements: Use if to specify a block of code to be executed, if a specified condition is true Use else to specify a block of code to be executed, if the same condition is false Use else if to specify a new condition to test, if the first condition is false Use switch to specify many alternative blocks of code to be executed.</p><ol><li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/selection-statements?wt.mc_id=studentamb_225706">IF</a></li><li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/selection-statements?wt.mc_id=studentamb_225706">IF-ELSE</a></li><li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/switch-expression?wt.mc_id=studentamb_225706">CONDITIONAL SWITCH</a></li><li>LOOPS ie <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/iteration-statements#the-for-statement?wt.mc_id=studentamb_225706">FOR LOOP</a>, <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/iteration-statements#the-while-statement?wt.mc_id=studentamb_225706">WHILE LOOP</a>, <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/iteration-statements#the-do-statement?wt.mc_id=studentamb_225706">DO WHILE LOOP</a>,<a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/iteration-statements#the-foreach-statement?wt.mc_id=studentamb_225706">FOREACH</a></li><li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/jump-statements#the-break-statement?wt.mc_id=studentamb_225706">BREAK</a> <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/jump-statements#the-continue-statement?wt.mc_id=studentamb_225706">CONTINUE</a></li><li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/exceptions/using-exceptions?wt.mc_id=studentamb_225706">EXCEPTIONS</a></li></ol><h3><strong>🕹️The if Statement</strong></h3><p>Use the else statement to specify a block of code to be executed if the condition is False.</p><pre>int time = 110;<br>if (time &lt; 18) //condition to be checked 🤔🤔<br>{<br> Console.WriteLine(&quot;Good day.&quot;); // block of code to be executed if<br>the condition is True<br>}<br>else<br>{<br> Console.WriteLine(&quot;Good evening.&quot;); // block of code to be executed <br>if the condition is False<br>}<br>// Outputs &quot;Good evening.&quot;</pre><h3>🕹️The else if Statement</h3><p>Use the else if statement to specify a new condition if the first condition is False.</p><pre>int time = 112;<br>if (time &lt; 10) //condition to be checked 🤔🤔<br>{<br> Console.WriteLine(&quot;Good morning.&quot;); // block of code to be executed<br>if the condition IF is True<br>}<br>else if (time &lt; 20) //condition to be checked 🤔🤔<br>{<br> Console.WriteLine(&quot;Good day.&quot;); // block of code to be executed if <br>the condition ELSE IF is True<br>}<br>else<br>{<br> Console.WriteLine(&quot;Good evening.&quot;); // block of code to be executed<br>if all the above conditions are False<br>}<br>// Outputs &quot;Good evening.&quot;</pre><h3>🕹️The Switch Statements</h3><p>Use the <a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/selection-statements#the-switch-statement?wt.mc_id=studentamb_225706">switch</a> statement to select one of many code blocks to be executed.</p><pre>Syntax<br>switch(expression)<br>{<br> case x:<br> // code block<br> break;<br> case y:<br> // code block<br> break;<br> default:<br> // code block<br> break;<br>}<br><br>This is how it works:<br> ⭐The switch expression is evaluated once <br> ⭐The value of the expression is compared with the values of each <br>case<br> ⭐If there is a match, the associated block of code is executed <br> ⭐The break and default keywords will be described later in this <br>chapter</pre><p>The example below uses the weekday number to calculate the weekday name:</p><pre>int day = 888;<br>switch (day)<br>{<br> case 1:<br> Console.WriteLine(&quot;Monday&quot;);<br> break;<br> case 2:<br> Console.WriteLine(&quot;Tuesday&quot;);<br> break;<br> case 3:<br> Console.WriteLine(&quot;Wednesday&quot;);<br> break;<br> case 4:<br> Console.WriteLine(&quot;Thursday&quot;);<br> break;<br> case 5:<br> Console.WriteLine(&quot;Friday&quot;);<br> break;<br> case 6:<br> Console.WriteLine(&quot;Saturday&quot;);<br>break;<br> case 7:<br> Console.WriteLine(&quot;Sunday&quot;);<br> break;<br> default :<br> Console.WriteLine(&quot;Invalid number of the day&quot;);<br> break;<br>}<br>  //output⬇️<br>//Invalid number of the day </pre><h3>🕹️ForLoop</h3><p>When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop:</p><pre>Syntax :<br>for (statement 1; statement 2; statement 3) <br>{<br>// code block to be executed<br>}<br>⭐ Statement 1 is executed (one time) before the execution of the code <br>block.<br>⭐ Statement 2 defines the condition for executing the code block.<br>⭐ Statement 3 is executed (every time) after the code block has been <br>executed.</pre><pre>// the basic for loop<br>int myVal = 15;<br>Console.WriteLine(&quot;The basic for loop:&quot;); /*it will output &quot;The basic for loop:&quot; */<br>for (int i = 0; i &lt; myVal; i++) {<br> Console.WriteLine(&quot;i is currently {0}&quot;, i);<br>}<br>//output.⬇️</pre><pre>The basic for loop: <br>i is currently 0 <br>i is currently 1 <br>i is currently 2 <br>i is currently 3 <br>i is currently 4 <br>i is currently 5 <br>i is currently 6 <br>i is currently 7 <br>i is currently 8 <br>i is currently 9 <br>i is currently 10 <br>i is currently 11 <br>i is currently 12 <br>i is currently 13 <br>i is currently 14 </pre><h3>Double ForLoops</h3><p>using two forloops to create a rightangled triangle od stars.</p><pre>//PRINT A TRIANGLE OF STARS<br>for (int i = 1; i &lt;= 6; i++)<br>{<br> for (int j = 1; j &lt;= i; j++)<br> {<br> Console.Write(&quot;*&quot;);<br> }<br> Console.WriteLine();<br>} <br>//output⬇️</pre><pre>*<br>**<br>***<br>****<br>*****<br>******</pre><h3>🕹️The foreach Loop</h3><p>There is also a foreach loop, which is used exclusively to loop through elements in an array:</p><pre>//the foreach-in loop can be used to iterate over sequences<br>int[] nums = new int[] {3, 14, 15, 92, 6};<br>Console.WriteLine(&quot;The foreach loop:&quot;);<br>foreach (int i in nums) {<br> Console.WriteLine(&quot;i is currently {0}&quot;, i);<br>}<br>/* outputThe foreach loop: <br>i is currently 3 <br>i is currently 14 <br>i is currently 15 <br>i is currently 92 <br>i is currently 6 */<br></pre><pre>// count the number of o&#39;s in the string<br>string str = &quot;The quick brown fox jumps over the lazy dog&quot;;<br>var count = 0;<br>foreach (char c in str) {<br> if (c == &#39;t&#39;) {<br> count++;<br> }<br>}<br>Console.WriteLine(&quot;Counted {0} o characters&quot;, count);<br>//output Counted 1 o characters</pre><h3>🕹️Loops</h3><p>Loops can execute a block of code as long as a specified condition is reached. Loops are handy because they save time, reduce errors, and they make code more readable.</p><h3>🕹️While Loop:</h3><p>The while loop loops through a block of code as long as a specified condition is True:</p><pre>Syntax<br> while (condition) <br> {<br> // code block to be executed<br> }<br></pre><p>In the example below, the code in the loop will run, over and over again, as long as a variable (i) is less than 5:</p><pre>int i = 0;<br>while (i &lt; 5)<br>{<br> Console.WriteLine(i);<br> i++;<br>}<br>/* output<br>   0 <br>   1 <br>   2 <br>   3 <br>   4 */<br></pre><h3>🕹️The Do-While Loop</h3><p>The do/while loop is a variant of the while loop. This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true.</p><pre>Syntax:<br> do <br> {<br> // code block to be executed<br> }<br> while (condition);<br>int i = 0;<br>do<br>{<br> Console.WriteLine(i);<br> i++;<br>}<br>while (i &lt; 5);<br>/*0 <br>1 <br>2 <br>3 <br>4 */<br></pre><h3>🕹️Break</h3><p>You have already seen the break statement used in an earlier chapter of this tutorial. It was used to “jump out” of a switch statement.</p><p>The break statement can also be used to jump out of a loop. This example jumps out of the loop when i is equal to 4:</p><pre>for (int i = 0; i &lt; 10; i++)<br>{<br> if (i == 9)<br> {<br> // Console.WriteLine(&quot;Break!!!&quot;); //<br> break;<br> }<br> Console.WriteLine(i);<br>}<br>/* output<br>0 <br>1 <br>2 <br>3 <br>4 <br>5 <br>6 <br>7 <br>8 */<br></pre><h3>🕹️Continue</h3><p>The continue statement breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop.</p><p>This example skips the value of 4:</p><pre>for (int i = 0; i &lt; 10; i++)<br>{<br> if (i == 4)<br> {<br> continue;<br> }<br> Console.WriteLine(i);<br>}<br>/* output<br>0 <br>1 <br>2 <br>3 <br>5 <br>6 <br>7 */</pre><h3>🕹️Break and Continue in While Loop</h3><p>You can also use break and continue in while loops:</p><pre>int[] values = {3, 7, 12, 23, 25, 28, 29, 36, 47, 57};<br>Console.WriteLine(&quot;Using break and continue :&quot;);<br>foreach (int val in values)<br>{<br> // The continue statement skips the rest of the loop entirely<br> // and jumps to the next iteration (if there is one)<br> if (val &gt;= 20 &amp;&amp; val &lt;= 29) {<br> continue;<br> }<br> // The break statement stops the loop and exits<br> if (val &gt;= 40) {<br> break;<br> }<br> Console.WriteLine($&quot;val is currently {val}&quot;); // print the value<br>}<br>/* output<br>Using break and continue : <br>val is currently 3 <br>val is currently 7 <br>val is currently 12 <br>val is currently 36 */</pre><h3>🕹️Exceptions — Try..Catch</h3><p>When executing C# code, different errors can occur: coding errors made by the programmer, errors due to wrong input, or other unforeseeable things. When an error occurs, C# will normally stop and generate an error message. The technical term for this is: C# will throw an exception (throw an error).</p><pre>The try statement allows you to define a block of code to be tested <br>for errors while it is being executed.<br>The catch statement allows you to define a block of code to be <br>executed, if an error occurs in the try block.<br>The try and catch keywords come in pairs:<br>Syntax:<br> try <br> {<br> // Block of code to try<br> }<br> catch (Exception e)<br> {<br> // Block of code to handle errors<br> }</pre><pre>try<br>{<br> int[] myNumbers = {1, 2, 3};<br> Console.WriteLine(myNumbers[10]);<br>}<br>catch (Exception e)<br>{<br> Console.WriteLine(e.Message);<br>}<br>/*Index was outside the bounds of the array. */</pre><pre>// You can also output your own error message:<br>try<br>{<br> int[] myNumbers = {1, 2, 3};<br> Console.WriteLine(myNumbers[10]);<br>}<br>catch (Exception e)<br>{<br> Console.WriteLine(&quot;Something went wrong.&quot;);<br>}<br>/* output<br>Something went wrong. */</pre><h3>🕹️Exceptions — Finally</h3><p>The finally statement lets you execute code, after try…catch, regardless of the result:</p><pre>try<br>{<br> int[] myNumbers = {1, 2, 3};<br> Console.WriteLine(myNumbers[10]);<br>}<br>catch (Exception e)<br>{<br> Console.WriteLine(&quot;Something went wrong.&quot;);<br>}<br>finally<br>{<br> Console.WriteLine(&quot;The &#39;try catch&#39; is finished.&quot;);<br>}<br>/*output<br>Something went wrong. <br>The &#39;try catch&#39; is finished. */</pre><h3>🕹️The throw keyword</h3><p>The throw statement allows you to create a custom error. The throw statement is used together with an exception class. There are many exception classes available in C#: ArithmeticException, FileNotFoundException, IndexOutOfRangeException, TimeOutException, etc:</p><pre>int x = 100;<br>int y = 0;<br>int result;<br>try {<br> if (x &gt; 1000) {<br> throw new ArgumentOutOfRangeException(&quot;x&quot;,&quot;x has to be 1000 or<br>less&quot;);<br> }<br> result = x / y;<br> Console.WriteLine(&quot;The result is: {0}&quot;, result);<br>}<br>catch (DivideByZeroException e) {<br> Console.WriteLine(&quot;Whoops!&quot;);<br> Console.WriteLine(e.Message);<br>}<br>catch (ArgumentOutOfRangeException e) {<br> Console.WriteLine(&quot;Sorry, 1000 is the limit&quot;);<br> Console.WriteLine(e.Message);<br>}<br>finally {<br> Console.WriteLine(&quot;This code always runs.&quot;);<br>}<br>/* output<br>Whoops!<br>his code always runs. */<br><br></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c590f0b52ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should use a proxy server with Create React App]]></title>
            <link>https://medium.com/@kevin_comba/why-you-should-use-a-proxy-server-with-create-react-app-ed374bf6f3ae?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed374bf6f3ae</guid>
            <category><![CDATA[proxy-server]]></category>
            <category><![CDATA[http-proxy-middleware]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[middleware]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Sun, 09 Oct 2022 08:52:10 GMT</pubDate>
            <atom:updated>2022-10-09T08:52:10.240Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*TQ0N5jfRKucoj5Dn.png" /></figure><h3>Introduction</h3><p>There are many cases in which developers need to consume APIs from the backend while using Create React App (CRA) to build an application. Because most client apps are hosted on different servers than the backend application, there are complications that arise as a result of requests being sent across both servers. CRA supports proxying to mitigate or entirely eliminate these issues.</p><p>In this article, we will discuss what a proxy server is, why you should use a proxy server in development, and uses cases for proxying requests in a React application. Then, we will implement a real-life example of setting up a proxy server in React.</p><h3>Contents</h3><ul><li>What is a proxy server?</li><li>Why you should use a proxy server in development</li><li>Use cases for proxying requests in a React application</li><li>How to set up a proxy server in React</li><li>Using a manually created proxy in Create React App</li><li>Conclusion</li></ul><h3>What is a proxy server?</h3><p>A proxy server is a system or application that acts as a conduit between a client application and the server when it requests resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*PTzs_nT_OQdz1_Gy.png" /></figure><p>The diagram above illustrates how proxy servers work. When you make a request to a server, it is routed through the proxy, which receives the response from the server and transmits the information back to the client.</p><h3>Why you should use a proxy server in development</h3><p>You might be asking why it’s necessary to route some requests through a proxy before sending them to the server. The following scenarios need the use of a proxy server:</p><p>Need to protect your client from cross-site attacks? Proxy servers add an extra degree of protection by allowing server responses to be validated before being delivered to the client. They can be used as web filters and firewalls.</p><p>To avoid crashes, bandwidth must be conserved and server traffic must be regulated. Proxy servers can cache requests and server responses so that not all queries are transmitted to the server at the same time. This is typically done when dealing with static information and huge files.</p><p>Proxy servers are useful when client data must be protected or a request must be made anonymously. Proxy servers do not provide information to the server, such as the client’s location or IP address. Because the requests are not sent on a known network, this helps clients keep their data private by preventing hackers from intercepting important information.</p><p>Additionally, proxy servers can specify which requests are allowed and which are not. And finally, proxy servers can be used to log requests and the clients that make them within organizations that require it.</p><h3>Use cases for proxying requests in a React application</h3><p>After understanding why proxy servers are required, it is critical to understand real-life scenarios in which proxy servers can be implemented. Some examples of proxying requests in React applications are listed below.</p><p>First is requesting HTTPS APIs in development (<a href="https://localhost/">https://localhost</a>). Browsers have cross-origin limitations that block HTTPS API requests from HTTP sites running on localhost. Proxy servers can assist in redirecting requests to APIs without having to go via the browser’s default request options, which helps to evade several cross-origin limitations.</p><p>The second is fetching data from cross-origin APIs that don’t support CORs in web browsers. Certain APIs, regardless of the Hypertext Transfer Protocol, don’t support CORs for security concerns, and browsers impose same-origin policies to protect users from cross-site scripting (XSS). Proxy servers can be used to make API calls and then transmit the results to the web browser.</p><p>Finally, there is obtaining media resources from the server. A proxy server can be used to cache media files from the server, eliminating the need to send requests for such files to the server every time they are needed.</p><h3>How to set up a proxy server in React</h3><p>There are two common approaches of setting up proxy servers in React applications developed using CRA. We have the default CRA proxy option as well as the npm package <a href="https://www.npmjs.com/package/http-proxy-middleware">http-proxy-middleware</a>.</p><p>First, we will set up the application with CRA so we can set up the proxy servers.</p><h3>Create React App setup</h3><p>Make sure you have Node installed on your computer to use CRA. Then, in a new directory, start a terminal and run the following command:</p><pre>npx create-react-app proxyclient &amp;&amp; cd proxyclient</pre><p>The command above will create a new directory called proxyclient and set the terminal directory to /proxyclient. The following folders and files should be present in the folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/0*4gl_ZcclzDpOzjY0.png" /></figure><p>The package.json file should also have a similar structure:</p><pre>{<br>  &quot;name&quot;: &quot;proxyclient&quot;,<br>  &quot;version&quot;: &quot;0.1.0&quot;,<br>  &quot;private&quot;: true,<br>  &quot;dependencies&quot;: {<br>    &quot;@testing-library/jest-dom&quot;: &quot;^5.16.2&quot;,<br>    &quot;@testing-library/react&quot;: &quot;^12.1.3&quot;,<br>    &quot;@testing-library/user-event&quot;: &quot;^13.5.0&quot;,<br>    &quot;react&quot;: &quot;^17.0.2&quot;,<br>    &quot;react-dom&quot;: &quot;^17.0.2&quot;,<br>    &quot;react-scripts&quot;: &quot;5.0.0&quot;,<br>    &quot;web-vitals&quot;: &quot;^2.1.4&quot;<br>  },<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;react-scripts start&quot;,<br>    &quot;build&quot;: &quot;react-scripts build&quot;,<br>    &quot;test&quot;: &quot;react-scripts test&quot;,<br>    &quot;eject&quot;: &quot;react-scripts eject&quot;<br>  },<br>  &quot;eslintConfig&quot;: {<br>    &quot;extends&quot;: [<br>      &quot;react-app&quot;,<br>      &quot;react-app/jest&quot;<br>    ]<br>  },<br>  &quot;browserslist&quot;: {<br>    &quot;production&quot;: [<br>      &quot;&gt;0.2%&quot;,<br>      &quot;not dead&quot;,<br>      &quot;not op_mini all&quot;<br>    ],<br>    &quot;development&quot;: [<br>      &quot;last 1 chrome version&quot;,<br>      &quot;last 1 firefox version&quot;,<br>      &quot;last 1 safari version&quot;<br>    ]<br>  }<br>}</pre><p>Edit the App.js file in the src folder to include the following code:</p><pre>import React, { useEffect } from &#39;react&#39;<br>const App = () =&gt; {<br>  useEffect(() =&gt; {<br>    fetch(&#39;https://google.com/search?q=javascript&#39;)<br>      .then(resp =&gt; {<br>        console.log(resp);<br>        console.log(&#39;======success=======&#39;);<br>      })<br>      .catch(err =&gt; {<br>        console.log(&#39;======failure=======&#39;);<br>        console.log(err);<br>      });<br>  }, [])<br>  return (<br>    &lt;div&gt;App&lt;/div&gt;<br>  )<br>}<br>export default App</pre><p>Above, the fetch function is used to make a request to the cross-origin URL <a href="https://google.com/search?q=javascript">https://google.com/search?q=javascript</a>.</p><p>The application server should then be started so that we can view the response. Run the following command in the project directory’s terminal to start the application server:</p><pre>npm start</pre><p>By default, the above command will start listening on port 3000 on localhost or 127.0.0.1. If you open a browser and type “localhost:3000,” you should see something like this in the console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*Vxgoix1UTv7iUxDX.png" /></figure><h3>Using a CRA default proxy</h3><p>To avoid this problem, we’ll define our CRA’s default proxy by including a proxy field in the package.json file like to this:</p><pre>{<br>  ...,<br>  &quot;proxy&quot;: &quot;https://www.google.com&quot;,<br>  ...<br>}</pre><p>Then, in the App.js file, change the fetch request like so:</p><pre>fetch(&#39;/search?q=proxy&#39;)</pre><p>Above, we removed the origin and structure the request URL as if it were a same-origin request. The request should be successful, as shown in the browser console. It should output something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/0*S0hXMh-icMXnPJj5.png" /></figure><p>Take notice of the URL in the response; it was transmitted to the browser as a same origin, which resulted in <a href="http://localhost:3000/search?q=proxy">http://localhost:3000/search?q=proxy</a>, and the CORs error was gone.<br>The browser receives the request and transmits it to the proxy server, which then redirects the request to the actual API server specified in the package.json file.</p><p>We may also make requests to several servers by specifying the routes that should be used to target a specific domain. To accomplish this, we’ll structure our proxy field in the package.json file like so:</p><pre>{<br>  ...,<br>  &quot;proxy&quot;: {<br>    &quot;/search&quot; : {<br>      &quot;target&quot; : &quot;https://www.google.com&quot;,<br>      &quot;changeOrigin&quot; : true<br>    },<br>    &quot;/jobs&quot; : {<br>      &quot;target&quot; : &quot;https://stackoverflow.com&quot;,<br>      &quot;changeOrigin&quot; : true<br>    }<br>  }<br>  ...<br>}</pre><p>Above, we defined two paths: /search and /jobs, which target two separate domains.</p><p>When we execute a fetch request on /jobs, the browser sends the request as <a href="http://localhost:3000/jobs">http://localhost:3000/jobs</a>, but the proxy server forwards it as <a href="https://stackoverflow.com/jobs">https://stackoverflow.com/jobs</a>.</p><h3>Using a manually created proxy in Create React App</h3><p>If you don’t want to use the default CRA proxy, you may use the http-proxy-middleware npm package. Just note that this feature is available in react-scripts@2.0.0 or higher.</p><p>This package must be installed as a project dependency before it can be used. To do so, open a terminal and execute the following command in the project directory:</p><pre>npm i http-proxy-middleware --save</pre><p>Ensure you don’t have proxy defined in the package.json file, then create a new file named setupProxy.js in the src directory. Add the following code snippet to the setupProxy.js file:</p><pre>const { createProxyMiddleware } = require(&#39;http-proxy-middleware&#39;);<br>const proxy = {<br>    target: &#39;https://www.google.com&#39;,<br>    changeOrigin: true<br>}<br>module.exports = function(app) {<br>  app.use(<br>    &#39;/search&#39;,<br>    createProxyMiddleware(proxy)<br>  );<br>};</pre><p>The code snippet above exports a function to the application so that the proxy middleware is registered to the application as soon as the development server starts up, without the need to import it into any file. Once the application is launched, it will start automatically.</p><p>We used createProxyMiddleware from http-proxy-middleware that we installed previously to register a proxy target for /search.</p><p>In cases when there are several proxy targets, we simply call the app.use function as follows:</p><pre>const { createProxyMiddleware } = require(&#39;http-proxy-middleware&#39;);<br>const proxy = {<br>    target: &#39;https://www.google.com&#39;,<br>    changeOrigin: true<br>}<br>const proxy2 = {<br>    target: &#39;https://www.stackoverflow.com&#39;,<br>    changeOrigin: true,<br>}<br>module.exports = function(app) {<br>  app.use(<br>    &#39;/search&#39;,<br>    createProxyMiddleware(proxy)<br>  );<br><br><br>  app.use(<br>    &#39;/jobs&#39;,<br>    createProxyMiddleware(proxy2)<br>  );<br>};</pre><p>Above, we called the app.use method after creating another object named proxy2 that included the proxy parameters of the other target domain in order to construct a proxy middleware.</p><h3>Conclusion</h3><p>You may expect better security, confidential requests, regulated requests, and other benefits when you use proxy servers in your client applications. Now that you know why and how to use a dev proxy server with CRA, I encourage you to put it to use in your next project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed374bf6f3ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is an API▶️⬇️]]></title>
            <link>https://medium.com/@kevin_comba/what-is-an-api-%EF%B8%8F-%EF%B8%8F-671170b83e4a?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/671170b83e4a</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Thu, 01 Sep 2022 16:43:43 GMT</pubDate>
            <atom:updated>2022-09-01T16:43:43.702Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*bltKMYHhfWKo7AUbyDaKDA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Sdl93IrJdYqVyPlKKaidBQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*8gAWxSRnB32p1KSBf2h9xw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*WPMS-FesqPTcgD3oTRC9Eg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*tTM3dc8reeGUoD-Y8FLa2w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*1rT8DXfaBj0GE8GOHGNwDg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*MENKD75PwGi6Tu6LhyMkmA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*P5pxEgR7L5e28yMdSQTBCA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*gZ28NOcnce7ar4ZDzBtQlw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*2rzo_QmmgeLh0d3Gf8S5TA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=671170b83e4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Host your express API in Heroku in a second]]></title>
            <link>https://medium.com/@kevin_comba/host-your-express-api-in-heroku-in-a-second-17bdb7f7569b?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/17bdb7f7569b</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Thu, 25 Aug 2022 11:45:05 GMT</pubDate>
            <atom:updated>2022-08-25T11:46:00.318Z</atom:updated>
            <content:encoded><![CDATA[<p>step 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*26xY2vSNP5A8YyAJ.jpg" /></figure><p>step 1</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*3AOHjJd9NNdC01iF.jpg" /></figure><p>step 2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*2MT1CHGEtIOAjNqU.jpg" /></figure><p>step 3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*TSDWf9cvw4pxguWX.jpg" /></figure><p>step 4</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Yi8D-fet2n9mEjaf.jpg" /></figure><p>step 5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*UX9gfhkGfOQeCHOR.jpg" /></figure><p>step 6</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*LGnNnfurxRlCVKPl.jpg" /></figure><p>step 7</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*7n6Hq0XsNHThkUDf.jpg" /></figure><p>step 8</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*duvxiNcDzkYFFxWf.jpg" /></figure><p>Lets learn bye</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17bdb7f7569b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to JavaScript: Basics]]></title>
            <link>https://medium.com/@kevin_comba/introduction-to-javascript-basics-7dd352f98435?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dd352f98435</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[introduction-to-js]]></category>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Thu, 04 Aug 2022 15:00:52 GMT</pubDate>
            <atom:updated>2022-08-04T15:00:52.381Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5cimRVRh3wOf_Et1IO-gOg.png" /></figure><p><a href="https://dev.to/t/javascript">#javascript</a><a href="https://dev.to/t/webdev">#webdev</a><a href="https://dev.to/t/devops">#devops</a></p><p>Hello, amazing people 👋,</p><p>In this blog article, I am going to explain the basics of javascript.</p><p><em>Let’s get started.</em></p><h3>This Blog post will cover:</h3><pre>- What is JavaScript?<br>- How JavaScript is different from other programming languages <br>  like Java or C?<br>- How to include JavaScript in your HTML page?<br>- How to Write Comments in JavaScript?<br>- Variables in JavaScript<br>- Data types in JavaScript<br>- Operators in JavaScript<br>- Conditional Statements in JS<br>- Loops in JavaScript<br>- Functions in JavaScript</pre><h3>Prerequisites</h3><p>Before starting this article, you don’t need any previous JavaScript knowledge, but you should have some familiarity with HTML and CSS.</p><ul><li><a href="https://html.com/">Introduction to HTML</a></li><li><a href="https://www.w3schools.com/css/css_intro.asp">Introduction to CSS</a></li></ul><h3>What is JavaScript?</h3><p>JavaScript is a scripting language used to create and control dynamic web content.<br>It is an interpreted, lightweight object-oriented programming language that enables dynamic interactivity on websites. It can be anything from animated graphics to an automatically generated Facebook timeline. Once you have created your basic structure(HTML) and elegant vibe(CSS), JavaScript makes your website dynamic(automatically updateable).</p><p>If you are a software developer gravitated towards web development then you must learn javascript and once you have learned JavaScript there are many frameworks available which you can use to create multiple web applications. Nowadays javascript is also used in mobile app development, desktop app development, and game development. This opens many possibilities for you as a JavaScript developer.</p><h3>How JavaScript is different from other programming languages like Java or C++?</h3><p>The major difference is that JavaScript is a scripting language i.e it is not compiled and executed like C++ and java. It is dynamically typed whereas Java or C++ is statically typed. JavaScript is traditionally used to write scripts for web applications. The client receives the whole source of the script and the browser executes it — the browser has a JavaScript interpreter while the browser couldn’t execute Java or C++ programs. Javascript does not support multithreading while java or C++ is a multi-threaded language.</p><p><em>Now, javascript can run on the server via Node.js.</em></p><h3>How to include JavaScript in your HTML page?</h3><p>JavaScript can either be embedded directly inside the HTML page or placed in an external script file and referenced inside the HTML page. There are three places to put javascript code-</p><ul><li>between head tag of HTML page</li></ul><p><strong>Example-</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot;&gt;<br>    &lt;title&gt;Embedding JavaScript&lt;/title&gt;<br>    &lt;script&gt;<br>        document.getElementById(&quot;greet&quot;).innerHTML = &quot;Hello World!&quot;;<br>    &lt;/script&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div id=&quot;greet&quot;&gt;&lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>between body tag of HTML page</li></ul><p><strong>Example</strong></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot;&gt;<br>    &lt;title&gt;Embedding JavaScript&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div id=&quot;greet&quot;&gt;&lt;/div&gt;<br>    &lt;script&gt;<br>        document.getElementById(&quot;greet&quot;).innerHTML = &quot;Hello World!&quot;;<br>    &lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>In .js file(external javascript file)</li></ul><p><strong>Example-</strong><br><em>index.html</em></p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;utf-8&quot;&gt;<br>    &lt;title&gt;Linking External JavaScript&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div id=&quot;greet&quot;&gt;&lt;/div&gt;<br>    &lt;button onclick=&quot;greet()&quot;&gt;Show message&lt;/button&gt; <br>    &lt;script src=&quot;script.js&quot;&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><em>script.js</em></p><pre>function greet()<br>{<br>    document.getElementById(&quot;greet&quot;).innerHTML = &quot;Hello World!&quot;;<br>}</pre><h3>How to Write Comments in JavaScript?</h3><p>Comments are a meaningful way to deliver messages. It is not necessary but recommended to use comments to add information about the code, warnings, or suggestions so that others can easily understand and interpret your code.</p><p><strong>Types of comments in javascript</strong></p><ul><li>Single-line comment =&gt; Single-line comments are represented by double forward slashes (//).</li></ul><p><strong>Example</strong></p><pre>&lt;script&gt;  <br>var x=1;  <br>var y=2;  <br>var z=x+y;              // It adds values of x and y variable  <br>document.write(z);      // prints sum of x and y  <br>&lt;/script&gt;</pre><ul><li>Multi-line comment =&gt; It is represented by forward slash with an asterisk(/*) then asterisk with forward slash(*/).</li></ul><p><strong>Example</strong></p><pre>&lt;script&gt;<br>/*<br>The code below will change the heading with id = &quot;myP&quot; and the <br>paragraph with id = &quot;myP&quot; in my web page:<br>*/<br>document.getElementById(&quot;myH&quot;).innerHTML = &quot;My First Page&quot;;<br>document.getElementById(&quot;myP&quot;).innerHTML = &quot;My first paragraph.&quot;;<br>&lt;/script&gt;</pre><h3>Variables in JavaScript</h3><p>Variable means anything that can vary. These are the containers for storing data values. Also, JavaScript variables are loosely typed which means it does not require a data type to be declared. There are some rules while declaring a variable in js:-</p><p>1.) variable name must starts letter (a to z or A to Z), underscore( _ ), or dollar( $ ) sign.<br>2.) after the first letter we can use digits (0 to 9), for example- abc1<br>3.) javascript variables are case sensitive(x and X are different variables)</p><p><strong>Example of JavaScript variables</strong></p><p>Correct JavaScript variables=&gt;</p><pre>&lt;script&gt;<br>var x=10;<br>var _value=1.1;<br>var flag1=true;<br>var Name;               //declaration of variable<br>Name=&quot;neha&quot;;            //initialization of variable<br>&lt;/script&gt;</pre><p>Incorrect JavaScript variables=&gt;</p><pre>&lt;script&gt;<br>var  123=30;  <br>var *aa=320;  <br>&lt;/script&gt;</pre><p>There are two types of variables in javascript:</p><p><strong>1.)</strong> Local variables<br><strong>2.)</strong> Global Variables</p><h3>JavaScript local variable =&gt;</h3><p>Local variables are the variables that are defined inside block or function. They have a local scope which means that they are accessible within the function or block.</p><p><strong>Example-</strong></p><pre>&lt;script&gt;  <br>function fun()<br>{  <br>var x=10;    //local variable<br>console.log(x);   <br>}  <br>&lt;/script&gt;</pre><h3>JavaScript global variable =&gt;</h3><p>Global variables are the variables that are defined outside the functions or declared with a window object. They can be accessed from any function.</p><p><strong>Example-</strong></p><pre>&lt;script&gt;  <br>var data=200;     //global variable  <br>function a()<br>{  <br>console.log(data); <br>}  <br>function b()<br>{  <br>console.log(data); <br>}  <br>a();               //calling JavaScript function  <br>b();  <br>&lt;/script&gt;</pre><h3>Data types in JavaScript</h3><p>Data types basically specify what kind of data can be stored and manipulated within a program. JavaScript provides different data types to hold different types of values. In JS we don’t need to specify the type of the variable because it is dynamically used by the JavaScript engine.<br>Mainly there are two types of data types in javascript:-</p><p><strong>1.)</strong> Primitive data types<br><strong>2.)</strong> Non-Primitive data types</p><h3>Primitive data types:-</h3><p>Primitive data types can hold only one value at a time. There are five types of primitive data types in JS:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*mdvvqpK1IR1Hx9_w.png" /></figure><h3>Non-primitive data types:-</h3><p>Non-primitive data types can hold collections of values and more complex entities. There are mainly three types of non-primitive data types:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*VVkSfu4yikzDMFh1.png" /></figure><h3>Operators in JavaScript</h3><p>Operators are special symbols used to perform operations on operands. For example,</p><pre>var a=10,b=20;<br>var sum=a+b;</pre><p>Here, the + operator that performs addition, and &#39;a&#39; and &#39;b&#39; are operands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*tccxaiWDAWuhLbto.png" /></figure><h3>JavaScript Arithmetic Operators</h3><p>Arithmetic operators are used to perform arithmetic calculations. The arithmetic operators are as follows:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*GUnAD67TP7Pk-75E.png" /></figure><h3>JavaScript Assignment Operators</h3><p>Assignment operators are used to assign values to variables. The following are assignment operators in js:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*QoBpiETGDz8gmewV.png" /></figure><h3>JavaScript Comparison Operators</h3><p>Comparison operators compare two values and return a boolean value, either <strong>true</strong> or <strong>false</strong>. The following are Comparison operators in js:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*l2wY47vpMXm-h2xt.png" /></figure><h3>JavaScript Bitwise Operators</h3><p>Bitwise operators perform operations on binary representations of numbers. The bitwise operators are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*0VusIb55YobRTJsi.png" /></figure><h3>JavaScript Logical Operators</h3><p>Logical operators perform logical operations and return a boolean value, either true or false. The following are logical operators in js:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*nm5jKq_HgejVMeeB.png" /></figure><h3>Conditional Statements in JS</h3><p>Conditional statements control behavior in JavaScript and determine whether or not pieces of code can run.</p><h3>JS if Statement</h3><p>The most common type of conditional statement is the <strong>if-else</strong> statement. This statement only runs if the condition enclosed in parentheses () is true. There are three forms of if statement in JavaScript:-</p><ol><li>If Statement</li><li>If else statement</li><li>if else if statement</li></ol><p><strong>If statement example</strong></p><pre>&lt;script&gt;  <br>   var a=20;  <br>   if(a&gt;=20)<br>   {  <br>      alert(&quot;value of a is greater and equal to 20&quot;);  <br>   }  <br>&lt;/script&gt;</pre><p><strong>if-else statement example</strong></p><pre>&lt;script&gt;  <br>   var a=20;  <br>   if(a&gt;=20)<br>   {  <br>      alert(&quot;value of a is greater and equal to 20&quot;);  <br>   }  <br>   else<br>   {<br>      alert(&quot;value of a is less than 20&quot;); <br>   }<br>&lt;/script&gt;</pre><p><strong>if-else if statement example</strong></p><pre>&lt;script&gt;  <br>   var a=20;  <br>   if(a&gt;20)<br>   {  <br>      alert(&quot;value of a is greater than 20&quot;);  <br>   }  <br>   else if(a==20)<br>   {<br>      alert(&quot;value of a is equal to 20&quot;);<br>   }<br>   else<br>   {<br>      alert(&quot;value of a is less than 20&quot;); <br>   }<br>&lt;/script&gt;</pre><h3>JS switch Statement</h3><p>Switch statement is used to execute one code from multiple expressions. If there is a match, the associated block of code is executed and if there is no match, the default code block is executed.</p><p><strong>Example:-</strong></p><pre>&lt;script&gt;  <br>   var grade=&#39;C&#39;;  <br>   var result;  <br>   switch(grade){  <br>     case &#39;A&#39;:  <br>       result=&quot;A Grade&quot;;  <br>       break;  <br>     case &#39;B&#39;:  <br>       result=&quot;B Grade&quot;;  <br>       break;  <br>    case &#39;C&#39;:  <br>      result=&quot;C Grade&quot;;  <br>      break;  <br>    default:  <br>      result=&quot;No Grade&quot;;  <br>}  <br>alert(result);  <br>&lt;/script&gt;</pre><h3>Loops in JavaScript</h3><p>Loops are used for executing a block of statements repeatedly until a particular condition is satisfied. It makes the code compact. JavaScript supports different kinds of loops:</p><p>1.) for loop<br>2.) for-in loop<br>3.) while loop<br>4.) do-while loop</p><h3>JS For loop</h3><p>The for loop iterates the elements for the fixed number of times. Syntax of for loop is as follows:</p><pre>for(initialization; condition; increment)<br>{<br>     //code block to be executed<br>}</pre><p><strong>Example:-</strong></p><pre>&lt;script&gt;<br>     for(i=0;I&lt;10;i++)<br>     {<br>          document.write(i + &quot; &quot;)  <br>     }<br>&lt;/script&gt;</pre><p><strong>Output:-</strong><br>1 2 3 4 5 6 7 8 9</p><h3>JS For-in loop</h3><p>The for-in loop iterates through the properties of an Object. Syntax of for loop is as follows:</p><pre>for (key in object) {<br>  // code block to be executed<br>}</pre><p><strong>Example:-</strong></p><pre>&lt;script&gt;<br>var user = &quot;&quot;;<br>var person = {fname:&quot;Neha&quot;, lname:&quot;Soni&quot;, age:20}; <br>var x;<br>for (x in person) {<br>  user += person[x] + &quot; &quot;;<br>}<br>document.write(user);<br>&lt;/script&gt;</pre><p><strong>Output:-</strong><br>Neha Soni 20</p><h3>JS while loop</h3><p>The while loop iterates through a block of code as long as a specified condition is true. Syntax of while loop is as follows:</p><pre>while (condition)  <br>{  <br>   // code to be executed  <br>}</pre><p><strong>Example:-</strong></p><pre>&lt;script&gt;  <br>var count=0;  <br>while (count&lt;=5)  <br>{  <br>document.write(count + &quot; &quot;);  <br>count++;  <br>}  <br>&lt;/script&gt;</pre><p><strong>Output:-</strong><br>0 1 2 3 4 5</p><h3>JS do-while loop</h3><p>A do-while loop is similar to a while loop with one exception that the code is executed at least once whether condition is true or false. Syntax of do-while loop is as follows:-</p><pre>do<br>{  <br>   //code to be executed  <br>}while (condition);</pre><p><strong>Example:-</strong></p><pre>&lt;script&gt;  <br>var i=1;  <br>do{  <br>document.write(i + &quot;&lt;br/&gt;&quot;);  <br>i++;  <br>}while (i&lt;=5);  <br>&lt;/script&gt;</pre><p><strong>Output:-</strong>1 2 3 4 5</p><p><em>If you want to learn more about loops, </em><a href="https://data-flair.training/blogs/loop-in-javascript/"><em>Click here</em></a></p><h3>Functions in JavaScript</h3><p>Functions are one of the major pillars of JavaScript. It is a set of statements that performs some tasks or does some computation and then returns the result to the user. It helps you to divide a large program into small and makes a program a lot more efficient. The syntax of declaring a function is given below:-</p><pre>function functionName(arg1, arg2, ...argN)<br>{  <br> //code to be executed  <br>}</pre><p><strong>Let’s first see the simple example of a function in JS that doesn’t have any arguments.</strong></p><pre>&lt;html&gt;<br>  &lt;body&gt;<br>    &lt;input type=&quot;button&quot; onclick=&quot;msg()&quot; value=&quot;call function&quot;/&gt; </pre><pre>    &lt;script&gt;<br>      function msg(){              //function definition <br>        alert(&quot;Hello amazing people!&quot;);   //create an alert in browser<br>      }<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Function Parameters and Arguments=&gt;</strong></p><p>When you begin programming you may get confused between these two terms, but it is crucial to understand what they are and how are they different from each other.<br>So Let’s understand the difference between these two:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*JvYB0dJRWVORuYfJ.png" /></figure><p>To learn more about parameters and arguments <a href="https://www.geeksforgeeks.org/javascript-function-parameters/">Click here</a>.</p><p><strong>Function with Return Value=&gt;</strong></p><p>This is an optional JavaScript statement that returns a value from the function. We use the keyword return, followed by the statement or expression we want to return.</p><p><strong><em>Example:-</em></strong></p><pre>&lt;html&gt;<br>&lt;body&gt;<br>&lt;p&gt;What is the value of PI?&lt;/p&gt;</pre><pre>Ans:-&lt;span id=&quot;demo&quot;&gt;&lt;/span&gt;</pre><pre>&lt;script&gt;<br>document.getElementById(&quot;demo&quot;).innerHTML = getPI();</pre><pre>function getPI() {<br>  return Math.PI;<br>}<br>&lt;/script&gt;</pre><pre>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Note:- Return statement should be written in the last because it skips all code in the block written after that.</p><p><strong>Function Scope=&gt;</strong><br>As we know there are two types of variables in JS, local variables and global variables. Local variables are defined inside a function and cannot be accessed outside it. But a function can access any variable defined as a global variable.</p><p><em>Let’s understand exactly what I mean with the help of following code:</em></p><pre>&lt;html&gt;<br>  &lt;body&gt;<br>    &lt;h3&gt;Function Scope&lt;/h3&gt;</pre><pre>    &lt;script&gt;<br>      var num1 = 2;     //global variable<br>      document.write(&quot;Value of number 1 is &quot; + num1 + &quot;&lt;/br&gt;&quot;);  //global scope<br>      function parentFunction(){<br>        var num2 = 4;       //local variable<br>        num1 = 8;<br>        document.write(&quot;Number 1 is &quot; + num1 + &quot;&lt;/br&gt;&quot;);  //inside parent func.  <br>        document.write(&quot;Number 2 is &quot; + num2 + &quot;&lt;/br&gt;&quot;);  //local scope</pre><pre>        childFunction();      //child function called</pre><pre>        function childFunction(){      //nested function<br>          var num3 = 0;<br>          document.write(&quot;Number 2 is &quot; + num2 + &quot;&lt;/br&gt;&quot;);  // inside child func.<br>          document.write(&quot;Number 3 is &quot; + num3 + &quot;&lt;/br&gt;&quot;);  //local scope<br>        }<br>      }<br>      parentFunction(); //parent function called<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Output:-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/0*8lvopw-qtZGWOXVA.png" /></figure><h3>Conclusion:-</h3><p>HTML is the language of web content, but JavaScript is the language of web functionality. It is one of the fastest evolving languages, in terms of practices, tooling, and ecosystem. It’s an incredibly exciting language to be using right now.</p><p>In this blog, we have just scratched the surface of JavaScript. If you enjoyed learning and find it useful please do like and share so that, it reaches others as well 🤝</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dd352f98435" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Project Idea | Voice Based Email for Visually Challenged]]></title>
            <link>https://medium.com/@kevin_comba/project-idea-voice-based-email-for-visually-challenged-63c5b4060f6b?source=rss-c524afc125b------2</link>
            <guid isPermaLink="false">https://medium.com/p/63c5b4060f6b</guid>
            <dc:creator><![CDATA[Kevin Comba Gatimu]]></dc:creator>
            <pubDate>Sun, 24 Jul 2022 10:30:48 GMT</pubDate>
            <atom:updated>2022-07-24T10:30:48.615Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Project Title:</strong> Voice-based Email service for visually challenged people</p><p>We have seen that the inception of the Internet has dramatically revolutionized many fields. The Internet has made the life of people so easy that people today have access to any information they want sitting at their homes. One of the main fields that the Internet has revolutionized is communication. When talking about communication over the Internet, the first thing that comes to our mind is E-mail. E-mails are considered to be the most reliable way of communication over the Internet, for sending or receiving some important information. But there are special criteria for humans to access the Internet and the criteria is you must be able to see. You must be thinking that what sort of criteria is this, everyone with eyes can see. But there are also specially-abled people in our society who are not gifted with what you have. Yes, there are some visually challenged people or blind people who can not see things and thus can not see the computer screen or keyboard.<br>A survey shows that there are more than 250 million visually challenged people around the globe. That is, around 250 million people are unaware of how to use the Internet or E-mail. The only way by which a visually impaired person can send an E-mail is, they have to dictate the entire content of the mail to a third person( not visually challenged ) and then the third person will compose the mail and send it on their behalf of the visually impaired person.<br>But this is not the correct way to deal with this problem. It is very less likely that every time a visually challenged person can find someone for help. Although for these reasons the specially-abled people are criticized by our society.<br>So, for the betterment of society and giving equal status to such specially-abled people we have come up with this project idea which provides the user with the ability to send emails using voice commands without the need of a keyboard or any other visual things.</p><p><strong>Introduction:</strong> As the title suggests, the application will be a web-based application for visually impaired persons using IVR- Interactive voice response, thus enabling everyone to control their mail accounts using their voice only and to be able to read, send, and perform all the other useful tasks. The system will prompt the user with voice commands to perform certain actions and the user will respond to the same. <strong>The main benefit of this system is that the use of the keyboard is completely eliminated, the user will have to respond through voice and mouse click only.</strong><br>Now you must be thinking that how will a blind person will see the correct position on the screen for doing mouse clicks. But this system will perform actions based on the clicks only that is left-click or right-click, it does not depend on the portion of the screen where the cursor is placed before the click giving the user the freedom to click blindly anywhere on the screen.<br><strong>Design:</strong> The design of this project is divided into three phases as described below:</p><ol><li><strong>UI design</strong>: In this phase, the UI or the user interface of the project is developed. That is, the designing of the web pages that the user will use to interact.</li><li><strong>Database design</strong>: The database is considered to be the main pillar of every project. In our application, the database is used to store user details such as name, age, etc. The database here is also used to keep information about the emails sent or received or in the draft. The complete proposed design of the database is shown in the ER diagram below. This ER diagram shows all the tables with all fields and also the relationship between different tables.</li><li><strong>System design</strong>: In this phase, a complete flow diagram of the working system is designed. This flow diagram will show the details of all the events like actions to be performed for an event.</li></ol><p>After completion of the design phase, we will now start to implement our project.</p><p><strong>Implementation</strong></p><p><strong>Diagrams:</strong> Below are some important diagrams that explain the work and will be used in implementing the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4-846F23R_4mX742JMNzPw.png" /><figcaption><em>ER Diagram of Proposed Project</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*nDih9bTtkzMBzQxAcvUFvA.png" /><figcaption><em>Flow Diagram of Proposed Project</em></figcaption></figure><p>The above flow diagram explains the complete working of the project and the project can be easily implemented using the above flow diagram and ER diagram. However, the project is currently under development so we are providing details of a few modules which are already been developed by us:</p><ul><li><strong>Login:</strong> This is the very first page and will ask the user to enter login credentials. It will prompt the user with a voice command to enter the user name. After receiving the user name it will prompt again for a password. After receiving all of the details from the user, it will encrypt and check the validity of the details entered by the user. If valid, then the user will be redirected to the dashboard else will be sent back to the login page.</li><li><strong>Dashboard:</strong> After successful login, the user will be redirected to this page and this is the main page from where the user can perform all the activities like, composing a new mail, checking inbox, saving to draft, etc.<br>The below steps specifies the operation that will be executed based on a specific click of a mouse button. As the user is supposed to be blind, so it is allowed to click blindly anywhere on the screen:</li><li>Left Click to Compose a new Mail.</li><li>Right Click to Go to the Sent Mails.</li><li>Double Left Click to Go to the Inbox View.</li><li>Scroll Button Click to go to Trash Messages.</li><li>Double Right Click to Log out of the Session.</li><li>Below is the flowchart that explains this process:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*pvf_LtFMh4ugK4ajXBpx5w.jpeg" /><figcaption><em>Login &amp; Dashboard Flowchart</em></figcaption></figure><ul><li><strong>Common Rule:</strong><br>Left Click = Next Step<br>Right Click = Back<br>Scroll Button Click = Dashboard</li><li><strong>Compose a Mail:</strong> This module is used to compose a new mail. Below are the steps followed by this module to compose a new mail:</li></ul><ol><li>Left click from the dashboard to Compose a new Mail.</li><li>Give Voice Data about the Recipient, and CC, BCC, the Subject, and then the body</li><li>If satisfied with the current input Left Click to go to the next Stage</li><li>In the next Stage your voice will be recognized, Left Click to proceed</li><li>In this stage, your voice and input will be verified if any problem is found you are redirected to that or Left Click to proceed to Send the Mail or Right Click to Double Left Click to save as Draft</li></ol><ul><li><strong>Inbox:</strong> This page will store all of the emails received by the user. Below are steps explains how to access a mail from your inbox:</li><li>All the received Mails will be listed and sorted in order of date</li><li>Double left Click to give voice input to filter Mail, when Satisfied Left click to proceed</li><li>In this Stage your mail will be read out, Double Left Click to start/pause</li><li><strong>Trash:</strong> This folder will store all of the emails deleted by the user. Below steps provide a detailed explanation of this module:</li><li>All the deleted Mails will be listed and sorted in order of date</li><li>Double left Click to give voice input to filter Mail when Satisfied Left click to proceed to the Read Section.</li><li>In this Stage, your mail will be readout.</li><li>Double Left Click to start/pause</li><li>Left Click to proceed to Delete the Mail or Right Click to back</li><li>If in Delete Section Left Click to Delete the Mail</li><li><strong>Sent Mail:</strong> This folder will store all of the emails sent from the user. Below are steps explain the working of this module:</li><li>All the sent Mails will be listed and sorted in order of date</li><li>Double left Click to give voice input to filter Mail when Satisfied Left click to proceed to the Read Section.</li><li>In this Stage your mail will be read out, Double Left Click to start/pause</li><li>Left Click to proceed to Delete the Mail or Right Click to back</li><li>If in Delete Section Left Click to Delete the Mail</li></ul><p><strong>Tools Used:</strong> Apache HTTP Server, MySQL database and interpreters for scripts, PHP for handling backend of the web interface, HTML and CSS for creating Web-based UI, Google Speech-to-text and text-to-speech APIs.</p><p><strong>Application:</strong><br>This project is proposed for the betterment of society. This project aims to help the visually impaired people to be a part of growing digital India by using the internet and also aims to make the life of such people quite easily. Also, the success of this project will also encourage developers to build something more useful for visually impaired or illiterate people, who also deserve an equal standard in society.</p><p><strong>References</strong>:</p><ul><li>Jagtap Nilesh, Pawan Alai, Chavhan Swapnil and Bendre M.R.. “Voice Based System in Desktop and Mobile Devices for Blind People”. In International Journal of Emerging Technology and Advanced Engineering (IJETAE), 2014 on Pages 404–407</li><li>Ummuhanysifa U.,Nizar Banu P K , “Voice Based Search Engine and Web page Reader”. In<br>International Journal of Computational Engineering Research (IJCER). Pages 1–5.</li><li><a href="https://cloud.google.com/speech/docs/getting-started">https://cloud.google.com/speech/docs/getting-started</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63c5b4060f6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>