<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shubham Rathi</title>
    <description>The latest articles on DEV Community by Shubham Rathi (@ishubhamrathi).</description>
    <link>https://dev.to/ishubhamrathi</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%2F1211668%2Fb607b39c-35fd-4a60-9b58-31add70d2c89.jpg</url>
      <title>DEV Community: Shubham Rathi</title>
      <link>https://dev.to/ishubhamrathi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ishubhamrathi"/>
    <language>en</language>
    <item>
      <title>Must-Have Tunneling Tools for Developers: Effortlessly Expose Your Localhost in Minutes</title>
      <dc:creator>Shubham Rathi</dc:creator>
      <pubDate>Thu, 15 Aug 2024 12:31:06 +0000</pubDate>
      <link>https://dev.to/ishubhamrathi/tunnel-via-different-apps-easily-why-developers-should-consider-tunneling-jnc</link>
      <guid>https://dev.to/ishubhamrathi/tunnel-via-different-apps-easily-why-developers-should-consider-tunneling-jnc</guid>
      <description>&lt;p&gt;When working on development projects, especially on local environments, you might often need to expose your local server to the internet for testing or sharing with your team. Tunneling is your go-to solution. It works across platforms, but today, we'll focus on Ubuntu with a couple of tips that apply to other systems too. &lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use a Tunnel?
&lt;/h3&gt;

&lt;p&gt;Tunneling allows you to expose a locally running web application securely to the outside world. This is super helpful when you're:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sharing a live demo with a client&lt;/li&gt;
&lt;li&gt;Testing webhook integrations&lt;/li&gt;
&lt;li&gt;Collaborating with remote team members on development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One popular tunneling tool is Ngrok, but we'll also check out alternatives like Localtunnel and Pinggy. Each has its unique perks, so let’s dive in.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Ngrok
&lt;/h2&gt;

&lt;p&gt;Ngrok is the go-to for many devs because it’s easy to set up and has a good dashboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;For Ubuntu users, installing Ngrok is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install ngrok/ngrok/ngrok
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For other platforms, you can download Ngrok &lt;a href="https://ngrok.com/download" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;First, sign up for an account, then add your auth token:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngrok config add-authtoken &amp;lt;your-token&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start Tunneling
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ngrok http 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This exposes your local server running on port 8080 to the world via a public URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Localtunnel
&lt;/h2&gt;

&lt;p&gt;Localtunnel is another handy tool if you prefer a no-fuss setup with fewer features. It’s quick to get started and works with Node.js.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installation
&lt;/h3&gt;

&lt;p&gt;Install Localtunnel globally with npm&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install -g localtunnel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Start Tunneling
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lt --port 8080
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Bonus: Auto-reconnect
&lt;/h3&gt;

&lt;p&gt;You can set up a script to auto-reconnect in case of disconnections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;until lt --port 8085 --subdomain shubh-local --local-https false; do
  echo "Try again";
done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even create an alias for this command, making it easy to fire up the tunnel with a short keyword.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Pinggy
&lt;/h2&gt;

&lt;p&gt;If you’re looking for a lightweight solution, Pinggy might be up your alley. It’s simple and works well if you’re familiar with SSH.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start Tunneling
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh -p 443 -R0:localhost:8000 qr@a.pinggy.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This method doesn’t need much configuration, making it perfect for quick testing.&lt;/p&gt;

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

&lt;p&gt;Tunneling is an essential skill for developers who frequently work with local servers, webhooks, or need to demo apps remotely. Ngrok is still the king when it comes to features, but tools like Localtunnel and Pinggy give you more options based on your specific needs.&lt;/p&gt;

&lt;p&gt;Next time you need to share your localhost, give one of these tools a try and see which works best for you!&lt;/p&gt;

&lt;p&gt;Happy tunneling 🚀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Why main method in JAVA is declared in Static?</title>
      <dc:creator>Shubham Rathi</dc:creator>
      <pubDate>Sat, 13 Jan 2024 17:03:38 +0000</pubDate>
      <link>https://dev.to/ishubhamrathi/why-main-method-in-java-is-declared-in-static-3373</link>
      <guid>https://dev.to/ishubhamrathi/why-main-method-in-java-is-declared-in-static-3373</guid>
      <description>&lt;p&gt;The main() method is declared static so that JVM can call it without creating an instance of the class containing the main() method.&lt;/p&gt;

&lt;h3&gt;
  
  
  What if the main method is not static?
&lt;/h3&gt;

&lt;p&gt;If the main method of the java class is not static then it will throw an error, here you can try this code on any java compiler and it will throw the error.&lt;/p&gt;

