<?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 Atharv Bhadange on Medium]]></title>
        <description><![CDATA[Stories by Atharv Bhadange on Medium]]></description>
        <link>https://medium.com/@bhadange.atharv?source=rss-440eb7c323c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*-maK9Y9YMrZZ4OIc</url>
            <title>Stories by Atharv Bhadange on Medium</title>
            <link>https://medium.com/@bhadange.atharv?source=rss-440eb7c323c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:42:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhadange.atharv/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[AlphaSense Interview Experience]]></title>
            <link>https://medium.com/@bhadange.atharv/alphasense-interview-experience-85f731b6101a?source=rss-440eb7c323c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/85f731b6101a</guid>
            <category><![CDATA[alphasense]]></category>
            <category><![CDATA[on-campus]]></category>
            <category><![CDATA[interview-experience]]></category>
            <category><![CDATA[full-stack-developer]]></category>
            <category><![CDATA[freshers]]></category>
            <dc:creator><![CDATA[Atharv Bhadange]]></dc:creator>
            <pubDate>Fri, 31 May 2024 10:42:35 GMT</pubDate>
            <atom:updated>2024-06-24T06:27:21.355Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T4jexV-An1lhWhkgqki7bQ.png" /></figure><p>Embarking on an interview with a dream company is always a mix of excitement and nerves. My interview with AlphaSense, a leading Market Intelligence and Search platform, was no exception. As the last major company to visit our college for the batch of 2024, for the Software Engineer I role.</p><p>In this blog, I’ll take you through each round of the interview process and share my insights and key takeaways. Whether you’re preparing for a similar role or just curious about the process, stick around — there’s plenty to learn!</p><p>The interview journey comprised four rounds:</p><ol><li><strong>Coding Round</strong> (58 minutes)</li><li><strong>Tech 1</strong> (DSA-based, 45 minutes)</li><li><strong>Tech 2</strong> (CS fundamentals and résumé, 45 minutes)</li><li><strong>Director Round</strong> (30 to 45 minutes)</li></ol><p>All these rounds were conducted remotely. <br>Now, let’s delve into each round, as the process unfolded with increasing intrigue. Stick around till the end for the full story!</p><h3>1. Coding Round</h3><p>The coding round, conducted on the Hackerrank platform, was divided into three sections, each with its time constraints:</p><ol><li><strong>Coding Section</strong> — 2 questions — 40 minutes</li><li><strong>SQL</strong> — 2 questions — 10 minutes</li><li><strong>Problem-solving</strong> — 4 questions — 8 minutes</li></ol><p>Sections were randomly ordered for each candidate, and any time saved from one section was carried over to the next.</p><h3>1.1 Coding Section</h3><ol><li>The first question was a multiple-choice question (MCQ) focusing on HTTP requests, testing the understanding of how POST, PATCH, and GET methods operate.</li><li>The second question was rather unconventional, not commonly encountered in competitive programming contests or on platforms like LeetCode.</li></ol><ul><li>Given CSV data containing employee information such as Name, Department, and Years of Experience, candidates were tasked with performing one of three operations: finding the maximum experience, counting the number of employees in a department, and one other operation.</li><li>Seemingly straightforward, right? However, there was a twist. An additional note was provided which was initially overlooked by me.</li><li>The note highlighted that the data should be considered erroneous, akin to real-world input. This meant certain fields could be empty or of the wrong data type (e.g., Years of Experience could be a string, or a Name could be missing).</li><li>We had to handle these cases appropriately, ignoring erroneous entries while performing any aggregations.</li><li>By addressing each scenario meticulously, I successfully passed all 11 test cases. ✅</li></ul><h3>1.2 SQL</h3><p>Two SQL queries were asked:</p><ol><li>One revolving around understanding JOIN operations.</li><li>The other centred on aggregation principles.</li></ol><h3>1.3 Problem-Solving Section</h3><p>This section encompassed aptitude-based MCQs and one code snippet, requiring candidates to compute the output.</p><p>Results for this round were announced the same night, with 20 students, myself included, progressing to Tech 1, while a few others were placed on the waitlist.</p><h3>2. Tech 1</h3><p>Tech 1 primarily delved into DSA concepts. The interviewer commenced by introducing himself and inquired about my introduction. Drawing from my response, he followed up with questions regarding Docker, Golang, and Node.js. Subsequently, he transitioned to topics like dynamic programming and greedy approaches, seeking thorough explanations. This segment spanned approximately 15 minutes. After this, he directed me to an interactive code editor on HackerRank and presented a question.</p><p>The question revolved around identifying the index in the original sorted array from which the input array, which was a rotated version of the original, was derived. For instance:</p><ul><li>Initial Array: [1, 2, 3, 4, 5, 6, 7, 8] (zero-based index)</li><li>Input Array: [4, 5, 6, 7, 8, 1, 2, 3]</li><li>Output: k = 2</li></ul><p>Initially, I proposed a brute-force approach employing linear search. The interviewer asked about the time complexity of this solution and urged me to devise a more efficient strategy. Recognizing the potential for binary search, I began thinking of conditions to eliminate array halves. Though initially I was a bit confused with the conditions, the interviewer offered occasional hints, guiding me through the process. With only 10 minutes remaining, the interviewer prompted me to begin coding the solution. Despite not addressing all cases in the code within the time frame, my coding style and thought process were appraised positively.</p><p>Three key factors facilitated my success in this round:</p><ul><li><strong>Thinking Out Loud</strong>: Transforming the interview into a dialogue rather than a mere question-and-answer session.</li><li><strong>Coding Style and Thought Process Evaluation</strong>: Even with incomplete code, my approach was evaluated favourably.</li><li><strong>Asking Impactful Questions</strong>: Leveraging questions as opportunities for discussion, showcasing engagement and initiative.</li></ul><p>Ten students, myself included, advanced to the next round, marking a significant achievement.</p><h3>3. Tech 2</h3><p>Tech 2 delved deeply into the specifics of one line from my resume. Beginning with introductions, the interviewer scrutinized the languages listed on my resume and probed the extent of my proficiency in each. Our conversation revolved around comparing Golang and Java, delving into why I favoured Golang over Java.</p><p>Subsequently, he directed his attention to one of my internship experiences, focusing on a particular task mentioned in my resume. Going beyond the surface of a typical internship task, he dissected the intricacies of dealing with external dependencies. While conventional tasks often involve working within a pre-existing framework, he challenged me to envision scenarios where I would need to build these dependencies from scratch.</p><p>The discussion gradually unravelled into a meticulous exploration of implementing dependencies’ dependencies, encompassing data storage, queuing mechanisms, and the utilization of cron jobs. Throughout, the interviewer reiterated that there was no single correct solution; rather, he sought insight into my approach and thought process. Once again, transforming the interview into an interactive discussion proved invaluable.</p><p>Finally, he asked me about my understanding of normalization. Despite exceeding the allotted 45 minutes by around 10 minutes, he graciously entertained my questions and provided valuable feedback.</p><p>This round was one of the most thought-intensive rounds I gave in my college journey, challenging me to articulate and defend my methodologies and decisions.</p><p>Only four students, myself included, were shortlisted for the final round.</p><h3>4. Director Round</h3><p>The final leg of the interview process aimed to explore aspects of all-round learning, adaptability, and cultural alignment. Commencing with introductions, the interviewer initiated a discussion about my educational and family background.</p><p>Throughout the session, the interviewer posed thought-provoking questions like:</p><ol><li><strong>Beyond Tech</strong>: Apart from tech, in what domain do you think you might be in the top 10% in India?</li><li><strong>Out-of-the-Box Thinking</strong>: He followed up on the answer to my previous question with a case study discussion about any out-of-the-box features that I can think of about a tech platform for event management</li><li><strong>Lottery Scenario</strong>: Say you won a 1 CR lottery and, you only have 10 days to spend it(starting from today), how would you spend the money? The constraint is that whatever things that you spend on will be taken away after the 10 days. (DM me to know my response)</li><li><strong>Company Selection Criteria</strong>: What parameters would you judge a company before joining given that you have an offer from let’s say 3 of them and the compensation is the same for all of them. He followed up on my answer by asking which of the above parameters is non-negotiable, what company size (number of people) do you prefer, etc.</li></ol><p>As our conversation extended beyond the allocated time(about 15 minutes), the interviewer asked if I had any questions. This exchange was one of the most enjoyable and enriching discussions I’ve had, particularly with someone occupying such a high-ranking position. We communicated in Marathi, Hindi and English and it felt like a natural conversation.</p><p>Within 15 to 20 minutes, the results were announced. I was elated to discover that I was one of the two individuals selected for the role, marking a triumphant conclusion to a challenging yet rewarding college journey. 🎉</p><h3>Key Takeaways:</h3><ol><li><strong>Convert the Interview into a Discussion</strong>: Engage actively and think out loud to transform the interview from a rigid Q&amp;A session into an interactive and insightful dialogue.</li><li><strong>Ask Follow-up Questions</strong>: Tailor your questions based on previous exchanges with the interviewer, avoiding common and overused queries. This demonstrates attentiveness and engagement.</li><li><strong>Consider the Interview’s Role</strong>: Direct your questions according to the interviewer’s role within the company. For instance, ask about company culture when speaking to HR, delve into technical topics with engineers, and explore business questions with those who might have relevant insights.</li><li><strong>Seek Feedback</strong>: End the interview by asking for feedback about your performance. It provides valuable insights and helps gauge the interviewer’s perception of you.</li></ol><p>Keep going when everyone thinks you are crazy to turn down an offer, believe in yourself and strive for what you deserve.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85f731b6101a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Go REST API Boilerplate]]></title>
            <link>https://medium.com/@bhadange.atharv/go-rest-api-boilerplate-c9d25f99acbe?source=rss-440eb7c323c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9d25f99acbe</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[template]]></category>
            <dc:creator><![CDATA[Atharv Bhadange]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 04:19:21 GMT</pubDate>
            <atom:updated>2024-02-02T04:19:42.602Z</atom:updated>
            <content:encoded><![CDATA[<h3>Streamlined Development with GoFiber and PostgreSQL</h3><p>Building RESTful APIs in Go became much easier, thanks to this fantastic boilerplate that leverages the lightning-fast GoFiber framework and the robust PostgreSQL database. This well-structured project provides a solid foundation for your API development, freeing you to focus on your core application logic rather than reinventing common patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/0*hhoa21FELORspjmd" /></figure><p>The boilerplate adheres to best practices and offers a clean, organized structure to ensure maintainability and scalability.</p><h3>Folder Structure:</h3><ul><li>/api/v1 Encapsulates all API version 1 routes, controllers, services, and middleware.</li><li>/cmd Initialises the Fiber app and sets up basic middleware configurations.</li><li>/config Handles configuration and environment variables.</li><li>/db Manages database connections and interactions.</li><li>/handlers Manages responses and database transactions.</li><li>/models Contains auto-generated models from database tables using <a href="https://pkg.go.dev/github.com/volatiletech/sqlboiler/v4@v4.16.1">sqlboiler</a>.</li><li>/secure Stores SSL certificates (excluded from version control).</li><li>/types Defines custom types for cross-app usage.</li><li>/utils Provides utility functions.</li><li>main.go The entry point of the application.</li></ul><h3>How to Get Started</h3><ol><li><strong>Clone the Repo:</strong> Begin by cloning the repository to your local machine.</li><li><strong>Rename your projects:</strong> Replace the placeholder atharvbhadange/go-api-template with &lt;your-github-id/project-name&gt;.</li><li><strong>Install Dependency:</strong> Make sure you have Go installed and then run go install github.com/volatiletech/sqlboiler/v4/drivers/sqlboiler-psql@latest to install sqlboiler for model generation.</li><li><strong>Configure Database:</strong> Adjust the models/sqlboiler.toml file to match your PostgreSQL database configuration.</li><li><strong>Generate Models:</strong> Generate Go models from your database tables using sqlboiler psql within the models folder. Organise the generated models into the root models folder.</li><li><strong>Install Dependencies:</strong> Run go mod tidy to install all dependencies.</li><li><strong>Set Up Environment Variables:</strong> Create a .env file based on the .env.example template and fill in your specific configurations.</li><li><strong>Build and Run:</strong> Build the application using go build -o ./build/main &amp;&amp; ./build/main.</li></ol><h3>Optional Hot Reloading:</h3><p>For a more dynamic development experience, enable hot reloading with the following steps:</p><ol><li>Install <a href="https://github.com/cosmtrek/air">air</a>: Run go get github.com/cosmtrek/air.</li><li>Start with Hot Reloading: Start the app with hot reloading using air.</li></ol><h3>Additional Notes and Best Practices:</h3><ul><li>The boilerplate includes a <em>sample product API</em> implementation for reference.</li><li>It’s recommended to start new <em>PGX transactions</em> from controllers only.</li><li>All routes, except for the health check endpoint, are located under the /api/v1 path.</li><li>For better organisation, the models folder can be managed as a separate Git submodule.</li></ul><p>Ready to Build Efficient and Scalable REST APIs?</p><p>Source Code Attached here:</p><p><a href="https://github.com/atharv-bhadange/go-api-template">https://github.com/atharv-bhadange/go-api-template</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9d25f99acbe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-Node Setup using Citus]]></title>
            <link>https://medium.com/@bhadange.atharv/citus-multi-node-setup-69c900754da3?source=rss-440eb7c323c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/69c900754da3</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ec2-instance]]></category>
            <dc:creator><![CDATA[Atharv Bhadange]]></dc:creator>
            <pubDate>Mon, 15 Jan 2024 05:53:26 GMT</pubDate>
            <atom:updated>2024-01-15T05:59:15.391Z</atom:updated>
            <content:encoded><![CDATA[<p>This is part 2 of my blog series; check out the first part <a href="https://medium.com/p/21a0ef5efb30">here</a>.</p><h3>Prerequisites</h3><ol><li>Understanding of AWS EC2 instances</li><li>SSH protocol</li><li>Docker</li></ol><p>Start by launching two EC2 instances, designating one as the master node and the other as the worker node.</p><p>Opt for the Ubuntu image instead of Amazon Linux, and maintain the free tier defaults for instance types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yYKIErS3usx2Z3qVq-pcTA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hcA6VIA9Sh5nEdz0Hg0reA.png" /></figure><p>Create a key pair and download the certificate, which will be instrumental for SSH access. The security group required will be automatically generated.</p><p>Upon the successful launch of the master node, similarly, initiate another instance for the worker node. Add an inbound rule for PostgreSQL traffic to the newly created security group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zjDtkqx7jvno45zQWBK8zg.png" /></figure><p>To establish a connection with the instances, utilize an SSH client, employing the downloaded key for authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qC-71yuvk0YrO-FzvphCzw.png" /></figure><p>Next, install Docker on the instances to facilitate the execution of a Citus container. Update the system and install Docker using the following commands:</p><pre>sudo apt-get update<br>sudo snap install docker</pre><p>Start the Docker service with:</p><pre>sudo snap start docker</pre><p>Now, run the Citus container on the master node using:</p><pre>sudo docker run -d --name master -p 5432:5432 -e POSTGRES_PASSWORD=your_password citusdata/citus:alpine</pre><p>Verify the successful launch of the container by checking its status:</p><pre>sudo docker ps</pre><p>Repeat the same procedure on the worker node, naming the container running there as “worker.”</p><p>Adjust your application’s code to connect to the master node by modifying the host in the code snippet provided and running the server:</p><pre>dsn := &quot;host=&lt;your-instance-ip&gt; user=postgres password=your_password port=5432 sslmode=disable timezone=Asia/Kolkata&quot;</pre><p>Now, if you inspect the schema migrations by connecting to the running container on the master node by:</p><pre>sudo docker exec -it master psql -U postgres<br><br>\dt+</pre><p>You will see logs table on the master node, but not on the worker node.</p><p>Introduce some data to the logs table on the worker node using a Python script. This process may take a while due to network latency.</p><p>Proceed to shard the table by executing the following SQL query:</p><pre>SELECT create_distributed_table(&#39;logs&#39;, &#39;id&#39;);</pre><p>Designate the master node as the coordinator:</p><pre>SELECT citus_set_coordinator_host(&#39;&lt;hostname or your ip address&gt;&#39;, 5432);</pre><p>Add the Citus-worker instance as a worker node:</p><pre>SELECT citus_add_node(&#39;&lt;hostname or your ip address&gt;&#39;, 5432);</pre><p>Upon inspecting the tables on the worker instance, you will witness the successful completion of the Citus multi-node setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FbDN34jIa6GPyRpH1NIBzw.png" /></figure><p>PS: I have added 2 worker instances, hence it is showing 3 nodes in above image.</p><p>Find full implementation here: <a href="https://github.com/atharv-bhadange/log-ingestor">https://github.com/atharv-bhadange/log-ingestor</a></p><p><em>PPS: Your corrections/improvements are welcome!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69c900754da3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sharding PostgreSQL with Citus and Golang on GoFiber]]></title>
            <link>https://medium.com/@bhadange.atharv/sharding-postgresql-with-citus-and-golang-on-gofiber-21a0ef5efb30?source=rss-440eb7c323c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/21a0ef5efb30</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[database-sharding]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[horizontal-scaling]]></category>
            <dc:creator><![CDATA[Atharv Bhadange]]></dc:creator>
            <pubDate>Tue, 12 Dec 2023 07:43:40 GMT</pubDate>
            <atom:updated>2024-01-15T06:00:08.044Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sharding PostgreSQL with Citus and Golang</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*0cCsslOdvkAVhB_E.png" /></figure><p>In the world of data, scaling vertically has its limits. As we tread the path of managing vast amounts of information, the concept of sharding emerges as a powerful ally. Sharding not only distributes the data load but also unlocks the potential for seamless scalability. In the realm of micro-services, when dealing with log data, sharding becomes an indispensable strategy. In this guide, we embark on a journey to implement database sharding using the <a href="https://www.citusdata.com/">Citus</a> extension for PostgreSQL, complemented by a Golang backend powered by the GoFiber framework.</p><p>Before diving into the implementation, ensure you have a solid grasp of:</p><ol><li><a href="https://go.dev/">Golang</a> and the <a href="https://gofiber.io/">GoFiber</a> framework.</li><li><a href="https://www.postgresql.org/">PostgreSQL</a> fundamentals.</li><li><a href="https://www.docker.com/">Docker</a> container basics.</li></ol><h3>Step 1: Setting the Foundation with GoFiber</h3><ol><li><strong>Initializing the project:</strong></li></ol><pre>go mod init github.com/&lt;your-github&gt;/log-ingestor</pre><pre># folder structure<br>log-ingestor/<br>	|-- contoller/base.go<br>	|-- service/base.go<br>	|-- routes/base.go<br>	|-- db/db.go<br>	|-- model/log.go<br>	|-- script/call_script.py<br>	|-- go.mod<br>	|-- go.sum<br>	|-- main.go</pre><p>2. <strong>Adding GoFiber package:</strong></p><pre>go get github.com/gofiber/fiber/v2</pre><p>3.<strong> Initialising the Fiber app and setting up default routes:</strong></p><pre>// main.go<br>package main<br><br>import (<br> &quot;github.com/atharv-bhadange/log-ingestor/routes&quot;<br> &quot;github.com/gofiber/fiber/v2&quot;<br>)<br><br>func main() {<br> app := fiber.New()<br> routes.Setup(app)<br> app.Listen(&quot;:3000&quot;)<br>}</pre><p>Under routes/base.go, add the Setup function used in the above code</p><pre>// routes/base.go<br>package routes<br><br>import (<br> &quot;github.com/atharv-bhadange/log-ingestor/controller&quot;<br> &quot;github.com/gofiber/fiber/v2&quot;<br>)<br><br>func Setup(app *fiber.App) {<br> app.Get(&quot;/&quot;, controller.HealthCheck)<br>}</pre><p>Add the HealthCheck function to controller/base.go</p><pre>// controller/base.go<br>package controller<br><br>import (<br> &quot;github.com/gofiber/fiber/v2&quot;<br>)<br><br>func HealthCheck(c *fiber.Ctx) error {<br> return c.Status(200).JSON(model.Response{<br>  Status:  200,<br>  Message: &quot;Server is up and running&quot;,<br>  Data:    nil,<br> })<br>}</pre><p>Build and run the server to check for any errors so far</p><pre>go build -o main &amp;&amp; ./main</pre><h3>Step 2: Integrating CitusData for Distributed Database Magic:</h3><ol><li><strong>Installing and configuring CitusData:</strong></li></ol><pre>docker run -d --name coordinator -p 5432:5432 -e POSTGRES_PASSWORD=your_password citusdata/citus:12.1</pre><p>2. <strong>Connecting to the database using </strong><a href="https://gorm.io/index.html"><strong>GORM</strong></a><strong> as our ORM:</strong></p><pre># add gorm package<br>go get -u gorm.io/gorm<br>go get gorm.io/driver/postgres</pre><p>Add a function under db/db.go to connect to the database</p><pre>package db<br><br>import (<br> &quot;log&quot;<br> &quot;gorm.io/driver/postgres&quot;<br> &quot;gorm.io/gorm&quot;<br>)<br><br>var (<br> Db *gorm.DB<br>)<br><br>func Connect() error {<br> dsn := &quot;host=localhost user=postgres password=your_password port=5432 sslmode=disable&quot;<br> var err error<br> Db, err = gorm.Open(postgres.Open(dsn), &amp;gorm.Config{})<br> if err != nil {<br>  return err<br> }<br> log.Println(&quot;Database connected&quot;)<br> return nil<br>}</pre><p>3. <strong>Defining the structure for log messages.</strong></p><pre>{<br>  &quot;level&quot;: &quot;error&quot;,<br>  &quot;message&quot;: &quot;Failed to connect to DB&quot;,<br>  &quot;resourceId&quot;: &quot;server-1234&quot;,<br>  &quot;timestamp&quot;: &quot;2023-09-15T08:00:00Z&quot;,<br>  &quot;traceId&quot;: &quot;abc-xyz-123&quot;,<br>  &quot;spanId&quot;: &quot;span-456&quot;,<br>  &quot;commit&quot;: &quot;5e5342f&quot;,<br>  &quot;metadata&quot;: &quot;{&#39;source&#39;: &#39;client&#39;}&quot;<br>}</pre><p>Write a corresponding struct for it under model/log.go</p><pre>package model<br><br>import &quot;time&quot;<br><br>type Log struct {<br> ID         uint      `json:&quot;id&quot; gorm:&quot;column:id&quot;`<br> Level      string    `json:&quot;level&quot; gorm:&quot;column:level&quot;`<br> Message    string    `json:&quot;message&quot; gorm:&quot;column:message&quot;`<br> ResourceId string    `json:&quot;resourceId&quot; gorm:&quot;column:resourceId&quot;`<br> Timestamp  time.Time `json:&quot;timestamp&quot; gorm:&quot;column:timestamp&quot;`<br> TraceId    string    `json:&quot;traceId&quot; gorm:&quot;column:traceId&quot;`<br> SpanId     string    `json:&quot;spanId&quot; gorm:&quot;column:spanId&quot;`<br> Commit     string    `json:&quot;commit&quot; gorm:&quot;column:commit&quot;`<br> Metadata   string    `json:&quot;metadata&quot; gorm:&quot;column:metadata&quot;`<br>}<br><br>type Response struct {<br> Status  int         `json:&quot;status&quot;`<br> Message string      `json:&quot;message&quot;`<br> Data    interface{} `json:&quot;data&quot;`<br>}</pre><p><strong>Note:</strong> ‘id’ is kept simple uint which will be used to shard the database and the Response struct is used to structure the response from the endpoints.</p><h3>Step 3: Migrating to Database:</h3><ol><li><strong>Creating and migrating the Log table:</strong></li></ol><p>Add these lines after connecting to the database:</p><pre>err = Db.AutoMigrate(&amp;model.Log{})<br>if err != nil {<br>	return err<br>}<br><br>log.Println(&quot;Database migrated&quot;)</pre><p>Now, when you start the server, we are connected to the database and our Log table is migrated. We can verify this by connecting to the coordinator container and having a look at the tables present in it.</p><pre># to connect<br>docker exec -it coordinator psql -U postgres<br><br># to check tables<br>\dt</pre><h3>Step 4: Crafting Endpoints and Testing:</h3><ol><li><strong>Implementing CRUD endpoints:</strong></li></ol><pre>// routes/base.go<br>app.Post(&quot;/log&quot;, controller.AddLog)<br><br>app.Get(&quot;/log&quot;, controller.GetLog)<br><br>app.Get(&quot;/log/:id&quot;, controller.GetLogById)</pre><pre>// controller/base.go<br>func AddLog(c *fiber.Ctx) error {<br> var log model.Log<br><br> if err := c.BodyParser(&amp;log); err != nil {<br>  return c.Status(400).JSON(model.Response{<br>   Status:  400,<br>   Message: &quot;Bad request&quot;,<br>   Data:    nil,<br>  })<br> }<br><br> log, err := service.AddLog(log)<br> if err != nil {<br>  return c.Status(500).JSON(model.Response{<br>   Status:  500,<br>   Message: &quot;Internal server error&quot;,<br>   Data:    nil,<br>  })<br> }<br><br> return c.Status(200).JSON(model.Response{<br>  Status:  200,<br>  Message: &quot;Log added successfully&quot;,<br>  Data:    log.Message,<br> })<br>}<br><br><br>func GetLog(c *fiber.Ctx) error {<br><br> logs, err := service.GetLog()<br> if err != nil {<br>  return c.Status(500).JSON(model.Response{<br>   Status:  500,<br>   Message: &quot;Internal server error&quot;,<br>   Data:    nil,<br>  })<br> }<br><br> return c.Status(200).JSON(model.Response{<br>  Status:  200,<br>  Message: &quot;Log fetched successfully&quot;,<br>  Data:    logs,<br> })<br>}<br><br><br>func GetLogById(c *fiber.Ctx) error {<br><br> id_str := c.Params(&quot;id&quot;)<br> id, err := strconv.Atoi(id_str)<br> if err != nil {<br>  return c.Status(400).JSON(model.Response{<br>   Status:  400,<br>   Message: &quot;Bad request&quot;,<br>   Data:    nil,<br>  })<br> }<br><br> log, err := service.GetLogById(id)<br> if err != nil {<br>  return c.Status(500).JSON(model.Response{<br>   Status:  500,<br>   Message: &quot;Internal server error&quot;,<br>   Data:    nil,<br>  })<br> }<br><br> return c.Status(200).JSON(model.Response{<br>  Status:  200,<br>  Message: &quot;Log fetched successfully&quot;,<br>  Data:    log,<br> })<br>}</pre><pre>// service/base.go<br>package service<br><br>import (<br> &quot;github.com/atharv-bhadange/log-ingestor/db&quot;<br> &quot;github.com/atharv-bhadange/log-ingestor/model&quot;<br>)<br><br>func AddLog(log model.Log) (model.Log, error) {<br> tx := db.Db.Create(&amp;log)<br> if tx.Error != nil {<br>  return model.Log{}, tx.Error<br> }<br> return log, nil<br>}<br><br>func GetLog() ([]model.Log, error) {<br> var logs []model.Log<br> tx := db.Db.Order(&quot;id&quot;).Find(&amp;logs)<br> if tx.Error != nil {<br>  return nil, tx.Error<br> }<br> return logs, nil<br>}<br><br>func GetLogById(id int) (model.Log, error) {<br> var log model.Log<br> tx := db.Db.Where(&quot;id = ?&quot;, id).First(&amp;log)<br> if tx.Error != nil {<br>  return model.Log{}, tx.Error<br> }<br> return log, nil<br>}</pre><p>2. <strong>Testing the server and data manipulation:</strong></p><p>Under script/call_script.py, I have added a Python script to call the post endpoint and add dummy data. Tune the number of requests and sleep time as you need</p><pre>import requests<br>import json<br>import time<br>from datetime import datetime, timedelta<br>import random<br><br># Define variations for each field<br>levels = [&quot;info&quot;, &quot;warning&quot;, &quot;error&quot;, &quot;critical&quot;, &quot;debug&quot;]<br>messages = [&quot;Connection established&quot;, &quot;Failed to connect to DB&quot;, &quot;Resource not found&quot;, &quot;User not authenticated&quot;, &quot;User not authorized&quot;, &quot;Invalid request&quot;, &quot;Invalid response&quot;, &quot;Request timed out&quot;]<br>resource_ids = [&quot;server-1234&quot;, &quot;server-5678&quot;, &quot;server-91011&quot;, &quot;server-121314&quot;, &quot;server-151617&quot;, &quot;server-181920&quot;]<br>trace_ids = [&quot;abc-xyz-123&quot;, &quot;def-uvw-456&quot;, &quot;ghi-rst-789&quot;, &quot;jkl-mno-101112&quot;, &quot;pqr-stu-131415&quot;, &quot;vwx-efg-161718&quot;]<br>span_ids = [&quot;span-123&quot;, &quot;span-456&quot;, &quot;span-789&quot;, &quot;span-101112&quot;, &quot;span-131415&quot;, &quot;span-161718&quot;]<br>commits = [&quot;5e5342f&quot;, &quot;a1b2c3d&quot;, &quot;e4f5g6h&quot;, &quot;i7j8k9l&quot;, &quot;m0n1o2p&quot;, &quot;q3r4s5t&quot;]<br>metadata_values = [&quot;{&#39;key&#39;: &#39;value&#39;}&quot;, &quot;{&#39;type&#39;: &#39;log&#39;}&quot;, &quot;{&#39;source&#39;: &#39;app&#39;}&quot;, &quot;{&#39;source&#39;: &#39;server&#39;}&quot;, &quot;{&#39;source&#39;: &#39;client&#39;}&quot;, &quot;{&#39;source&#39;: &#39;database&#39;}&quot;]<br><br># Generate timestamps for the past 6 months<br>end_time = datetime.utcnow()<br>start_time = end_time - timedelta(days=180)<br><br># Function to generate a random timestamp within the specified range<br>def generate_random_timestamp():<br>    return start_time + timedelta(seconds=random.randint(0, int((end_time - start_time).total_seconds())))<br><br># API endpoint<br>api_url = &quot;http://localhost:3000/log&quot;<br><br># Number of requests<br>num_requests = 500<br><br>for _ in range(num_requests):<br>    data = {<br>        &quot;level&quot;: random.choice(levels),<br>        &quot;message&quot;: random.choice(messages),<br>        &quot;resourceId&quot;: random.choice(resource_ids),<br>        &quot;timestamp&quot;: generate_random_timestamp().strftime(&quot;%Y-%m-%dT%H:%M:%SZ&quot;),<br>        &quot;traceId&quot;: random.choice(trace_ids),<br>        &quot;spanId&quot;: random.choice(span_ids),<br>        &quot;commit&quot;: random.choice(commits),<br>        &quot;metadata&quot;: random.choice(metadata_values)<br>    }<br><br>    # Convert data to JSON<br>    json_data = json.dumps(data)<br><br>    # Make a POST request to the API<br>    response = requests.post(api_url, data=json_data, headers={&quot;Content-Type&quot;: &quot;application/json&quot;})<br><br>    # Print the response status code and sleep for 10ms<br>    print(f&quot;Status Code: {response.status_code}&quot;)<br>    time.sleep(0.01)</pre><h3>Step 5: Distributing Data Across Multiple Shards:</h3><p>Under the Postgres command line execute</p><pre>-- Convert the table to a distributed table, partition my &#39;id&#39; column<br>SELECT create_distributed_table(&#39;logs&#39;, &#39;id&#39;);</pre><p>This will automatically distribute the existing table’s data into multiple shards Create an index over the id column to create a distributed index</p><pre>CREATE INDEX log_id ON logs(id);</pre><p>To check the actual shard metadata try running</p><pre>SELECT * FROM citus_shards;</pre><p>You can see 32 shards created for your table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tWewJGIs8ZJarD0bemhgzw.png" /></figure><p>To check the placement of shards over the nodes:</p><pre>SELECT * from pg_dist_placement;</pre><p>As we are running on a single node, all the shards are in groupid 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*8KUIxNaN65mH127vxQv32g.png" /></figure><h3>Step 6: Scaling Beyond a Single Node:</h3><p>As we wrap up this chapter, anticipate the next instalment where we venture into setting up a <a href="https://medium.com/@bhadange.atharv/citus-multi-node-setup-69c900754da3">multi-node cluster</a> using <strong>AWS EC2 instances</strong>. Stay tuned for more insights, and if you enjoyed this journey, leave a 👏 to show your appreciation!</p><p>Find full implementation here: <a href="https://github.com/atharv-bhadange/log-ingestor">https://github.com/atharv-bhadange/log-ingestor</a></p><p><em>PS: Your corrections/improvements are welcome!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21a0ef5efb30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Real-Time Chat Application with gRPC and Go]]></title>
            <link>https://medium.com/@bhadange.atharv/building-a-real-time-chat-application-with-grpc-and-go-aa226937ad3c?source=rss-440eb7c323c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa226937ad3c</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[grpc]]></category>
            <dc:creator><![CDATA[Atharv Bhadange]]></dc:creator>
            <pubDate>Fri, 03 Nov 2023 17:40:35 GMT</pubDate>
            <atom:updated>2023-11-03T17:42:41.172Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*XNMpzy3PHD-aV26m.jpg" /></figure><p>gRPC, an open-source Remote Procedure Call framework, offers efficient communication between client and server applications. To make gRPC work, you need a well-defined message structure, which is defined in a Protocol Buffers (protobuf) file. In this article, we’ll show you how to set up a real-time chat application using gRPC in Go, including protobuf message definition and server-side implementation.</p><p>Prerequisites: Before diving into the tutorial, make sure you have a basic understanding of Go programming and goroutines. Familiarity with protobuf will also be beneficial.</p><p>Setting Up the Project:</p><ol><li>Start by creating a <strong>proto</strong> directory within your project&#39;s root directory to store your protobuf file.</li><li>Define your message structures in the protobuf file. While for this blog, we keep all the messages in one file, it’s good practice to structure your files logically.</li></ol><pre>syntax = &quot;proto3&quot;;<br><br>package chat;<br><br>option go_package = &quot;/gen&quot;;<br><br>import &quot;google/protobuf/timestamp.proto&quot;;<br><br>message User {<br>  string id = 1;<br>  string name = 2;<br>}<br><br>message Message {<br>  string id = 1;<br>  string content = 2;<br>  google.protobuf.Timestamp timestamp = 3;<br>}<br><br>message Connect {<br>  User user = 1;<br>  bool active = 2;<br>}<br><br>message Close {}<br><br>service Broadcast {<br>  rpc CreateStream(Connect) returns (stream Message);<br>  rpc BroadcastMessage(Message) returns (Close);<br>}</pre><p>Generating Go Code: To generate Go code from the protobuf structure, you need to install the Protocol Buffers compiler and its Go plugin. You can follow the installation guide on the gRPC official website (<a href="https://grpc.io/docs/languages/go/quickstart/">https://grpc.io/docs/languages/go/quickstart/</a>).</p><p>After installation, use the following command to generate the Go code:</p><pre>protoc --go_out=. --go-grpc_out=. proto/chat.proto</pre><p>This command creates a <strong>gen</strong> directory with two autogenerated files with <strong>.pb.go</strong> extensions. Remember not to edit these files.</p><p>Handling Import Errors: If you encounter import errors in the generated files, resolve them by running the following commands:</p><pre>go get -u github.com/golang/protobuf/{proto,protoc-gen-go}<br>go get -u google.golang.org/grpc</pre><p>Now, you’re ready to start coding the server side of your gRPC chat application.</p><p><strong>Server Implementation:</strong> First, create handler functions and services as defined in the protobuf file. To handle connections and maintain a pool of connections, you’ll need to define some Go structs.</p><pre>type Connection struct {<br>	proto.UnimplementedBroadcastServer<br>	stream proto.Broadcast_CreateStreamServer<br>	id     string<br>	active bool<br>	error  chan error<br>}<br><br>type Pool struct {<br> proto.UnimplementedBroadcastServer<br> Connection []*Connection<br>}</pre><p>Here, the <strong>proto</strong> directory refers to the <strong>/gen</strong> directory we previously created.</p><p>To implement the <strong>BroadcastServer</strong> interface, embed the <strong>UnimplementedBroadcastServer</strong> struct in your struct. The <strong>CreateStream</strong> function connects and listens to messages published in a group.</p><pre>func (p *Pool) CreateStream(pconn *proto.Connect, stream proto.Broadcast_CreateStreamServer) error {<br> conn := &amp;Connection{<br>  stream: stream,<br>  id:     pconn.User.Id,<br>  active: true,<br>  error:  make(chan error),<br> }<br><br> p.Connection = append(p.Connection, conn)<br><br> return &lt;-conn.error<br>}</pre><p>The <strong>BroadcastMessage</strong> function iterates through all active connections and sends messages asynchronously using goroutines to avoid blocking operations.</p><pre>func (s *Pool) BroadcastMessage(ctx context.Context, msg *proto.Message) (*proto.Close, error) {<br> wait := sync.WaitGroup{}<br> done := make(chan int)<br><br> for _, conn := range s.Connection {<br>  wait.Add(1)<br><br>  go func(msg *proto.Message, conn *Connection) {<br>   defer wait.Done()<br><br>   if conn.active {<br>    err := conn.stream.Send(msg)<br>    fmt.Printf(&quot;Sending message to: %v from %v&quot;, conn.id, msg.Id)<br><br>    if err != nil {<br>     fmt.Printf(&quot;Error with Stream: %v - Error: %v\n&quot;, conn.stream, err)<br>     conn.active = false<br>     conn.error &lt;- err<br>    }<br>   }<br>  }(msg, conn)<br><br> }<br><br> go func() {<br>  wait.Wait()<br>  close(done)<br> }()<br><br> &lt;-done<br> return &amp;proto.Close{}, nil<br>}</pre><p>The <strong>sync.WaitGroup</strong> is used to ensure the connection to the stream remains open until messages are sent to all active connections.</p><p>Creating a gRPC Server: In your <strong>main.go</strong> file, create the gRPC server for your chat application.</p><pre>func main() {<br> // Create a new gRPC server<br> grpcServer := grpc.NewServer()<br><br> // Create a new connection pool<br> var conn []*handler.Connection<br><br> pool := &amp;handler.Pool{<br>  Connection: conn,<br> }<br><br> // Register the pool with the gRPC server<br> proto.RegisterBroadcastServer(grpcServer, pool)<br><br> // Create a TCP listener at port 8080<br> listener, err := net.Listen(&quot;tcp&quot;, &quot;:8080&quot;)<br><br> if err != nil {<br>  log.Fatalf(&quot;Error creating the server %v&quot;, err)<br> }<br><br> fmt.Println(&quot;Server started at port :8080&quot;)<br><br> // Start serving requests at port 8080<br> if err := grpcServer.Serve(listener); err != nil {<br>  log.Fatalf(&quot;Error creating the server %v&quot;, err)<br> }<br>}</pre><p>Run your application with the following command:</p><pre>go build -o main &amp;&amp; main.go</pre><p>Testing with Postman: To test your real-time chat application, you can use Postman:</p><ol><li>Create a new gRPC request</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qtH6DhjygvE9F0oPJ4e29w.png" /></figure><p>2. Enter the URL <strong>localhost:8080</strong> and import the protobuf file from your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIH2WSivUkPRaACAXCD10g.png" /></figure><p>3. You will automatically get the two methods created in the functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfxwavdePCM2lmkwSmAk_g.png" /></figure><p>4. First, create a connection to the stream and invoke the method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfxwavdePCM2lmkwSmAk_g.png" /></figure><p>5. In another tab, create a broadcaster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FWJofjUz8u2lOVc7wdoAkw.png" /></figure><p>6. When you invoke the method, you will see the received message in the first tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gv65RrJpleQ1h-Qx4GrJDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*vDRPlYkjq86eEj42kCUp-g.png" /></figure><p>7. Similarly, by connecting from multiple tabs, the list will grow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*_zfaa1hdz3x2gJ8W_JwQ_g.png" /></figure><p>In this article, we’ve demonstrated how to build a real-time chat application using gRPC and Go. By following the steps for protobuf message definition, server-side implementation, and testing with Postman, you can create your chat application with ease.</p><p>Do leave your feedback, I am willing to know what works and what does not.</p><p>Find the full source code below:</p><p><a href="https://github.com/atharv-bhadange/grpc-chat">https://github.com/atharv-bhadange/grpc-chat</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa226937ad3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Application for WearOS]]></title>
            <link>https://medium.com/@bhadange.atharv/flutter-application-for-wearos-68d73a10a562?source=rss-440eb7c323c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/68d73a10a562</guid>
            <category><![CDATA[wear-os]]></category>
            <category><![CDATA[samsung-galaxy-watch-4]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Atharv Bhadange]]></dc:creator>
            <pubDate>Tue, 19 Sep 2023 13:02:16 GMT</pubDate>
            <atom:updated>2023-12-03T04:45:13.841Z</atom:updated>
            <content:encoded><![CDATA[<h3>Prerequisites:</h3><ol><li>Flutter installation and basic understanding of Flutter</li><li>Samsung Galaxy Watch (or any watch with WearOS)</li></ol><h3>Initial Setup</h3><ul><li>Enable developer options from Settings, go to About Watch &gt; Software Information, and tap multiple times on Software Version.</li><li>Connect your watch and PC on the same Wi-Fi network</li><li>Go to developer options then enable ADB debugging</li><li>Then turn on the wireless debugging option</li><li>Click on the Pair New Device option</li><li>Note the IP address, Port Number and the Pairing code</li><li>On your PC, go to the Android path (for MacOS it is under ~/Library)</li></ul><pre>cd Library/Android/sdk/platform-tools</pre><ul><li>Pair your PC by running</li></ul><pre>adb pair {IP Address}:{Port Number} {Pairing Code}</pre><ul><li>This will add your PC to the watch for debugging, from next time you can connect to your watch by using</li></ul><pre>adb connect {IP Address}:{Port Number}</pre><p><strong>NOTE: follow </strong><a href="https://stackoverflow.com/questions/10303639/adb-command-not-found"><strong>this</strong></a><strong> if you get the ADB command not found error</strong></p><h3>Create Flutter Project</h3><pre>flutter create watch_counter_app</pre><ul><li>Open the project in VS Code, you will be able to see your watch device available for debugging.</li><li>If you directly do flutter run the application will start on your device but with a cluttered UI, so let us take a step back.</li></ul><h3>Adding plugins</h3><ul><li>Add the following 2 packages to your pubsepc.yaml file by using</li></ul><pre>flutter pub add wear wearable_rotary</pre><ul><li>The <a href="https://pub.dev/packages/wear">wear plugin</a> might be outdated, change the packages ext.kotlin_version of the package from the .pub-cache folder to the version that is prompted in the error that you get when you try to run the application.</li><li>Also, change the minSdkVersion of your project to 23</li></ul><h3>Lets Code:</h3><ul><li>First of all, let&#39;s remove the App Bar and the Floating Action Button to make the screen clutter-free</li><li>Add 2 buttons above and below the text, one for adding and one for subtracting, which should look like this</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*byMib23Tn5wzmqv_pQKQ2Q.jpeg" /><figcaption>Sample UI</figcaption></figure><ul><li>Add a method to decrementing the counter as well and connect the respective onTap properties of the buttons.</li><li>The MyHomePage widget should look like this:</li></ul><pre>class MyHomePage extends StatefulWidget {<br>  const MyHomePage({super.key});<br><br>  @override<br>  State&lt;MyHomePage&gt; createState() =&gt; _MyHomePageState();<br>}<br><br>class _MyHomePageState extends State&lt;MyHomePage&gt; {<br>  int _counter = 0;<br><br>  void _incrementCounter() {<br>    setState(() {<br>      _counter++;<br>    });<br>  }<br><br>  void _decrementCounter() {<br>    setState(() {<br>        _counter--;<br>    });<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Center(<br>        child: Column(<br>          mainAxisAlignment: MainAxisAlignment.center,<br>          children: &lt;Widget&gt;[<br>            ElevatedButton(<br>              onPressed: _incrementCounter,<br>              child: const Icon(Icons.add),<br>            ),<br>            const Text(<br>              &#39;Counter:&#39;,<br>            ),<br>            Text(<br>              &#39;$_counter&#39;,<br>              style: Theme.of(context).textTheme.headlineMedium,<br>            ),<br>            ElevatedButton(<br>              onPressed: _decrementCounter,<br>              child: const Icon(Icons.remove),<br>            ),<br>          ],<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><ul><li>Now you can see your app fully functional</li></ul><h3>Changing theme based on mode</h3><ul><li>Watch has 2 modes: Ambient and Active</li><li>Turn on your <em>Always On Display</em> to see the Ambient mode</li><li>Wrap the Material Widget in AmbientMode widget enabled by the <em>wear plugin</em></li><li>Set the colorScheme property according to the mode provided by the builder</li></ul><pre>class MyApp extends StatelessWidget {<br>  const MyApp({super.key});<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return AmbientMode(<br>      builder: (context, mode, child) {<br>        return MaterialApp(<br>          title: &#39;Watch Counter&#39;,<br>          theme: ThemeData(<br>            visualDensity: VisualDensity.compact,<br>            colorScheme: mode == WearMode.active<br>                ? const ColorScheme.light()<br>                : const ColorScheme.dark(),<br>            useMaterial3: true,<br>          ),<br>          home: child,<br>        );<br>      },<br>      child: const MyHomePage(),<br>    );<br>  }<br>}</pre><h3>Use the watch dial to change the counter</h3><ul><li>Let’s use the <a href="https://pub.dev/packages/wearable_rotary">wearable_rotary</a> package for this</li><li>Add the following method to the MainActivity.kt file to extend the rotation motion to flutter from the native library and restart the app.</li></ul><pre>import android.view.MotionEvent<br>import com.samsung.wearable_rotary.WearableRotaryPlugin<br><br>class MainActivity : FlutterActivity() {<br>    override fun onGenericMotionEvent(event: MotionEvent?): Boolean {<br>        return when {<br>            WearableRotaryPlugin.onGenericMotionEvent(event) -&gt; true<br>            else -&gt; super.onGenericMotionEvent(event)<br>        }<br>    }<br>}</pre><ul><li>In main.dart, Add a StreamSubscription of type RotaryEvent enabled by the package</li></ul><pre>late final StreamSubscription&lt;RotaryEvent&gt; _rotarySubscription;</pre><ul><li>Initial this stream in the initState() method</li></ul><pre>@override<br>  void initState() {<br>    super.initState();<br>    _rotarySubscription = rotaryEvents.listen(handleRotaryEvent);<br>  }</pre><ul><li>Create another method handleRotaryEvent to read the direction of the scroll</li></ul><pre>void handleRotaryEvent(RotaryEvent event) {<br>    if (event.direction == RotaryDirection.clockwise) {<br>      _incrementCounter();<br>    } else {<br>      _decrementCounter();<br>    }<br>  }</pre><ul><li>Don’t forget to dispose of the stream</li></ul><pre>@override<br>  void dispose() {<br>    _rotarySubscription.cancel();<br>    super.dispose();<br>  }</pre><ul><li>Now if you use your dial and rotate clockwise the the counter increments and decrements anti-clockwise.</li></ul><h3>Final result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*Y4gepZqupWPzzHBgZzF3nQ.gif" /></figure><p>Similarly, you can use various sensors of your watch to create amazing applications.</p><p>Find the full source code <a href="https://github.com/atharv-bhadange/Watch-App">here</a>, and do drop a ⭐ on the GitHub Repository.</p><p>Leave a 👏 if you loved the explanation</p><p>#GDG #GDGPune #blogathonS02 #devfest2023</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68d73a10a562" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Schlumberger Interview Experience | Fullstack Developer | On-campus]]></title>
            <link>https://medium.com/@bhadange.atharv/schlumberger-interview-experience-fullstack-developer-on-campus-7fe069c687f8?source=rss-440eb7c323c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fe069c687f8</guid>
            <category><![CDATA[on-campus]]></category>
            <category><![CDATA[schlumberger]]></category>
            <category><![CDATA[full-stack-developer]]></category>
            <category><![CDATA[freshers]]></category>
            <category><![CDATA[interview-experience]]></category>
            <dc:creator><![CDATA[Atharv Bhadange]]></dc:creator>
            <pubDate>Sat, 19 Aug 2023 12:28:09 GMT</pubDate>
            <atom:updated>2023-08-29T10:59:32.976Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/174/1*-GtfAUo_yi1UrG881VfoLA.png" /></figure><p>Do you want to give a mock interview for Google? Do you want to wait for 2 hours for your following interview round without knowing if it will be the last?</p><p>Apply at SLB, the one answer to both questions.</p><p>One of the most challenging interview processes of all, SLB comes with a whopping 6 rounds of screening, including the Online Assessment.</p><p>The company came to our campus offering 19.7LPA CTC and kept the eligibility for CE, IT, and EnTC. They sent the OA link to only 333 people amongst roughly 600 people who applied.</p><p>Let’s break it down one by one</p><h3>Online Assessment</h3><ul><li>It was conducted from home on the DoSelect platform.</li><li>It consisted of 3 sections for a time limit of 1.5 hours and 22 questions(20 MCQs and 2 coding questions).</li><li>But there is a catch, 20 MCQs were divided into 2 sections and each section had an individual time limit of 10mins.</li><li>1st section consisted of theoretical questions (some multi-correct some single-correct). They were doable in 10mins of time. All the questions were based on Java.</li><li>2nd section questions were lengthy. All of them consisted of code snippets that you had to dry run or debug. All of them were in Java again and 10 mins wasn’t sufficient for this section. The questions might seem difficult to people who don’t know Java in depth, but they consisted of topics like error handling(try-catch-finally), string buffers, and inheritance.</li><li>3rd section was child’s play. It had 2 coding questions and they were not the same for all. The overall difficulty was the same for everyone (Easy on Leetcode). I got the easiest of all</li><li>Integer to binary</li><li>Tell if 2 strings are anagrams</li><li>They shortlisted 121 candidates after this round including me</li></ul><h3>Group Discussion</h3><ul><li>I know, everyone was surprised as you are right now. It was the first time for almost everyone to attend a GD for an interview.</li><li>As they had to eliminate the majority of the chunk in this round, they made groups of 10 and they had given topics like Artificial Intelligence vs Human Intelligence, the Impact of Social media, etc.</li><li>From each group, they sent roughly 4 or 5 people into the next round, all of them going in parallel.</li><li>I was in the first round for the GD and immediately got called for Technical Interview 1</li></ul><h3>Technical Interview 1</h3><ul><li>I went in, and the interviewer asked for a copy of my resume and started asking about some of the mentioned keywords.</li><li>First, he asked what I know about MongoDB and how can I connect to a MongoDB database.</li><li>Then he asked me what all I know about Docker, then asked me to write a sample Dockerfile for any application(I was familiar with node so I wrote that)</li><li>He then asked me about my previous Internship experiences.</li><li>Starting with the first and easy DSA question, he asked me to write down the code for adding 2 binary strings.</li><li>Next, he asked what I knew about a BST, then he asked if I could work on inserting and deleting a node from a BST. I mentioned I won’t be perfect with code, so he instructed me to dry-run my approach on a sample BST.</li><li>Further, he asked me what is a Linked List and what is the advantage of it over Arrays. Then he asked me to write the code for sorting a Linked List (wrote kind of a broken Merge Sort code for it). He asked a few questions related to my code.</li><li>He asked if I had any questions and that was it.</li><li>This one lasted for about 35–40 mins and immediately I was called for the next round.</li></ul><h3>Managerial Round</h3><ul><li>This interview was with the project manager at the company.</li><li>First, he started by asking for my introduction apart from my technical side. (including family background, schooling, and stuff)</li><li>Then he asked how I would explain SLB to a new person.</li><li>Another HR type of question was, let’s say if you get an offer from Google what will you do?</li><li>What progress do you want to see in yourself 3 years from now?</li><li>Further, I was asked to talk about my most significant project followed by its details.</li><li>This round concluded with some questions from my side.</li></ul><p>Here comes a long 3 hours of break where I was waiting for a response from the team which was busy with GD and interviews of other candidates.</p><p>They then called me for another round of technical interview.</p><h3>Technical Round 2</h3><ul><li>Here, I was again asked for the details about MongoDB, Firebase, and NoSQL in general. He asked which would I choose between MongoDB and Firebase.</li><li>Then he asked some basic questions about Node.js.</li><li>After 1 or 2 more questions on my resume, he started with DSA. The first one was easy again, to sort an array consisting of only zeros and ones, the next was to reverse a string.</li><li>Then he asked me to design a database for our canteen management system.</li><li>He kept on asking me about my thought process along the way, cross-questioned, and suggested changes.</li><li>Then he asked me 2 puzzles:</li><li>Given 4, 10cm and 5cm sticks each, arrange them in a way so that they form exactly 3 squares(do let me know if you figure out)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hh_Qdx3S9hCJxUt8bC7SRA.jpeg" /><figcaption>Credits: <a href="https://medium.com/u/a46c5452e143">Sameer Bramhecha</a></figcaption></figure><ul><li>He drew a rectangle and 2 circles below it, he said, “Say this is a bus, which direction is it going?” (the logic behind this was to look for the door of the bus if it is facing you then it’s going left, otherwise right)</li><li>After this one, in an hour or so, my HR interview was scheduled.</li></ul><h3>HR round</h3><ul><li>2 HRs greeted me and asked me to start with my intro.</li><li>Then they went on to ask some questions about my background.</li><li>Further, they asked which is the top preferred company of mine that I would like to join.</li><li>What are your long-term and short-term goals?</li><li>What is SLB?</li><li>What did you learn from the PPT?</li><li>What skills do you bring to the table?</li><li>Last and most tricky one, if not SLB then what?</li><li>They asked me to leave and said that the results would be announced by EOD.</li></ul><p>After a whole 6 hours of grinding and waiting, the result?</p><p><strong>REJECTED</strong></p><p>Who got selected? 2 girls from the IT department.</p><p>🫡</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fe069c687f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>