<?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 Avinash Kumar on Medium]]></title>
        <description><![CDATA[Stories by Avinash Kumar on Medium]]></description>
        <link>https://medium.com/@avinashbest?source=rss-cd809de4c470------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MT0iD8_j5lZhCAK8aJcQpg.jpeg</url>
            <title>Stories by Avinash Kumar on Medium</title>
            <link>https://medium.com/@avinashbest?source=rss-cd809de4c470------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 20:17:09 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@avinashbest/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[Understanding Kotlin Coroutines on Android]]></title>
            <link>https://avinashbest.medium.com/understanding-kotlin-coroutines-on-android-ddbcca03106e?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/ddbcca03106e</guid>
            <category><![CDATA[need]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[coroutines-in-kotlin]]></category>
            <category><![CDATA[coroutine]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Sun, 25 May 2025 21:16:52 GMT</pubDate>
            <atom:updated>2025-07-30T16:12:24.436Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PgNp4aPoA3mi8DHt" /><figcaption>Photo by <a href="https://unsplash.com/@louis993546?utm_source=medium&amp;utm_medium=referral">Louis Tsai</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Why do we need something called coroutines on Android?</p><p>The dream code can be written as:</p><pre>fun theDreamCode() {<br>    val user = fetchUserData() // NetworkOnMainThreadException<br>    textView.text = user.name<br>}</pre><p>Then, we can use threads:</p><pre>fun theDreamCode() {<br>    Thread {<br>      val user = fetchUserData()<br>      textView.text = user.name // Called from wrong thread exception<br>    }<br>}</pre><p>Okay, we can finally solve the above problem with callbacks:</p><pre>fun theDreamCode() {<br>    fetchUserData { user -&gt;<br>      textView.text = user.name <br>      // Prone to OutOfMemory as there can be 100(s) of callbacks in a project, <br>      // And this leads to be leaking of the callbacks.<br>    }<br>}</pre><blockquote>This can also be solved using an overridden method to stop or cancel the subscription or callbacks.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*ZwfY-YmJ1xhxcKIflUfvDQ.png" /></figure><blockquote>The the onStop() method looks like a mess.</blockquote><h3><strong>We can also solve this by using RxJava:</strong></h3><pre>fun fetchUser() : Observable&lt;User&gt; = ...<br><br>fetchUser()<br>  .as(autoDispoable(AndroidLifecycleScopeProvider.from(this)))<br>  .subscribe { user -&gt;<br>    textView.text = user.name<br>  }</pre><h3>Or, by using LiveData:</h3><pre>fun fetchUser() : LiveData&lt;User&gt; = ...<br><br>fetchUser()<br>  .observe(viewLifecycleOwner) { user -&gt;<br>    textView.text = user.name<br>  }</pre><p>Hence, the problem is solved, then why coroutines?</p><p><strong>As per the 2018 Developer Survey:</strong></p><ol><li>Threading and concurrency in Android are too difficult.</li><li>Developers should extend LiveData and make it more like RxJava.</li><li>As per concurrency UX research:</li></ol><blockquote>This is an in-depth interview with 9 professional developers. They share their weekly feedback around threading and concurrency and how they solved it.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5WjNIBFTphd-sJIimCwHQ.png" /><figcaption>comparision</figcaption></figure><ol><li><strong>LiveData: </strong>Love it, but want a complete solution. As the only main thread supports.</li><li><strong>RxJava:</strong> Powerful, highly adopted, but often misused and perceived as an overkill solution to concurrency.</li><li><strong>Coroutines:</strong> Seems like the best solution, but there is a need for maturation of the extension, and developers feels that a steep learning curve awaits…</li></ol><blockquote>Desired Solution: Simplified, Comprehensive &amp; Robust.</blockquote><h3><strong>Coroutine Primer:</strong></h3><p>Coroutines simplify async code by replacing callbacks. Replace the main safety callback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a-t1VpkS5EN_8hoyWYvm7w.jpeg" /><figcaption>Coroutine working</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mNIg0VOkEAc1jwjmRASLgQ.jpeg" /><figcaption>Coroutine context &amp; Dispatchers.</figcaption></figure><h4>How does the stack behave with suspend functions?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YuGRqz-QsshKdkrzEjprEg.jpeg" /><figcaption>stack-behaviour</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMMUHghHeQyu_3NqlBixUw.jpeg" /><figcaption>suspend fun, in stack</figcaption></figure><h3>Working of timeout in any coroutine API:</h3><p>Considering LiveData API:</p><pre>fun &lt;T&gt; LiveData(<br>    context: CoroutineContext = EmptyCoroutineContext,<br>    timeoutInMs: Long = DEFAULT_TIMEOUT,<br>    @BuilderInterence block: suspend LiveDataScope&lt;T&gt;.() -&gt; Unit<br>)</pre><p>The infamous rotation problems in Android:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HjsKOn0Jkskx5hzP4JGtuw.jpeg" /></figure><h3>Coroutine Leaks:</h3><p>These are a kind of memory leak, but a serious problem, worse than memory leaks.</p><p>Coroutines can resume itself. Not only it can use memory but also CPU, it can write file or do network operation which doesn’t need to be happen.</p><p>To solve the problem, coroutine introduces scope Coroutines run “in” scope:</p><ul><li>Scopes can cancel all coroutines.</li><li>Scopes get uncaught exceptions</li><li>Use scopes to avoid leaks.</li></ul><p>So, there are multiple scopes provided to avoid leaks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fDgjJfPGLoqdggDQ6VWFjw.jpeg" /><figcaption>scopes in coroutines</figcaption></figure><p>But the lifecycleScope is tightly coupled with the UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8hPtfmnb1ceNUkY_Rmc0Pg.jpeg" /><figcaption>lifecycle-scope in coroutine coupling</figcaption></figure><p>Thanks for reading.</p><p>References / Credit for this post:</p><ul><li><a href="https://youtu.be/BOHK_w09pVA">https://youtu.be/BOHK_w09pVA</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ddbcca03106e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How does Exponential Backoff work?]]></title>
            <link>https://medium.com/bobble-engineering/how-does-exponential-backoff-work-90ef02401c65?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/90ef02401c65</guid>
            <category><![CDATA[http-request]]></category>
            <category><![CDATA[interceptors]]></category>
            <category><![CDATA[okhttpclient]]></category>
            <category><![CDATA[android-api-calls]]></category>
            <category><![CDATA[exponential-backoff]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Sat, 18 Mar 2023 16:26:48 GMT</pubDate>
            <atom:updated>2023-03-18T16:26:48.833Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*OuWgvq5aa5pgKnCl.png" /></figure><p>Exponential Backoff is a popular technique used to handle HTTP requests that fail due to network issues or server errors. When an HTTP request fails, the traditional approach is to simply retry the request after a certain interval of time. However, this can result in multiple failed requests and may even overload the server.</p><p>To address this issue, we can use the Exponential Backoff technique in the HTTP Interceptor. In this blog, we will explore how to implement Exponential Backoff in the HTTP Interceptor in Android.</p><h3>What is an HTTP Interceptor?</h3><p>An HTTP Interceptor is an object that intercepts outgoing HTTP requests and incoming HTTP responses. It is used to add or remove headers, modify request or response data, or perform other actions before the request or response is sent or received.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t-FNY-1kndQOyAsU7OhHHg.png" /></figure><h3>How does Exponential Backoff work?</h3><p>Exponential Backoff is a technique that increases the waiting time between retries exponentially. This means that the waiting time between each retry is multiplied by a factor that increases with each retry. For example, the first retry may wait for 1 second, the second retry may wait for 2 seconds, the third retry may wait for 4 seconds, and so on.</p><p>This technique reduces the number of failed requests and prevents server overload by gradually increasing the waiting time between retries.</p><h3>How to implement Exponential Backoff in the HTTP Interceptor in Android?</h3><p>To implement Exponential Backoff in the HTTP Interceptor in Android, we can use the okhttp3.Interceptor interface. This interface intercepts outgoing HTTP requests and incoming HTTP responses. Here is a sample code snippet:</p><pre>class ExponentialBackoffInterceptor : Interceptor {<br>    private var retryCount = 0 <br><br>    @Throws(IOException::class)<br>    override fun intercept(chain: Interceptor.Chain): Response {<br>        val request = chain.request()<br>        <br>        var waitingTimeForClient = System.currentTimeMillis - lastNetworkCall<br>        val waitTime = (Math.pow(2.0, retryCount.toDouble()) * 1000).toLong()<br><br>        if (waitingTimeForClient &lt; waitTime &amp;&amp; retryCount &lt; MAX_RETRY) {<br>            throw IOException(&quot;ExponentialBackoffInterceptorIOException ${waitTime}ms&quot;)<br>        }<br><br>        var response = chain.proceed(request)<br><br>        if (response.isSuccessful) {<br>            Log.d(TAG, &quot;Api call: Successful&quot;)<br>            lastNetworkCall = System.currentTimeMillis()<br>            retryCount = 0 // resetting to 0<br>        } else {<br>            Log.d(TAG, &quot;Api call: Not Successful&quot;)<br>            lastNetworkCall = System.currentTimeMillis()<br>            retryCount += 1 // Increment every time<br>        }<br><br>        return response<br>    }<br>}</pre><p>In this code, we first create an instance of the Interceptor interface and implement the intercept() method. We then create a variable waitintTimeForClient to keep track of how much time client have to wait for more for the next API call.</p><p>Inside the intercept() method, we first get the current HTTP request using chain.request(). We then execute the request using chain.proceed(request) and storing the response in the response variable.</p><p>If the request fails, we update the lateNetworkCall time and calculate the waiting time using the formula (Math.pow(2.0, retryCount.toDouble()) * 1000).toLong(). We then wait for the calculated time by throwing our custom error using throw IOException(message) which let the request on hold until the wait time is completed and proceed request using chain.proceed(request).</p><p>We repeat this process whenever client makes an API request until the request is successful or we have reached the maximum number of retries defined by the MAX_RETRIES variable. We then reset the retryCount to 0 after a successful request and return the final response.</p><h3>Conclusion</h3><p>In this blog, we have explored how to implement a simple flow of Exponential Backoff in the HTTP Interceptor in Android. This technique helps prevent server overload and reduces the number of failed requests by gradually increasing the waiting time between retries. You can further customize it as per your need.</p><p>By using the code snippet provided above, you can easily implement Exponential Backoff in your own Android application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90ef02401c65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bobble-engineering/how-does-exponential-backoff-work-90ef02401c65">How does Exponential Backoff work?</a> was originally published in <a href="https://medium.com/bobble-engineering">Bobble Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Global dependency resolution in android gradle]]></title>
            <link>https://medium.com/bobble-engineering/global-dependency-resolution-in-android-gradle-f9dacacdbbee?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9dacacdbbee</guid>
            <category><![CDATA[gradle]]></category>
            <category><![CDATA[resolutions]]></category>
            <category><![CDATA[dependencies]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[global]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Thu, 01 Sep 2022 08:02:57 GMT</pubDate>
            <atom:updated>2022-09-01T08:02:57.862Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>We might have a case where we are stuck in a situation where we have a fairly large project in android and many submodules inside it, managing the dependencies is quite a tedious task for the whole project.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*89FxNOfLuZC4ZxjNbx0Rkg.png" /><figcaption>Gradle</figcaption></figure><p>To solve this problem, we came across the solution i.e, <strong>global dependency resolution</strong> in which there is a single gradle file that contains all the dependencies which are used throughout the whole project so that we can standardize it via the single gradle file.</p><p>Now, the first step is to make a <strong><em>dependencies.gradle</em></strong> file at the project level in your android project.</p><p>Inside the <strong><em>dependencies.gradle</em></strong> file creates an <strong><em>ext{}</em></strong> block where all the dependencies will go as shown below.</p><pre>ext {<br>    // Contains the core android tools version<br>    toolsVersion = [<br>            android     : [<br>                    gradleVersion   : &quot;7.2.1&quot;,<br>                    kotlinVersion   : &quot;1.6.21&quot;,<br>                    minSdk          : 23, // Android 6.0<br>                    compileSdk      : 32,<br>                    targetSdk       : 32, // Android 12L<br>                    buildToolVersion: &quot;30.0.3&quot;,<br>                    ndkVersion      : &quot;22.0.7026061&quot;,<br>            ],<br>            junit       : &quot;4.13.2&quot;,<br>            espressoCore: &quot;3.4.0&quot;,<br>            extJunit    : &quot;1.1.3&quot;,<br>            multidex    : &quot;2.0.1&quot;,<br>            annotation  : &quot;1.4.0&quot;<br>    ]<br>    supportLibVersions = [<br>            appcompat       : &quot;1.5.0&quot;,<br>            emojiAppcompat  : &quot;1.1.0&quot;,<br>            material        : &quot;1.6.1&quot;, // Material UI<br>            recyclerview    : &quot;1.2.1&quot;,<br>            constraintlayout: &quot;2.1.4&quot;,<br>            cardview        : &quot;1.0.0&quot;,<br>            emoji           : &quot;1.1.0&quot; // androidx.emoji<br>    ]<br>    libVersions = [<br>            firebaseBom              : &quot;25.12.0&quot;,<br>            facebookSdk              : &quot;12.3.0&quot;,<br>            playServicesGcm          : &quot;17.0.0&quot;,<br>            playServicesAuth         : &quot;19.0.0&quot;,<br>            glide                    : &quot;4.13.2&quot;,<br>            retrofit                 : &quot;2.9.0&quot;,<br>            moshi                    : &quot;1.13.0&quot;,</pre><pre>     ]<br>}</pre><blockquote><em>You</em> can categorize as many as you want at your convenience.</blockquote><p>Now, in Project-level <strong><em>build.gradle </em></strong>you need to add one line (i.e,<strong><em> apply from: ‘dependencies.gradle’</em></strong>) to activate this gradle file for global access.</p><pre>// Top-level build file where you can add configuration options common to all sub-projects/modules.<br>plugins <strong>{<br>    ...<br>    </strong>id &#39;com.android.application&#39; version &#39;7.2.1&#39; apply <strong>false<br>    </strong>id &#39;org.jetbrains.kotlin.android&#39; version &#39;1.6.21&#39; apply <strong>false<br>    ...<br>}<br><br></strong>apply from: &#39;dependencies.gradle&#39;<br><br>task clean(type: Delete) <strong>{<br>    </strong>delete rootProject.buildDir<br><strong>}</strong></pre><p>Now, after syncing the project. Our, new <strong><em>dependencies.gradle</em></strong> file is ready to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*sxEePGnhhGN6vz2suwdPcg.png" /></figure><p>Earlier we use the dependencies shown below:</p><pre>implementation &quot;com.google.android.material:material:1.6.1&quot;</pre><p>Now we access dependencies like this, in the dependencies block we can access the dependencies via kotlin string template as shown below:</p><pre>implementation &quot;com.google.android.material:material:$<strong>{</strong>supportLibVersions.material<strong>}</strong>&quot;<br>implementation &quot;androidx.multidex:multidex:$<strong>{</strong>toolsVersion.multidex<strong>}</strong>&quot;<br>implementation &quot;androidx.browser:browser:$<strong>{</strong>libVersions.browser<strong>}</strong>&quot;<br>implementation &quot;androidx.cardview:cardview:$<strong>{</strong>supportLibVersions.cardview<strong>}</strong>&quot;<br>implementation &quot;androidx.appcompat:appcompat:$<strong>{</strong>supportLibVersions.appcompat<strong>}</strong>&quot;<br>implementation &quot;com.squareup.retrofit2:retrofit:$<strong>{</strong>libVersions.retrofit<strong>}</strong>&quot;<br>implementation &quot;com.github.bumptech.glide:glide:$<strong>{</strong>libVersions.glide<strong>}</strong>&quot;</pre><blockquote><strong>NOTE</strong>: For Groovy string interpolation you must use double quotes (“).</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9dacacdbbee" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bobble-engineering/global-dependency-resolution-in-android-gradle-f9dacacdbbee">Global dependency resolution in android gradle</a> was originally published in <a href="https://medium.com/bobble-engineering">Bobble Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrate autofill with keyboards (or Input Method Editors)]]></title>
            <link>https://medium.com/bobble-engineering/integrate-autofill-with-keyboards-or-input-method-editors-c715ee4b7e1?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/c715ee4b7e1</guid>
            <category><![CDATA[keyboard]]></category>
            <category><![CDATA[autofill]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mei]]></category>
            <category><![CDATA[integrate]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Thu, 01 Sep 2022 05:58:19 GMT</pubDate>
            <atom:updated>2022-09-01T05:58:19.668Z</atom:updated>
            <content:encoded><![CDATA[<p>From Android 11, keyboards and other input-method editors (IMEs) can display autofill suggestions inline, in the form of a suggestion strip on the keyboard, instead of the system displaying these in the form of a dropdown menu. Since, these autofill suggestions can contain private data, such as passwords or credit card information, the suggestions are hidden from IME until the user selects one.</p><blockquote><em>If </em>an IME or a password manager does not support inline autofill or it is disabled from Google’s setting or other password manager autofill service, suggestions will be shown in the drop-down menu, as they were before Android 11.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*4IH7Eb6zV26kIt_p06-cXg.png" /><figcaption>Working Autofill Inline Suggestion in Mint Keyboard.</figcaption></figure><h3>Workflow:</h3><ol><li>As soon as the user focuses on an input field that triggers autofill, like password, username, or credit-card input field.</li><li>The platform queries the current IME and the appropriate suggestion provider to see if they support the inline suggestion. If the current suggestion provider does not support the inline suggestion, then the suggestion will be shown in the form of a drop-down menu, as on Android 10 and lower.</li><li>The platform asks the IME to provide a suggestion request. This suggestion request specifies the maximum number of suggestions the IME would like, and also provides presentation specs for each suggestion. The presentation specs specify things like maximum size, text size, color, and font data, allowing the suggestion includes a callback to inflate a View<strong><em> </em></strong>containing the suggestion’s UI.</li><li>Each suggestion includes a callback to inflate a View containing the suggestion&#39;s UI.</li><li>The keyboard shows the suggestions by calling the callback method to inflate each suggestion’s View. To protect the user’s confidential information, the keyboard or IME does not see what the suggestions are at this stage.</li><li>If the user chooses any of the suggestions, the IME is informed the same way it would have been if the user had chosen a suggestion from a drop-down list.</li></ol><h3><strong>Configure IMEs to support inline autofill</strong></h3><p>Your IME must set the android:supportsInlineSuggestions to true .</p><pre>&lt;input-method<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:supportsInlineSuggestions=&quot;true&quot;/&gt;</pre><p>When the platform needs autofill suggestions, it calls your IMEs <a href="https://developer.android.com/reference/android/inputmethodservice/InputMethodService#onCreateInlineSuggestionsRequest(android.os.Bundle)">InputMethodService.onCreateInlineSuggestionsRequest(</a>) method. You must implement the method and return a <a href="https://developer.android.com/reference/android/view/inputmethod/InlineSuggestionsRequest">InlineSuggestionsRequest</a> specifying the following:</p><ul><li>Number of suggestions your IME would like</li><li>An <a href="https://developer.android.com/reference/android/widget/inline/InlinePresentationSpec">InlinePresentationSpec</a> for each suggestion, defining how it would be presented.</li></ul><blockquote><strong>Note:</strong> If you provide fewer presentation specs than the number of suggestions requested, the last spec is used for all the excess suggestions. This means, for example, that if you provide only a single presentation spec, the suggestion provider uses that spec for all the suggestions.</blockquote><p><em>When the platform has suggestions, it calls your IMEs </em><em>onInlineSuggestionsResponse() method, passing a </em><em>InlineSuggestionsResponse containing the suggestions. You must implement this method. Your implementation calls </em><em>InlineSuggestionsResponse.getInlineSuggestions() to get the list of suggestions then inflate each suggestion by calling its </em><em>InlineSuggestion.inflate() method.</em></p><p>Now, we are going to implement the <a href="https://developer.android.com/reference/android/inputmethodservice/InputMethodService#onCreateInlineSuggestionsRequest(android.os.Bundle)">InputMethodService.onCreateInlineSuggestionsRequest(</a>) method:</p><pre>@Override<br><strong>public </strong>InlineSuggestionsRequest onCreateInlineSuggestionsRequest(Bundle uiExtras) {<br>    mSuggestionStrip.setVisibility(View.<em>VISIBLE</em>);<br>    Log.<em>d</em>(<em>TAG</em>, &quot;onCreateInlineSuggestionsRequest() called&quot;);<br>    StylesBuilder stylesBuilder = UiVersions.<em>newStylesBuilder</em>();<br>    @SuppressLint(&quot;RestrictedApi&quot;) Style style = InlineSuggestionUi.<em>newStyleBuilder</em>()<br>            .setSingleIconChipStyle(<br>                    <strong>new </strong>ViewStyle.Builder()<br>                            .setBackground(<br>                                    Icon.<em>createWithResource</em>(<strong>this</strong>, R.drawable.<em>chip_background</em>))<br>                            .setPadding(0, 0, 0, 0)<br>                            .build())<br>            .setChipStyle(<br>                    <strong>new </strong>ViewStyle.Builder()<br>                            .setBackground(Icon.<em>createWithResource</em>(<strong>this</strong>, R.drawable.<em>chip_background</em>))<br>                            .setPadding(toPixel(5 + 8), 0, toPixel(5 + 8), 0)<br>                            .build())<br>            .setStartIconStyle(<strong>new </strong>ImageViewStyle.Builder().setLayoutMargin(0, 0, 0, 0).build())<br>            .setTitleStyle(<br>                    <strong>new </strong>TextViewStyle.Builder()<br>                            .setLayoutMargin(toPixel(4), 0, toPixel(4), 0)<br>                            .setTextColor(Color.<em>parseColor</em>(&quot;#FF202124&quot;))<br>                            .setTextSize(16)<br>                            .build())<br>            .setSubtitleStyle(<br>                    <strong>new </strong>TextViewStyle.Builder()<br>                            .setLayoutMargin(0, 0, toPixel(4), 0)<br>                            .setTextColor(Color.<em>parseColor</em>(&quot;#99202124&quot;)) // 60% opacity<br>                            .setTextSize(14)<br>                            .build())<br>            .setEndIconStyle(<strong>new </strong>ImageViewStyle.Builder().setLayoutMargin(0, 0, 0, 0).build())<br>            .build();<br>    stylesBuilder.addStyle(style);<br>    Bundle stylesBundle = stylesBuilder.build();<br><br>    <strong>final </strong>ArrayList&lt;InlinePresentationSpec&gt; presentationSpecs = <strong>new </strong>ArrayList&lt;&gt;();<br>    presentationSpecs.add(<strong>new </strong>InlinePresentationSpec.Builder(<strong>new </strong>Size(100, getHeight()),<br>            <strong>new </strong>Size(740, getHeight())).setStyle(stylesBundle).build());<br>    presentationSpecs.add(<strong>new </strong>InlinePresentationSpec.Builder(<strong>new </strong>Size(100, getHeight()),<br>            <strong>new </strong>Size(740, getHeight())).setStyle(stylesBundle).build());<br><br>    <strong>return new </strong>InlineSuggestionsRequest.Builder(presentationSpecs)<br>            .setMaxSuggestionCount(InlineSuggestionsRequest.<em>SUGGESTION_COUNT_UNLIMITED</em>)<br>            .build();<br>}</pre><p>After implementing <a href="https://developer.android.com/reference/android/inputmethodservice/InputMethodService#onCreateInlineSuggestionsRequest(android.os.Bundle)">onCreateInlineSuggestionsRequest(</a>), the platform will get a callback in the form of a response that contains the desired suggestion for that specific input field. Now, we have to handle the onInlineSuggestionsResponse() method:</p><pre>@Override<br><strong>public boolean </strong>onInlineSuggestionsResponse(InlineSuggestionsResponse response) {<br>    Log.<em>d</em>(<em>TAG</em>, &quot;onInlineSuggestionsResponse() called: &quot; + response.getInlineSuggestions().size());<br>    cancelDelayedDeletion();<br>    postPendingResponse(response);<br>    <strong>return true</strong>;<br>}</pre><p>In<strong><em> cancelDelayedDeletion() </em></strong>method, we remove the callbacks from the <strong>Handler</strong>.</p><p>After that the <strong><em>postPendingResponse()</em></strong> will look like this:</p><pre><strong>private void </strong>postPendingResponse(InlineSuggestionsResponse response) {<br>    cancelPendingResponse();<br>    <strong>final </strong>List&lt;InlineSuggestion&gt; inlineSuggestions = response.getInlineSuggestions();<br>    mResponseState = ResponseState.<em>RECEIVE_RESPONSE</em>;<br>    mPendingResponse = () -&gt; {<br>        mPendingResponse = <strong>null</strong>;<br>        <strong>if </strong>(mResponseState == ResponseState.<em>START_INPUT </em>&amp;&amp; inlineSuggestions.isEmpty()) {<br>            scheduleDelayedDeletion();<br>        } <strong>else </strong>{<br>            inflateThenShowSuggestions(inlineSuggestions);<br>        }<br>        mResponseState = ResponseState.<em>RESET</em>;<br>    };<br>    mHandler.post(mPendingResponse);<br>}</pre><p>Which in-turn calls the most important method (i.e, <strong><em>inflateThenShowSuggestions()</em></strong>)that inflates the inline suggestion view on the keyboard or IMEs.</p><pre><strong>private void </strong>inflateThenShowSuggestions(List&lt;InlineSuggestion&gt; inlineSuggestions) {<br>    <strong>final int </strong>totalSuggestionsCount = inlineSuggestions.size();<br>    <strong>if </strong>(inlineSuggestions.isEmpty()) {<br>        // clear the suggestions and then return<br>        getMainExecutor().execute(() -&gt; updateInlineSuggestionStrip(Collections.<em>EMPTY_LIST</em>));<br>        <strong>return</strong>;<br>    }<br><br>    <strong>final </strong>Map&lt;Integer, SuggestionItem&gt; suggestionMap = Collections.<em>synchronizedMap</em>((<br>            <strong>new </strong>TreeMap&lt;&gt;()));<br>    <strong>final </strong>ExecutorService executor = Executors.<em>newSingleThreadExecutor</em>();<br><br>    <strong>for </strong>(<strong>int </strong>i = 0; i &lt; totalSuggestionsCount; i++) {<br>        <strong>final int </strong>index = i;<br>        <strong>final </strong>InlineSuggestion inlineSuggestion = inlineSuggestions.get(i);<br>        <strong>final </strong>Size size = <strong>new </strong>Size(ViewGroup.LayoutParams.<em>WRAP_CONTENT</em>,<br>                ViewGroup.LayoutParams.<em>WRAP_CONTENT</em>);<br><br>        inlineSuggestion.inflate(<strong>this</strong>, size, executor, suggestionView -&gt; {<br>            Log.<em>d</em>(<em>TAG</em>, &quot;new inline suggestion view ready&quot;);<br>            <strong>if </strong>(suggestionView != <strong>null</strong>) {<br>                suggestionView.setOnClickListener((v) -&gt; Log.<em>d</em>(<em>TAG</em>, &quot;Received click on the suggestion&quot;));<br>                suggestionView.setOnLongClickListener((v) -&gt; {<br>                    Log.<em>d</em>(<em>TAG</em>, &quot;Received long click on the suggestion&quot;);<br>                    <strong>return true</strong>;<br>                });<br>                <strong>final </strong>SuggestionItem suggestionItem = <strong>new </strong>SuggestionItem(<br>                        suggestionView, /*isAction*/ inlineSuggestion.getInfo().isPinned());<br>                suggestionMap.put(index, suggestionItem);<br>            } <strong>else </strong>{<br>                suggestionMap.put(index, <strong>null</strong>);<br>            }<br><br>            // Update the UI once the last inflation completed<br>            <strong>if </strong>(suggestionMap.size() &gt;= totalSuggestionsCount) {<br>                <strong>final </strong>ArrayList&lt;SuggestionItem&gt; suggestionItems = <strong>new </strong>ArrayList&lt;&gt;(<br>                        suggestionMap.values());<br>                getMainExecutor().execute(() -&gt; updateInlineSuggestionStrip(suggestionItems));<br>            }<br>        });<br>    }<br>}</pre><p>The full working code is available on my <a href="https://github.com/avinashbest/autofill-keyboard-api30.git"><strong><em>GitHub</em></strong></a> as well as on <a href="https://android.googlesource.com/platform/development/+/master/samples/AutofillKeyboard/"><strong><em>AOSP</em></strong></a>./</p><blockquote>Further reading official documentation: <a href="https://developer.android.com/guide/topics/text/ime-autofill">https://developer.android.com/guide/topics/text/ime-autofill</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c715ee4b7e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bobble-engineering/integrate-autofill-with-keyboards-or-input-method-editors-c715ee4b7e1">Integrate autofill with keyboards (or Input Method Editors)</a> was originally published in <a href="https://medium.com/bobble-engineering">Bobble Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Month and Year Picker in Android: Material User Interface]]></title>
            <link>https://avinashbest.medium.com/creating-a-month-and-year-picker-in-android-material-user-interface-40b3461425b5?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/40b3461425b5</guid>
            <category><![CDATA[year-picker]]></category>
            <category><![CDATA[kotlin-date-picker]]></category>
            <category><![CDATA[android-month-picker]]></category>
            <category><![CDATA[kotlinandroid]]></category>
            <category><![CDATA[month-picker]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Sat, 04 Sep 2021 13:45:52 GMT</pubDate>
            <atom:updated>2021-09-04T13:45:52.232Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*B13dfAHnHEI0K3n5" /><figcaption><a href="https://material.io/components/date-pickers/android">https://material.io/components/date-pickers/android</a></figcaption></figure><p>Hey, we all know that it is quite difficult to remove date from the Material Date Picker in android, but after a lot of searching I found something that does the work perfectly for my work.</p><p>I found a Library by <a href="https://github.com/premkumarroyal"><strong>GitHub@premkumarroyal</strong></a>, which does the work, it was not as easy as I was expecting because all the libraries are available in java and for being a Kotlin developer there is not any library to do so.</p><blockquote><strong>https://github.com/premkumarroyal/MonthAndYearPicker</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*fTunM5Vni7LRNjPD" /><figcaption><a href="https://github.com/premkumarroyal/MonthAndYearPicker">https://github.com/premkumarroyal/MonthAndYearPicker</a></figcaption></figure><ul><li>The very first thing comes is, as we all know the dependency.</li></ul><pre>dependencies <strong>{<br>    ...</strong><br>//    https://github.com/premkumarroyal/MonthAndYearPicker<br>    implementation &#39;com.whiteelephant:monthandyearpicker:1.3.0&#39;<br>    ...<br><strong>}</strong></pre><ul><li>So, first we are going to create the <strong>theme.xml or styles.xml</strong> for this month picker if you to customize the color your wish but <strong>don’t change the id of the colors.</strong></li></ul><pre>&lt;style name=&quot;MonthPickerDialogStyle&quot;&gt;<br>    &lt;item name=&quot;monthBgColor&quot;&gt;@color/white&lt;/item&gt;<br>    &lt;item name=&quot;monthBgSelectedColor&quot;&gt;@color/orange&lt;/item&gt;<br>    &lt;item name=&quot;monthFontColorSelected&quot;&gt;@color/white&lt;/item&gt;<br>    &lt;item name=&quot;monthFontColorNormal&quot;&gt;@android:color/black&lt;/item&gt;<br>    &lt;item name=&quot;monthFontColorDisabled&quot;&gt;@android:color/darker_gray&lt;/item&gt;<br><br>    &lt;item name=&quot;headerBgColor&quot;&gt;@color/orange&lt;/item&gt;<br>    &lt;item name=&quot;headerFontColorSelected&quot;&gt;#fff&lt;/item&gt;<br>    &lt;item name=&quot;headerFontColorNormal&quot;&gt;#85FFFFFF&lt;/item&gt;<br>    &lt;item name=&quot;headerTitleColor&quot;&gt;#fff&lt;/item&gt;<br><br>    &lt;item name=&quot;dialogActionButtonColor&quot;&gt;@color/orange&lt;/item&gt;<br>&lt;/style&gt;</pre><ul><li>Now, in <strong>activity_main.xml or any other layout xml</strong> you want it, just copy &amp; paste the code, customization as per your choice.</li></ul><pre>...<br>&lt;com.google.android.material.textfield.TextInputLayout<br>    android:id=&quot;@+id/dateOfBirth&quot;<br>  style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;<br>    android:layout_width=&quot;0dp&quot;<br>    android:layout_height=&quot;wrap_content&quot;<br>    android:layout_marginTop=&quot;16dp&quot;<br>    android:hint=&quot;Date of Birth&quot;<br>    app:endIconDrawable=&quot;@drawable/calender_icon_orange&quot;<br>    app:endIconMode=&quot;custom&quot;<br>    app:endIconTint=&quot;@color/orange&quot;<br>    app:layout_constraintEnd_toEndOf=&quot;@id/schoolName&quot;<br>    app:layout_constraintStart_toStartOf=&quot;@id/schoolName&quot;<br>    app:layout_constraintTop_toBottomOf=&quot;@id/schoolName&quot;<br>    app:placeholderText=&quot;Jan 2000&quot;&gt;<br><br>    &lt;com.google.android.material.textfield.TextInputEditText<br>        android:id=&quot;@+id/dateOfBirthInput&quot;<br>        android:layout_width=&quot;match_parent&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:inputType=&quot;date&quot; /&gt;<br><br>&lt;/com.google.android.material.textfield.TextInputLayout&gt;<br>...</pre><ul><li>Now, it&#39;s time to write the logic part in <strong>Activity or Fragment </strong>as per your choice, <strong>I’m writing this under an Activity.</strong></li></ul><blockquote><strong>Note: Don’t forget to activate the viewBinding feature, because I’m using viewBinding to bind the xml to the activity.</strong></blockquote><pre>lateinit var inputDateOfBirth: String</pre><pre>...</pre><pre>val today = Calendar.getInstance(TimeZone.getTimeZone(&quot;UTC&quot;))<br>val builder = MonthPickerDialog.Builder(<br>    this, <strong>{ </strong>selectedMonth, selectedYear <strong>-&gt;<br>        </strong>inputDateOfBirth = &quot;${getMonthString(selectedMonth)} $selectedYear&quot;<br>        binding.dateOfBirthInput.setText(inputDateOfBirth)<br>    <strong>}</strong>,<br>    today.get(Calendar.<em>YEAR</em>),<br>    today.get(Calendar.<em>MONTH</em>)<br>)<br><br>builder.setActivatedMonth(Calendar.<em>APRIL</em>)<br>    .setMinYear(1980)<br>    .setActivatedYear(2021)<br>    .setMaxYear(2030)<br>    .setMinMonth(Calendar.<em>FEBRUARY</em>)<br>    .setTitle(&quot;SELECT MONTH AND YEAR OF BIRTHDAY&quot;)<br>    .setMonthRange(Calendar.<em>JANUARY</em>, Calendar.<em>DECEMBER</em>)</pre><pre>...</pre><blockquote><strong>There are a lot of methods available for the convivence, don’t forgot to checkout at the GitHub repository.</strong></blockquote><blockquote><a href="https://github.com/premkumarroyal/MonthAndYearPicker"><strong>https://github.com/premkumarroyal/MonthAndYearPicker</strong></a></blockquote><ul><li>Where you want your listener you can add to that xml object, just a single line code.</li></ul><pre>...</pre><pre>binding.dateOfBirth.setEndIconOnClickListener <strong>{<br>    </strong>builder.build().show()<br><strong>}</strong></pre><pre>...</pre><ul><li>One more thing, I have added is an extension function which return the corresponding month string with the parameter as the month number (Integer).</li></ul><pre>private fun getMonthString(month: Int): String {<br>    val result = when (month) {<br>        0 -&gt; &quot;Jan&quot;<br>        1 -&gt; &quot;Feb&quot;<br>        2 -&gt; &quot;Mar&quot;<br>        3 -&gt; &quot;Apr&quot;<br>        4 -&gt; &quot;May&quot;<br>        5 -&gt; &quot;Jun&quot;<br>        6 -&gt; &quot;Jul&quot;<br>        7 -&gt; &quot;Aug&quot;<br>        8 -&gt; &quot;Sept&quot;<br>        9 -&gt; &quot;Oct&quot;<br>        10 -&gt; &quot;Nov&quot;<br>        11 -&gt; &quot;Dec&quot;<br>        else -&gt; {<br>            &quot;Apr&quot;<br>        }<br>    }<br>    return result<br>}</pre><blockquote><strong>Note: The most important part is to handle the Manifest merge error, just a line of replace in AndroidManifest.xml in application element.</strong></blockquote><pre>...</pre><pre>tools:replace=&quot;android:icon&quot;</pre><pre>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*jk2HoxnCgriGirW9hQsgmA.gif" /></figure><h3><strong>Credits:</strong></h3><blockquote><strong>LinkedIn: </strong><a href="https://www.linkedin.com/in/avinashbest/">https://www.linkedin.com/in/avinashbest/</a></blockquote><blockquote><strong>GitHub:</strong> <a href="https://github.com/avinashbest">https://github.com/avinashbest</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40b3461425b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core Java Basics: Quick Reference]]></title>
            <link>https://avinashbest.medium.com/core-java-quick-reference-a1b0984fa834?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1b0984fa834</guid>
            <category><![CDATA[java-reference]]></category>
            <category><![CDATA[avinashbest]]></category>
            <category><![CDATA[core-java]]></category>
            <category><![CDATA[core-java-tutorial]]></category>
            <category><![CDATA[code-with-mosh]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Fri, 06 Aug 2021 19:51:30 GMT</pubDate>
            <atom:updated>2021-08-07T04:35:58.846Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qxw4gNoAvMoKj2EA.jpg" /><figcaption>Java</figcaption></figure><h3>Function:</h3><ul><li>A block of code that performs a task.</li></ul><pre>void sendEmail(){<br>        ...<br>    }</pre><ul><li>camelNamingConvention</li></ul><h3>Class:</h3><ul><li>A container for related functions.</li></ul><pre>public class Main {<br>        public void main() {<br>            ...<br>        }<br>    }</pre><ul><li>PascalNamingConvention</li></ul><h3>Compilation Process:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r6MgJ4EvTl46oVhi.png" /><figcaption>Compilation Process</figcaption></figure><ul><li><strong>JRE</strong>: Java Runtime Environment</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wAhHoMooV0D3kZ5H.png" /><figcaption>JRE</figcaption></figure><pre>avinashbest/ $ javac Main.java</pre><pre>avinashbest/ $ cd ..</pre><pre>src/ $ java com.avinashbest.Main</pre><h3>Interesting Facts about Java:</h3><ul><li>Java was developed by James Gosling in 1995.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qVsehiVsooW6vlfk.png" /></figure><h3>Types:</h3><ul><li>Primitive: for storing simple values, like numbers, characters, booleans.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*uXDkk85Owk6c20tb.png" /></figure><ul><li>How primitive types are stored in memory.</li></ul><pre>public class Main {<br>        public static void main(String[] args) {<br>            int x = 1;<br>            int y = 1;<br>        }<br>    }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*ADMJkbg5uofkOflQ.png" /></figure><ul><li>Reference: for storing complex objects, like date, mail, message</li><li>How primitive types are stored in memory.</li></ul><pre>public class Main {<br>        public static void main(String[] args) {<br>            Point point1 = new Point(1, 1);<br>            Point point2 = point1;<br>        }<br>    }<br>}<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*-XqNA6SgatZodfSb.png" /></figure><h3>String:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            String message = &quot;Hello World&quot; + &quot;!!&quot;;</pre><pre>            System.out.println(message.endsWith(&quot;!!&quot;));<br>            System.out.println(message.startsWith(&quot;!!&quot;));<br>            System.out.println(message.length());<br>            System.out.println(message.indexOf(&quot;l&quot;));<br>            System.out.println(message.indexOf(&quot;sky&quot;));<br>            System.out.println(message.replace(&quot;!&quot;, &quot;*&quot;));<br>            System.out.println(message.toLowerCase(Locale.ROOT));<br>            System.out.println(message.toUpperCase(Locale.ROOT));<br>            System.out.println(message.trim()) ; /*To remove unnecessary space.*/</pre><pre>            /*NOTE: IN JAVA, ALL THE METHOD WHICH PERFORM OPERATION ON STRING RETURNS A NEW STRING.*/<br>            /*ALL THE STRING IN JAVA ARE IMMUTABLE*/<br>            System.out.println(message);<br>        }<br>    }</pre><h3>Escape Sequence:</h3><pre>public class Main {</pre><pre>        public static void main(String[] args) {<br>            String message1 = &quot;Hello \&quot;Avinash\&quot;&quot;;<br>            String message2 = &quot;C:\\Windows\\...&quot;;<br>            String message3 = &quot;C:\nWindows\n...&quot;;<br>            String message4 = &quot;C:\tWindows\t...&quot;;</pre><pre>            System.out.println(message1);<br>            System.out.println(message2);<br>            System.out.println(message3);<br>            System.out.println(message4);<br>        }<br>    }</pre><h3>Arrays:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int[] number = {2, 4, 6, 8, 10};<br>            System.out.println(number.length);<br>            Arrays.sort(number);<br>            System.out.println(Arrays.toString(number));<br>        }<br>    }</pre><h3>Multi-Dimensional Arrays:</h3><pre>public class Main {</pre><pre>        public static void main(String[] args) {<br>            int[][] numbers = {{1, 2, 3}, {4, 5, 6}};<br>            System.out.println(Arrays.toString(numbers));<br>            System.out.println(Arrays.deepToString(numbers));<br>        }<br>    }</pre><h3>Arithmetic Expressions:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int result = 10 + 3;<br>            System.out.println(result);<br>            result = 10 - 3;<br>            System.out.println(result);<br>            result = 10 / 3;<br>            System.out.println(result);<br>            result = 10 * 3;<br>            System.out.println(result);<br>            result = 10 % 3;<br>            System.out.println(result);<br>        }<br>    }</pre><h3>Increment / Decrement Operator:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int x = 1;<br>            x++;<br>            System.out.println(x);<br>            ++x;<br>            System.out.println(x);</pre><pre>            x = 1;<br>            int y = x++; // post-increment<br>            System.out.println(x + &quot;\t&quot; + y);<br>            y = ++x; //pre-increment<br>            System.out.println(x + &quot;\t&quot; + y);</pre><pre>            x += 2; //x = x + 2<br>            System.out.println(x);<br>            x -= 2; //x = x - 2<br>            System.out.println(x);<br>            x *= 2; //x = x * 2<br>            System.out.println(x);<br>            x /= 2; //x = x / 2<br>            System.out.println(x);<br>            x %= 2; //x = x % 2<br>            System.out.println(x);<br>        }<br>    }</pre><h3>Order of Operations:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*p-Jah5M7GsE-BQes.png" /></figure><pre>public class Main {<br>        public static void main(String[] args) {<br>            int x = (10 + 3) * 2;<br>        }<br>    }</pre><h3>Type Casting:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            /*Implicit Casting*/<br>            /*byte &gt; short &gt; int &gt; long &gt; float &gt; double*/<br>            short x = 1;<br>            int y = x + 2;<br>            System.out.println(y);<br>            /*Explicit Casting*/<br>            double a = 1.1;<br>            int b = (int) (a + 2);<br>            System.out.println(b);<br>            /*Parsing String in Integer*/<br>            String str = &quot;123&quot;;<br>            System.out.println(Integer.parseInt(str));<br>        }<br>    }</pre><h3>The Math Class:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            System.out.println(Math.round(1.2F));<br>            System.out.println(Math.round(1.2));<br>            System.out.println(Math.ceil(1.2));<br>            System.out.println(Math.floor(1.2));<br>            System.out.println(Math.max(200, 300));<br>            System.out.println(Math.min(200, 300));<br>            System.out.println(Math.random());//by default return a doubleType random number b/w 0 to 1<br>            System.out.println(Math.round(Math.random() * 100));<br>            System.out.println((int) (Math.random() * 100));<br>        }<br>    }</pre><h3>Formatting Numbers:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            NumberFormat currency = NumberFormat.getCurrencyInstance();<br>            String result = currency.format(123456.789);<br>            System.out.println(result);</pre><pre>            NumberFormat percent = NumberFormat.getPercentInstance();<br>            String percentage = percent.format(0.1);<br>            System.out.println(percentage);</pre><pre>            System.out.println(NumberFormat.getCurrencyInstance().format(134343134313L));<br>        }<br>    }</pre><h3>Reading Input:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            Scanner scanner = new Scanner(System.in);<br>            System.out.print(&quot;Age: &quot;);<br>            byte age = scanner.nextByte();<br>            System.out.print(&quot;Name: &quot;);<br>    //        String name = scanner.next(); //returns the next token<br>            String name = scanner.nextLine().trim(); //returns next line<br>            System.out.println(&quot;You are &quot; + age);<br>            System.out.println(&quot;Your name &quot; + name);<br>        }<br>    }</pre><h3>Mortgage Calculator — v1.0:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            final byte MONTHS_IN_YEAR = 12;<br>            final byte PERCENT = 100;</pre><pre>            Scanner scanner = new Scanner(System.in);</pre><pre>            System.out.print(&quot;Principal: &quot;);<br>            int principal = scanner.nextInt();</pre><pre>            System.out.print(&quot;Annual Interest Rate: &quot;);<br>            float annualInterest = scanner.nextFloat();<br>            float monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;</pre><pre>            System.out.print(&quot;Period (Years): &quot;);<br>            byte years = scanner.nextByte();<br>            int numberOfPayments = years * MONTHS_IN_YEAR;</pre><pre>            /*calculating mortgage*/<br>            double mortgage = principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) <br>            / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1));</pre><pre>            System.out.println(&quot;Mortgage: &quot; + NumberFormat.getCurrencyInstance().format(mortgage));<br>        }<br>    }</pre><h3>Comparison Operators:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int x = 1;<br>            int y = 1;<br>            System.out.println(x == y);<br>            System.out.println(x != y);<br>            System.out.println(x &gt; y);<br>            System.out.println(x &gt;= y);<br>            System.out.println(x &lt; y);<br>            System.out.println(x &lt;= y);<br>        }<br>    }</pre><h3>Logical Operators:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int temperature = 22;<br>            boolean isWarm = temperature &gt; 20 &amp;&amp; temperature &lt; 30;<br>            System.out.println(isWarm);</pre><pre>            boolean hasHighIncome = true;<br>            boolean hasGoodCredit = true;<br>            boolean hasCriminalRecord = false;<br>            boolean isEligible = (hasGoodCredit || hasHighIncome) &amp;&amp; !hasCriminalRecord;<br>            System.out.println(isEligible);<br>        }<br>    }</pre><h3>if-statement:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int temperature = 32;<br>            if (temperature &gt; 32) {<br>                System.out.println(&quot;It&#39;s a hot day&quot;);<br>                System.out.println(&quot;Drink water&quot;);<br>            } else if (temperature &gt; 20) {<br>                System.out.println(&quot;Beautiful day&quot;);<br>            } else {<br>                System.out.println(&quot;Cold day&quot;);<br>            }<br>            /*Simplifying if-statement*/<br>            int income = 120_000;<br>            boolean hasHighIncome;<br>            if (income &gt; 100_000) {<br>                hasHighIncome = true;<br>            } else {<br>                hasHighIncome = false;<br>            }<br>            /*Above Expression can be simplified by professional be like*/<br>            int income = 120_000;<br>            boolean hasHighIncome = income &gt; 100_000;<br>        }<br>    }</pre><h3>Ternary Operators:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int income = 120_000;<br>            String className;<br>            if (income &gt; 100_000) {<br>                className = &quot;First&quot;;<br>            } else {<br>                className = &quot;Economy&quot;;<br>            }<br>            /*Simplification can be done as*/<br>            income = 120_000;<br>            className = &quot;Economy&quot;;<br>            if (income &gt; 100_000) {<br>                className = &quot;First&quot;;<br>            }<br>            /*More Simplification can be done using Ternary Operator*/<br>            income = 120_000;<br>            className = (income &gt; 100_000) ? &quot;First&quot; : &quot;Economy&quot;;<br>        }<br>    }</pre><h3>Switch Statements:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            String role = &quot;admin&quot;;<br>            switch (role) {<br>                case &quot;admin&quot;:<br>                    System.out.println(&quot;You&#39;re an admin&quot;);<br>                    break;<br>                case &quot;moderator&quot;:<br>                    System.out.println(&quot;You&#39;re a moderator&quot;);<br>                    break;<br>                default:<br>                    System.out.println(&quot;You&#39;re a guest&quot;);<br>            }</pre><pre>            if (role == &quot;admin&quot;) {<br>                System.out.println(&quot;You&#39;re an admin&quot;);<br>            } else if (role == &quot;moderator&quot;) {<br>                System.out.println(&quot;You&#39;re a moderator&quot;);<br>            } else {<br>                System.out.println(&quot;You&#39;re a guest&quot;);<br>            }<br>        }<br>    }</pre><h3>Exercise: FizzBuzz:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            Scanner scanner = new Scanner(System.in);<br>            System.out.print(&quot;Number: &quot;);<br>            int number = scanner.nextInt();</pre><pre>            boolean moduloFive = (number % 5) == 0;<br>            boolean moduloThree = (number % 3) == 0;</pre><pre>            if (moduloFive &amp;&amp; moduloThree) {<br>                System.out.println(&quot;FizzBuzz&quot;);<br>            } else if (moduloFive) {<br>                System.out.println(&quot;Fizz&quot;);<br>            } else if (moduloThree) {<br>                System.out.println(&quot;Buzz&quot;);<br>            } else {<br>                System.out.println(number);<br>            }<br>        }<br>    }</pre><h3>Loops in Java:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            Scanner scan = new Scanner(System.in);<br>            /*FOR LOOPS*/<br>            for (int i = 0; i &lt; 5; i++) {<br>                System.out.println(&quot;Hello, Java!&quot;);<br>            }<br>            /*WHILE LOOPS: USED WHEN DON&#39;T KNOW HOW MANY TIMES WE NEED TO EXECUTE CODE*/<br>            int i = 0;<br>            while (i &lt; 5) {<br>                System.out.println(&quot;Hello, Java!&quot;);<br>                i++;<br>            }</pre><pre>            String input = &quot;&quot;;<br>            while (!input.equals(&quot;quit&quot;)) {<br>                System.out.print(&quot;Input: &quot;);<br>                input = scan.next().toLowerCase(Locale.ROOT);<br>                System.out.println(input);<br>            }<br>            /*DO-WHILE LOOPS: SIMILAR TO WHILE-LOOP BUT IT EXECUTES ATLEAST 1 TIME*/<br>            do {<br>                System.out.print(&quot;Input: &quot;);<br>                input = scan.next().toLowerCase(Locale.ROOT);<br>                System.out.println(input);<br>            } while (!input.equals(&quot;quit&quot;));<br>        }<br>    }</pre><h3>Break &amp; Continue Keywords:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            Scanner scan = new Scanner(System.in);<br>            String input = &quot;&quot;;</pre><pre>            while (true) {<br>                System.out.print(&quot;Input: &quot;);<br>                input = scan.next().toLowerCase(Locale.ROOT);<br>                if (input.equals(&quot;pass&quot;)) {<br>                    continue;/*moves control to the beginning of  the loop*/<br>                }<br>                if (input.equals(&quot;quit&quot;)) {<br>                    break;/*break out of the loop*/<br>                }<br>                System.out.println(input);<br>            }<br>        }<br>    }</pre><h3>Mortgage Calculator — v2.0:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            final byte MONTHS_IN_YEAR = 12;<br>            final byte PERCENT = 100;</pre><pre>            int principal;<br>            float annualInterest;<br>            float monthlyInterest;<br>            byte years;<br>            int numberOfPayments;</pre><pre>            Scanner scanner = new Scanner(System.in);</pre><pre>            while (true) {<br>                System.out.print(&quot;Principal ($1K - $1M): &quot;);<br>                principal = scanner.nextInt();<br>                if (principal &gt;= 1000 &amp;&amp; principal &lt;= 1_000_000) {<br>                    break;<br>                }<br>                System.out.println(&quot;Enter a value between $1000 and $1,000,000&quot;);<br>            }</pre><pre>            while (true) {<br>                System.out.print(&quot;Annual Interest Rate (1% - 30%): &quot;);<br>                annualInterest = scanner.nextFloat();<br>                if (annualInterest &gt;= 1 &amp;&amp; annualInterest &lt;= 30) {<br>                    monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;<br>                    break;<br>                }<br>                System.out.println(&quot;Enter a value between 1 and 30&quot;);<br>            }</pre><pre>            while (true) {<br>                System.out.print(&quot;Period (1 Years- 30 Years): &quot;);<br>                years = scanner.nextByte();<br>                if (years &gt;= 1 &amp;&amp; years &lt;= 30) {<br>                    numberOfPayments = years * MONTHS_IN_YEAR;<br>                    break;<br>                }<br>                System.out.println(&quot;Enter a value between 1 and 30&quot;);</pre><pre>            }<br>            /*calculating mortgage*/<br>            double mortgage = principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) <br>            / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1));</pre><pre>            System.out.println(&quot;Mortgage: &quot; + NumberFormat.getCurrencyInstance().format(mortgage));<br>        }<br>    }</pre><h3>Creating Methods:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            String message = greetUser(&quot;Avinash&quot;, &quot;Kumar&quot;);<br>            System.out.println(message);<br>        }</pre><pre>        public static String greetUser(String firstName, String lastName){<br>          return &quot;Hello &quot; + firstName + &quot; &quot; + lastName;<br>        }<br>    }</pre><h3>Mortgage Calculator — v3.0:</h3><pre>public class Main {<br>        public static void main(String[] args) {<br>            int principal = (int) readNumber(&quot;Principal ($1K - $1M): &quot;, 1000, 1_000_000);<br>            float annualInterest = (float) readNumber(&quot;Annual Interest Rate (1% - 30%): &quot;, 1, 30);<br>            byte years = (byte) readNumber(&quot;Period (1 Years- 30 Years): &quot;, 1, 30);</pre><pre>            double mortgage = calculateMortgage(principal, annualInterest, years);<br>            System.out.println(&quot;Mortgage: &quot; + NumberFormat.getCurrencyInstance().format(mortgage));<br>        }</pre><pre>        public static double readNumber(String prompt, double min, double max) {<br>            Scanner scanner = new Scanner(System.in);<br>            double value;<br>            while (true) {<br>                System.out.print(prompt);<br>                value = scanner.nextDouble();<br>                if (value &gt;= min &amp;&amp; value &lt;= max) {<br>                    break;<br>                }<br>                System.out.println(&quot;Enter a value between &quot; + min + &quot; and &quot; + max);<br>            }<br>            return value;<br>        }</pre><pre>        public static double calculateMortgage(int principal, float annualInterest, byte years) {<br>            final byte MONTHS_IN_YEAR = 12;<br>            final byte PERCENT = 100;</pre><pre>            float monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;<br>            short numberOfPayments = (short) (years * MONTHS_IN_YEAR);</pre><pre>            return principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) <br>            / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1));<br>        }<br>    }</pre><h3>Mortgage Calculator — Clean Code:</h3><pre>public class Main {<br>        final static byte MONTHS_IN_YEAR = 12;<br>        final static byte PERCENT = 100;</pre><pre>        public static void main(String[] args) {<br>            int principal = (int) readNumber(&quot;Principal ($1K - $1M): &quot;, 1000, 1_000_000);<br>            float annualInterest = (float) readNumber(&quot;Annual Interest Rate (1% - 30%): &quot;, 1, 30);<br>            byte years = (byte) readNumber(&quot;Period (1 Years- 30 Years): &quot;, 1, 30);</pre><pre>            printMortgage(principal, annualInterest, years);</pre><pre>            printPaymentSchedule(principal, annualInterest, years);<br>        }</pre><pre>        private static void printPaymentSchedule(int principal, float annualInterest, byte years) {<br>            System.out.println();<br>            System.out.println(&quot;PAYMENTS SCHEDULE:&quot;);<br>            System.out.println(&quot;------------------&quot;);<br>            for (short month = 1; month &lt;= years * MONTHS_IN_YEAR; month++) {<br>                double balance = calculateBalance(principal, annualInterest, years, month);<br>                System.out.println(NumberFormat.getCurrencyInstance().format(balance));<br>            }<br>        }</pre><pre>        private static void printMortgage(int principal, float annualInterest, byte years) {<br>            System.out.println();<br>            System.out.println(&quot;MORTGAGE&quot;);<br>            System.out.println(&quot;--------&quot;);<br>            double mortgage = calculateMortgage(principal, annualInterest, years);<br>            System.out.println(&quot;Monthly Payments: &quot; + NumberFormat.getCurrencyInstance().format(mortgage));<br>        }</pre><pre>        public static double readNumber(String prompt, double min, double max) {<br>            Scanner scanner = new Scanner(System.in);<br>            double value;<br>            while (true) {<br>                System.out.print(prompt);<br>                value = scanner.nextDouble();<br>                if (value &gt;= min &amp;&amp; value &lt;= max) {<br>                    break;<br>                }<br>                System.out.println(&quot;Enter a value between &quot; + min + &quot; and &quot; + max);<br>            }<br>            return value;<br>        }</pre><pre>        public static double calculateBalance(int principal, float annualInterest, byte years, short numberOfPaymentsMade) {<br>            float monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;<br>            short numberOfPayments = (short) (years * MONTHS_IN_YEAR);</pre><pre>            double balance = principal * (Math.pow(1 + monthlyInterest, numberOfPayments) <br>            - Math.pow(1 + monthlyInterest, numberOfPaymentsMade)) <br>            / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1);</pre><pre>            return balance;<br>        }</pre><pre>        public static double calculateMortgage(int principal, float annualInterest, byte years) {<br>            float monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;<br>            short numberOfPayments = (short) (years * MONTHS_IN_YEAR);</pre><pre>            return principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) <br>            / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1));<br>        }<br>    }</pre><h3>Refactoring</h3><ul><li>Changing the structure of the code without changing its behaviour.</li><li>Keep your methods short</li><li>Extract repetitive patterns</li><li>Extract highly related statements</li></ul><h3>Types of Errors</h3><ul><li>Compile — Time Errors</li><li>Run — Time Errors</li></ul><h3>Running a Java Archive (.jar) in local:</h3><pre>$ java -jar file-name.jar</pre><h3>Thank You!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*UaiYWrCybq4rt85i.png" /></figure><h3>Credits:</h3><ul><li>CodeWithMosh - <a href="https://codewithmosh.com/">https://codewithmosh.com/</a></li><li>Avinash Kumar - <a href="https://github.com/avinashbest/core-java">https://github.com/avinashbest/core-java</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1b0984fa834" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Super Charge Your Linux Experience, By following these steps.]]></title>
            <link>https://avinashbest.medium.com/super-charge-your-linux-experience-by-following-these-steps-f8aacbb45b2c?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8aacbb45b2c</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[after-linux-install]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[boost-linux]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Tue, 16 Mar 2021 16:46:56 GMT</pubDate>
            <atom:updated>2021-03-16T19:09:26.429Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>After installing a fresh Linux Distro Ubuntu</strong>, you should probably do these following things to super charge your Linux experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*Tbul4fJLsWz8f5iDUXkiDQ.png" /><figcaption>Linux</figcaption></figure><ul><li>First thing you should setup after installing the Ubuntu OS is setup the live patch system, it allows you to install and update the Linux kernel without restarting the system.<strong> It’s not recommended for personal computer but if you want you can use this feature.</strong></li><li>By default Ubuntu distro only allows you to access the default repository for the software installation but you get access to many 3rd party software as well, by checking the feature shown below from the software update menu, check the canonical partners software.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*7foR-RN9o9h2MvcghELOSQ.png" /></figure><ul><li>So, the first command we are going to run on the freshly installed Linux machine, Open the terminal and just copy paste the given below command:</li></ul><blockquote><strong>sudo apt-get update; sudo apt-get upgrade</strong></blockquote><ul><li>These command will check for update and install various packages, as you have a freshly installed operating system but there may be some updates available for installation. After that just<strong> restart </strong>the system.</li><li>Now install the required drivers from the ‘Additional drivers application’ (if available).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*AptOP0O9JPoPLFr4xiLurw.png" /></figure><ul><li>Now open the terminal and run the given command to install essential.</li></ul><blockquote><strong>sudo apt-get install build-essential</strong></blockquote><h3>Now its time to install some software and improve performance of the machine.</h3><ul><li>You may use the Ubuntu software application to install using GUI interface but we are going through the another way which is with the help of <strong>Terminal.</strong></li><li>Now open the terminal and copy &amp; paste the below commands, these commands will install VLC media player, GIMP for Photo Editing Software and gparted for disk management, synaptic which is excellent for package management.</li></ul><blockquote><strong>sudo apt-get install vlc gimp gparted synaptic</strong></blockquote><ul><li>Download the Google Chrome from the Web, and open the terminal where the file is downloaded and run the below command to install the google chrome.</li></ul><blockquote><strong>sudo dpkg -i package_name</strong></blockquote><p>To play most of the video and music file you need to install the <strong>Ubuntu media codec</strong> which are by default restricted, to install run the below command. You will be asked to accept the user’s agreement <strong>press the tab key</strong> and then hit the <strong>enter key</strong>.</p><blockquote><strong>sudo apt-get install ubuntu-restricted-extras</strong></blockquote><ul><li>A regular backup of the system is really a good habit, so there is a timeshift ubuntu backup tool which is very powerful to restore you system from system crashing and mesh-ups, it can completely restore your system even if you completely delete your system. To install it run the below command.</li></ul><blockquote><strong>sudo apt-get install timeshift</strong></blockquote><ul><li>Here, comes my favorite feature, everyone have a favourite application which they use frequently, preload is a intellegent demon that observe that the which application you use the most and keep them in memory before you open them (it works like cache memory).</li></ul><blockquote><strong>sudo apt-get install preload</strong></blockquote><ul><li>Advanced <strong>firefox</strong> tweaks for stellar improvement, the GPU of the system is pretty most idle most of the time but have payed for it, so why now let it to be work, the GPU are extremely powerful for the tasks like <strong>rendering, </strong>but by default browser in Linux uses CPU to do the most of the stuffs. Lets make our GPU to work open firefox.</li><li>Lets enable the hardware acceleration for the firefox, type <strong><em>about:config</em></strong> in the address bar and accept the terms then search for <strong><em>layers.acceleration.force-enabled </em></strong>and set the boolean to <strong>true</strong> which is by default set to be false in Ubuntu</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ptKXuKOvZ0Q7H3iI_PRgA.png" /><figcaption>firefox</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jFdDikVZ_BgxNRwyJ-7J5w.png" /><figcaption>hardware-acceleration firefox</figcaption></figure><ul><li>Further one more step to boost some more performance by enabling the <strong><em>gfx.webrender.all </em></strong>as shown below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8kbyzkbnILiGJZMvmh8Pw.png" /><figcaption>gfx.webrender.all</figcaption></figure><ul><li>The most important feature is GNOME Tweak tool which enable to use 3rd extension and themes and many more thing just run the below command to install and explore about it (it would be a very large topic if covered in this blog)</li></ul><blockquote><strong>sudo apt-get install gnome-tweak-tool</strong></blockquote><ul><li>Then <em>install the browser compatible for gnome tweak tool </em>to customise the Ubuntu as per your choice (with a wide range of themes, extension and many more features), open the <strong>chrome web store</strong> or <strong>firefox ad-ons</strong> and search for <strong>gnome shell integration.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dEGj_Lvrvfgkk3JxyvhmOQ.png" /></figure><ul><li>To Improve the Laptop Battery life: Just run the given below command and you don’t need to do anything else. It’ll make your laptop battery last longer by implementing some power-saving protocols.</li></ul><blockquote><strong>sudo apt install tlp tlp-rdw</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*I5DbpkcU-dejt1M3fPe7cA.png" /></figure><blockquote><strong>Thanks for reading: follow me </strong><a href="https://medium.com/u/cd809de4c470"><strong>Avinash Kumar</strong></a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8aacbb45b2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Configuring C++ Debugger in VS Code]]></title>
            <link>https://avinashbest.medium.com/configuring-c-debugger-in-vs-code-96912c0ecc06?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/96912c0ecc06</guid>
            <category><![CDATA[debugger]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[cpp-vscode]]></category>
            <category><![CDATA[cpp-debugger]]></category>
            <category><![CDATA[midebuggerpath]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Sat, 28 Nov 2020 20:32:58 GMT</pubDate>
            <atom:updated>2020-11-28T20:32:58.191Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Debugger: </strong>A debugger or debugging tool is a computer program used to test and debug other programs. The main use of a debugger is to run the target program under controlled conditions that permit the programmer to track its operations in progress and monitor changes in computer resources that may indicate malfunctioning code.</blockquote><p>To start a debug session in a program first you have to make a break-point from where the malfunctioning is happening in the code, for e.g, below is a program demonstrated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZTuZ_Nxlq-Qibm80KjIoKg.png" /></figure><blockquote>Now, Click on Run Menu =&gt; Start Debugging, then the VS code will ask you to configure the debugger because VS code only ships with Node.js Debugger by default, Click on Add Configuration, You will be redirected to a editor named “launch.json” like this:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uz5tZDYLiSwvFoiFqDn-lQ.png" /></figure><blockquote>Now You will see a Add Configuration button on the bottom right-side, Click on and Select the gdb launch</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bAtMvLvyEZXgi5Q304Rf7g.png" /></figure><blockquote>Now, Configure the launch.json file same as below code is given:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCEAnJFEzgjCgHd9feK59A.png" /></figure><blockquote>You have Careful while giving value to miDebuggerPath, if the compiler is already added in the path variable just leave it blank, it will automatically calls the gdb.exe which is the debugger of the C++ ships with MinGW library, otherwise add the folder location of the gdb.exe</blockquote><p>Congratulations! Debugger is set. Go to terminal compile the program using -g flag with g++ which will create a.exe file in the same directory, Now just Click on Run Menu =&gt; Start Debugging.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jtP9POzfNGk1zZa5P8SWCw.png" /></figure><blockquote>Don’t forget to remove the break-point after work done.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96912c0ecc06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Writing and Formatting in GitHub Markdown.]]></title>
            <link>https://avinashbest.medium.com/basic-writing-and-formatting-in-github-markdown-44ed8566f4aa?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/44ed8566f4aa</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[github-markdown]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[formatting-code]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Sat, 21 Nov 2020 20:29:59 GMT</pubDate>
            <atom:updated>2020-11-21T20:29:59.933Z</atom:updated>
            <content:encoded><![CDATA[<p>To create a heading, add #(pound) one to six before the Heading text. The number of # will determine the size of the heading</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxF5eqpPylzV5HkjYdOzZw.png" /></figure><h3>Styling Text:</h3><p>You can indicate emphasis with bold, italic &amp; strike through</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*_a7vmPQeu7E7FDZAyIpcxw.png" /></figure><h3><strong>Quoting Text:</strong></h3><p>You can quote text with &gt; symbol</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*bZmJv6KxmXcdfYRxLZCI7w.png" /></figure><h3><strong>Quoting Code:</strong></h3><p>You can call out code or command within a sentence or paragraph with ‘single backticks’. The text within the backticks will not be formatted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_w6qIWWugKo_Q4eDYo3Ew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*BWcNDo3DxVcbDR6pstPRag.png" /></figure><h3><strong>Links:</strong></h3><p>You can create an inline link by wrapping link text in brackets [ ], and then wrapping the URL in parentheses ( ). Below Image, having file id which you find for every file available on internet, giving below id is of google drive image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vpxAVRolDoxaB_jaVfnCYw.png" /></figure><h3><strong>Lists:</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*UmrEZgVgQuMHIP-9GV4eMg.png" /></figure><h3><strong>Creating Table:</strong></h3><p>You can create Table using | symbol, and you can use :-: for center alignment text in the cell, :- for left alignment, similarly for right alignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*rs7z374kCOqPPrPiV9PaZg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44ed8566f4aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Uninstall & Install Windows Notepad.exe]]></title>
            <link>https://avinashbest.medium.com/uninstall-install-windows-notepad-exe-683df30b0712?source=rss-cd809de4c470------2</link>
            <guid isPermaLink="false">https://medium.com/p/683df30b0712</guid>
            <category><![CDATA[notepad]]></category>
            <category><![CDATA[windows-10]]></category>
            <category><![CDATA[re-install-notepad]]></category>
            <category><![CDATA[uninstall-notepad]]></category>
            <category><![CDATA[lost-notepad]]></category>
            <dc:creator><![CDATA[Avinash Kumar]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 19:24:53 GMT</pubDate>
            <atom:updated>2020-11-15T19:24:53.153Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have uninstalled the Notepad application and now want it back, you can easily reinstall it in just few steps, or if you lose it by mistake it’s just a few steps away to re-install it.</p><p>Step 1. Open Setting and Goto Apps &amp; Features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e3SWUr5OcrQ7N-aC9ZPU_w.png" /></figure><p>Step 2. In the Right Panel of the Window, Click on Optional Features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TrH67LupwrKsfbAMkfJcOQ.png" /></figure><p>Step 3. In the Left Panel of the Window, Click on + Add a Feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z8YLuN8JmTVc9CbxVzuJDQ.png" /></figure><p>Step 4. Now a pop-up Window Open, here you have to search “Notepad” and just click on Bottom-Left Install Button. Congrats! You have your notepad back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANI8jqc2RDOmTQeu8H7j_A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=683df30b0712" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>