&lt;p&gt;Moreover, if a JAVA class is declared without a static keyword, the JVM has to create an instance of the main Class, and because the constructor might be overloaded and include arguments, there will be no reliable and consistent way for the JVM to find the main method in Java.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class MyClass {
    public void main(String args[]) {
      System.out.println("Hello World!!");
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: Main method is not static in class MyClass, please define the main method as:
   public static void main(String[] args)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Day 1 with kotlin [Mastering Kotlin in 100 Days]</title>
      <dc:creator>Shubham Rathi</dc:creator>
      <pubDate>Sat, 13 Jan 2024 10:11:01 +0000</pubDate>
      <link>https://dev.to/ishubhamrathi/day-1-with-kotlin-mastering-kotlin-in-100-days-146a</link>
      <guid>https://dev.to/ishubhamrathi/day-1-with-kotlin-mastering-kotlin-in-100-days-146a</guid>
      <description>&lt;h2&gt;
  
  
  Variable Types in kotlin
&lt;/h2&gt;

&lt;p&gt;&lt;u&gt;var vs val&lt;/u&gt;&lt;br&gt;
The value of variable type val can not be changed later on,&lt;br&gt;
forex, &lt;strong&gt;val a = 5&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Later on, you cannot make this a = 6&lt;br&gt;
To achieve this you need to initialize this with &lt;strong&gt;var a = 5&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Set up a separate connection pool for reader and writer DB access | SpringBoot JOOQ</title>
      <dc:creator>Shubham Rathi</dc:creator>
      <pubDate>Sat, 13 Jan 2024 09:35:46 +0000</pubDate>
      <link>https://dev.to/ishubhamrathi/set-up-a-separate-connection-pool-for-reader-and-writer-db-access-springboot-jooq-3g17</link>
      <guid>https://dev.to/ishubhamrathi/set-up-a-separate-connection-pool-for-reader-and-writer-db-access-springboot-jooq-3g17</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;🔍 Disclaimer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following is based on my experience and knowledge, and may not represent the best approach or most up-to-date information. Please feel free to share your insights and correct any outdated information.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is an open dialogue; let's learn and improve together.&lt;/em&gt; 🚀&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You might be using DB in your corporate application and may need a separate connection pool for the reader and writer DB connection.&lt;/p&gt;

&lt;p&gt;One of the advantages of using this is that you can measure the no of requests your reader and writer handle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Note: Problem with existing migration
&lt;/h2&gt;

&lt;p&gt;In the initial setup, you might enter a problem where you will see your reader and writer connection are going from the connection. So, what's the cause!!&lt;/p&gt;

&lt;p&gt;The cause is simple - existing queries, you need to check if your existing queries follow some pattern to not get into this problem. This happens when you write in db and then return, this causes that reader connection to connect to the writer, make sure to make your reader and writer queries go through separate queries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up in SpringBoot a different pool connection for JOOQ
&lt;/h2&gt;

&lt;p&gt;To set up this make two different instances of DSlContxt, one for select queries and one for writing queries like insert, and update.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.jooq.DSLContext

class DSLContextResolver(
    private val reader: DSLContext,
    private val writer: DSLContext
) {
    fun getReaderContext(): DSLContext = reader

    fun getWriterContext(): DSLContext = writer
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of using direct DSLContext we will be using our custom DSLContextResolver class. For ex:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private val readerContext = dslContextResolver.getReaderContext()
private val writerContext = dslContextResolver.getWriterContext()

    fun getBookById(id: Long): Book {
        return readerContext.selectFrom(Tables.BOOK)
            .where(Tables.BOOK.ID.eq(id))
            .fetchOne()

    fun addNewBook(book: Book): Book {
        return writerContext.insertInto(Tables.BOOK)
            .set(
                Book(
                    name = book.name,
                    author = book.author,
                    pages = book.pages,
                    ratings = book.ratings,
                )
                    .toBookRecord
            )
            .returning()
            .fetchOne()!!
            .toBook
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So this is how we can achieve our target. and as earlier I discussed the problem, we can solve this by using returning, if you want to read after inserting or updating. Or, you can use your reader context separately.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Getting Started with SpringBoot in Kotlin/Java [DRAFT]</title>
      <dc:creator>Shubham Rathi</dc:creator>
      <pubDate>Sun, 07 Jan 2024 16:34:43 +0000</pubDate>
      <link>https://dev.to/ishubhamrathi/roadmap-for-backend-developers-in-springboot-javakotlin-draft-56k7</link>
      <guid>https://dev.to/ishubhamrathi/roadmap-for-backend-developers-in-springboot-javakotlin-draft-56k7</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;🔍 Disclaimer:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The following is based on my experience and knowledge, and may not represent the best approach or most up-to-date information. Please feel free to share your insights and correct any outdated information.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This is an open dialogue; let's learn and improve together.&lt;/em&gt; 🚀&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you are a beginner, you might face problems when you find resources in a particular language. My best advice is whenever you look for a resource be neutral to language as you might not find the best resource, you can always implement the same logic in another language&lt;/p&gt;

&lt;p&gt;For example in Spring Boot, if you go with Kotlin (Gradle Kotlin DSL), on the internet you might find more implementation pom.xml rather than gradle in Kotlin. But when you match both syntaxes, you will learn how to read pom.xml and can convert it on your own without any AI to gradle compatible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Note
&lt;/h2&gt;

&lt;p&gt;As a general approach before starting anything, you should know why SpringBoot and what's the alternatives in the market.&lt;/p&gt;

&lt;p&gt;Springboot is widely used in ITs as a backend, because of its flexibility and ease to maintain large services using micro service and MVC architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Springboot vs Spring Framework?
&lt;/h2&gt;

&lt;p&gt;Simple -&amp;gt; Springboot is made over spring framework allows more functionality as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easily create standalone applications.&lt;/li&gt;
&lt;li&gt;Offers production-ready features.&lt;/li&gt;
&lt;li&gt;SpringBoot is easier to launch.&lt;/li&gt;
&lt;li&gt;Easier customization and management.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prerequisite&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;IntelliJ IDE [Community/ Enterprise]&lt;/li&gt;
&lt;li&gt;Java/Kotlin &lt;/li&gt;
&lt;li&gt;Knowledge of MVC Architecture&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Getting Started with SpringBoot
&lt;/h2&gt;

&lt;p&gt;We will be creating a basic REST Server. Use &lt;a href="https://start.spring.io/"&gt;https://start.spring.io/&lt;/a&gt; to create a start template for us. You can choose your combination as per your need. I am going with Gradle-Kotlin with language Kotlin.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependency and Plugins in Springboot
&lt;/h3&gt;

&lt;p&gt;Dependency is nothing but a 'Library' that provides specific functionality that we can use in our application&lt;/p&gt;

&lt;p&gt;whereas, plugins are used to: create jar files, create war files, compile code, unit test code, create project documentation, and on and on.&lt;/p&gt;

&lt;p&gt;We will be adding some dependencies to start with.&lt;br&gt;
-Spring Web- Provides functionality like live reload of server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--feze7YcJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6guzg6dbdv44e91kk9n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--feze7YcJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6guzg6dbdv44e91kk9n.png" alt="start.srping.io-Website" width="800" height="411"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will generate a zip file, extract it, and open it on IDE. When you open this, you will see some sync going on in the background i.e. Gradle Sync, this will download all the necessary dependencies to plugins defined in build.gradle.kt file.&lt;/p&gt;

&lt;h4&gt;
  
  
  Project Structure
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.
└── src
    ├── main
    │   ├── kotlin
    │   │   └── com.example.demo
    │   │       └── Demo.Application.kt
    │   └── resources
    │       ├── static
    │       ├── template
    │       └── application.properties
    └── test
        └── kotlin
            └── com.example.demo
                └── Demo.Application.kt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;src is our classpath where is our all application logic coded.&lt;/p&gt;

&lt;h3&gt;
  
  
  DemoApplication.kt Explained
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@SpringBootApplication
class DemoApplication

fun main(args: Array&amp;lt;String&amp;gt;) {
    runApplication&amp;lt;DemoApplication&amp;gt;(*args)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;@SpringBootApplication This is provided by springboot annotations, we will look at some annotations and their use cases.&lt;/p&gt;

&lt;p&gt;The @SpringBootApplication annotation is equivalent to using &lt;strong&gt;@Configuration&lt;/strong&gt;, &lt;strong&gt;@EnableAutoConfiguration&lt;/strong&gt;, and &lt;strong&gt;@ComponentScan&lt;/strong&gt; with their default attributes, as shown in the following example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;@EnableAutoConfiguration:&lt;/strong&gt; enable Spring Boot’s auto-configuration mechanism&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@ComponentScan:&lt;/strong&gt; enable @Component scan on the package where the application is located&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;@Configuration:&lt;/strong&gt; allow to register extra beans in the context or import additional configuration classes&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Beans in SpringBoot
&lt;/h3&gt;

&lt;p&gt;Beans are just like objects of classes, but these are not objects of class, these are objects of spring framework context and managed by spring&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
