<?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 Ravi Agheda on Medium]]></title>
        <description><![CDATA[Stories by Ravi Agheda on Medium]]></description>
        <link>https://medium.com/@raviagheda?source=rss-847765d12adc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Y6vW4H9Afr_IOs0q2z-fIA.png</url>
            <title>Stories by Ravi Agheda on Medium</title>
            <link>https://medium.com/@raviagheda?source=rss-847765d12adc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:25:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raviagheda/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[Setting Up Llama 3.2 Locally with Ollama and Open WebUI: A Complete Guide]]></title>
            <link>https://raviagheda.medium.com/setting-up-llama-3-2-locally-with-ollama-and-open-webui-a-complete-guide-019ee3c0897c?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/019ee3c0897c</guid>
            <category><![CDATA[llama-3]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ollama]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Thu, 03 Apr 2025 07:47:45 GMT</pubDate>
            <atom:updated>2025-04-03T07:47:45.363Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ll use Ollama as tool for setting up the llama3.2 model in our local device.</p><p>Requirements for Llama3.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*90sRBa-aQmt6kJXw.png" /></figure><h3>1 Install Ollama</h3><p>Download the Ollama from here: <a href="https://ollama.com/">https://ollama.com/</a> and install it locally. It should be very easy to install just one click.<br>It’ll automatically setup the CLI path, if not please explore the documentation.</p><p>you can explore the models from supported by ollama here<br><a href="https://ollama.com/search">https://ollama.com/search</a></p><h3>2 Setup the model, in our case Llama3.2</h3><pre>ollama run llama3.2:latest</pre><p>It should download the modal and spin it up in your terminal, you can have chat directly from the terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*l1QvDC6ZHilS66bP.png" /></figure><p>Once we’re good that part, now it’s time to setup the UI ( like chatGPT )</p><h3>3 Setup Open-WebUI</h3><p>Open WebUI is an extensible, self-hosted AI interface that adapts to your workflow, all while operating entirely offline.</p><p>Checkout their docs from here: <a href="https://docs.openwebui.com/">https://docs.openwebui.com/</a></p><p>we’ll use the docker to setup the interface locally, run this command</p><pre>docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main</pre><p>Once docker is up successfully go to port 3000 and you’re good to go.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*FjciO6zJj1zZUFRU.png" /></figure><p>You can run other models and change them directly from the open webui interface.</p><p>Enjoy….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=019ee3c0897c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitHub Action with EC2 using SSH]]></title>
            <link>https://raviagheda.medium.com/github-action-with-ec2-using-ssh-1a1895fef29?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a1895fef29</guid>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cicd]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Sat, 26 Aug 2023 06:31:09 GMT</pubDate>
            <atom:updated>2023-08-26T06:31:09.947Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0aFqrKMoyZYr7qJ_w8LsKA.jpeg" /></figure><p>It’s pretty easy to set up GitHub action with AWS EC2 for deployments using SSH key, follow these 3 breakdowns to implement the pipeline.</p><h3>1. Generate SSH Key</h3><pre>cd ~/.ssh<br>ssh-keygen -t rsa -b 4096 -C &quot;your_email@example.com&quot;</pre><p>Enter file name: “key_name”<br>ls and list out files of the .ssh folder, you should see &quot;key_name&quot; and &quot;key_name.pub&quot;</p><ul><li>Add public key to authorized keys</li></ul><pre>cat github-actions.pub &gt;&gt; ~/.ssh/authorized_keys</pre><p>For detailed information on the SSH Key generation process check this reference: <a href="https://zellwk.com/blog/github-actions-deploy/">https://zellwk.com/blog/github-actions-deploy/</a></p><h3>2. Set Github Secrets</h3><p>SSH_PRIVATE_KEY: private key that we created on ec2<br>HOST_NAME / IP_ADDRESS: Elastic IP or IP of EC2<br>USER_NAME: the user name of the ec2 user.</p><h3>3. Create a branch_name.yml ( for dev branch dev.yml ) file under .github/workflows</h3><p>Update the dev to your branch name</p><pre>name: Deploy<br><br>on:<br>  push:<br>    branches: [ dev ]<br>jobs:<br>  Deploy:<br>    name: Deploy to EC2<br>    runs-on: ubuntu-latest<br>    steps:<br>      - uses: actions/checkout@v2 <br>      - name: Build &amp; Deploy<br>        env:<br>            PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}<br>            HOSTNAME: ${{secrets.SSH_HOST}}<br>            USER_NAME: ${{secrets.USER_NAME}}<br>        run: |<br>          echo &quot;$PRIVATE_KEY&quot; &gt; private_key &amp;&amp; chmod 600 private_key<br>          ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} &#39;<br>              # Now we have got the access of EC2 and we will start the deploy .<br>              cd /home/ubuntu/&lt;PROJECT_DIRECTORY&gt; &amp;&amp;<br>              git checkout dev &amp;&amp;<br>              git fetch --all &amp;&amp;<br>              git reset --hard origin/dev &amp;&amp;<br>              git pull origin dev &amp;&amp;<br>              sudo npm i &amp;&amp;<br>              sudo npm run build &amp;&amp;<br>              sudo pm2 stop ./dist/index.js &amp;&amp;<br>              sudo pm2 start ./dist/index.js<br>              &#39;</pre><p>Gist Ref: <a href="https://gist.github.com/raviagheda/c69ae5e884f4490b1af656dbd80c00dd">https://gist.github.com/raviagheda/c69ae5e884f4490b1af656dbd80c00dd</a></p><p>Enjoy!</p><p>If you are here it means you may have enjoyed reading this blog. Just follow me <a href="https://dev.to/raviagheda">“Ravi Agheda”</a> which will motivate to write more, and contribute to open source. You can make me a <a href="https://www.buymeacoffee.com/raviagheda">coffee☕️</a> . Small support comes a long way!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a1895fef29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Love Mongodb ? Try Tigris db once.]]></title>
            <link>https://raviagheda.medium.com/love-mongodb-try-tigris-db-once-d104bbdacd42?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d104bbdacd42</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[tigris]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 05:20:36 GMT</pubDate>
            <atom:updated>2023-04-18T05:27:35.320Z</atom:updated>
            <content:encoded><![CDATA[<h3>Love Mongodb ? Try Tigris db once.</h3><p>Tigris db is one the best no sql databases I came across after the Mongodb.</p><p>We love MongoDB for its ease of use and features, powered queries easy model setup, and complex operations.<br>But still, there are many things we have to handle on our own, i.e. Environment based setup, etc.</p><p>Whereas Tigris provides native integration for branching environments, we can setup the main, staging, and dev branch for the different databases using env config.</p><p>In order to get one more step further we have a tigris db to explore. Let’s discuss some key points of difference of tigris db and mongodb to get more idea around it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*MA1QwxooEOBIcpYQ.jpeg" /></figure><p>How Tigris differ from MongoDB from the tigris doc</p><ul><li>Unlike MongoDB, Tigris follows a modern composable architecture with loosely coupled components. Furthermore, compute is separated from storage, allowing for independent scaling and a more resilient system.</li><li>The storage layer in Tigris is built on FoundationDB, and Tigris inherits the strong consistency guarantees, and the scalability of FoundationDB.</li><li>Tigris provides automatic database sharding, and shard keys are unnecessary as the data distribution is automatically handled. This ensures true serverless behavior with no painful transition from a non-sharded to a sharded MongoDB cluster.</li><li>Tigris’ open source Kubernetes-native design allows it to be deployed anywhere in the cloud in the user’s account, ensuring that the user is always in control of their data.</li><li>Some other differentiating features include global interactive ACID transactions, consistent secondary indexes, and an integrated search platform.</li></ul><p>Try the Tigirs database with express app, visit: <a href="https://www.tigrisdata.com/">https://www.tigrisdata.com/</a><br>Signup, and create a test app. It’ll provide a command set of npm. Create an express app using it and you’ll be able to explore the codebase and queries.</p><p>Here’s a reference of express tigris app: <a href="https://github.com/raviagheda/express-tigrisdb">https://github.com/raviagheda/express-tigrisdb</a></p><p>Fun Fact: If we move to tigress db then our will be as follow MEAN will be TEAN, and MERN will be TERN.</p><p>If you are here it means you may have enjoyed reading this blog. Just follow me<br>Ravi Agheda<br>which will motivate to write more, and contribute to open source. You can make me a coffee☕️ . Small support comes a long way!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d104bbdacd42" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Art of Debugging: Techniques for Effective Problem-Solving]]></title>
            <link>https://raviagheda.medium.com/the-art-of-debugging-techniques-for-effective-problem-solving-4b5f41b39df8?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b5f41b39df8</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[debug]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Sat, 15 Apr 2023 19:34:31 GMT</pubDate>
            <atom:updated>2023-04-16T03:21:30.950Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7o8MqcjwDRkvz-3d0kiW2w.jpeg" /></figure><p><strong>Debugging</strong> is an essential part of the software development process. It’s the process of identifying and resolving errors, bugs, or issues that prevent the code from running correctly. However, debugging is often seen as a tedious and frustrating task, and many developers struggle with finding effective techniques to solve problems efficiently. In this blog post, we’ll explore some creative and unique techniques that can help developers improve their debugging skills and become more effective problem-solvers.</p><h3>Divide and Conquer</h3><p>The divide and conquer approach involves breaking down a problem into smaller, more manageable pieces. This technique is particularly useful when dealing with complex issues that involve multiple components or dependencies. By isolating the problem, developers can focus their efforts on specific areas, reducing the scope of the issue and making it easier to solve. This technique is also useful for identifying the root cause of a problem, which can help prevent similar issues from arising in the future.</p><h3>Rubber Duck Debugging</h3><p>Rubber Duck Debugging is a technique that involves explaining the problem to an inanimate object, such as a rubber duck. This technique may sound silly, but it’s a useful way to approach problems from a different perspective. By explaining the problem out loud, developers can often identify issues they might have overlooked. This technique is also useful for clarifying the problem to other team members, which can help improve collaboration and communication.</p><h3>Debugging with Print Statements</h3><p>Debugging with print statements involves inserting log statements into the code to track the execution flow and identify issues. This technique is particularly useful for tracking down issues that are difficult to reproduce or that occur intermittently. By logging key variables or function calls, developers can gain insights into the behavior of the code and identify areas where issues are occurring. This technique is also useful for gaining a better understanding of how the code is executing, which can help improve overall code quality.</p><h3>Pair Programming</h3><p>Pair programming involves two developers working together on the same codebase, sharing ideas and solving problems collaboratively. This technique is particularly useful when dealing with complex issues that require a fresh perspective or expertise in a specific area. By working together, developers can share knowledge, identify issues more quickly, and come up with more creative solutions. Pair programming is also an excellent way to improve team collaboration and communication, which can lead to more effective problem-solving in the long run.</p><h3>Conclusion</h3><p>Debugging is a critical skill for developers, but it can also be a frustrating and time-consuming process. By using the creative and unique techniques discussed in this blog post, developers can approach problems from a fresh perspective, improve collaboration and communication, and become more effective problem-solvers. To implement these techniques successfully, it’s essential to prioritize clear and concise communication with your team, maintain a detailed record of the debugging process, and be willing to experiment with different methods until you find what works best for you. Remember, the art of debugging is not just about finding and fixing issues; it’s also about developing a problem-solving mindset that focuses on continuous improvement and finding creative solutions to complex problems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b5f41b39df8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to integrate swagger UI in your node project with auto-generation?]]></title>
            <link>https://raviagheda.medium.com/how-to-integrate-swagger-ui-in-your-node-project-with-auto-generation-df866d7fff15?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/df866d7fff15</guid>
            <category><![CDATA[swagger]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Sat, 15 Apr 2023 19:26:12 GMT</pubDate>
            <atom:updated>2023-04-15T19:26:12.501Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZ_9RCtAHeiPmCey9dzWkA.jpeg" /></figure><p>Swagger is a tool for documenting and testing APIs. It provides an interface for exploring endpoints, testing input and output data, and generating client libraries for different programming languages.</p><p>In this blog post, we will look at how to integrate Swagger into a Node.js project using the Swagger UI and Swagger Autogen libraries and output JSON.</p><p><strong>Installing Swagger UI and Swagger Autogen</strong><br>The first step is to install the Swagger UI and Swagger Autogen libraries. We can do this using npm. Open a terminal window and navigate to the root directory of your Node.js project. Then, run the following command:</p><p>Swagger is a tool for documenting and testing APIs. It provides an interface for exploring endpoints, testing input and output data, and generating client libraries for different programming languages. In this blog post, we will look at how to integrate Swagger into a Node.js project using the Swagger UI and Swagger Autogen libraries and output JSON.</p><p>Installing Swagger UI and Swagger Autogen<br>The first step is to install the Swagger UI and Swagger Autogen libraries. We can do this using npm. Open a terminal window and navigate to the root directory of your Node.js project. Then, run the following command:</p><pre>npm install swagger-ui-express swagger-autogen</pre><p>This will install the Swagger UI and Swagger Autogen libraries in your project.</p><p>Setting up Swagger UI<br>Once the libraries are installed, we need to set up Swagger UI in our Node.js project. Create a new file in your project root directory called swagger.js. This file will contain the Swagger UI setup code.</p><pre>const swaggerUi = require(&#39;swagger-ui-express&#39;);<br>const swaggerDocument = require(&#39;./swagger.json&#39;);<br><br>module.exports = (app) =&gt; {<br>  app.use(&#39;/api-docs&#39;, swaggerUi.serve, swaggerUi.setup(swaggerDocument));<br>};</pre><p>This code sets up the Swagger UI middleware for our Express app. The swaggerUi.serve middleware serves the Swagger UI files, and the swaggerUi.setup middleware creates a new route at /api-docs where we can access the Swagger UI.</p><p>The swaggerDocument variable is a JSON file that describes the API endpoints, input and output data, and other details about our API. We will create this file later in this blog.</p><p>Setting up Swagger Autogen<br>Now that we have set up Swagger UI, we need to set up Swagger Autogen. This library automatically generates Swagger documentation based on our Express app’s route handlers.</p><p>Create a new file in your project root directory called swagger-autogen.js. This file will contain the Swagger Autogen setup code.</p><pre>const swaggerAutogen = require(&#39;swagger-autogen&#39;)();<br><br>const outputFile = &#39;./swagger.json&#39;;<br>const endpointsFiles = [&#39;./routes/*.js&#39;];<br><br>const config = {<br>    info: {<br>        title: &#39;Blog API Documentation&#39;,<br>        description: &#39;&#39;,<br>    },<br>    tags: [ ],<br>    host: &#39;localhost:3000/api&#39;,<br>    schemes: [&#39;http&#39;, &#39;https&#39;],<br>};<br><br>swaggerAutogen(outputFile, endpointsFiles, config);</pre><p>This code sets up Swagger Autogen to generate Swagger documentation for our API endpoints. The outputFile variable is the name of the JSON file where the documentation will be saved. The endpointsFiles variable is an array of paths to our Express app’s route handler files.</p><p>Let me know in the comment if your swagger requirement is resolved by this blog.</p><p>And, You can make me a <a href="https://www.buymeacoffee.com/raviagheda">coffee☕️</a></p><p>Thank you for reading through, Follow me for more content :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df866d7fff15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup AWS S3 bucket for NodeJS]]></title>
            <link>https://raviagheda.medium.com/setup-aws-s3-bucket-for-nodejs-3bdf4a3453a0?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bdf4a3453a0</guid>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[aws-sdk]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Sat, 07 Jan 2023 18:13:28 GMT</pubDate>
            <atom:updated>2023-01-07T18:13:28.820Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon Simple Storage Service (S3) is one of the best tool to store the file/media. Let’s set it up with nodejs framework.</p><ol><li>Setup S3 bucket with public access.</li><li>Integrate S3 with NodeJS.</li></ol><h3>1. Setup S3 bucket with public access.</h3><p>First thing first, let’s create a bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*hYQIAptEb7dzR6rI.png" /></figure><p>Enter the name and Change the region if required, here I’m keeping it Oregon as default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*dXOREYm6vA0Yx3JJ.png" /></figure><p>As I need a public bucket so I’m enabling a ACL and keeping Radio options as it is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*UJYaQulIJLM6BhFH.png" /></figure><p>Same as above, uncheck the checkbox in order to make it public.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*wp85BWnnbYcKnq0c.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*XBljyRoCHLHf6r7X.png" /></figure><p>Keep rest of the options as it is unless required, and hit create bucket button.<br>Now once bucket is created we would have to update the bucket policy in order to access it as public bucket.</p><ol><li>Open a Bucket</li><li>Go to permission and scroll down to Bucket Policy, and Edit</li></ol><pre>{<br>    &quot;Version&quot;: &quot;2008-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AllowPublicRead&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: &quot;*&quot;<br>            },<br>            &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::ravis-blog-bucket/*&quot;<br>        }<br>    ]<br>}</pre><p>Make sure that you update the bucket name inside the policy code “Resource”.</p><p>In order to test the setup, upload a single file and try to access it from outside, i.e. Incognito.</p><h3>2. Integrate S3 with NodeJS</h3><p>Assuming you already have express app setup and we are ready to proceed with aws sdk setup. In order to acccess S3 apis from nodejs we would need to install aws-sdk npm package.</p><p>Lets also install the uuid and mime as helper packages.</p><pre>const { S3 } = require(&#39;aws-sdk&#39;);<br>const uuid = require(&#39;uuid&#39;).v4;<br>const mime = require(&quot;mime&quot;);</pre><pre>const s3 = new S3();<br>const uploader = (file, filepath) =&gt; {<br>    console.log(&quot;uploading file -&gt; &quot;, file);<br>    const params = {<br>        Bucket: process.env.AWS_S3_BUCKET, // ravis-blog-bucket<br>        Key: `${filepath}${uuid()}_${Date.now()}_.${mime.getExtension(file.mimetype)}`,<br>        Body: file.buffer<br>    };<br>    console.log(params);<br>    return s3.upload(params);<br>}</pre><p>Now it’s ready for user, we can call the uploader function and pas multipart file and filePath ( location path at S3, i.e. images/logos/ ).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bdf4a3453a0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to host an Angular app on Heroku]]></title>
            <link>https://towardsdev.com/how-to-host-angular-app-on-heroku-665317d1f47f?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/665317d1f47f</guid>
            <category><![CDATA[express]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[heroku]]></category>
            <category><![CDATA[hosting]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Sat, 25 Jun 2022 09:52:02 GMT</pubDate>
            <atom:updated>2023-01-07T18:39:30.032Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cvPxdVQxT8aUH39a" /><figcaption>Photo by <a href="https://unsplash.com/@johnschno?utm_source=medium&amp;utm_medium=referral">John Schnobrich</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>We need an express server to make the Angular app live.</p><h3>Install express and path.</h3><p>npm install express path</p><p>Create server.js</p><pre>const express = require(&#39;express&#39;);<br>const path = require(&#39;path&#39;);<br>const app = express();<br>app.use(express.static(__dirname + &#39;/dist/&lt;FOLDER_NAME&gt;&#39;));<br>// Link index.html of build folder with router.<br>app.get(&#39;/*&#39;, (req,res,next) =&gt; {<br>    res.sendFile(path.join(__dirname + &#39;/dist/&lt;FOLDER_NAME&gt;/index.html&#39;));<br>});<br><br>app.listen(process.env.PORT || 8000);</pre><h3>Add these lines in package.json</h3><p>inside scripts</p><pre>&quot;start&quot;: &quot;node server.js&quot;,<br>&quot;heroku-postbuild&quot;: &quot;ng build --prod&quot;</pre><p>Add engines inside package.json</p><pre>&quot;engines&quot;: {<br>    &quot;node&quot;: &quot;14.15.3&quot;,<br>    &quot;npm&quot;: &quot;6.14.9&quot;<br>  },</pre><h3>Add this project to GitHub and connect this repository with your Heroku app.</h3><p>Click on deploy.</p><p>Thanks for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=665317d1f47f" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/how-to-host-angular-app-on-heroku-665317d1f47f">How to host an Angular app on Heroku</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mongoose auto timestamp]]></title>
            <link>https://towardsdev.com/mongoose-auto-timestamp-5bd32b39a4d2?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/5bd32b39a4d2</guid>
            <category><![CDATA[mongoose]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[express]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Sat, 25 Jun 2022 09:47:51 GMT</pubDate>
            <atom:updated>2022-08-03T06:44:13.050Z</atom:updated>
            <content:encoded><![CDATA[<h3>Let mongoose schema handle timestamps for you</h3><p>It’s a little difficult to manage createdAt and updatedAt on each Create and Update operation.</p><p>We can have it handled by mongoose built-in features. There are three ways to add timestamps in the mongoose schema</p><h3>1. createdAt and updatedAt in timestamp format.</h3><pre>const mySchema = new mongoose.Schema(<br>    {<br>        name: String,<br>    }, <br>    {<br>        timestamps: true,<br>    }<br>);</pre><h4>output:</h4><p>createdAt: 2021-02-02T06:12:26.668Z,<br>updatedAt: 2021-02-02T06:12:48.930Z</p><h3>2. Timestamp with a custom field name</h3><p>By default, the names of the fields are createdAt and updatedAt. Customize the field names by setting timestamps.createdAt and timestamps.updatedAt.</p><pre>const mySchema = new mongoose.Schema(<br>    {<br>        name: String,<br>    }, <br>    {<br>        timestamps: { createdAt: &#39;addedAt&#39;, updatedAt: &#39;modifiedAt&#39; },<br>    }<br>);</pre><h4>output:</h4><p>addedAt: 2021-02-02T06:12:26.668Z,<br>modifiedAt: 2021-02-02T06:12:48.930Z</p><h3>3. Timestamp with number format (double)</h3><p>By default, Mongoose uses new Date() to get the current time. If you want to overwrite the function Mongoose uses to get the current time, you can set the timestamps.currentTime option. Mongoose will call the timestamps.currentTime function whenever it needs to get the current time.</p><pre>const mySchema = new mongoose.Schema(<br>    {<br>        name: String,<br>        createdAt: Number,<br>        updatedAt: Number,<br>    }, <br>    {<br>        timestamps: { currentTime: ()=&gt; Date.now() },<br>    }<br>);</pre><h4>output:</h4><p>createdAt: 1612246845043,<br>updatedAt: 1612246853068</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5bd32b39a4d2" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/mongoose-auto-timestamp-5bd32b39a4d2">🦝 Mongoose auto timestamp</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to redirect the domain to port number using Nginx and setup SSL ?]]></title>
            <link>https://towardsdev.com/configure-nginx-and-ssl-on-linux-instance-2980b37c5fd?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2980b37c5fd</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[domains]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Sat, 25 Jun 2022 09:35:32 GMT</pubDate>
            <atom:updated>2024-05-31T12:26:35.507Z</atom:updated>
            <content:encoded><![CDATA[<h3>Nginx Configuration Setup</h3><h3><a href="https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-20-04">Install Nginx</a></h3><pre>sudo apt update<br>sudo apt install nginx</pre><h3>Link port with domain</h3><p>Open this file in nano or vim /etc/nginx/nginx.conf</p><pre>http{<br>  server{<br>    listen 80;<br>    server_name DOAMIN.com www.DOMAIN.com;<br>    location / {<br>      proxy_set_header X-Real-IP $remote_addr;<br>      proxy_set_header Host $http_host;<br>      proxy_pass http://&lt;IP_ADDRESS&gt;;<br>    }<br>  }<br>}</pre><p>After updating nginx.conf apply these commands<br>Test nginx.conf sudo nginx -t<br>Restart nginx service sudo systemctl restart nginx or sudo service nginx restart<br>Check nginx status sudo systemctl status nginx or sudo service nginx status</p><h3>Issue ssl certificate from certbot</h3><p>Ref: <a href="https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/">https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/</a></p><h3>Install certbot</h3><pre>sudo apt-get update<br>sudo apt-get install certbot<br>sudo apt-get install python-certbot-nginx</pre><h3>Obtain the SSL/TLS Certificate</h3><p>sudo certbot --nginx -d example.com -d <a href="http://www.example.com/">www.example.com</a></p><p>It’ll handle the required modification for https in nginx.conf</p><h3><a href="https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/#auto-renewal">Automatically Renew Let’s Encrypt Certificates</a></h3><p>crontab -e<br>0 12 * * * /usr/bin/certbot renew --quiet</p><h3>Manually setup SSL and https configuration on nginx</h3><pre>http{<br>  server{<br>    listen 80;<br>    server_name spotcodes.in www.spotcodes.in;<br>    return 301 https://$server_name$request_uri;<br>  }</pre><pre>  server {<br>    listen 443 ssl;<br>    server_name spotcodes.in www.spotcodes.in;</pre><pre>    ssl_certificate /etc/letsencrypt/live/spotcodes.in/cert.pem;<br>    ssl_certificate_key /etc/letsencrypt/live/spotcodes.in/privkey.pem;</pre><pre>    location / {<br>    proxy_set_header X-Real-IP $remote_addr;<br>    proxy_set_header Host $http_host;<br>    proxy_pass http://3.83.202.107:2001;<br>    }<br>  }<br>}</pre><h3>Test SSL certificate installation</h3><p><a href="https://www.experte.com/ssl-check">https://www.experte.com/ssl-check</a></p><h4>Usefull links and credits</h4><ul><li><a href="https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/#auto-renewal">https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/#auto-renewal</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04">https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04</a></li><li><a href="https://levelup.gitconnected.com/how-to-install-ssl-certificate-for-nginx-server-in-amazon-linux-2986f51371fb">https://levelup.gitconnected.com/how-to-install-ssl-certificate-for-nginx-server-in-amazon-linux-2986f51371fb</a></li><li><a href="https://www.youtube.com/watch?v=X3Pr5VATOyA">https://www.youtube.com/watch?v=X3Pr5VATOyA</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2980b37c5fd" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/configure-nginx-and-ssl-on-linux-instance-2980b37c5fd">How to redirect the domain to port number using Nginx and setup SSL ?</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I created facemash app in angular]]></title>
            <link>https://raviagheda.medium.com/how-i-created-facemash-app-in-angular-9656ab6e9c26?source=rss-847765d12adc------2</link>
            <guid isPermaLink="false">https://medium.com/p/9656ab6e9c26</guid>
            <category><![CDATA[ratings]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[web]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Ravi Agheda]]></dc:creator>
            <pubDate>Fri, 11 Sep 2020 16:37:41 GMT</pubDate>
            <atom:updated>2020-09-11T16:48:31.020Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XrzP9Gnb6OHX4Iqd" /><figcaption>Photo by <a href="https://unsplash.com/@joshgmit?utm_source=medium&amp;utm_medium=referral">Joshua Golde</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Visit the site <a href="https://facemash-d8ce0.web.app/">here</a></p><p>After watching The Social Network movie I was very excited to create similar like facemash so I decided to create a web app for ranking wallpapers.</p><p>So, first of all, I needed a ranking algorithm so I did some research about Elo rating algorithms and how it works for ranking chess players</p><p>So here’s the ranking algorithm that you can use if you plan to create something like this.</p><pre>float Probability(int rating1, int rating2) <br>{ <br>    return 1.0 * 1.0 / (1 + 1.0 *  <br>           pow(10, 1.0 * (rating1 - rating2) / 400)); <br>} </pre><pre>// Function to calculate Elo rating <br>// K is a constant. <br>// d determines whether Player A wins or Player B.  <br>void EloRating(float Ra, float Rb, int K, bool d) <br>{   </pre><pre>    // To calculate the Winning <br>    // Probability of Player B <br>    float Pb = Probability(Ra, Rb); </pre><pre>    // To calculate the Winning <br>    // Probability of Player A <br>    float Pa = Probability(Rb, Ra); </pre><pre>    // Case -1 When Player A wins <br>    // Updating the Elo Ratings <br>    if (d == 1) { <br>        Ra = Ra + K * (1 - Pa); <br>        Rb = Rb + K * (0 - Pb); <br>    } </pre><pre>    // Case -2 When Player B wins <br>    // Updating the Elo Ratings <br>    else { <br>        Ra = Ra + K * (0 - Pa); <br>        Rb = Rb + K * (1 - Pb); <br>    } </pre><pre>    cout &lt;&lt; &quot;Updated Ratings:-\n&quot;; <br>    cout &lt;&lt; &quot;Ra = &quot; &lt;&lt; Ra &lt;&lt; &quot; Rb = &quot; &lt;&lt; Rb;</pre><p>This code is from <a href="https://www.geeksforgeeks.org/elo-rating-algorithm/#:~:text=Elo%20Rating%20Algorithm%20is%20widely,rating%20of%20players%20is%20updated.">Geeks for Geeks</a></p><p>So phase 1 is completed<br>Now another task was to find enough images for ranking them.<br>For that stuff, I recommend using open-source images from a site like Unsplash, pexels, pixabay, etc..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GkiM4KtChh8zCqCnTA_Faw.png" /></figure><p>After then using my angular skills I developed a web app with simple UI which shows two random images and when you click them it’s rank will be updated and you will get new images for further ranking</p><p>There’s also a dashboard where you can check the ranking of all images.</p><h4>Source Code <a href="https://github.com/raviagheda/facemash">Github</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9656ab6e9c26" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>