<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aniket</title>
    <description>The latest articles on Forem by Aniket (@aniiket).</description>
    <link>https://forem.com/aniiket</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1077266%2Fe99563ee-46be-4305-a2c0-875a47e2e8d1.jpg</url>
      <title>Forem: Aniket</title>
      <link>https://forem.com/aniiket</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aniiket"/>
    <language>en</language>
    <item>
      <title>Demystifying Frontend and Backend Development: A Beginner's Guide</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Sat, 30 Sep 2023 11:46:16 +0000</pubDate>
      <link>https://forem.com/aniiket/demystifying-frontend-and-backend-development-a-beginners-guide-2o25</link>
      <guid>https://forem.com/aniiket/demystifying-frontend-and-backend-development-a-beginners-guide-2o25</guid>
      <description>&lt;p&gt;In the vast and dynamic world of web development, two key terms you'll often hear are "frontend" and "backend." These terms are foundational to understanding how websites and web applications are built. If you're new to web development, they might seem a bit confusing at first. But fear not! In this beginner's guide, we'll break down the concepts of frontend and backend development to help you grasp their roles and differences&lt;/p&gt;




&lt;h2&gt;
  
  
  Frontend Development
&lt;/h2&gt;

&lt;p&gt;Imagine you're browsing your favorite website, clicking buttons, filling out forms, and scrolling through pages. Everything you see and interact with on the website is the result of frontend development. Frontend developers, also known as client-side developers, are responsible for creating the user interface (UI) and ensuring a seamless and visually appealing user experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Responsibilities of Frontend Developers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Design and Layout&lt;/strong&gt;: Frontend developers work with web designers to transform visual designs (usually created using tools like Adobe XD or Sketch) into actual web pages. They determine how elements such as text, images, buttons, and forms are arranged on the screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User Interface (UI)&lt;/strong&gt;: They create the interactive elements you see on a website, like dropdown menus, sliders, and modals. This involves using technologies such as HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), and JavaScript.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Responsiveness&lt;/strong&gt;: Ensuring that websites look and function well on various devices and screen sizes, from smartphones to desktop computers, is a crucial part of frontend development. This practice is known as responsive web design.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross-Browser Compatibility&lt;/strong&gt;: Frontend developers need to make sure that websites work consistently across different web browsers like Chrome, Firefox, and Safari.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance Optimization&lt;/strong&gt;: Optimizing the website's performance to reduce loading times and improve user experience is another key responsibility. This may involve compressing images, minifying code, and using Content Delivery Networks (CDNs).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Backend Development
&lt;/h2&gt;

&lt;p&gt;Now, let's dive into the backend of web development. The backend, often referred to as the server-side, is the part of a web application that users don't see directly. It consists of the server, databases, and server-side application logic. Backend developers are responsible for making sure that everything on the frontend works smoothly by handling data, logic, and server operations.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Responsibilities of Backend Developers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Server Management&lt;/strong&gt;: Backend developers manage the web server, which stores and serves the web application's files, including HTML, CSS, JavaScript, and media files. They ensure the server is secure, reliable, and responsive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Database Management&lt;/strong&gt;: Data is crucial for web applications. Backend developers design, create, and maintain databases to store and manage data efficiently. They use database management systems like MySQL, PostgreSQL, or MongoDB.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Application Logic&lt;/strong&gt;: The backend code contains the application's core logic. It processes requests from the frontend, interacts with the database, and sends back the necessary data. Popular backend programming languages include Python, Ruby, Node.js, and PHP.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt;: Backend developers are responsible for implementing security measures to protect user data and prevent unauthorized access or data breaches. They use techniques like encryption and authentication.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;API Development&lt;/strong&gt;: Often, web applications need to interact with external services or allow third-party developers to build on top of them. Backend developers create APIs (Application Programming Interfaces) to facilitate such interactions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Frontend and Backend Collaboration
&lt;/h2&gt;

&lt;p&gt;Frontend and backend development are not isolated processes. They work hand in hand to create a functional and visually appealing web application. Here's how they collaborate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Frontend-Backend Communication&lt;/strong&gt;: The frontend sends requests to the backend, and the backend responds with data or actions. This communication happens through APIs and typically uses technologies like JSON (JavaScript Object Notation) for data exchange.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data Rendering&lt;/strong&gt;: The frontend takes the data provided by the backend and displays it in a user-friendly manner. For example, a frontend developer might use JavaScript to render a list of products retrieved from the backend.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User Interactivity&lt;/strong&gt;: Frontend developers create features that allow users to interact with the web application. When users submit forms, click buttons, or perform any action, the frontend communicates with the backend to process those actions.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In summary, frontend development focuses on what users see and interact with on a website, while backend development deals with the behind-the-scenes operations, data storage, and application logic. Both are essential components of web development, and understanding their roles and how they collaborate is a fundamental step for anyone looking to embark on a web development journey.&lt;/p&gt;

&lt;p&gt;As you continue to explore web development, you'll find that there's much more to learn within each of these domains. So, whether you choose to specialize in frontend or backend development, or even become a full-stack developer proficient in both, this foundational knowledge will serve as your compass on your coding adventure. Happy coding!&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Follow and like for more such blogs.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Connect me on &lt;a href="https://www.linkedin.com/in/aniket-mahajan-275305243/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading until the end.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Building Your First Rock Paper Scissors Game: A Beginner's Guide</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Fri, 29 Sep 2023 14:18:11 +0000</pubDate>
      <link>https://forem.com/aniiket/building-your-first-rock-paper-scissors-game-a-beginners-guide-2gdm</link>
      <guid>https://forem.com/aniiket/building-your-first-rock-paper-scissors-game-a-beginners-guide-2gdm</guid>
      <description>&lt;p&gt;Are you a budding web enthusiast looking to dip your toes into the world of web development? If you've just started your journey and want to create something fun and interactive, you're in the right place. In this beginner-friendly blog post, we'll walk you through the process of building your very own &lt;strong&gt;Rock Paper Scissors&lt;/strong&gt; game using &lt;strong&gt;HTML, CSS, and JavaScript&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is Rock Paper Scissors?
&lt;/h2&gt;

&lt;p&gt;Ofc you're familiar with this game but if you aren't here's a quick summary :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Rock Paper Scissors&lt;/strong&gt; is a classic hand game played between two people. The game has three possible outcomes other than a tie: Rock crushes Scissors, Scissors cuts Paper, and Paper covers Rock. It's a simple yet entertaining game that we'll bring to life on your web page.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we dive into coding, make sure you have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A basic understanding of HTML, CSS, and JavaScript.&lt;/li&gt;
&lt;li&gt;A code editor like Visual Studio Code, Sublime Text, or any other of your choice.&lt;/li&gt;
&lt;li&gt;A passion for learning and a desire to have fun while coding!&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Let's Get Started!
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Setting Up Your HTML
&lt;/h3&gt;

&lt;p&gt;We'll begin by creating the structure of our web page using HTML. Open your code editor and follow these steps:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As we need to have all the other files connected we need to link them to our HTML file.&lt;/p&gt;

&lt;p&gt;Furthermore we can add &lt;strong&gt;PRESS START 2P&lt;/strong&gt; which is a cool font for a game which gives it a retro and gamifying feel.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
    &amp;lt;link rel="stylesheet" href="css/index.css"&amp;gt; &amp;lt;!-- Link to your CSS file --&amp;gt;
    &amp;lt;script src="src/index.js" async&amp;gt;&amp;lt;/script&amp;gt; &amp;lt;!-- Link to your JavaScript file --&amp;gt;
    &amp;lt;link href='https://fonts.googleapis.com/css?family=Press Start 2P' rel='stylesheet'&amp;gt; &amp;lt;!-- A cool retro font --&amp;gt;
    &amp;lt;title&amp;gt;RPS&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now we need basic buttons that when we click the JS knows what exactly we have clicked&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To do so we will have two sets of buttons, one for the Computer and other for the user, but only make the user one's clickable &lt;br&gt;
Computer side has given buttons because buttons can transform their positions unlike images which can't. We will be using transform to show more interactivity. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Be sure add images to Rock Paper and Scissors in your code. I have rotated them to make the orientation of those pictures correct.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        &amp;lt;button  id="c1" &amp;gt;
            &amp;lt;img src="assets/paper.png" alt="paper" style="transform: rotate(90deg);" &amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;button  id="c2" &amp;gt;
            &amp;lt;img src="assets/rock.png" alt="rock" style="transform: rotate(90deg);" &amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;button  id="c3" &amp;gt;
            &amp;lt;img src="assets/sissors.png" alt="scissors" style="transform: rotate(90deg);" &amp;gt;
        &amp;lt;/button&amp;gt;


        &amp;lt;button id="b1" &amp;gt;
            &amp;lt;img src="assets/paper.png" alt="paper" style="transform: rotate(-90deg);"&amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;button id="b2" &amp;gt;
            &amp;lt;img src="assets/rock.png" alt="rock" style="transform: rotate(-90deg);"&amp;gt;
        &amp;lt;/button&amp;gt;
        &amp;lt;button id="b3" &amp;gt;
            &amp;lt;img src="assets/sissors.png" alt="scissors" style="transform: rotate(-90deg);"&amp;gt;
        &amp;lt;/button&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;We also too need a scoreboard, other stats and a reset button.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;div class="infocon"&amp;gt;
        &amp;lt;h1&amp;gt;Rock Paper Scissors&amp;lt;/h1&amp;gt;
        &amp;lt;h1 id="wl"&amp;gt;&amp;lt;/h1&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;div class="details"&amp;gt;
        &amp;lt;h3 &amp;gt;Tries:&amp;lt;span id="try"&amp;gt;0&amp;lt;/span&amp;gt;/5&amp;lt;/h3&amp;gt;
        &amp;lt;h3 &amp;gt;Wins :&amp;lt;span id="wins"&amp;gt;0&amp;lt;/span&amp;gt;&amp;lt;/h3&amp;gt;
        &amp;lt;h3 &amp;gt;Lose :&amp;lt;span id="lose"&amp;gt;0&amp;lt;/span&amp;gt;&amp;lt;/h3&amp;gt;
        &amp;lt;h3 &amp;gt;Ties :&amp;lt;span id="ties"&amp;gt;0&amp;lt;/span&amp;gt;&amp;lt;/h3&amp;gt;
        &amp;lt;h3&amp;gt;__________&amp;lt;/h3&amp;gt;
        &amp;lt;h2 &amp;gt;WINNER:&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;span id="total"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/h2&amp;gt;&amp;lt;br&amp;gt;
        &amp;lt;h3&amp;gt;__________&amp;lt;/h3&amp;gt;
        &amp;lt;button id="reset" onclick="reset()"&amp;gt;RESET&amp;lt;/button&amp;gt;&amp;lt;br&amp;gt;
    &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Adding CSS to your Html
&lt;/h2&gt;

&lt;p&gt;Now, let's style our game using CSS. Create a new CSS file (e.g., index.css) and add the following styles:&lt;br&gt;
CSS depends on your own taste, feel free to make it in your own style.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/* Set the font and background color */
body {
    font-family: 'Press Start 2P';
    background-color: #C8F1F3;
}

/* Style buttons */
button {
    border: 0px;
    background-color: #C8F1F3;
}

/* Add animation to selected buttons */
.selected {
    transform: translateX(0%) translateY(-175%);
    transition: transform 1.5s ease-in-out;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;You can take reference for CSS if you want from &lt;a href="https://github.com/Aniike-t/RockPaperScissors/blob/master/css/index.css" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this CSS code, we've set the font, background color, and styles for buttons. The &lt;strong&gt;.selected&lt;/strong&gt; class adds a cool animation to the selected buttons.&lt;/p&gt;




&lt;h2&gt;
  
  
  Adding JavaScript for Interactivity
&lt;/h2&gt;

&lt;p&gt;With your HTML and CSS in place, it's time to add JavaScript to make your game interactive and functional. Below, we'll break down the key JavaScript functions and their roles in your Rock Paper Scissors game.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Initializing Variables&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let computerChoice = 0;
let a= 0;
const wl=document.getElementById("wl");
let wlt=[0,0,0];
let tries=0;
const W= document.getElementById("wins");
const L= document.getElementById("lose");
const T= document.getElementById("ties");
const Tr= document.getElementById("try");
const Total= document.getElementById("total");

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

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;In this section, you declare and initialize various variables that will be used to keep track of game statistics and elements on your web page. These variables will store information like the user's and computer's choices, win/loss/tie counts, and references to HTML elements where you'll display game outcomes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;getComputerChoice() Function&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function getComputerChoice() {
    return Math.floor(Math.random() * 3) + 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function generates a random number (1, 2, or 3) to simulate the computer's choice in the game. Each number corresponds to Rock, Paper, or Scissors, respectively.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;AnimateComp() Function&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function AnimateComp(objc) {
    console.log("anim")
    document.getElementById(objc).classList.add("selectedC");
    setTimeout(function () {
        document.getElementById(objc).classList.remove("selectedC");
    }, 3000);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;AnimateComp() is responsible for adding and removing a class called "selectedC" from the computer's choice button, creating an animation effect when the computer makes a selection. This function adds a class to the button and removes it after 3 seconds to reset the animation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;determineWinner() Function&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function determineWinner(userChoice, computerChoice) {
    computerChoice= a;

    if (userChoice === computerChoice) {
        wl.innerHTML="ITS A TIE";
        wlt[2]+=1;
    } else if ((userChoice===3 &amp;amp;&amp;amp; computerChoice===1)||(userChoice===2 &amp;amp;&amp;amp; computerChoice===3)||(userChoice===1 &amp;amp;&amp;amp; computerChoice===2)){
        wl.innerHTML="YOU WONN!";
        wlt[0]+=1;
    } else {
        wl.innerHTML="YOU LOSEE!";
        wlt[1]+=1;
    }
    // ...Above code is available on GitHub
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;determineWinner() takes two arguments: userChoice and computerChoice. It calculates the game result and updates the display accordingly. If it's a tie, a message is shown, and the tie count is incremented. If the user wins or loses, the respective message is displayed, and the win or loss count is updated. The function also keeps track of the number of tries and calculates the overall winner after 5 tries.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;userChoiceHandler() Function&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function userChoiceHandler(userChoice) {
    setTimeout(function () {
       determineWinner(userChoice, computerChoice);
    }, 4000);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;userChoiceHandler() is called when the user makes a choice by clicking a button. It sets a timeout of 4 seconds (4000 milliseconds) before calling determineWinner(). This delay simulates the computer making its choice before revealing the result.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Event Listeners for User Choices&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.getElementById("b1").addEventListener("click", function () {
    animateSelection("b1");
    setTimeout(function () {
        userChoiceHandler(1);
    }, 1000);
});
//Same for other buttons too
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;animateSelection() Function&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function animateSelection(obj) {
    computerChoice = getComputerChoice();
    if(computerChoice===1){a= computerChoice;AnimateComp("c1")}
    else if(computerChoice===2){a=computerChoice;AnimateComp("c2")}
    else{a=computerChoice;AnimateComp("c3")} 
    document.getElementById(obj).classList.add("selected");
    setTimeout(function () {
        document.getElementById(obj).classList.remove("selected");
    }, 3000);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;animateSelection() is responsible for simulating the computer's choice, animating the user's choice button, and adding/removing the "selected" class to create a visual effect. The computer's choice is determined, the animation is applied to the user's choice button, and the class is removed after 3 seconds.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;reset() Function&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function reset(){
    wlt=[0,0,0];
    tries=0;
    wl.innerHTML="";
    W.innerHTML=wlt[0];
    L.innerHTML=wlt[1];
    T.innerHTML=wlt[2];
    Tr.innerHTML=tries;
    Total.innerHTML=""
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reset() is a function to reset the game statistics when the "RESET" button is clicked. It clears the win, loss, tie, and try counts, as well as any displayed messages.&lt;/p&gt;

&lt;p&gt;For the above code visit my &lt;a href="https://github.com/Aniike-t/RockPaperScissors/blob/master/src/index.js" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  END RESULT
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbjo93gmmepmji243bmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbjo93gmmepmji243bmt.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;




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

&lt;p&gt;With these JavaScript functions, your Rock Paper Scissors game is now fully functional and interactive. These code snippets handle everything from generating computer choices to determining winners and providing visual feedback to the user. You can further customize and enhance your game as you continue to explore the world of web development. Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Aniike-t/RockPaperScissors" rel="noopener noreferrer"&gt;GITHUB&lt;/a&gt; for the above game&lt;/p&gt;




&lt;p&gt;Follow and like for more such blogs.&lt;br&gt;
Connect me on &lt;a href="https://www.linkedin.com/in/aniket-mahajan-275305243/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading until the end.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Command-Line Planner in C (with Saving and Loading)</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Mon, 25 Sep 2023 17:20:21 +0000</pubDate>
      <link>https://forem.com/aniiket/command-line-planner-in-c-with-saving-and-loading-5365</link>
      <guid>https://forem.com/aniiket/command-line-planner-in-c-with-saving-and-loading-5365</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;A calendar or planner is a great tool to help keep track of appointments, events, and tasks. In this tutorial, I'll guide you through the process of creating a simple command-line calendar and planner using the C programming language. Not only will you be able to add and view events, but we'll also implement the ability to save your events to a file and load them back when you start the program again. Let's get started!&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Basic knowledge of the C programming language.&lt;/li&gt;
&lt;li&gt;A C compiler installed on your system (e.g., GCC) or a Repl.&lt;/li&gt;
&lt;li&gt;A text editor or an Integrated Development Environment (IDE) for writing C code.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Our event calender will following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Add Event&lt;/strong&gt;: We can add events by specifying a date (in the format YYYY-MM-DD) and a description for the event.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;View Events for a Date&lt;/strong&gt;: We can view all events scheduled for a specific date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;View All Events&lt;/strong&gt;: We can see a list of all the events in the calendar.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Save Events to File&lt;/strong&gt;: Events can be saved to a text file for persistence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load Events from File&lt;/strong&gt;: When the program starts, it will attempt to load previously saved events from the file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Exit&lt;/strong&gt;: We can exit the program, and it will save the events before exiting.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 1: Define the Event Structure
&lt;/h2&gt;

&lt;p&gt;We will start by defining a structure to represent an event. Open your text editor and create a new C source file (e.g., 'calendar.c'). Add the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

typedef struct Event {
    char date[12];   // Date in format YYYY-MM-DD
    char description[100];
} Event;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Implement Functions
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function to add an event to the calendar
void addEvent(Event *calendar, int *eventCount) {
    if (*eventCount &amp;gt;= 100) {
        printf("Calendar is full. Cannot add more events.\n");
        return;
    }

    Event newEvent;
    printf("Enter event date (YYYY-MM-DD): ");
    scanf("%s", newEvent.date);
    printf("Enter event description: ");
    getchar();  // Consume newline left in the buffer
    fgets(newEvent.description, sizeof(newEvent.description), stdin);

    calendar[*eventCount] = newEvent;
    (*eventCount)++;
    printf("Event added successfully!\n");
}

// Function to view events for a specific date
void viewEvents(Event *calendar, int eventCount, char *date) {
    printf("Events for %s:\n", date);
    for (int i = 0; i &amp;lt; eventCount; i++) {
        if (strcmp(calendar[i].date, date) == 0) {
            printf("- %s", calendar[i].description);
        }
    }
    printf("\n");
}

// Function to view all events
void viewAllEvents(Event *calendar, int eventCount) {
    printf("All Events:\n");
    for (int i = 0; i &amp;lt; eventCount; i++) {
        printf("Date: %s\n", calendar[i].date);
        printf("Description: %s", calendar[i].description);
    }
    printf("\n");
}

// Function to save events to a text file
void saveEventsToFile(Event *calendar, int eventCount, const char *filename) {
    FILE *file = fopen(filename, "w");
    if (file == NULL) {
        printf("Error opening file for saving.\n");
        return;
    }

    for (int i = 0; i &amp;lt; eventCount; i++) {
        fprintf(file, "%s\n", calendar[i].date);
        fprintf(file, "%s", calendar[i].description);
    }

    fclose(file);
}

// Function to load events from a text file
int loadEventsFromFile(Event *calendar, int *eventCount, const char *filename) {
    FILE *file = fopen(filename, "r");
    if (file == NULL) {
        return 0;  // File doesn't exist or cannot be opened
    }

    while (fscanf(file, "%s", calendar[*eventCount].date) != EOF) {
        fgetc(file);  // Consume newline
        fgets(calendar[*eventCount].description, sizeof(calendar[*eventCount].description), file);
        (*eventCount)++;
    }

    fclose(file);
    return 1;  // File successfully loaded
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Implement the Main Function
&lt;/h2&gt;

&lt;p&gt;In the main function, the program to load events from a file (creating a new file if not found), and it will also save events before exiting:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int main() {
    Event calendar[100];  // Array to store events
    int eventCount = 0;   // Number of events in the calendar

    // Try loading events from a file, create a new file if not found
    if (!loadEventsFromFile(calendar, &amp;amp;eventCount, "events.txt")) {
        printf("No saved events found. Creating a new calendar.\n");
    }

    while (1) {
        printf("\nOptions:\n");
        printf("1. Add Event\n");
        printf("2. View Events for a Date\n");
        printf("3. View All Events\n");
        printf("4. Save Events to File\n");
        printf("5. Exit\n");
        printf("Enter your choice: ");

        int choice;
        scanf("%d", &amp;amp;choice);

        switch (choice) {
            case 1:
                addEvent(calendar, &amp;amp;eventCount);
                break;
            case 2: {
                char date[12];
                printf("Enter date (YYYY-MM-DD): ");
                scanf("%s", date);
                viewEvents(calendar, eventCount, date);
                break;
            }
            case 3:
                viewAllEvents(calendar, eventCount);
                break;
            case 4:
                saveEventsToFile(calendar, eventCount, "events.txt");
                printf("Events saved to file.\n");
                break;
            case 5:
                printf("Exiting...\n");
                // Save events before exiting
                saveEventsToFile(calendar, eventCount, "events.txt");
                exit(0);
            default:
                printf("Invalid choice. Try again.\n");
        }
    }
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Step 4: Compile and Run
&lt;/h2&gt;

&lt;p&gt;You can run the following program through GCC compiler or online coding IDE.&lt;/p&gt;


&lt;h3&gt;
  
  
  You can run the following program here :
&lt;/h3&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@AniketMahajan5/Plannner?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Thank you so much for reading.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Follow and Like for more.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also follow me on &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/aniket-mahajan-275305243/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt;, I think building connections is better &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>c</category>
    </item>
    <item>
      <title>React-i-Py</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Sun, 24 Sep 2023 12:30:31 +0000</pubDate>
      <link>https://forem.com/aniiket/react-i-py-4gal</link>
      <guid>https://forem.com/aniiket/react-i-py-4gal</guid>
      <description>&lt;p&gt;&lt;strong&gt;Welcome to the Second Article of the series "ReactPy"&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  ReactJS
&lt;/h3&gt;

&lt;p&gt;As ReactJS takes a approach of JSX to display HTML elements by Javascript.&lt;/p&gt;

&lt;h3&gt;
  
  
  Similar Approach is taken by Python
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;In the world of web development, the creation of a web application often involves a division of responsibilities between the client and server. The client handles the presentation and user interface, while the server manages data and logic. However, ReactPy, a Python library, takes a different approach by centralizing both the view and its associated data and logic within a single Python codebase. This innovative approach allows developers to construct HTML interfaces in Python itself, simplifying the development process. In this blog post, we'll explore how ReactPy empowers developers to create web interfaces using familiar Python syntax.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Let's see the key differences between HTML and ReactPy
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Let's start by comparing traditional HTML with ReactPy. Suppose we want to create a simple web page with a title and a to-do list. In standard HTML, it would look like this:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML

&amp;lt;h1&amp;gt;My Todo List&amp;lt;/h1&amp;gt;
&amp;lt;ul&amp;gt;
    &amp;lt;li&amp;gt;Build a cool new app&amp;lt;/li&amp;gt;
    &amp;lt;li&amp;gt;Share it with the world!&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;With ReactPy, we can achieve the same result using Python code:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;ReactPy

from reactpy import html

layout = html.div(
    html.h1("My Todo List"),
    html.ul(
        html.li("Build a cool new app"),
        html.li("Share it with the world!"),
    ),
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The ReactPy code closely resembles the HTML structure, with Python functions like &lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;ul&lt;/code&gt;, and &lt;code&gt;li&lt;/code&gt; corresponding to their HTML tag counterparts. However, to capture the layout, we wrap it in a &lt;code&gt;div&lt;/code&gt; and assign it to a variable.&lt;/p&gt;


&lt;h3&gt;
  
  
  Attributes of HTML in ReactPy
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Web pages often contain elements with various attributes, such as images with source URLs, classes for styling, styles for positioning, and more. In standard HTML, you would use attributes like this:&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML

&amp;lt;img
    src="https://picsum.photos/id/237/500/300"
    class="img-fluid"
    style="width: 50%; margin-left: 25%;"
    alt="Billie Holiday"
    tabindex="0"
/&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In ReactPy, you can add these attributes using a Python dictionary:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt;ReactPy

html.img(
    {
        "src": "https://picsum.photos/id/237/500/300",
        "class_name": "img-fluid",
        "style": {"width": "50%", "margin_left": "25%"},
        "alt": "Billie Holiday",
        "tab_index": "0",
    }
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Key Differences
&lt;/h3&gt;

&lt;p&gt;There are some key differences to note. First, ReactPy uses snake_case for attribute names, unlike the dash-separated words in HTML. For instance, &lt;code&gt;tab-index&lt;/code&gt; becomes &lt;code&gt;tab_index&lt;/code&gt;, and &lt;code&gt;margin-left&lt;/code&gt; becomes &lt;code&gt;margin_left&lt;/code&gt;. Second, instead of using a string for the style attribute, ReactPy employs a dictionary to define CSS properties. This approach simplifies code readability and avoids the need to escape characters within strings. Lastly, to prevent conflicts with the Python keyword class, ReactPy uses &lt;code&gt;class_name&lt;/code&gt; for the &lt;code&gt;class&lt;/code&gt; attribute.&lt;/p&gt;


&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;In conclusion, ReactPy offers web developers a Pythonic way to create web interfaces by centralizing HTML layout and attributes within Python code. This approach not only simplifies the development process but also makes the code more readable and maintainable. Whether you're building a simple web page or a complex web application, ReactPy can streamline your development workflow and empower you to leverage Python's strengths in the world of web development. Give it a try and experience the benefits of Python-powered web development with ReactPy.&lt;/p&gt;


&lt;h3&gt;
  
  
  For more information visit
&lt;/h3&gt;


&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://reactpy.dev/docs/guides/creating-interfaces/html-with-reactpy/index.html#html-with-reactpy" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--sTC03OXe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://raw.githubusercontent.com/reactive-python/reactpy/main/branding/png/reactpy-logo-landscape-padded.png" height="419" class="m-0" width="800"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://reactpy.dev/docs/guides/creating-interfaces/html-with-reactpy/index.html#html-with-reactpy" rel="noopener noreferrer" class="c-link"&gt;
          HTML With ReactPy - ReactPy
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          In a typical Python-based web application the responsibility of defining the view along with its backing data and logic are distributed between a client and server respectively. With ReactPy, both ...
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://res.cloudinary.com/practicaldev/image/fetch/s--OATM8u9A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://reactpy.dev/docs/_static/reactpy-logo.ico" width="256" height="256"&gt;
        reactpy.dev
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;






&lt;p&gt;Connect me on &lt;a href="https://www.linkedin.com/in/aniket-mahajan-275305243/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Follow and like for more .&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>python</category>
    </item>
    <item>
      <title>ReactPy = React + Python ?</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Sun, 24 Sep 2023 08:53:28 +0000</pubDate>
      <link>https://forem.com/aniiket/reactpy-react-python--40mb</link>
      <guid>https://forem.com/aniiket/reactpy-react-python--40mb</guid>
      <description>&lt;h2&gt;
  
  
  Ever heard of writing a React App in Python, this is what ReactPy is all about.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;ReactPy is a library for building user interfaces in Python without Javascript. ReactPy interfaces are made from components that look and behave similar to those found in ReactJS. Designed with simplicity in mind, ReactPy can be used by those without web development experience while also being powerful enough to grow with your ambitions.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Let's start by installing ReactPy :-
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;To start using ReactPy, you'll first need to install it. Depending on your choice of backend, you can install ReactPy along with the corresponding backend implementation. Here's how you can do it:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Installing with Starlette Backend&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install "reactpy[starlette]"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;You can substitute &lt;code&gt;starlette&lt;/code&gt; with any other backend as you want, example: &lt;code&gt;FastAPI&lt;/code&gt; , &lt;code&gt;Flask&lt;/code&gt; , &lt;code&gt;Django&lt;/code&gt; , etc&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Installing a Pure Version of ReactPy&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you prefer a "pure" version of ReactPy without a specific backend, you can install it without any extras :&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install reactpy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This option is useful if you plan to use a custom backend or if you want to manually manage dependencies for your chosen backend.&lt;/p&gt;


&lt;h2&gt;
  
  
  "Hello, World!"
&lt;/h2&gt;

&lt;p&gt;Let's get started by creating the first App using ReactPy&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To get started, setup your coding environment as you want such as an IDE, preferrably use VScode or Replit's ReactPy.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Configuring Your ReactPy Application&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To run ReactPy in production, you'll need to configure your chosen backend with a ReactPy view. The following steps demonstrate how to set up and run ReactPy with a sample backend. Remember that the process may vary depending on your chosen backend, but the basic structure remains consistent.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Import Necessary Modules&lt;/strong&gt;: Import the required modules from your chosen backend and ReactPy.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from reactpy import component, html
from reactpy.backend.my_chosen_backend import configure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Define Your React Component&lt;/strong&gt;: Create a React component using ReactPy. This component will be the core of your web application. In this example, we create a simple "Hello, world!" component.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@component
def HelloWorld():
    return html.h1("Hello, world!")

run(HelloWorld)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Suppose you're using Flask Framework
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from reactpy import component, html
from reactpy.backend.flask import configure
from flask import Flask

@component
def HelloWorld():
    return html.h1("Hello, World!")

app = Flask(__name__)
configure(app, HelloWorld)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You can run the program here :&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@AniketMahajan5/HelloWorld?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;






&lt;p&gt;Connect me on &lt;a href="https://www.linkedin.com/in/aniket-mahajan-275305243/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Follow and like for more .&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>react</category>
    </item>
    <item>
      <title>Simple Regex in C</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Thu, 21 Sep 2023 11:28:32 +0000</pubDate>
      <link>https://forem.com/aniiket/simple-regex-in-c-7g7</link>
      <guid>https://forem.com/aniiket/simple-regex-in-c-7g7</guid>
      <description>&lt;h3&gt;
  
  
  Why? Why not to learn something we implement in software but didn't knew how it works under the hood.
&lt;/h3&gt;




&lt;p&gt;Yesterday, while I was searching for ideas, I came across an article on the internet about a Regex matcher in the C language. Why did I decide to implement a Regex in C? Because I was curious about how regular expressions work under the hood in any language. And what better language to implement it in than C?&lt;/p&gt;

&lt;p&gt;C is faster than most other languages and more understandable than higher-level languages. It offers the best of both worlds: performance and maintainability through readability.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Credits:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I would like to share the credits with : Rob Pike of Princeton University&lt;/p&gt;

&lt;p&gt;The original code for this was written by Rob Pike whose article I did came across.&lt;/p&gt;




&lt;p&gt;If you are new to Regex just visit this &lt;a href="https://github.com/ziishaned/learn-regex"&gt;Github Repo&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;To make a Regex Matcher we need to understand what we really need to implement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  c    matches any literal character c
  .    matches any single character
  ^    matches the beginning of the input string
  $    matches the end of the input string
  *    matches zero or more occurrences of the previous character
  \0   terminating condition
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Let's Dive into code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's say we have two strings one is the Regex expression and other is the text we need to match:&lt;/p&gt;

&lt;p&gt;We can declare them by:&lt;br&gt;
&lt;code&gt;char *regexp = "[your regex here]";&lt;/code&gt;&lt;br&gt;
&lt;code&gt;char *text   = "[text here]";&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We will pass these values through the main function and result will be obtained in &lt;code&gt;result&lt;/code&gt; variable which can be either &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;0&lt;/code&gt; representing &lt;code&gt;true&lt;/code&gt; or &lt;code&gt;false&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int result = match(regexp, text);
if (result)
   printf("Pattern found in the text.\n");
else
   printf("Pattern not found in the text.\n");

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

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Match Function:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int match(char *regexp, char *text) {
    if (regexp[0] == '^')
        return matchhere(regexp+1, text);
    do {
        if (matchhere(regexp, text))
            return 1;
    } while (*text++ != '\0');
    return 0;
}
int matchhere(char *regexp, char *text) {
    if (regexp[0] == '\0')
        return 1;
    if (regexp[1] == '*')
        return matchstar(regexp[0], regexp+2, text);
    if (regexp[0] == '$' &amp;amp;&amp;amp; regexp[1] == '\0')
        return *text == '\0';
    if (*text!='\0' &amp;amp;&amp;amp; (regexp[0]=='.' || regexp[0]==*text))
        return matchhere(regexp+1, text+1);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;What all this code does :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;^&lt;/strong&gt; : When the ^ symbol is used at the beginning of a regular expression, it signifies that the pattern must match at the beginning of the text. If the first character of the regular expression does not match the first character of the text, the function returns 0, indicating that there is no match. In other words, the ^ character ensures that the pattern starts matching from the very beginning of the text. If it doesn't, the function returns false (0).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;c&lt;/strong&gt;: The c character in a regular expression represents any literal character 'c'. It matches exactly with the character 'c' in the text. If the character 'c' in the regular expression doesn't match the corresponding character in the text, the function returns 0, indicating that there is no match.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.&lt;/strong&gt;: The . character in a regular expression is a wildcard that matches any single character in the text. It is a placeholder for any character. For example, if the regular expression contains a.b, it would match any character between 'a' and 'b' in the text. If there is no matching character in the text, the function returns 0.&lt;/p&gt;

&lt;p&gt;&lt;b&gt; * &lt;/b&gt;: The * character in a regular expression indicates zero or more occurrences of the previous character or expression. For instance, ab* would match 'a' followed by zero or more 'b' characters. The function checks for zero or more occurrences of the previous character in the regular expression and returns 1 if a match is found; otherwise, it returns 0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;$&lt;/strong&gt;: The $ character in a regular expression represents the end of the input string (text). It ensures that the pattern must match at the very end of the text. If the regular expression consists of only $ and the text reaches its end as well, the function returns 1, indicating a successful match at the end of the text. If the text still has characters remaining, the function returns 0, indicating no match at the end of the text.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;You can use above Regex Matcher here :&lt;/strong&gt;&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@AniketMahajan5/StringMatcher?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;



&lt;p&gt;Code Available here : &lt;strong&gt;&lt;a href="https://github.com/Aniike-t/C_Regex_Matcher"&gt;Github&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;You can get the whole &lt;a href="https://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html"&gt;Article&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Follow and like for more such blogs.&lt;br&gt;
Connect me on &lt;a href="https://www.linkedin.com/in/aniket-mahajan-275305243/"&gt;LinkedIn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thanks for reading until the end.&lt;/strong&gt;&lt;/p&gt;




</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>learning</category>
    </item>
    <item>
      <title>Simple Code Interpreter In C</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Wed, 20 Sep 2023 06:49:20 +0000</pubDate>
      <link>https://forem.com/aniiket/simple-code-interpreter-in-c-5d39</link>
      <guid>https://forem.com/aniiket/simple-code-interpreter-in-c-5d39</guid>
      <description>&lt;h4&gt;
  
  
  Ever wondered how a interpreter works ? I wondered too.
&lt;/h4&gt;




&lt;p&gt;The basic concept for a computer/how it translates basic human logic to machine level logic goes to &lt;strong&gt;Automata Theory&lt;/strong&gt; of Computer Science by an well renowned English mathematician, computer scientist, logician, cryptanalyst, philosopher and theoretical biologist &lt;strong&gt;Alan Turing&lt;/strong&gt; .&lt;/p&gt;




&lt;p&gt;Learn more about Automata Theory here : &lt;/p&gt;
&lt;div class="ltag__wikipedia--container"&gt;
  &lt;div class="ltag__wikipedia--header"&gt;
    &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8Y-xY3vU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/wikipedia-logo-0a3e76624c7b1c3ccdeb9493ea4add6ef5bd82d7e88d102d5ddfd7c981efa2e7.svg" class="ltag__wikipedia--logo" alt="Wikipedia Logo" width="128" height="128"&gt;
    &lt;a href="https://en.wikipedia.org/wiki/Automata_theory" rel="noopener noreferrer"&gt;Automata theory&lt;/a&gt;
  &lt;/div&gt;
  &lt;div class="ltag__wikipedia--extract"&gt;&lt;p&gt;&lt;b&gt;Automata theory&lt;/b&gt; is the study of abstract machines and automata, as well as the computational problems that can be solved using them. It is a theory in theoretical computer science with close connections to mathematical logic. The word &lt;i&gt;automata&lt;/i&gt; comes from the Greek word αὐτόματος, which means "self-acting, self-willed, self-moving". An automaton is an abstract self-propelled computing device which follows a predetermined sequence of operations automatically. An automaton with a finite number of states is called a Finite Automaton (FA) or Finite-State Machine (FSM). The figure on the right illustrates a finite-state machine, which is a well-known type of automaton. This automaton consists of states and transitions. As the automaton sees a symbol of input, it makes a transition to another state, according to its transition function, which takes the previous state and current input symbol as its arguments.&lt;/p&gt;&lt;/div&gt;
  &lt;div class="ltag__wikipedia--btn--container"&gt;
    
      &lt;a href="https://en.wikipedia.org/wiki/Automata_theory" rel="noopener noreferrer"&gt;View on Wikipedia&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;





&lt;p&gt;&lt;strong&gt;What we are implementing toady ?&lt;/strong&gt;&lt;br&gt;
A stack based simple interpreter for beginners in C&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite :&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Well versed with C language.&lt;/li&gt;
&lt;li&gt;Implementation and working of Stack .&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;strong&gt;Let's start with implementing simple Addition interpreter in C&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;let's start with implementing :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What we need ?&lt;/strong&gt; A set of predefined words which are reserved for the program to follow instructions given by the user.&lt;/p&gt;

&lt;p&gt;What are these instructions? If you've ever written assembly code, you're likely familiar with them. Instructions are commands provided to a computer at a high level. Essentially, an instruction is a directive given to a computer's processor by a computer program. In this context, even though we're not directly interfacing with the computer's processor, we're achieving a similar effect through an interpreter implemented in C.&lt;/p&gt;

&lt;p&gt;An &lt;code&gt;enum&lt;/code&gt; in the C language is a keyword used to define a data type that consists of a set of named integral constants. These constants are typically used to represent related values or options in a more readable and expressive manner within a program.&lt;/p&gt;

&lt;p&gt;Why use &lt;code&gt;enums&lt;/code&gt;? To simply reserve specific words or values for use as keywords.&lt;/p&gt;

&lt;p&gt;These are the keywords we will be reserving :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;typedef enum {
    LOAD_CONSTANT, //Tell machine to load value
    ADD,           //Instruct machine to add
    PRINT,         //Print the Stack-Top
    HALT,          //Exit the program
} OpCode;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And a stack too, we limited static stack to 100 but can dynamic using stack using linked list.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#define STACK_SIZE 100
double stack[STACK_SIZE];
int stackTop = 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We will be predefining the values to add to keep it simple:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Constants for the bytecode program
double constants[] = {
    10.0,
    20.0,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;PUSH AND POP for the Stack&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Function to push a value onto the stack
void push(double value) {
    if (stackTop &amp;lt; STACK_SIZE) {
        stack[stackTop++] = value;
    } else {
        printf("Stack overflow!\n");
    }
}

// Function to pop a value from the stack
double pop() {
    if (stackTop &amp;gt; 0) {
        return stack[--stackTop];
    } else {
        printf("Stack underflow!\n");
        return 0.0;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Lets start with the logic of this program&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int ip = 0;  // Instruction pointer

int main() {
    while (1) {
        OpCode instruction = bytecode[ip++];
        switch (instruction) {
            case LOAD_CONSTANT: {
                int constantIndex = bytecode[ip++];
                double constantValue = constants[constantIndex];
                push(constantValue);
                break;
            }
            case ADD: {
                double b = pop();
                double a = pop();
                double result = a + b;
                push(result);
                break;
            }
            case PRINT: {
                double value = pop();
                printf("Result: %lf\n", value);
                break;
            }
            case HALT: {
                return 0;  // Exit the program
            }
        }
    }
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Explanation :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;While Loop (while (1) { ... }):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Imagine this loop as a never-ending cycle, like a carousel that keeps spinning.&lt;/li&gt;
&lt;li&gt;Inside this loop, our program will keep doing things repeatedly.
Fetching Instructions (OpCode instruction = bytecode[ip++];):&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Fetching Instructions (OpCode instruction = bytecode[ip++];):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpCode instruction is like a note that tells us what to do next.&lt;/li&gt;
&lt;li&gt;bytecode[ip++] is like turning the page in the recipe book to get the next step.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Switch Statement (switch (instruction) { ... }):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We look at the instruction and decide which action to take.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;LOAD_CONSTANT:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is like a step that tells us to remember a number, say, 10.
int constantIndex is like remembering the page number where we found 10.&lt;/li&gt;
&lt;li&gt;double constantValue is like writing down the number 10 on a piece of paper.&lt;/li&gt;
&lt;li&gt;push(constantValue) is like putting that piece of paper in our pocket.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ADD:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's like a step that says, "Take two numbers and add them."
double b = pop(); is like taking two pieces of paper with numbers written on them.&lt;/li&gt;
&lt;li&gt;double a = pop(); is like reading the numbers from those papers.&lt;/li&gt;
&lt;li&gt;double result = a + b; is like adding those numbers together and getting a new number.&lt;/li&gt;
&lt;li&gt;push(result) is like putting the new number on a new piece of paper and keeping it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;PRINT:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's like a step that says, "Tell me what number you have."
double value = pop(); is like taking out the piece of paper with a number.&lt;/li&gt;
&lt;li&gt;printf("Result: %lf\n", value); is like showing that number to someone.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HALT:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's like the last step in the book that says, "We're done reading."&lt;/li&gt;
&lt;li&gt;return 0; is like leaving closing the book.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;



&lt;p&gt;*&lt;em&gt;Let's have a sample program : *&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// The bytecode program
unsigned char bytecode[] = {
    LOAD_CONSTANT, 0,  // Load constant 10
    LOAD_CONSTANT, 1,  // Load constant 20
    ADD,               // Add the top two values on the stack
    PRINT,             // Print the result
    HALT,              // Halt the interpreter
};

// Constants for the bytecode program
double constants[] = {
    10.0,
    20.0,
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Working of above code:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Start&lt;br&gt;
----&amp;gt;&lt;br&gt;
LOAD_CONSTANT (Load 10)&lt;br&gt;
----&amp;gt;&lt;br&gt;
LOAD_CONSTANT (Load 20)&lt;br&gt;
----&amp;gt;&lt;br&gt;
ADD (Add 10 and 20)&lt;br&gt;
----&amp;gt;&lt;br&gt;
PRINT (Print the result)&lt;br&gt;
----&amp;gt;&lt;br&gt;
HALT (Stop the interpreter)&lt;br&gt;
----&amp;gt;&lt;br&gt;
End&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;This is very simple interpreter, advanced ones use statements like jumps, loops, etc and advance concepts of &lt;code&gt;Turing Machines&lt;/code&gt; ,which are different and can do even more than Stack based interpreters&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;As a beginner you can try to implement statements like :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Jump &lt;/li&gt;
&lt;li&gt;Subtract&lt;/li&gt;
&lt;li&gt;Other mathematical operations&lt;/li&gt;
&lt;li&gt;Brainstorm more ideas ............&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;You can use this interpreter here, fork to experiment more :&lt;/p&gt;


&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@AniketMahajan5/SimpleStack-Based-Code-Interpreter?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;






&lt;p&gt;Code is available here : &lt;a href="https://github.com/Aniike-t/Simple_Stack_Based_Code_Interpreter_C"&gt;Github&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Thank you so much for reading.&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Follow and Like for more .&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can also follow me on &lt;strong&gt;&lt;a href="https://www.linkedin.com/in/aniket-mahajan-275305243/"&gt;LinkedIn&lt;/a&gt;&lt;/strong&gt;, I think building connections is better &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>c</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Single Page Image Editor</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Tue, 19 Sep 2023 14:16:50 +0000</pubDate>
      <link>https://forem.com/aniiket/single-page-image-editor-4ok</link>
      <guid>https://forem.com/aniiket/single-page-image-editor-4ok</guid>
      <description>&lt;h3&gt;
  
  
  Why did I make it? As a beginner, I need to understand how exactly JavaScript works. This small project made me think about how would I implement these features using JavaScript.
&lt;/h3&gt;




&lt;p&gt;This project is for beginners, so beginners follow up the guide and if you are experienced feel to add something you are free to do so.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Look at the end result, that's we gonna create today&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--luSTz1gc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wemw1tz408cmil9gz574.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--luSTz1gc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wemw1tz408cmil9gz574.png" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Let's dive into coding :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you can see the webpage we need basic set of five inputs of type = "range" which makes a slider on the HTML page which we can further use to manipulate properties of the image. Further on we need an input type = "file", an img tag to show the preview of the image and a download button to download the resulting image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;label for="brightness"&amp;gt;Brightness:&amp;lt;br&amp;gt;&amp;lt;/label&amp;gt;
&amp;lt;input type="range" id="brightness" min="0" max="2" step="0.1" value="1"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Next, we can make similar tags for Contrast, Saturation, Blur and Rotation. Now we need to take input, need a button to download and need an img tag to show the preview of the image.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;input type="file" id="image-input" accept="image/*"&amp;gt;
&amp;lt;img id="image-preview" src=""&amp;gt;

&amp;lt;button id="download-btn"&amp;gt;Download Image&amp;lt;/button&amp;gt;

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

&lt;/div&gt;


&lt;p&gt;Now we have an external frame, but now we need the working under the hood that is the JavaScript. Add event listener to every input and button.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const brightnessRange = document.getElementById('brightness');
//Other property codes go here

const imageInput = document.getElementById('image-input');
const imagePreview = document.getElementById('image-preview');

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

&lt;/div&gt;


&lt;p&gt;After adding these we need to show a preview of the image in our browser which can be done using the link we get from input to redirect it to the preview link.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;imageInput.addEventListener('change', (e) =&amp;gt; {
  const file = e.target.files[0]; // We need to traget the first link/file.
  const reader = new FileReader(); //make a FileReader class.
  reader.onload = () =&amp;gt; {
    imagePreview.src = reader.result;
  }; //Load image in preview as soon as FileReader reads the image.
  if (file) {
    reader.readAsDataURL(file);
  }//If file holds a valid rendered image load it.
});

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

&lt;/div&gt;


&lt;p&gt;Now we need to manipulate the image preview section, adding EventListener to each element seems the way.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brightnessRange.addEventListener('input', applyFilters);
//.......make similar for other sections
rotateRange.addEventListener('input', applyFilters);

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

&lt;/div&gt;


&lt;p&gt;Take the input change and call the function applyFilters.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function applyFilters() {
  const brightnessValue = brightnessRange.value;
  const contrastValue = contrastRange.value;
  const saturationValue = saturationRange.value;
  const blurValue = blurRange.value;
  const rotateValue = rotateRange.value;
  //Manipulate the style to make changes in CSS of image. 
  //We can also use TweenLite to do so.  
  imagePreview.style.filter = `brightness(${brightnessValue}) contrast(${contrastValue}) saturate(${saturationValue}) blur(${blurValue}px)`;
  imagePreview.style.transform = `rotate(${rotateValue}deg)`;
}

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

&lt;/div&gt;


&lt;p&gt;Now we need to download this image. We can do this by adjusting a canvas onto the preview image and adding an EventListener to the download button. But we need to manipulate the image first and then give a trigger to download the image.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;downloadButton.addEventListener('click', () =&amp;gt; {
  //Initialise a canvas
  const canvas = document.createElement('canvas');
  const context = canvas.getContext('2d');

  // Set canvas dimensions
  canvas.width = imagePreview.width;
  canvas.height = imagePreview.height;

  // Apply filters and transformations to the canvas
  context.filter = `brightness(${brightnessRange.value}) contrast(${contrastRange.value}) saturate(${saturationRange.value})`;
  context.rotate((rotateRange.value * Math.PI) / 180); 
  // Convert degrees to radians
  context.drawImage(imagePreview, 0, 0, canvas.width, canvas.height); 
  // Draw image with matching dimensions

  // Convert canvas to data URL
  const editedImageURL = canvas.toDataURL('image/jpeg');

  // Create a download link
  const downloadLink = document.createElement('a');
  downloadLink.href = editedImageURL;
  downloadLink.download = 'edited_image.jpg';
  downloadLink.click();
});

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

&lt;/div&gt;


&lt;p&gt;Add CSS to make it look better as you want.&lt;/p&gt;



&lt;p&gt;Disclaimer: The rotate image button is not working as intended. &lt;br&gt;
Suggestion: Try to use a blank canvas and draw the image onto the canvas to rotate it.&lt;/p&gt;

&lt;p&gt;You can use this editor here : &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag__replit"&gt;
  &lt;iframe height="550px" src="https://repl.it/@AniketMahajan5/SimpleImageEditor?lite=true"&gt;&lt;/iframe&gt;
&lt;/div&gt;






&lt;p&gt;Thank You for following till the end and your lovely support !&lt;br&gt;
Follow and Like for more......&lt;br&gt;
That's it for the day 👋&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Blood Group Survey WebApp</title>
      <dc:creator>Aniket</dc:creator>
      <pubDate>Sat, 16 Sep 2023 13:34:22 +0000</pubDate>
      <link>https://forem.com/aniiket/blood-group-survey-webapp-49jb</link>
      <guid>https://forem.com/aniiket/blood-group-survey-webapp-49jb</guid>
      <description>&lt;p&gt;Hello &lt;strong&gt;👋&lt;/strong&gt; , this is my first Blog.&lt;/p&gt;

&lt;p&gt;This Flask application allows users to input their name, age, blood group, and quantity of blood they are willing to donate. The data is stored in a SQLite database. A notification is displayed to the user after they submit their response.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites :
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Basic Knowledge of Python&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Flask, SQLAlchemy and Plyer&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Dive in :
&lt;/h3&gt;

&lt;p&gt;Let's dive into how you could make a simple Python survey app with minimal coding as a beginner. Dependencies are Flask Framework which allows Python to interact with the Web world, SQLAlchemy to store all the data and Plyer to notify the user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's start by creating some Python Code for storing data and then move onto Python and HTML :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Requirements are the Person's Name, Blood Group, Age and Quantity of blood donated, so firstly we will create a class that connects to SQLAlchemy to create a table for the same.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
db = SQLAlchemy()

#creation of database
db = SQLAlchemy(app)
with app.app_context():
    db.create_all()

class Response(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50))
    age = db.Column(db.Integer)
    blood_group = db.Column(db.String(5))
    quantity = db.Column(db.Integer)

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

&lt;/div&gt;



&lt;p&gt;Now we need to create a route such that an HTML file is loaded as soon as the webpage is loaded. We need to create a route using Flask Framework using GET and POST methods to retrieve information/data between the webpage, Python and our database. Blood groups are defined so that only valid entries are taken into consideration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Global Variable
blood_groups = ['A+', 'A-', 'B+', 'B-', 'O+', 'O-', 'AB+', 'AB-']
@app.route('/', methods=['GET', 'POST'])
def home():  
    db.create_all()
    if request.method == "POST" and 'submit' in request.form: 
        blood_group = request.form['blood_group']
        Name=request.form['Name']
        Age= int(request.form['Age'])
        Quantity= int(request.form['Quantity'])
        if Age&amp;lt;18:
            return redirect('/')     
        else:
            response = Response(blood_group=blood_group, name=Name, age=Age, quantity=Quantity)
            db.session.add(response)
            db.session.commit()
            #Notification Block goes here       
            return redirect('/')   
    return render_template('home.html', blood_groups=blood_groups)

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

&lt;/div&gt;



&lt;p&gt;As you can see we have just created a simple route that redirects us to the file name &lt;code&gt;home.html&lt;/code&gt; we are using a POST method to retrieve the data, the same method should be used in the HTML file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form class="form" action="#" method="POST"&amp;gt;
      &amp;lt;h1&amp;gt;Blood Group Survey&amp;lt;/h1&amp;gt;
      &amp;lt;h3&amp;gt;Enter Name&amp;lt;/h3&amp;gt;
      &amp;lt;input type="text" name ="Name" required&amp;gt;
      &amp;lt;h3&amp;gt;Age&amp;lt;/h3&amp;gt;
      &amp;lt;input type="text" name ="Age" required&amp;gt;
      &amp;lt;h3&amp;gt;Quantity Of Blood&amp;lt;/h3&amp;gt;
      &amp;lt;input type="text" name ="Quantity" required&amp;gt;
      &amp;lt;h3&amp;gt;Please select your blood group:&amp;lt;/h3&amp;gt;
      &amp;lt;select id="blood_group" name="blood_group"&amp;gt;&amp;lt;br&amp;gt;
        {% for group in blood_groups %}
        &amp;lt;option value="{{ group }}" &amp;gt;{{ group }}&amp;lt;/option&amp;gt;
        {% endfor %}
      &amp;lt;/select&amp;gt;
      &amp;lt;input class="button" type="submit" value="submit" name= "submit"&amp;gt;
&amp;lt;/form&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Now we just need to create a notification block using Python and Plyer which can be imported. This provides desktop notifications to the user for better interactiveness.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            #plyer notification
            notification.notify(
                title='Entry Added',
                message='Respond Successfully Addded',
                app_name='Blood Donation Survey',
            )

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

&lt;/div&gt;



&lt;p&gt;CSS can also be added to make it look better. The code uploaded on GitHub consists of CSS and all the integration required and a step-by-step guide in the Readme file to do so.&lt;/p&gt;

&lt;h3&gt;
  
  
  Result :
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1LUN1zaL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1692985188764/2bda78db-47fe-41d5-a635-51657a8a18d7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1LUN1zaL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://cdn.hashnode.com/res/hashnode/image/upload/v1692985188764/2bda78db-47fe-41d5-a635-51657a8a18d7.png" alt="" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;GitHub : &lt;a href="https://github.com/Aniike-t/Simple-Py-Projects/tree/main/Blood%20Group%20App"&gt;https://github.com/Aniike-t/Simple-Py-Projects/tree/main/Blood%20Group%20App&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Myself Aniket, Thank you for reading my first blog.&lt;/strong&gt;&lt;br&gt;
Also posted on : &lt;a href="https://anii1ket.hashnode.dev/blood-donation-survey-webapp"&gt;https://anii1ket.hashnode.dev/blood-donation-survey-webapp&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>python</category>
    </item>
  </channel>
</rss>
