<?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:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Ghost Code]]></title><description><![CDATA[Code. Errors. Ideas. Coffee.]]></description><link>https://ghostcode.in/</link><image><url>https://ghostcode.in/favicon.png</url><title>Ghost Code</title><link>https://ghostcode.in/</link></image><generator>Ghost 5.25</generator><lastBuildDate>Tue, 14 Apr 2026 22:28:48 GMT</lastBuildDate><atom:link href="https://ghostcode.in/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[App Architecture Study: Instagram]]></title><description><![CDATA[<!--kg-card-begin: html-->
<p>Instagram is one of the most used social media apps in Android and iOS. The core functionality of this app is around sharing photos instantly and it performs this function with a certain simplicity and elegance. </p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="425" height="754" src="https://ghostcode.in/wp-content/uploads/2016/09/insta-3.jpg" alt class="wp-image-48720" srcset="https://ghostcode.in/content/images/wordpress/2016/09/insta-3.jpg 425w, https://ghostcode.in/content/images/wordpress/2016/09/insta-3-169x300.jpg 169w" sizes="(max-width: 425px) 100vw, 425px"><figcaption>The simplicity of Instagram</figcaption></figure></div>



<p>We can learn a lot about design when we delve</p>]]></description><link>https://ghostcode.in/app-architecture-study-instagram/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed042</guid><category><![CDATA[android]]></category><category><![CDATA[app]]></category><category><![CDATA[arch]]></category><category><![CDATA[General]]></category><category><![CDATA[instagram]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Fri, 24 May 2019 16:54:42 GMT</pubDate><media:content url="https://ghostcode.in/content/images/wordpress/2016/09/instagram-banner-01.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: html-->
<img src="https://ghostcode.in/content/images/wordpress/2016/09/instagram-banner-01.png" alt="App Architecture Study: Instagram"><p>Instagram is one of the most used social media apps in Android and iOS. The core functionality of this app is around sharing photos instantly and it performs this function with a certain simplicity and elegance. </p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" width="425" height="754" src="https://ghostcode.in/wp-content/uploads/2016/09/insta-3.jpg" alt="App Architecture Study: Instagram" class="wp-image-48720" srcset="https://ghostcode.in/content/images/wordpress/2016/09/insta-3.jpg 425w, https://ghostcode.in/content/images/wordpress/2016/09/insta-3-169x300.jpg 169w" sizes="(max-width: 425px) 100vw, 425px"><figcaption>The simplicity of Instagram</figcaption></figure></div>



<p>We can learn a lot about design when we delve deeper into the design of Instagram.  Over the years, Instagram has evolved in its design and with the addition of new features, edging closer to a more simpler design that highlights it&#x2019;s core, the photos.</p>



<p>Check out the App breakdown in the following presentation:</p>



<div class="ead-preview"><div class="ead-document" style="position: relative;padding-top: 90%;"><iframe src="//view.officeapps.live.com/op/embed.aspx?src=http%3A%2F%2Fghostcode.in%2Fwp-content%2Fuploads%2F2016%2F09%2FInstagram-architecture.pptx" title="Embedded Document" class="ead-iframe" style="width: 100%;height: 100%;border: none;position: absolute;left: 0;top: 0;"></iframe></div></div>



<p>Also check out this article: <a href="https://medium.com/lauren-swainstons-portfolio/10-universal-design-principles-as-used-by-instagram-56c042ee9a00">10 Universal Design Principles as used by Instagram</a> by <a href="https://medium.com/@laurenjaneswainston">Lauren Swainston</a>, where some of the finer design principles used by Instagram are highlighted.</p>



<p><em><strong>Disclaimer:</strong>&#xA0;The views and opinions expressed in this article are those of the authors and do not reflect the official analysis of Whatsapp. This article is a personal analysis based on a visual interpretation on the architecture of the app.</em></p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[How to create the 'Share to' popup in Android using share intent?]]></title><description><![CDATA[<!--kg-card-begin: html--><p>Providing the option for users to share data from your app to another app is very useful. This feature maybe used just to share the install link of your app for reference credits or just for social sharing.</p>
<p>Google provides a very simple method of sharing data to other apps.</p>]]></description><link>https://ghostcode.in/how-to-create-the-share-to-popup-in-android-using-share-intent/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed041</guid><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Sat, 09 Mar 2019 14:33:49 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>Providing the option for users to share data from your app to another app is very useful. This feature maybe used just to share the install link of your app for reference credits or just for social sharing.</p>
<p>Google provides a very simple method of sharing data to other apps. This is using the Share Intent. Below shows the use of share intent, where a text and an image are shared:</p>
<pre class="brush: xml; title: ; notranslate" title>
File file = new File(getActivity().getCacheDir(), &quot;app_promo.png&quot;);

Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, &quot;Check out this awesome app&quot;);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
sendIntent.setType(&quot;image/*&quot;);
context.startActivity(Intent.createChooser(sendIntent, &quot;Share to:&quot;));
</pre>
<p>If you use the above code in the OnClickListener of the Share button, you will have implemented the Share feature in your app. Yes, it is as simple as that</p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[Custom Toolbar - Image on Toolbar in Android]]></title><description><![CDATA[<!--kg-card-begin: html-->
<p>The toolbar is one of the Material Design elements which is very versatile when used along with AppBarLayout. In this article, we are going to see how we can replace the standard toolbar of android with a custom toolbar that holds an image.</p>



<p>First, make sure to create a Basic</p>]]></description><link>https://ghostcode.in/custom-toolbar-image-on-toolbar-in-android/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed040</guid><category><![CDATA[android]]></category><category><![CDATA[General]]></category><category><![CDATA[toolbar]]></category><category><![CDATA[xml]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Wed, 20 Feb 2019 09:28:05 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html-->
<p>The toolbar is one of the Material Design elements which is very versatile when used along with AppBarLayout. In this article, we are going to see how we can replace the standard toolbar of android with a custom toolbar that holds an image.</p>



<p>First, make sure to create a Basic Activity from the template picker and not the Empty activity as we need the Coordinator Layout with the App Bar Layout.  Below you can see the default activity_main.xml generated:</p>



<p><pre class="brush: xml; title: activity_main.xml; notranslate" title="activity_main.xml"> 
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    tools:context=&quot;.MainActivity&quot;&amp;gt;

    &amp;lt;com.google.android.material.appbar.AppBarLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:theme=&quot;@style/AppTheme.AppBarOverlay&quot;&amp;gt;

        &amp;lt;androidx.appcompat.widget.Toolbar
            android:id=&quot;@+id/toolbar&quot;
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;?attr/actionBarSize&quot;
            android:background=&quot;?attr/colorPrimary&quot;
            app:popupTheme=&quot;@style/AppTheme.PopupOverlay&quot; /&amp;gt;

    &amp;lt;/com.google.android.material.appbar.AppBarLayout&amp;gt;

    &amp;lt;include layout=&quot;@layout/content_main&quot; /&amp;gt;

    &amp;lt;com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id=&quot;@+id/fab&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_gravity=&quot;bottom|end&quot;
        android:layout_margin=&quot;@dimen/fab_margin&quot;
        app:srcCompat=&quot;@drawable/ic_action_more&quot; /&amp;gt;

&amp;lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&amp;gt;
</pre></p>



<p>Create a new layout called toolbar.xml. We need to add the image in the Toolbar element. But as this element can have only one child, we will place our ImageView in a ConstraintLayout. Additionally, you can also set the background colour of the toolbar, below eg. shown uses the bg colour white. </p>



<p>Make sure to have the app_logo.png added to the drawable folder and support for respective screen sizes.</p>



<p><pre class="brush: xml; title: toolbar.xml; notranslate" title="toolbar.xml">
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;android.support.v7.widget.Toolbar
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;?actionBarSize&quot;
    android:elevation=&quot;5dp&quot;
    app:contentInsetLeft=&quot;0dp&quot;
    app:contentInsetStart=&quot;0dp&quot;
    android:background=&quot;@android:color/white&quot;&amp;gt;

    &amp;lt;android.support.constraint.ConstraintLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;
        &amp;lt;ImageView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_marginEnd=&quot;8dp&quot;
            android:layout_marginStart=&quot;8dp&quot;
            android:src=&quot;@drawable/app_logo&quot;
            app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
            app:layout_constraintEnd_toEndOf=&quot;parent&quot;
            app:layout_constraintStart_toStartOf=&quot;parent&quot;
            app:layout_constraintTop_toTopOf=&quot;parent&quot; /&amp;gt;
    &amp;lt;/android.support.constraint.ConstraintLayout&amp;gt;
&amp;lt;/android.support.v7.widget.Toolbar&amp;gt;
</pre></p>



<p>If you require a left or right icon for navigation, you can add them to the constraint layout with the respective constraints.</p>



<p>To add this custom layout to our main layout, we need to replace the standard Toolbar element with the custom layout like shown below:</p>



<p><pre class="brush: xml; title: ; notranslate" title>
&amp;lt;com.google.android.material.appbar.AppBarLayout
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;wrap_content&quot;&amp;gt;

    &amp;lt;include layout=&quot;@layout/toolbar&quot; /&amp;gt;
&amp;lt;/com.google.android.material.appbar.AppBarLayout&amp;gt;
</pre></p>



<p>Here is the final activity_main.xml:</p>



<p><pre class="brush: xml; title: activity_main.xml; notranslate" title="activity_main.xml"> 
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&amp;gt;
&amp;lt;androidx.coordinatorlayout.widget.CoordinatorLayout
    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
    xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
    xmlns:tools=&quot;http://schemas.android.com/tools&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;match_parent&quot;
    tools:context=&quot;.MainActivity&quot;&amp;gt;

    &amp;lt;com.google.android.material.appbar.AppBarLayout
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;

        &amp;lt;include layout=&quot;@layout/toolbar&quot; /&amp;gt;

    &amp;lt;/com.google.android.material.appbar.AppBarLayout&amp;gt;

    &amp;lt;include layout=&quot;@layout/content_main&quot; /&amp;gt;

    &amp;lt;com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id=&quot;@+id/fab&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_gravity=&quot;bottom|end&quot;
        android:layout_margin=&quot;@dimen/fab_margin&quot;
        app:srcCompat=&quot;@drawable/ic_action_more&quot; /&amp;gt;

&amp;lt;/androidx.coordinatorlayout.widget.CoordinatorLayout&amp;gt;
</pre></p>



<p>

And voila! You now have a custom toolbar with an image icon. 

</p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[Understanding and Leveraging Machine Learning in Conversational AI (using Rasa)]]></title><description><![CDATA[<!--kg-card-begin: html--><section class="section section--body">
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<p class="graf graf--h3">What makes a good conversation? A good conversation is one where you get the person you are speaking with interested in speaking, maybe by asking a few questions, making small talk and the filler conversation.</p>
<p class="graf graf--p">Consider this conversation:</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">Me: </em></strong><em class="markup--em markup--p-em">Hi, I am Gaurav.<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">John:</em></strong><em class="markup--em markup--p-em"> Hi, I am John.<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">Me:</em></strong><em class="markup--em markup--p-em"> How</em></p></div></div></section>]]></description><link>https://ghostcode.in/understanding-and-leveraging-machine-learning-in-conversational-ai/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed03f</guid><category><![CDATA[getting started]]></category><category><![CDATA[machine learning]]></category><category><![CDATA[nlp]]></category><category><![CDATA[rasa]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Mon, 31 Dec 2018 19:03:55 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><section class="section section--body">
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<p class="graf graf--h3">What makes a good conversation? A good conversation is one where you get the person you are speaking with interested in speaking, maybe by asking a few questions, making small talk and the filler conversation.</p>
<p class="graf graf--p">Consider this conversation:</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">Me: </em></strong><em class="markup--em markup--p-em">Hi, I am Gaurav.<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">John:</em></strong><em class="markup--em markup--p-em"> Hi, I am John.<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">Me:</em></strong><em class="markup--em markup--p-em"> How are you doing?<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">John:</em></strong><em class="markup--em markup--p-em"> I am doing good. You?<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">Me:</em></strong><em class="markup--em markup--p-em"> I am doing good too. So, I hear you are an expert on ML. So, can you tell me what it is?<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">John:</em></strong><em class="markup--em markup--p-em"> Hmmm, ML stands for Machine Learning. It is the process of, er, a computer&#x2019;s ability to learn by itself on providing some training data.<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">Me:</em></strong><em class="markup--em markup--p-em"> Ah! I get it. Sort of like how a kid learns, right?<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">John:</em></strong><em class="markup--em markup--p-em"> Yes, in it&#x2019;s simplest form.<br>
</em><em class="markup--em markup--p-em"><strong>Me:&#xA0;</strong>And what is DL?<br>
</em><em class="markup--em markup--p-em"><strong>John:&#xA0;</strong>Well, DL stands for Deep Learning. It is more like a subset of&#xA0;Machine Learning. It mostly uses&#xA0;algorithms, somewhat based on the&#xA0;working of the brain. You would have heard of Artificial Neural Networks, right?<br>
</em><em class="markup--em markup--p-em"><strong>Me: </strong>Oh yes! So, Artificial Neural Networks like Convolutional Neural Networks and Recurrent Networks are part of DL?<br>
<strong>John:&#xA0;</strong>Yes, indeed.<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">Me:</em></strong><em class="markup--em markup--p-em">&#xA0;Now I understand. Thanks for the explanation.<br>
</em><strong class="markup--strong markup--p-strong"><em class="markup--em markup--p-em">John:</em></strong><em class="markup--em markup--p-em"> Anytime.</em></p>
<p class="graf graf--p">There is an interaction, a to and fro between me and John and through this conversation I get an idea of what Machine learning&#xA0;and Deep learning are. There are multiple ways this conversation could have played out and that dynamic interaction is what we are looking to replicate with ML.</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong"><img loading="lazy" class="alignleft" src="https://cdn-images-1.medium.com/max/750/1*TdcIRxkro_uMcjtfHNoBfA.png" alt width="252" height="449" data-image-id="1*TdcIRxkro_uMcjtfHNoBfA.png" data-width="273" data-height="486"></strong></p>
<p>Conversational AIs can conduct <strong class="markup--strong markup--p-strong">human-like interactions </strong>with humans using Natural Language Processing (NLP). They are evolved versions of the chatbots, that may serves up automated responses or a default fallback response. Conversational AIs are essentially smart chatbots.</p>
<p class="graf graf--p">Consider a simple bot that tells you more about Coffee, the startup that I&#xA0;spend most of days at.</p>
<p class="graf graf--p">On being asked &#x201C;How are you?&#x201D;, the bot responds &#x201C;Wonderful! Thanks for asking.&#x201D; It even thanks you for asking. There is a lot of to and fro in this conversation and you can go through it in the image. I would like to bring your attention to the last message, &#x201C;I know, right?&#x201D; in response to my &#x201C;Oh! Great.&#x201D; That sort of dynamic interaction or I would say, more of a reaction to my statement is what makes a bot smart and this is where ML and AI play a major part.</p>
<p class="graf graf--p">So, lets have a look at what are the options for building such a bot.</p>
</div>
</div>
</section>
<section class="section section--body">
<div class="section-content"></div>
</section>
<p>&#xA0;</p>
<section class="section section--body">
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<h3 class="graf graf--h3"></h3>
<h3 class="graf graf--h3">The Chatbot Ecosystem</h3>
<p class="graf graf--p">There are multiple ways of going about building a smart conversational AI. You can leverage <strong class="markup--strong markup--p-strong">bot building platforms</strong> such as <a href="http://dialogflow.com">DialogFlow</a>, <a href="https://www.ibm.com/watson/">IBM Watson</a>, <a href="http://wit.ai">wit.ai</a>, <a href="http://recast.ai">recast.ai</a>, <a href="http://rasa.com">Rasa</a> and more. Bot building platforms allow you to build an end to end conversational NLP with the ability to process and predict an action based on your intent. These platforms also provide options for integrating with a frontend platform of your choice.</p>
<figure class="graf graf--figure">
<p><figure style="width: 624px" class="wp-caption aligncenter"><img loading="lazy" class="graf-image" src="https://cdn-images-1.medium.com/max/1000/1*x_FS6GaSMFkGsPvhkbCHQw.png" alt width="624" height="540" data-image-id="1*x_FS6GaSMFkGsPvhkbCHQw.png" data-width="624" data-height="540"><figcaption class="wp-caption-text">Chatbot&#xA0;Ecosystem. Source: <a href="https://recast.ai">Recast.ai</a></figcaption></figure></p></figure>
</div>
</div>
</section>
<p class="graf graf--p">Optionally, you can opt in for NLP providers such as Rasa NLU, wit.ai, IBM Watson, AWS and more. These platforms provide you only the Natural Language Processing part upon which you can build your custom processing and ML model to generate a conversational flow.</p>
<h3 class="graf graf--h3">Flow of Conversational AI</h3>
<p class="graf graf--p">A basic Conversational AI takes in the user request via text or voice, and passes it to the following modules:</p>
<ul class="postList">
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Connector modules:</strong><br>
This is the conversational platform, the frontend, and can be a website or app, where the user interacts with the AI.</li>
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Input Modules:</strong><br>
The user request is feed to this module, which does Natural Language Understanding.</li>
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Dialogue Management<br>
</strong>This module takes the NLU text and maintains the context of the conversation. It then uses Machine Learning model such as an RNN or LSTM to suggest an appropriate action to be taken. This module can also be connected to a backend or database to perform additional processing based on suggested action.<br>
In the below example, it recognizes that the user is requesting the weather and connects to the weather API to perform the appropriate action.</li>
</ul>
<figure class="graf graf--figure">
<p><figure style="width: 960px" class="wp-caption aligncenter"><img loading="lazy" class="graf-image" src="https://cdn-images-1.medium.com/max/1000/1*5-8WeNwE6AKyksukg-yV8w.png" alt width="960" height="372" data-image-id="1*5-8WeNwE6AKyksukg-yV8w.png" data-width="960" data-height="372"><figcaption class="wp-caption-text">Source: <a href="https://rasa.com">Rasa<br></a></figcaption></figure></p></figure>
<ul class="postList">
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Output Modules<br>
</strong>This module performs Natural Language Generation to return an appropriate response to the user.</li>
</ul>
<p class="graf graf--p">The user is sent back a AI response via text or voice through the Connector Module.</p>
<h3 class="graf graf--h3">Conversational AI with&#xA0;<a class="markup--user markup--h3-user" href="https://medium.com/u/fb02cb4905b7" target="_blank" rel="noopener noreferrer" data-href="https://medium.com/u/fb02cb4905b7" data-anchor-type="2" data-user-id="fb02cb4905b7" data-action-value="fb02cb4905b7" data-action="show-user-card" data-action-type="hover">Rasa</a></h3>
<figure class="graf graf--figure"><img class="graf-image aligncenter" src="https://cdn-images-1.medium.com/max/1000/1*TexK4FaUGTsOVmF_Lk9pLA.png" data-image-id="1*TexK4FaUGTsOVmF_Lk9pLA.png" data-width="287" data-height="136"></figure>
<p class="graf graf--p"><a class="markup--user markup--p-user" href="https://medium.com/u/fb02cb4905b7" target="_blank" rel="noopener noreferrer" data-href="https://medium.com/u/fb02cb4905b7" data-anchor-type="2" data-user-id="fb02cb4905b7" data-action-value="fb02cb4905b7" data-action="show-user-card" data-action-type="hover">Rasa</a> is an open source bot framework, which can be used to build contextual AI assistants and chatbots. It has the following 2 components:<br>
1. <strong class="markup--strong markup--p-strong">Rasa NLU</strong>, which interprets the user message.<br>
2. <strong class="markup--strong markup--p-strong">Rasa Core</strong>, which tracks the conversation and decides what happens next. Rasa Core suggests the most appropriate action to be taken</p>
<figure class="graf graf--figure">
<p><figure style="width: 690px" class="wp-caption aligncenter"><img loading="lazy" class="graf-image" src="https://cdn-images-1.medium.com/max/1000/1*T2B3yUEJP4s9eNWsoxNK4g.png" alt width="690" height="439" data-image-id="1*T2B3yUEJP4s9eNWsoxNK4g.png" data-width="690" data-height="439"><figcaption class="wp-caption-text">Rasa Stack. Source: <a href="https://rasa.com">Rasa</a></figcaption></figure></p></figure>
<p class="graf graf--p">Rasa doesn&#x2019;t have any pre-built models on a server that you can call using an API. You will need to prepare the training data and load it into Rasa. However, you are in complete control of all the components of your chatbot, which makes it totally worth the time.</p>
<p class="graf graf--p">Let&#x2019;s take a closer look at the 2 components of Rasa stack and how they work with NLP and ML.</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Natural Language Understanding (Rasa NLU):</strong></p>
<p class="graf graf--p">Rasa NLU processes user input text and understands what the user is trying to say. Basically, it takes the user text as input and extracts the <strong class="markup--strong markup--p-strong">intent</strong> and <strong class="markup--strong markup--p-strong">entities</strong> from it.</p>
<ul class="postList">
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Intent:</strong> An intent represents the purpose of a user&#x2019;s input, what the user wants to do. The user input text is first vectorized and then the intent of the text is extracted.</li>
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Entity:</strong> An entity represents a term or object that is relevant to your intents and that provides a specific context for an intent.</li>
</ul>
<p class="graf graf--p">Taking the <strong class="markup--strong markup--p-strong">example</strong> of the &#x201C;What&#x2019;s the weather like tomorrow?&#x201D;, we can get the following:</p>
<ul class="postList">
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Intent:</strong> &#x201C;request_weather&#x201D; =&gt;User is requesting for the weather.</li>
<li class="graf graf--li"><strong class="markup--strong markup--li-strong">Entity:</strong> { &#x201C;date&#x201D;: &#x201C;tomorrow&#x201D; } =&gt; When is the user requesting the weather for?<br>
You can define additional intents based on your application. For eg., you can also define a &#x201C;place&#x201D; entity, so that you can understand which place the weather should be requested from.</li>
</ul>
<figure class="graf graf--figure">
<p><figure style="width: 895px" class="wp-caption aligncenter"><img loading="lazy" class="graf-image" src="https://cdn-images-1.medium.com/max/1000/1*C0svsN-7VQHnozDH6sAU8w.png" alt width="895" height="378" data-image-id="1*C0svsN-7VQHnozDH6sAU8w.png" data-width="895" data-height="378"><figcaption class="wp-caption-text">Rasa NLU. Source: <a href="https://rasa.com">Rasa</a></figcaption></figure></p></figure>
<p class="graf graf--p">For a breakdown and the deeper understanding of the Rasa NLU, you can check out an article I previously wrote on <a class="markup--anchor markup--p-anchor" href="https://medium.com/@gauravgpunjabi/getting-started-with-machine-learning-ea0dc29e3ff6" target="_blank" rel="noopener noreferrer" data-href="https://medium.com/@gauravgpunjabi/getting-started-with-machine-learning-ea0dc29e3ff6">Understanding Rasa NLU</a>.</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Dialog Handling (Rasa Core):</strong></p>
<p class="graf graf--p">Upon extracting the data from user input, the intent and entities are passed to Rasa Core. <strong class="markup--strong markup--p-strong">Rasa</strong><strong class="markup--strong markup--p-strong">Core</strong> decides what happens next in this conversation. It uses machine learning-based dialogue management to predict the <strong class="markup--strong markup--p-strong">next best action</strong> based on the input from NLU, the conversation history and your training data.</p>
<figure class="graf graf--figure">
<p><figure style="width: 848px" class="wp-caption aligncenter"><img loading="lazy" class="graf-image" src="https://cdn-images-1.medium.com/max/1000/1*PqRAx3z0n38oV8rZeESCJw.png" alt width="848" height="395" data-image-id="1*PqRAx3z0n38oV8rZeESCJw.png" data-width="848" data-height="395"><figcaption class="wp-caption-text">Dialog Handling. Source: <a href="https://rasa.com">Rasa<br></a></figcaption></figure></p></figure>
<p class="graf graf--p">Rasa Core uses a neural network implemented in <a class="markup--anchor markup--p-anchor" href="http://keras.io/" target="_blank" rel="noopener noreferrer" data-href="http://keras.io/">Keras</a>, with the default model architecture based on LSTM to predict the next action.</p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">LSTMs</strong> (Long Short Term Memory networks) are a special kind of Recurrent Neural Network (RNN), capable of selectively remembering patterns for long durations of time. LSTMs can thus help in maintaining the context of conversations and also predicting the next action. You can check out this article on the <a class="markup--anchor markup--p-anchor" href="https://www.analyticsvidhya.com/blog/2017/12/fundamentals-of-deep-learning-introduction-to-lstm/" target="_blank" rel="noopener noreferrer" data-href="https://www.analyticsvidhya.com/blog/2017/12/fundamentals-of-deep-learning-introduction-to-lstm/">Introduction to LSTM</a> to understand LSTMs further. You can also check out <a class="markup--anchor markup--p-anchor" href="http://vishalgupta.me/deck/char_lstms/#/" target="_blank" rel="noopener noreferrer" data-href="http://vishalgupta.me/deck/char_lstms/#/">this presentation</a> by <a href="https://www.linkedin.com/in/vishalg8897/">Vishal Gupta</a>.</p>
<p class="graf graf--p">For our example of the weather request, an action of &#x201C;location_question&#x201D; or &#x201C;weather_api_call&#x201D; is suggested. Finally, based on the action type, the relevant response is generated by the Rasa NLG, which is part of Rasa Core.</p>
<p class="graf graf--p">This covers the basics of how machine learning is used to build a Conversational AI. Now you will have an understanding of the flow of conversation and how the different components of Rasa come together to perform the required tasks. A major advantage of Rasa is that the components are interchangeable. You can make use of Rasa Core and Rasa NLU separately plugging it into your custom built models.</p>
<p class="graf graf--p">You can get started with building your first Rasa Conversational AI by checking out this Google colab notebook: <a class="markup--anchor markup--p-anchor" href="https://colab.research.google.com/drive/1pIcv7eEKhNnl2zf4JPl9FvTv1sInlhBT" target="_blank" rel="nofollow noopener noreferrer" data-href="https://colab.research.google.com/drive/1pIcv7eEKhNnl2zf4JPl9FvTv1sInlhBT">https://colab.research.google.com/drive/1pIcv7eEKhNnl2zf4JPl9FvTv1sInlhBT</a></p>
<blockquote class="graf graf--blockquote"><p><em class="markup--em markup--blockquote-em">If you have any comments, I&#x2019;d be happy to discuss further. Respond here or </em><a class="markup--anchor markup--blockquote-anchor" href="https://twitter.com/gauravgpunjabi" target="_blank" rel="nofollow nofollow noopener noreferrer" data-href="https://twitter.com/GauravGladstone"><em class="markup--em markup--blockquote-em">find me on twitter</em></a></p></blockquote>
<section class="section section--body">
<div class="section-content"></div>
</section>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[General Resources: Interesting Frameworks, Articles & Videos]]></title><description><![CDATA[<!--kg-card-begin: html--><p>Below you will some interesting resources and articles that will help you in your development journey. Have a look and you may find something that will help in the learning process.</p>
<p><img loading="lazy" class="aligncenter size-full wp-image-48695" src="https://ghostcode.in/wp-content/uploads/2018/09/pexels-photo-270404.jpeg" alt width="940" height="528" srcset="https://ghostcode.in/content/images/wordpress/2018/09/pexels-photo-270404.jpeg 940w, https://ghostcode.in/content/images/wordpress/2018/09/pexels-photo-270404-300x169.jpeg 300w, https://ghostcode.in/content/images/wordpress/2018/09/pexels-photo-270404-768x431.jpeg 768w" sizes="(max-width: 940px) 100vw, 940px"></p>
<p><strong>CodingRadio</strong>&#xA0;provides you with music to help you focus<br>
<a href="https://codingradio.xyz/?ref=producthunt">https://codingradio.xyz/?ref=producthunt</a></p>
<p><strong>Compendium Maps:</strong>&#xA0;a</p>]]></description><link>https://ghostcode.in/general-resources-interesting-frameworks-articles-videos/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed03e</guid><category><![CDATA[articles]]></category><category><![CDATA[frameworks]]></category><category><![CDATA[General]]></category><category><![CDATA[reading]]></category><category><![CDATA[resources]]></category><category><![CDATA[videos]]></category><category><![CDATA[youtube]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Sat, 01 Sep 2018 22:36:19 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>Below you will some interesting resources and articles that will help you in your development journey. Have a look and you may find something that will help in the learning process.</p>
<p><img loading="lazy" class="aligncenter size-full wp-image-48695" src="https://ghostcode.in/wp-content/uploads/2018/09/pexels-photo-270404.jpeg" alt width="940" height="528" srcset="https://ghostcode.in/content/images/wordpress/2018/09/pexels-photo-270404.jpeg 940w, https://ghostcode.in/content/images/wordpress/2018/09/pexels-photo-270404-300x169.jpeg 300w, https://ghostcode.in/content/images/wordpress/2018/09/pexels-photo-270404-768x431.jpeg 768w" sizes="(max-width: 940px) 100vw, 940px"></p>
<p><strong>CodingRadio</strong>&#xA0;provides you with music to help you focus<br>
<a href="https://codingradio.xyz/?ref=producthunt">https://codingradio.xyz/?ref=producthunt</a></p>
<p><strong>Compendium Maps:</strong>&#xA0;a visual summary of the climate debate<br>
<a href="http://bit.ly/2Kh6qq0">http://bit.ly/2Kh6qq0</a></p>
<p>Welcome to&#xA0;<strong>Debatepedia</strong>! &#x2013; Debatepedia, the Wikipedia of Debates<br>
<a href="http://bit.ly/2tupMUY">http://bit.ly/2tupMUY</a></p>
<p><strong>HTML5 Game Framework</strong><br>
<a href="http://phaser.io/">http://phaser.io</a></p>
<p><strong>Stealthy</strong>&#xA0;&#x2013; Secure decentralized communication<br>
<a href="https://www.stealthy.im/">https://www.stealthy.im</a></p>
<p><strong>Trusting Trust</strong>&#xA0;&#x2013; an experiment<br>
<a href="https://agnelvishal.github.io/TrustingTrust/pc/index.html">https://agnelvishal.github.io/TrustingTrust/pc/index.html</a></p>
<h3>Articles and Reading Resources:</h3>
<p><strong>Want to know how to hack websites??</strong><br>
<a href="https://cnhv.co/3durm">https://cnhv.co/3durm</a></p>
<p><strong>Amazing thread on Probablistic Programming in a real life scenario.</strong><br>
<a href="https://news.ycombinator.com/item?id=17220861">https://news.ycombinator.com/item?id=17220861</a></p>
<p><strong>E823: Lambda School CEO Austen Allred created an immersive online training for software engineers at no upfront cost, disrupts education by eliminating student debt &amp; aligning incentives of his school with those of its learners<br>
</strong><a href="http://thisweekinstartups.com/austen-allred-lambda-school/">http://thisweekinstartups.com/austen-allred-lambda-school/</a></p>
<p><strong>Resume Skills list<br>
</strong><a href="http://www.thisisinsider.com/best-resume-skills-list-linkedin-jobs-2018-4">http://www.thisisinsider.com/best-resume-skills-list-linkedin-jobs-2018-4</a></p>
<p><strong>Richard Stallman extreme views on computing.</strong><br>
<a href="https://stallman.org/stallman-computing.html">https://stallman.org/stallman-computing.html</a></p>
<p><strong>Top 8 Programmer Hobbies</strong><br>
<a href="http://bit.ly/2I83ONW">http://bit.ly/2I83ONW</a></p>
<p><strong>&#x201C;5 Steps to Online Privacy with Firefox&#x201D;</strong><br>
<a href="https://medium.com/@jovanovski/5-steps-to-online-privacy-with-firefox-b33a2e72416c">https://medium.com/@jovanovski/5-steps-to-online-privacy-with-firefox-b33a2e72416c</a></p>
<p><strong>Microsoft&#x2019;s free courses</strong><br>
<a href="https://www.linkedin.com/feed/update/urn:li:activity:6387123787783114754/">https://www.linkedin.com/feed/update/urn:li:activity:6387123787783114754/</a></p>
<p><strong>Sierra Leone just ran the first blockchain-based election</strong><br>
<a href="https://techcrunch.com/2018/03/14/sierra-leone-just-ran-the-first-blockchain-based-election/">https://techcrunch.com/2018/03/14/sierra-leone-just-ran-the-first-blockchain-based-election/</a></p>
<p><strong>Wall Street rethinks blockchain projects as euphoria meets reality</strong><br>
<a href="https://www.reuters.com/article/us-banks-fintech-blockchain/wall-street-rethinks-blockchain-projects-as-euphoria-meets-reality-idUSKBN1H32GO">https://www.reuters.com/article/us-banks-fintech-blockchain/wall-street-rethinks-blockchain-projects-as-euphoria-meets-reality-idUSKBN1H32GO</a></p>
<p><strong>The Importance of Using Strong Keys in Signing JWTs</strong><br>
<a href="https://auth0.com/blog/brute-forcing-hs256-is-possible-the-importance-of-using-strong-keys-to-sign-jwts/">https://auth0.com/blog/brute-forcing-hs256-is-possible-the-importance-of-using-strong-keys-to-sign-jwts/</a></p>
<p><strong>Where to store your JWTs</strong><br>
<a href="https://auth0.com/docs/security/store-tokens#where-to-store-your-jwts">https://auth0.com/docs/security/store-tokens#where-to-store-your-jwts</a></p>
<p><strong>How to design for everyone?</strong><br>
<a href="http://www.fastcompany.com/90160000/how-to-design-for-everyone-in-3-steps">www.fastcompany.com/90160000/how-to-design-for-everyone-in-3-steps</a></p>
<h3>Raspberry Pi:</h3>
<p><strong>Raspberry Pi Internet Radio</strong><br>
<a href="http://www.bobrathbone.com/raspberrypi/pi_internet_radio.html">http://www.bobrathbone.com/raspberrypi/pi_internet_radio.html</a></p>
<p><strong>Raspberry Pi FM Transmitter</strong><br>
<a href="https://www.raspberrypi.org/magpi/raspberry-pi-fm-transmitter/">https://www.raspberrypi.org/magpi/raspberry-pi-fm-transmitter/</a></p>
<h3>REST API Clients:</h3>
<p><b>Postman<br>
</b><a href="https://www.getpostman.com/">https://www.getpostman.com/</a></p>
<p>Postman is an API development environment,</p>
<p><b>Swagger</b><b><br>
</b><a href="https://swagger.io/">https://swagger.io/</a></p>
<p>Swagger aides in development across the entire API lifecycle, from design and documentation, to test and deployment</p>
<p><b>Insomnia REST Client<br>
</b><a href="https://insomnia.rest/">https://insomnia.rest/</a></p>
<p>Reuse API keys or session IDs.</p>
<h3>Videos:</h3>
<p><strong>The four pillars of a decentralized society<br>
</strong><a href="https://youtu.be/8oeiOeDq_Nc">https://youtu.be/8oeiOeDq_Nc</a></p>
<p><strong>Project SHIVOM (Official Video) | Powering the Next Era of Genomics through Blockchain<br>
</strong><a href="https://youtu.be/jce9vB5zbps">https://youtu.be/jce9vB5zbps</a></p>
<p><strong>Secrets of the DOM Virtual Machine<br>
</strong><a href="https://youtu.be/kD3LaHtwMm8">https://youtu.be/kD3LaHtwMm8</a></p>
<p><strong>Build real-world games with Google Maps APIs<br>
</strong><a href="https://youtu.be/QC51FEF0JeY">https://youtu.be/QC51FEF0JeY</a></p>
<p><strong>The Art of Writing Software<br>
</strong><a href="https://www.youtube.com/watch?v=QdVFvsCWXrA&amp;feature=youtu.be">https://www.youtube.com/watch?v=QdVFvsCWXrA&amp;feature=youtu.be</a></p>
<p><strong>NodeJS in Tamil<br>
</strong><a href="https://www.youtube.com/watch?v=J8GyTIHc-T4">https://www.youtube.com/watch?v=J8GyTIHc-T4</a></p>
<p>* * *</p>
<p><em>If you have any comments, I&#x2019;d be happy to discuss further. Respond here or&#xA0;<a class="markup--anchor markup--blockquote-anchor" href="https://twitter.com/GauravGladstone" target="_blank" rel="noopener noreferrer">find me on twitter</a></em></p>
<div class="section-divider">
<hr class="section-divider">
</div>
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<p id="99e0" class="graf graf--p graf--leading graf--trailing"><em class="markup--em markup--p-em">Originally published in&#xA0;</em><a class="markup--anchor markup--p-anchor" href="http://www.build2learn.in/2018/07/23/general-resources-interesting-frameworks-and-articles/" target="_blank" rel="nofollow noopener noreferrer" data-href="http://www.build2learn.in/2018/07/23/resources-for-machine-learning-from-the-basics-to-working-models/"><em class="markup--em markup--p-em">build2learn.in</em></a></p>
</div>
</div>
<p>&#xA0;</p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[GitHub Repos that you should check out]]></title><description><![CDATA[<!--kg-card-begin: html--><p>Github is a very useful source of a lot of open source projects. If you find any repo of your interest from the list below, fork it and go through the code. Reverse engineering is a good way to learn. This process will give you a lot of questions, which</p>]]></description><link>https://ghostcode.in/github-repos-that-you-should-check-out/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed03d</guid><category><![CDATA[General]]></category><category><![CDATA[github]]></category><category><![CDATA[links]]></category><category><![CDATA[programming]]></category><category><![CDATA[repos]]></category><category><![CDATA[resources]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Mon, 20 Aug 2018 14:32:23 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>Github is a very useful source of a lot of open source projects. If you find any repo of your interest from the list below, fork it and go through the code. Reverse engineering is a good way to learn. This process will give you a lot of questions, which in the process of understanding and answering will help you expand your knowledge.</p>
<p><img loading="lazy" class="aligncenter size-full wp-image-48628" src="https://ghostcode.in/wp-content/uploads/2017/01/github-logo.png" alt width="573" height="248" srcset="https://ghostcode.in/content/images/wordpress/2017/01/github-logo.png 573w, https://ghostcode.in/content/images/wordpress/2017/01/github-logo-300x130.png 300w" sizes="(max-width: 573px) 100vw, 573px"></p>
<p><strong>Mother of all demo apps<br>
</strong><a href="https://github.com/gothinkster/realworld">https://github.com/gothinkster/realworld</a></p>
<p><strong>Build your own (insert technology here)</strong><br>
<a href="https://github.com/danistefanovic/build-your-own-x">https://github.com/danistefanovic/build-your-own-x</a></p>
<p><strong>List of Free Software network services and web applications which can be hosted locally.</strong><br>
<a href="https://github.com/Kickball/awesome-selfhosted">https://github.com/Kickball/awesome-selfhosted</a></p>
<p><strong>Face detection library in 200 lines of JS<br>
</strong><a href="https://github.com/tehnokv/picojs/">https://github.com/tehnokv/picojs/</a></p>
<p><strong>Watch matches in a terminal&#xA0;</strong><br>
<a href="https://github.com/cedricblondeau/world-cup-2018-cli-dashboard?ref=producthunt">https://github.com/cedricblondeau/world-cup-2018-cli-dashboard?ref=producthunt</a></p>
<p>&#x201C;<strong>Backblaze B2</strong>&#xA0;provides the cheapest cloud object storage and transfer available on the internet. Comparatively, AWS S3 is 320% more expensive to store and 400% more expensive to transfer to the internet.&#x201D;<br>
<a href="https://github.com/sibblegp/b2blaze">https://github.com/sibblegp/b2blaze</a></p>
<p><strong>A tool to encrypt files on git, and you can maintain an oss project without giving up your keys.<br>
</strong><a href="https://github.com/AGWA/git-crypt">https://github.com/AGWA/git-crypt</a></p>
<p><strong>Rasa NLU &#x2013; Turn Natural Language into structured data:<br>
</strong><a href="https://github.com/RasaHQ/rasa_nlu">https://github.com/RasaHQ/rasa_nlu</a></p>
<p><strong>Useful resource for Tamil machine learning applications.<br>
</strong><a href="https://github.com/Ezhil-Language-Foundation/open-tamil">https://github.com/Ezhil-Language-Foundation/open-tamil</a></p>
<p><strong>Tamil text to speech<br>
</strong><a href="https://github.com/tshrinivasan/tamil-tts-install">https://github.com/tshrinivasan/tamil-tts-install</a></p>
<p><strong>YouTube downloader<br>
</strong><a href="https://rg3.github.io/youtube-dl/">https://rg3.github.io/youtube-dl/</a></p>
<p><strong>A personal terminal-based dashboard utility</strong>, designed for displaying infrequently-needed, but very important, daily data<br>
<a href="https://github.com/senorprogrammer/wtf">https://github.com/senorprogrammer/wtf</a></p>
<p><strong>An interesting decentralized alternative to Slack.</strong><br>
<a href="https://github.com/ssbc/patchwork">https://github.com/ssbc/patchwork</a></p>
<p><strong>YouTube Downloader<br>
</strong><a href="https://rg3.github.io/youtube-dl/">https://rg3.github.io/youtube-dl/</a></p>
<p><strong>Whatsapp Web bot:<br>
</strong><a href="https://github.com/bruno222/whatsapp-web-bot">https://github.com/bruno222/whatsapp-web-bot</a></p>
<p><strong>The only cheat sheet you need<br>
</strong><a href="https://github.com/chubin/cheat.sh">https://github.com/chubin/cheat.sh</a></p>
<p><strong>A list of SWAG opportunities<br>
</strong><a href="https://github.com/swapagarwal/swag-for-dev">https://github.com/swapagarwal/swag-for-dev</a></p>
<p>* * *</p>
<p><em>If you have any comments, I&#x2019;d be happy to discuss further. Respond here or&#xA0;<a class="markup--anchor markup--blockquote-anchor" href="https://twitter.com/GauravGladstone" target="_blank" rel="noopener noreferrer">find me on twitter</a></em></p>
<div class="section-divider">
<hr class="section-divider">
</div>
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<p id="99e0" class="graf graf--p graf--leading graf--trailing"><em class="markup--em markup--p-em">Originally published in&#xA0;</em><a class="markup--anchor markup--p-anchor" href="http://www.build2learn.in/2018/07/23/github-repos-that-you-should-check-out/" target="_blank" rel="nofollow noopener noreferrer" data-href="http://www.build2learn.in/2018/07/23/resources-for-machine-learning-from-the-basics-to-working-models/"><em class="markup--em markup--p-em">build2learn.in</em></a></p>
</div>
</div>
<p>&#xA0;</p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[Resources for Machine Learning: From the basics to working models]]></title><description><![CDATA[<!--kg-card-begin: html--><p class="graf graf--p">The textbook definition of Machine Learning goes something like this: a subset of Artificial Intelligence that uses statistical techniques to get computers to learn without being explicitly programmed. Simply put, Machine Learning is making computers learn like humans by training it.</p>
<p>Below you will find a pool of resources from</p>]]></description><link>https://ghostcode.in/resources-for-machine-learning-from-the-basics-to-working-models/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed03c</guid><category><![CDATA[machine learning]]></category><category><![CDATA[python]]></category><category><![CDATA[tensorflow]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Sun, 12 Aug 2018 10:47:52 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p class="graf graf--p">The textbook definition of Machine Learning goes something like this: a subset of Artificial Intelligence that uses statistical techniques to get computers to learn without being explicitly programmed. Simply put, Machine Learning is making computers learn like humans by training it.</p>
<p>Below you will find a pool of resources from cheatsheets to working models that will get you started in the field of ML.</p>
<p><img loading="lazy" class="aligncenter size-full wp-image-48682" src="https://ghostcode.in/wp-content/uploads/2018/09/ml_basics_cheatsheet_b2l-coffee.png" alt width="1152" height="648" srcset="https://ghostcode.in/content/images/wordpress/2018/09/ml_basics_cheatsheet_b2l-coffee.png 1152w, https://ghostcode.in/content/images/wordpress/2018/09/ml_basics_cheatsheet_b2l-coffee-300x169.png 300w, https://ghostcode.in/content/images/wordpress/2018/09/ml_basics_cheatsheet_b2l-coffee-768x432.png 768w, https://ghostcode.in/content/images/wordpress/2018/09/ml_basics_cheatsheet_b2l-coffee-1024x576.png 1024w" sizes="(max-width: 1152px) 100vw, 1152px"></p>
<p><strong>Machine Learning Cheatsheets<br>
</strong><a href="https://www.rankred.com/machine-learning-cheat-sheets/">https://www.rankred.com/machine-learning-cheat-sheets/</a></p>
<p><strong>Top-down learning path: Machine Learning for Software</strong>&#xA0;<strong>Engineers</strong><br>
<a href="https://github.com/ZuzooVn/machine-learning-for-software-engineers">https://github.com/ZuzooVn/machine-learning-for-software-engineers</a></p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Tutorial for Andrej Karpathy&#x2019;s CNN Course! Really comprehensive tutorial to start from</strong>&#xA0;<strong class="markup--strong markup--p-strong">scratch</strong><br>
<a class="markup--anchor markup--p-anchor" href="http://cs231n.github.io/" target="_blank" rel="noopener noreferrer">http://cs231n.github.io/</a></p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Making neural nets uncool again<br>
</strong><a class="markup--anchor markup--p-anchor" href="http://www.fast.ai/" target="_blank" rel="noopener noreferrer">http://www.fast.ai</a></p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">NLP using Torch<br>
</strong><a class="markup--anchor markup--p-anchor" href="https://harvard-ml-courses.github.io/cs287-web/" target="_blank" rel="noopener noreferrer">https://harvard-ml-courses.github.io/cs287-web/</a></p>
<p><strong>Lip Reading &#x2013; Cross Audio-Visual Recognition using 3D Convolutional Neural Networks<br>
</strong><a href="https://github.com/astorfi/lip-reading-deeplearning">https://github.com/astorfi/lip-reading-deeplearning</a></p>
<p><strong>Collection of Interactive Machine Learning Examples<br>
</strong><a href="http://tools.google.com/seedbank/">http://tools.google.com/seedbank/</a></p>
<p><strong>Glow: Better Reversible Generative Models<br>
</strong><a href="https://blog.openai.com/glow/">https://blog.openai.com/glow/</a></p>
<p><strong>Neural Network based Startup Name Generator<br>
</strong><a href="https://www.kdnuggets.com/2018/04/neural-network-startup-name-generator.html">https://www.kdnuggets.com/2018/04/neural-network-startup-name-generator.html</a></p>
<p><strong>Neural Joke</strong>&#xA0;<strong>Generation</strong><br>
<a href="https://web.stanford.edu/class/cs224n/reports/2760332.pdf">https://web.stanford.edu/class/cs224n/reports/2760332.pdf</a></p>
<p><strong>Keras Models in the browser<br>
</strong><a href="https://transcranial.github.io/keras-js/#/">https://transcranial.github.io/keras-js/#/</a></p>
<p><strong>Font Meme Generator<br>
</strong><a href="https://fontmeme.com/text-generator/">https://fontmeme.com/text-generator/</a></p>
<p><strong>Tensorflow.js</strong><br>
<a href="https://js.tensorflow.org/">https://js.tensorflow.org</a></p>
<p><strong>Build a DNA-personalized app<br>
</strong><a href="https://genomelink.io/developers/">https://genomelink.io/developers/</a></p>
<p><strong>Tensorflow Dev Summit 2018 keynote<br>
</strong><a href="https://www.youtube.com/watch?v=kSa3UObNS6o&amp;feature=youtu.be">https://www.youtube.com/watch?v=kSa3UObNS6o&amp;feature=youtu.be</a></p>
<p><strong>TensorFlowJS: Machine Learning In JavaScript<br>
</strong><a href="https://youtu.be/656l4IfhM10">https://youtu.be/656l4IfhM10</a></p>
<h3><strong>Articles and Reading Resources:</strong></h3>
<p><strong>Self-Study Machine Learning Projects<br>
</strong><a href="http://bit.ly/2IFA1YT">http://bit.ly/2IFA1YT</a></p>
<p><strong>Project- Gun Detector (a custom object detector)</strong><br>
Teammate-<a href="https://www.linkedin.com/in/ACoAABsg7ysBj-ObpzsEaEpIaTeUIkwE4xcmS8c/">&#xA0;<b>Jyot Prakash Verma</b><br>
</a>Framework Used &#x2013; Tensorflow<br>
<a href="https://www.linkedin.com/feed/update/urn:li:activity:6409461318050508800">https://www.linkedin.com/feed/update/urn:li:activity:6409461318050508800</a></p>
<p><strong>How a Beginner Used Small Projects To Get Started in Machine Learning and Compete on Kaggle<br>
</strong><a href="http://bit.ly/2IFnqFr">http://bit.ly/2IFnqFr</a></p>
<p><strong>Why ML interfaces will be more like pets than machines &#xAB; Pete Warden&#x2019;s blog<br>
</strong><a href="http://bit.ly/2MgTX7A">bit.ly/2MgTX7A</a></p>
<p><strong>Building Mobile Applications with TensorFlow &#x2013; a free book<br>
</strong><a href="https://oreil.ly/2JGh7Cv">https://oreil.ly/2JGh7Cv</a></p>
<p><strong>Fruit Decay detection<br>
</strong><a href="http://www.ijircce.com/upload/2016/august/150_fruittedection.pdf">http://www.ijircce.com/upload/2016/august/150_fruittedection.pdf</a></p>
<p><strong>Facial emotion recognition<br>
</strong><a href="https://medium.com/@rishiswethan.c.r/emotion-detection-using-facial-landmarks-and-deep-learning-b7f54fe551bf">https://medium.com/@rishiswethan.c.r/emotion-detection-using-facial-landmarks-and-deep-learning-b7f54fe551bf</a></p>
<p><strong>WaveNet is being used to generate the Google Assistant voices for US English and Japanese across all platforms<br>
</strong><a href="https://deepmind.com/blog/wavenet-launches-google-assistant/">https://deepmind.com/blog/wavenet-launches-google-assistant/</a></p>
<p><strong>How to learn deep learning in 6 months<br>
</strong><a href="https://towardsdatascience.com/how-to-learn-deep-learning-in-6-months-e45e40ef7d48">https://towardsdatascience.com/how-to-learn-deep-learning-in-6-months-e45e40ef7d48</a></p>
<p><strong>Reading an Academic Paper&#x200A;&#x2014;&#x200A;DL/ML/AI<br>
</strong><a href="https://blog.goodaudience.com/reading-an-academic-paper-dl-ml-ai-2fa02976a571">https://blog.goodaudience.com/reading-an-academic-paper-dl-ml-ai-2fa02976a571</a></p>
<h3><strong>AI:</strong></h3>
<p><strong>AI Principles by Google<br>
</strong><a href="https://www.blog.google/topics/ai/ai-principles/">https://www.blog.google/topics/ai/ai-principles/</a></p>
<p><strong>AI Researchers from Google, Microsoft &amp; Facebook answer questions<br>
</strong><a href="https://www.reddit.com/r/science/comments/7yegux/aaas_ama_hi_were_researchers_from_google/?utm_source=reddit-android">https://www.reddit.com/r/science/comments/7yegux/aaas_ama_hi_were_researchers_from_google/?utm_source=reddit-android</a></p>
<p><strong>Browse passages from books using experimental AI<br>
</strong><a href="https://books.google.com/talktobooks/">https://books.google.com/talktobooks/</a></p>
<h3><strong>Datasets:</strong></h3>
<p><strong>Yelp dataset<br>
</strong><a href="https://www.yelp.com/dataset/download">https://www.yelp.com/dataset/download</a></p>
<p><strong>Let&#x2019;s Go dataset<br>
</strong><a href="https://github.com/DialRC/LetsGoDataset">https://github.com/DialRC/LetsGoDataset</a></p>
<h3><b>Chatbots:</b></h3>
<p><strong>CakeChat: Emotional Generative Dialog System &#x2013; as used in&#xA0;<a href="https://replika.ai/">Replika</a><br>
</strong><a href="https://github.com/lukalabs/cakechat">https://github.com/lukalabs/cakechat</a></p>
<p class="graf graf--p"><strong class="markup--strong markup--p-strong">Rasa NLU<br>
</strong><a class="markup--anchor markup--p-anchor" href="https://github.com/RasaHQ/rasa_nlu" target="_blank" rel="nofollow noopener noreferrer">https://github.com/RasaHQ/rasa_nlu</a></p>
<p><strong>Making a simple Telegram Bot<br>
</strong><a href="http://www.developintelligence.com/blog/2017/08/building-serverless-chatbot-aws-zappa-telegram-api-ai/">http://www.developintelligence.com/blog/2017/08/building-serverless-chatbot-aws-zappa-telegram-api-ai/</a></p>
<p><strong>Messages with a fake virtual companion<br>
</strong><a href="https://www.kaggle.com/eibriel/rdany-conversations">https://www.kaggle.com/eibriel/rdany-conversations</a></p>
<p><strong>Bot Testing</strong></p>
<p><a href="http://dimon.co/">http://dimon.co/</a></p>
<p><a href="http://bottesting.co/">http://bottesting.co/</a></p>
<p><a href="https://www.quora.com/How-do-you-test-chatbot">https://www.quora.com/How-do-you-test-chatbot</a></p>
<p>* * *</p>
<p><em>If you have any comments, I&#x2019;d be happy to discuss further. Respond here or&#xA0;<a class="markup--anchor markup--blockquote-anchor" href="https://twitter.com/GauravGladstone" target="_blank" rel="noopener noreferrer">find me on twitter</a></em></p>
<section class="section section--body section--first">
<div class="section-content"></div>
</section>
<section class="section section--body section--last">
<div class="section-divider">
<hr class="section-divider">
</div>
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<p id="99e0" class="graf graf--p graf--leading graf--trailing"><em class="markup--em markup--p-em">Originally published in&#xA0;</em><a class="markup--anchor markup--p-anchor" href="http://www.build2learn.in/2018/07/23/resources-for-machine-learning-from-the-basics-to-working-models/" target="_blank" rel="nofollow noopener noreferrer" data-href="http://www.build2learn.in/2018/07/23/resources-for-machine-learning-from-the-basics-to-working-models/"><em class="markup--em markup--p-em">build2learn.in</em></a></p>
</div>
</div>
</section>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[Python Resources: Getting Started to Going Full Stack]]></title><description><![CDATA[<!--kg-card-begin: html--><p>Python is one of the most used languages. Whether you are starting out with the basics of programming or if you want to build a full stack web app or a smart machine learning algorithm, python is a great language that will you seamlessly implement your solution. Check out some</p>]]></description><link>https://ghostcode.in/python-resources-getting-started-to-going-full-stack/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed03a</guid><category><![CDATA[python]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Sat, 28 Jul 2018 15:29:04 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>Python is one of the most used languages. Whether you are starting out with the basics of programming or if you want to build a full stack web app or a smart machine learning algorithm, python is a great language that will you seamlessly implement your solution. Check out some really useful resources below that will get you started on your journey or assist you on your path.</p>
<p><img loading="lazy" class="aligncenter size-full wp-image-48690" src="https://ghostcode.in/wp-content/uploads/2018/09/Python3-powered_hello-world.svg.png" alt width="2000" height="1077" srcset="https://ghostcode.in/content/images/wordpress/2018/09/Python3-powered_hello-world.svg.png 2000w, https://ghostcode.in/content/images/wordpress/2018/09/Python3-powered_hello-world.svg-300x162.png 300w, https://ghostcode.in/content/images/wordpress/2018/09/Python3-powered_hello-world.svg-768x414.png 768w, https://ghostcode.in/content/images/wordpress/2018/09/Python3-powered_hello-world.svg-1024x551.png 1024w" sizes="(max-width: 2000px) 100vw, 2000px"></p>
<p><b>Learn python in Y Minutes</b><br>
<a href="http://bit.ly/2KPiAqP">http://bit.ly/2KPiAqP</a></p>
<p><b>Flask &#x2013; Full Stack Python</b><br>
<a href="http://bit.ly/2IZS0tg">http://bit.ly/2IZS0tg</a></p>
<p><strong class="markup--strong markup--p-strong">Django&#x200A;&#x2014;&#x200A;Getting Started with the Python Web Framework<br>
</strong><a href="https://docs.djangoproject.com/en/2.1/intro/overview/">https://docs.djangoproject.com/en/2.1/intro/overview/</a></p>
<p id="ea58" class="graf graf--p graf-after--mixtapeEmbed"><strong class="markup--strong markup--p-strong">Beautiful Soup&#x200A;&#x2014;&#x200A;Web scraping in python<br>
</strong><a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/">https://www.crummy.com/software/BeautifulSoup/bs4/doc/</a><strong class="markup--strong markup--p-strong"><br>
</strong></p>
<p class="graf graf--p graf-after--mixtapeEmbed"><b>An easier way to use pygame</b><br>
<a href="http://bit.ly/2NyIcdu">http://bit.ly/2NyIcdu</a></p>
<p><b>A simple Pythong GUI Library.</b><br>
<a href="http://easygui.sourceforge.net/">http://easygui.sourceforge.net/</a></p>
<p><b>Developing a Single Page App with Flask and Vue.js<br>
</b><a href="https://testdriven.io/developing-a-single-page-app-with-flask-and-vuejs">https://testdriven.io/developing-a-single-page-app-with-flask-and-vuejs</a></p>
<p><b>Python projects &#x2013; Modules &#x2013; Code Club</b><br>
<a href="http://bit.ly/2u4jlFs">http://bit.ly/2u4jlFs</a></p>
<p><b>What are small projects to build for a beginner in Python? &#x2013; Quora<br>
</b><a href="http://bit.ly/2u0HxbG">http://bit.ly/2u0HxbG</a></p>
<p><b>awesome-python &#x2013; A curated list of awesome Python frameworks<br>
</b><a href="https://github.com/vinta/awesome-python">https://github.com/vinta/awesome-python</a></p>
<p><b>Data streaming in Python: generators, iterators, iterables | RaRe Technologie</b><b>s<br>
</b><a href="https://rare-technologies.com/data-streaming-in-python-generators-iterators-iterables/">https://rare-technologies.com/data-streaming-in-python-generators-iterators-iterables/</a></p>
<p><b>Python 3.7 new features<br>
</b><a href="https://realpython.com/python37-new-features/">https://realpython.com/python37-new-features/</a></p>
<p><b>Use coupon FBFREE18 and get 100% discount on Python course at udemy. &#xA0;Here is the link for the same<br>
</b><a href="https://www.udemy.com/python-complete/">https://www.udemy.com/python-complete/\</a></p>
<p><b>This is a Python/Django based event management system. A meetup clone.<br>
</b><a href="http://bit.ly/2rKJJ5V">http://bit.ly/2rKJJ5V</a></p>
<p><b>Invent with Python<br>
</b><a href="https://inventwithpython.com/">https://inventwithpython.com</a></p>
<p><b>Game obstacles<br>
</b><a href="https://github.com/nerd455/ObstacleGame">https://github.com/nerd455/ObstacleGame</a></p>
<p><b>Scientific Python in the Browser<br>
</b><a href="http://droettboom.com/blog/2018/04/04/python-in-the-browser/">http://droettboom.com/blog/2018/04/04/python-in-the-browser/</a></p>
<p><b>Open Source Python Game Agent Framework<br>
</b><a href="http://serpent.ai/">http://serpent.ai</a></p>
<p><b>PySpark- Transformation &amp; Actions<br>
</b><a href="https://drive.google.com/file/d/1c5Koaz6krkUIunsieL1V-AYBbQKiXab4/view">https://drive.google.com/file/d/1c5Koaz6krkUIunsieL1V-AYBbQKiXab4/view</a></p>
<p>* * *</p>
<p><em>If you have any comments, I&#x2019;d be happy to discuss further. Respond here or&#xA0;<a class="markup--anchor markup--blockquote-anchor" href="https://twitter.com/GauravGladstone" target="_blank" rel="noopener noreferrer">find me on twitter</a></em></p>
<div class="section-divider">
<hr class="section-divider">
</div>
<div class="section-content">
<div class="section-inner sectionLayout--insetColumn">
<p id="99e0" class="graf graf--p graf--leading graf--trailing"><em class="markup--em markup--p-em">Originally published in&#xA0;</em><a class="markup--anchor markup--p-anchor" href="http://www.build2learn.in/2018/07/23/python-resources-getting-started-to-going-full-stack/" target="_blank" rel="nofollow noopener noreferrer" data-href="http://www.build2learn.in/2018/07/23/resources-for-machine-learning-from-the-basics-to-working-models/"><em class="markup--em markup--p-em">build2learn.in</em></a></p>
</div>
</div>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[Getting Started with Machine Learning: Starting at the End by understanding Rasa NLU]]></title><description><![CDATA[<!--kg-card-begin: html--><p id="4ed3" class="graf graf--p graf-after--figure">Getting started with Machine Learning is a daunting task. Where do I start in this complex maze? Should I start in the center or at the edges? Math or Algorithms?</p>
<p id="3ad3" class="graf graf--p graf-after--p">What made sense was to start at the end. But what end? There are many projects that have been built</p>]]></description><link>https://ghostcode.in/getting-started-with-machine-learning-starting-at-the-end-by-understanding-rasa-nlu/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed039</guid><category><![CDATA[basics]]></category><category><![CDATA[getting started]]></category><category><![CDATA[machine learning]]></category><category><![CDATA[nlp]]></category><category><![CDATA[nlu]]></category><category><![CDATA[rasa]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Tue, 10 Jul 2018 10:00:21 GMT</pubDate><media:content url="https://ghostcode.in/content/images/wordpress/2018/07/rasa_nlu_bg-ghost_code.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: html--><img src="https://ghostcode.in/content/images/wordpress/2018/07/rasa_nlu_bg-ghost_code.jpg" alt="Getting Started with Machine Learning: Starting at the End by understanding Rasa NLU"><p id="4ed3" class="graf graf--p graf-after--figure">Getting started with Machine Learning is a daunting task. Where do I start in this complex maze? Should I start in the center or at the edges? Math or Algorithms?</p>
<p id="3ad3" class="graf graf--p graf-after--p">What made sense was to start at the end. But what end? There are many projects that have been built with ML. So, which one do I choose? The choice was made easier for me when&#xA0;<a class="markup--user markup--p-user" href="https://medium.com/@bhavaniravi" target="_blank" rel="noopener noreferrer" data-href="https://medium.com/@bhavaniravi" data-anchor-type="2" data-user-id="74e6436117a8" data-action-value="74e6436117a8" data-action="show-user-card" data-action-type="hover">Bhavani Ravi</a>&#xA0;was working to understand a project that has already built using Machine Learning for Natural Language Processing (NLP)&#x200A;&#x2014;&#x200A;<a class="markup--anchor markup--p-anchor" href="https://github.com/GauravG8/rasa_nlu" target="_blank" rel="nofollow noopener noreferrer" data-href="https://github.com/GauravG8/rasa_nlu">Rasa NLU</a>. My interest in NLP was at an all time high because of my recent project in chatbots. This was serendipity, two mangoes with one stone.</p>
<p id="f412" class="graf graf--p graf-after--p">What does&#xA0;<a class="markup--user markup--p-user" href="https://medium.com/@RasaHQ" target="_blank" rel="noopener noreferrer" data-href="https://medium.com/@RasaHQ" data-anchor-type="2" data-user-id="fb02cb4905b7" data-action-value="fb02cb4905b7" data-action="show-user-card" data-action-type="hover">Rasa</a>&#xA0;NLU do? Rasa NLU is a tool for understanding what is being said in short pieces of text. For example, by taking a short text message like:</p>
<blockquote id="0bac" class="graf graf--blockquote graf--startsWithDoubleQuote graf-after--p"><p>&#x201C;I&#x2019;m looking for a Chinese restaurant in my area&#x201D;</p></blockquote>
<p id="4f96" class="graf graf--p graf-after--blockquote">It returns structured data like:</p>
<pre id="9077" class="graf graf--pre graf-after--p"><code class="markup--code markup--pre-code">intent: search_restaurant
  entities: 
    - cuisine : Chinese
    - location : my area</code></pre>
<h3 id="be09" class="graf graf--h3 graf-after--pre">Beginning at the&#xA0;Start</h3>
<p id="ba71" class="graf graf--p graf-after--h3">First, we looked at the command that should be executed to start training of our model:</p>
<pre id="eba0" class="graf graf--pre graf-after--p">python -m rasa_nlu.train \
    --config sample_configs/config_spacy.yml \
    --data data/examples/rasa/demo-rasa.json \
    --path projects</pre>
<p id="47f4" class="graf graf--p graf-after--pre">This led us to the&#xA0;<a class="markup--anchor markup--p-anchor" href="https://github.com/GauravG8/rasa_nlu/blob/master/rasa_nlu/train.py" target="_blank" rel="nofollow noopener noreferrer" data-href="https://github.com/GauravG8/rasa_nlu/blob/master/rasa_nlu/train.py">train.py</a>&#xA0;in the rasa_nlu folder. Thats where all the magic happens (or atleast the training in this case). Digging deeper, we found the&#xA0;<strong class="markup--strong markup--p-strong">do_train()</strong>&#xA0;function, which is called on executing the above command. It takes the&#xA0;<strong class="markup--strong markup--p-strong">config</strong>,&#xA0;<strong class="markup--strong markup--p-strong">data</strong>&#xA0;and&#xA0;<strong class="markup--strong markup--p-strong">path&#xA0;</strong>specified during execution.</p>
<style>.gist table { margin-bottom: 0; }</style>
<div style="tab-size: 8" id="gist90613608" class="gist">
<div class="gist-file" translate="no">
<div class="gist-data">
<div class="js-gist-file-update-container js-task-list-container file-box">
<div id="file-train-py" class="file my-2">
<div itemprop="text" class="Box-body p-0 blob-wrapper data type-python  ">
<div class="js-check-bidi js-blob-code-container blob-code-content">
<p>  <template class="js-file-alert-template"></template></p>
<div data-view-component="true" class="flash flash-warn flash-full d-flex flex-items-center">
  <svg aria-hidden="true" height="16" viewbox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"/>
</svg><p></p>
<p>    <span><br>
      This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.<br>
      <a href="https://github.co/hiddenchars" target="_blank">Learn more about bidirectional Unicode characters</a><br>
    </span></p>
<div data-view-component="true" class="flash-action">        <a href="{{ revealButtonHref }}" data-view-component="true" class="btn-sm btn">    Show hidden characters<br>
</a>
</div>
</div>
<p><br>
<template class="js-line-alert-template"><br>
  <span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e"><br>
    <svg aria-hidden="true" height="16" viewbox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
    <path fill-rule="evenodd" d="M8.22 1.754a.25.25 0 00-.44 0L1.698 13.132a.25.25 0 00.22.368h12.164a.25.25 0 00.22-.368L8.22 1.754zm-1.763-.707c.659-1.234 2.427-1.234 3.086 0l6.082 11.378A1.75 1.75 0 0114.082 15H1.918a1.75 1.75 0 01-1.543-2.575L6.457 1.047zM9 11a1 1 0 11-2 0 1 1 0 012 0zm-.25-5.25a.75.75 0 00-1.5 0v2.5a.75.75 0 001.5 0v-2.5z"/>
</svg><br>
</span></template></p>
<table data-hpc class="highlight tab-size js-file-line-container js-code-nav-container js-tagsearch-file" data-tab-size="8" data-paste-markdown-skip data-tagsearch-lang="Python" data-tagsearch-path="train.py">
<tr>
<td id="file-train-py-L1" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="1"></td>
<td id="file-train-py-LC1" class="blob-code blob-code-inner js-file-line"><span class="pl-k">def</span> <span class="pl-en">do_train</span>(<span class="pl-s1">cfg</span>,  <span class="pl-c"># type: RasaNLUModelConfig</span></td>
</tr>
<tr>
<td id="file-train-py-L2" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="2"></td>
<td id="file-train-py-LC2" class="blob-code blob-code-inner js-file-line">             <span class="pl-s1">data</span>,  <span class="pl-c"># type: Text</span></td>
</tr>
<tr>
<td id="file-train-py-L3" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="3"></td>
<td id="file-train-py-LC3" class="blob-code blob-code-inner js-file-line">             <span class="pl-s1">path</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,  <span class="pl-c"># type: Optional[Text]</span></td>
</tr>
<tr>
<td id="file-train-py-L4" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="4"></td>
<td id="file-train-py-LC4" class="blob-code blob-code-inner js-file-line">             <span class="pl-s1">project</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,  <span class="pl-c"># type: Optional[Text]</span></td>
</tr>
<tr>
<td id="file-train-py-L5" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="5"></td>
<td id="file-train-py-LC5" class="blob-code blob-code-inner js-file-line">             <span class="pl-s1">fixed_model_name</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,  <span class="pl-c"># type: Optional[Text]</span></td>
</tr>
<tr>
<td id="file-train-py-L6" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="6"></td>
<td id="file-train-py-LC6" class="blob-code blob-code-inner js-file-line">             <span class="pl-s1">storage</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,  <span class="pl-c"># type: Optional[Text]</span></td>
</tr>
<tr>
<td id="file-train-py-L7" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="7"></td>
<td id="file-train-py-LC7" class="blob-code blob-code-inner js-file-line">             <span class="pl-s1">component_builder</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,  <span class="pl-c"># type: Optional[ComponentBuilder]</span></td>
</tr>
<tr>
<td id="file-train-py-L8" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="8"></td>
<td id="file-train-py-LC8" class="blob-code blob-code-inner js-file-line">             <span class="pl-s1">url</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,  <span class="pl-c"># type: Optional[Text]</span></td>
</tr>
<tr>
<td id="file-train-py-L9" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="9"></td>
<td id="file-train-py-LC9" class="blob-code blob-code-inner js-file-line">             <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>  <span class="pl-c"># type: Any</span></td>
</tr>
<tr>
<td id="file-train-py-L10" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="10"></td>
<td id="file-train-py-LC10" class="blob-code blob-code-inner js-file-line">             ):</td>
</tr>
<tr>
<td id="file-train-py-L11" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="11"></td>
<td id="file-train-py-LC11" class="blob-code blob-code-inner js-file-line">    <span class="pl-s">&quot;&quot;&quot;Loads the trainer and the data and runs the training of the model.&quot;&quot;&quot;</span></td>
</tr>
<tr>
<td id="file-train-py-L12" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="12"></td>
<td id="file-train-py-LC12" class="blob-code blob-code-inner js-file-line">    </td>
</tr>
<tr>
<td id="file-train-py-L13" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="13"></td>
<td id="file-train-py-LC13" class="blob-code blob-code-inner js-file-line">    <span class="pl-s1">trainer</span> <span class="pl-c1">=</span> <span class="pl-v">Trainer</span>(<span class="pl-s1">cfg</span>, <span class="pl-s1">component_builder</span>)</td>
</tr>
<tr>
<td id="file-train-py-L14" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="14"></td>
<td id="file-train-py-LC14" class="blob-code blob-code-inner js-file-line">    <span class="pl-s1">persistor</span> <span class="pl-c1">=</span> <span class="pl-en">create_persistor</span>(<span class="pl-s1">storage</span>)</td>
</tr>
<tr>
<td id="file-train-py-L15" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="15"></td>
<td id="file-train-py-LC15" class="blob-code blob-code-inner js-file-line">    <span class="pl-k">if</span> <span class="pl-s1">url</span> <span class="pl-c1">is</span> <span class="pl-c1">not</span> <span class="pl-c1">None</span>:</td>
</tr>
<tr>
<td id="file-train-py-L16" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="16"></td>
<td id="file-train-py-LC16" class="blob-code blob-code-inner js-file-line">        <span class="pl-s1">training_data</span> <span class="pl-c1">=</span> <span class="pl-en">load_data_from_url</span>(<span class="pl-s1">url</span>, <span class="pl-s1">cfg</span>.<span class="pl-s1">language</span>)</td>
</tr>
<tr>
<td id="file-train-py-L17" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="17"></td>
<td id="file-train-py-LC17" class="blob-code blob-code-inner js-file-line">    <span class="pl-k">else</span>:</td>
</tr>
<tr>
<td id="file-train-py-L18" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="18"></td>
<td id="file-train-py-LC18" class="blob-code blob-code-inner js-file-line">        <span class="pl-s1">training_data</span> <span class="pl-c1">=</span> <span class="pl-en">load_data</span>(<span class="pl-s1">data</span>, <span class="pl-s1">cfg</span>.<span class="pl-s1">language</span>)</td>
</tr>
<tr>
<td id="file-train-py-L19" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="19"></td>
<td id="file-train-py-LC19" class="blob-code blob-code-inner js-file-line">    <span class="pl-s1">interpreter</span> <span class="pl-c1">=</span> <span class="pl-s1">trainer</span>.<span class="pl-en">train</span>(<span class="pl-s1">training_data</span>, <span class="pl-c1">**</span><span class="pl-s1">kwargs</span>)</td>
</tr>
<tr>
<td id="file-train-py-L20" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="20"></td>
<td id="file-train-py-LC20" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="file-train-py-L21" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="21"></td>
<td id="file-train-py-LC21" class="blob-code blob-code-inner js-file-line">    <span class="pl-k">if</span> <span class="pl-s1">path</span>:</td>
</tr>
<tr>
<td id="file-train-py-L22" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="22"></td>
<td id="file-train-py-LC22" class="blob-code blob-code-inner js-file-line">        <span class="pl-s1">persisted_path</span> <span class="pl-c1">=</span> <span class="pl-s1">trainer</span>.<span class="pl-en">persist</span>(<span class="pl-s1">path</span>,</td>
</tr>
<tr>
<td id="file-train-py-L23" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="23"></td>
<td id="file-train-py-LC23" class="blob-code blob-code-inner js-file-line">                                         <span class="pl-s1">persistor</span>,</td>
</tr>
<tr>
<td id="file-train-py-L24" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="24"></td>
<td id="file-train-py-LC24" class="blob-code blob-code-inner js-file-line">                                         <span class="pl-s1">project</span>,</td>
</tr>
<tr>
<td id="file-train-py-L25" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="25"></td>
<td id="file-train-py-LC25" class="blob-code blob-code-inner js-file-line">                                         <span class="pl-s1">fixed_model_name</span>)</td>
</tr>
<tr>
<td id="file-train-py-L26" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="26"></td>
<td id="file-train-py-LC26" class="blob-code blob-code-inner js-file-line">    <span class="pl-k">else</span>:</td>
</tr>
<tr>
<td id="file-train-py-L27" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="27"></td>
<td id="file-train-py-LC27" class="blob-code blob-code-inner js-file-line">        <span class="pl-s1">persisted_path</span> <span class="pl-c1">=</span> <span class="pl-c1">None</span></td>
</tr>
<tr>
<td id="file-train-py-L28" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="28"></td>
<td id="file-train-py-LC28" class="blob-code blob-code-inner js-file-line">
</td>
</tr>
<tr>
<td id="file-train-py-L29" class="blob-num js-line-number js-code-nav-line-number js-blob-rnum" data-line-number="29"></td>
<td id="file-train-py-LC29" class="blob-code blob-code-inner js-file-line">    <span class="pl-k">return</span> <span class="pl-s1">trainer</span>, <span class="pl-s1">interpreter</span>, <span class="pl-s1">persisted_path</span></td>
</tr>
</table>
</div></div>
<p></p></div>
</div></div>
<div class="gist-meta">
        <a href="https://gist.github.com/GauravG8/7247a032bee69d7653ac1e3b3a6cf9d9/raw/207aad0f6a9d85e1562f6de4815fbe474044005d/train.py" style="float:right">view raw</a><br>
        <a href="https://gist.github.com/GauravG8/7247a032bee69d7653ac1e3b3a6cf9d9#file-train-py"><br>
          train.py<br>
        </a><br>
        hosted with &#x2764; by <a href="https://github.com">GitHub</a>
      </div>
<p></p></div>
</div>
<h3 id="297e" class="graf graf--h3 graf-after--figure">Trainer</h3>
<p id="3722" class="graf graf--p graf-after--h3">Now, in the&#xA0;<strong class="markup--strong markup--p-strong">do_train()</strong>&#xA0;function, we see that the Trainer model is initially called.</p>
<pre id="5385" class="graf graf--pre graf-after--p">trainer = Trainer(cfg, component_builder)</pre>
<p id="7529" class="graf graf--p graf-after--pre">Two arguments are passed to the Trainer model in&#xA0;<a class="markup--anchor markup--p-anchor" href="https://github.com/GauravG8/rasa_nlu/blob/master/rasa_nlu/model.py" target="_blank" rel="nofollow noopener noreferrer" data-href="https://github.com/GauravG8/rasa_nlu/blob/master/rasa_nlu/model.py">model.py</a>:</p>
<ul class="postList">
<li id="d069" class="graf graf--li graf-after--p"><strong class="markup--strong markup--li-strong">config</strong>&#xA0;(sample_configs/config_spacy.yml) to use for the training, and</li>
<li id="96a4" class="graf graf--li graf-after--li"><strong class="markup--strong markup--li-strong">component_builder</strong>, which is the pipeline specification. In our case, we had not specified the component_builder.</li>
</ul>
<p id="8434" class="graf graf--p graf-after--li">The Trainer basically loads the config and uses the component_builder to build a trainer model. As we had not specified the component_builder, the default&#xA0;<a class="markup--anchor markup--p-anchor" href="https://spacy.io/usage/processing-pipelines" target="_blank" rel="nofollow noopener noreferrer" data-href="https://spacy.io/usage/processing-pipelines">spaCy component pipeline</a>&#xA0;is loaded for us because of the specified spaCy config.</p>
<figure id="786d" class="graf graf--figure graf-after--p">
<div class="aspectRatioPlaceholder is-locked">
<div class="aspectRatioPlaceholder-fill"></div>
<div class="progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded" data-image-id="1*N_rRGCNctsX2tHhhR8H-lw.png" data-width="923" data-height="200" data-action="zoom" data-action-value="1*N_rRGCNctsX2tHhhR8H-lw.png" data-scroll="native"><canvas class="progressiveMedia-canvas js-progressiveMedia-canvas" width="75" height="15"></canvas><img class="progressiveMedia-image js-progressiveMedia-image" src="https://cdn-images-1.medium.com/max/1000/1*N_rRGCNctsX2tHhhR8H-lw.png" data-src="https://cdn-images-1.medium.com/max/1000/1*N_rRGCNctsX2tHhhR8H-lw.png" alt="Getting Started with Machine Learning: Starting at the End by understanding Rasa NLU"></div>
</div><figcaption class="imageCaption">SpaCy Language Processing Pipeline</figcaption></figure>
<h3 id="084d" class="graf graf--h3 graf-after--figure">Persistor</h3>
<p id="5af0" class="graf graf--p graf-after--h3">The next function is the persistor, which functions to store the data. You can specify AWS, GC, Azure or None. This is optional and we did not specify the same.</p>
<pre id="b2a8" class="graf graf--pre graf-after--p">persistor = create_persistor(storage)</pre>
<h3 id="278d" class="graf graf--h3 graf-after--pre">Training Data</h3>
<p id="8734" class="graf graf--p graf-after--h3">Next, the training data can be taken from either the url or from local. We had specified the data in local with our command (data/examples/rasa/demo-rasa.json).</p>
<pre id="fd74" class="graf graf--pre graf-after--p">if url is not None:
      training_data = load_data_from_url(url, cfg.language)    
else:
      training_data = load_data(data, cfg.language)</pre>
<h3 id="0f33" class="graf graf--h3 graf-after--pre">Interpreter</h3>
<p id="e4ab" class="graf graf--p graf-after--h3">This data is sent to the trainer, we had created above for training and generating an interpreter.</p>
<pre id="b45c" class="graf graf--pre graf-after--p">interpreter = trainer.train(training_data, **kwargs)</pre>
<p id="7114" class="graf graf--p graf-after--pre">The&#xA0;<strong class="markup--strong markup--p-strong">train()&#xA0;</strong>function in the Trainer model gets the&#xA0;<strong class="markup--strong markup--p-strong">training_data</strong>&#xA0;and iterates through it to generate a spaCy model. This is returned as the&#xA0;<strong class="markup--strong markup--p-strong">interpertor</strong>, which can interpret the input data and give structured data output.</p>
<h3 id="f6b4" class="graf graf--h3 graf-after--p">Persisted Path</h3>
<p id="4119" class="graf graf--p graf-after--h3">If path is provided, as in our case (projects) data is persisted to the path.</p>
<h3 id="23c8" class="graf graf--h3 graf-after--p">The Result</h3>
<p id="473e" class="graf graf--p graf-after--h3">And finally, the do_train() function returns the&#xA0;<strong class="markup--strong markup--p-strong">trainer</strong>, the&#xA0;<strong class="markup--strong markup--p-strong">interpreter</strong>&#xA0;and the&#xA0;<strong class="markup--strong markup--p-strong">persisted_path</strong>. Now, we can make use of the generated interpreter for getting intents and the entities. This can further be used for Natural Language Understanding, which is what is used in the&#xA0;<a class="markup--user markup--p-user" href="https://medium.com/@RasaHQ" target="_blank" rel="noopener noreferrer" data-href="https://medium.com/@RasaHQ" data-anchor-type="2" data-user-id="fb02cb4905b7" data-action-value="fb02cb4905b7" data-action="show-user-card" data-action-type="hover">Rasa</a>&#xA0;core.</p>
<figure id="97db" class="graf graf--figure graf-after--p">
<div class="aspectRatioPlaceholder is-locked">
<div class="aspectRatioPlaceholder-fill"></div>
<div class="progressiveMedia js-progressiveMedia graf-image is-canvasLoaded is-imageLoaded" data-image-id="1*uLrVng_Yek4tf50deSAd-w.gif" data-width="500" data-height="210" data-scroll="native">
<p>&#xA0;</p>
<figure style="width: 500px" class="wp-caption aligncenter"><img loading="lazy" class="progressiveMedia-image js-progressiveMedia-image" src="https://cdn-images-1.medium.com/max/1000/1*uLrVng_Yek4tf50deSAd-w.gif" alt="Getting Started with Machine Learning: Starting at the End by understanding Rasa NLU" width="500" height="210" data-src="https://cdn-images-1.medium.com/max/1000/1*uLrVng_Yek4tf50deSAd-w.gif"><figcaption class="wp-caption-text">Lightsaber locked and loaded</figcaption></figure>
</div>
</div>
</figure>
<p id="0ca0" class="graf graf--p graf-after--figure">Equipped with this knowledge of how a trainer works in a final NLP product, I began my journey deeper into Machine Learning. I do have more questions than when I started, but at least now I know where to look and what direction to take. So, sometimes, it is better to start at the end and then go back to the beginning. This way you will get a load of questions, which will help you direct your focus towards a path that will take you in deeper.</p>
<p id="71c4" class="graf graf--p graf-after--p graf--trailing">Hope this article helped you also get started or enhanced your experience with Machine Learning. Do feel free to drop any queries that you have below.</p>
<p class="graf graf--p graf-after--p graf--trailing" style="text-align: center;">* * *</p>
<p class="graf graf--p graf-after--p graf--trailing"><em class="markup--em markup--blockquote-em">Originally published on July 7th, 2018 at <a href="https://medium.com/@gauravgpunjabi/getting-started-with-machine-learning-ea0dc29e3ff6">medium.com</a></em></p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[How to remove padding around button widgets in Android?]]></title><description><![CDATA[<!--kg-card-begin: html--><p>When using the default button widget in Android, you can see that the button comes with its own preset padding. When trying to stylize the button with a custom background, it gets really annoying to have this fixed background.</p>
<p><img loading="lazy" class="aligncenter wp-image-48527 size-medium" src="https://ghostcode.in/wp-content/uploads/2016/12/button2@GhostCode-300x38.png" alt width="300" height="38" srcset="https://ghostcode.in/content/images/wordpress/2016/12/button2@GhostCode-300x38.png 300w, https://ghostcode.in/content/images/wordpress/2016/12/button2@GhostCode.png 701w" sizes="(max-width: 300px) 100vw, 300px"></p>
<p>You can remove the padding around the button by using&#xA0;</p>]]></description><link>https://ghostcode.in/how-to-remove-padding-around-button-widgets-in-android/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed038</guid><category><![CDATA[android]]></category><category><![CDATA[basics]]></category><category><![CDATA[button]]></category><category><![CDATA[Design]]></category><category><![CDATA[padding]]></category><category><![CDATA[widgets]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Tue, 16 May 2017 18:25:28 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>When using the default button widget in Android, you can see that the button comes with its own preset padding. When trying to stylize the button with a custom background, it gets really annoying to have this fixed background.</p>
<p><img loading="lazy" class="aligncenter wp-image-48527 size-medium" src="https://ghostcode.in/wp-content/uploads/2016/12/button2@GhostCode-300x38.png" alt width="300" height="38" srcset="https://ghostcode.in/content/images/wordpress/2016/12/button2@GhostCode-300x38.png 300w, https://ghostcode.in/content/images/wordpress/2016/12/button2@GhostCode.png 701w" sizes="(max-width: 300px) 100vw, 300px"></p>
<p>You can remove the padding around the button by using&#xA0;setting the minWidth and minHeight to 0.</p>
<pre class="brush: xml; title: ; notranslate" title>
&lt;Button 
    android:minHeight=&quot;0dp&quot; 
    android:minWidth=&quot;0dp&quot; 
    ...
</pre>
<p>Now you can customize the padding by using the android:padding attribute</p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[How to display HTML content in UILabel Swift 3]]></title><description><![CDATA[<!--kg-card-begin: html--><p>First we take&#xA0;a HTML string as input and then process this string to generate an Attributed String which can be set to the UILabel.&#xA0; Below are the steps in the process:</p>
<ul>
<li>Data is taken from the string using the unicode encoding.</li>
</ul>
<pre>let data = string.data(using: String.</pre>]]></description><link>https://ghostcode.in/how-to-display-html-content-in-uilabel-swift-3/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed037</guid><category><![CDATA[apple]]></category><category><![CDATA[html]]></category><category><![CDATA[string from html]]></category><category><![CDATA[swift]]></category><category><![CDATA[swift 3]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Fri, 21 Apr 2017 18:11:34 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>First we take&#xA0;a HTML string as input and then process this string to generate an Attributed String which can be set to the UILabel.&#xA0; Below are the steps in the process:</p>
<ul>
<li>Data is taken from the string using the unicode encoding.</li>
</ul>
<pre>let data = string.data(using: String.Encoding.unicode, allowLossyConversion: true)</pre>
<ul>
<li>Using the&#xA0;NSHTMLTextDocumentType, an NSAttributedString is generated.</li>
</ul>
<pre>if let d = data {
    let str = try NSAttributedString(data: d,
        options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
        documentAttributes: nil)
    return str
}
</pre>
<ul>
<li>This string can be set to the UILabel to display&#xA0;HTML formatted text.</li>
</ul>
<pre class="lang-swift prettyprint prettyprinted"><code><span class="pln">myLabel</span><span class="pun">.</span><span class="pln">attributedText </span><span class="pun">= str</span></code></pre>
<p>Have a look at the complete function below:</p>
<pre class="brush: java; title: ; notranslate" title>
private func stringFromHtml(string: String) -&gt; NSAttributedString? {
    do {
        let data = string.data(using: String.Encoding.unicode, allowLossyConversion: true)
        if let d = data {
            let str = try NSAttributedString(data: d,
               options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType],
               documentAttributes: nil)
            return str
        }
    } catch {
        print (&quot;Failed to get HTML from string&quot;)
    }
    return nil
}
</pre>
<p>This function has been written in Swift 3.</p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[How to get the time in Android relative to current time? - In number of seconds, minutes, hours or days ago]]></title><description><![CDATA[<!--kg-card-begin: html--><p>Many a time, we shall be dealing with time in a number of varied DateTime formats. We have discussed about some of the ways to standardize DateTime in a previous article. In this article, we shall learn how to get the time relative to current time.</p>
<p>Without further adieu, lets</p>]]></description><link>https://ghostcode.in/how-to-get-the-time-relative-to-current-time-in-number-of-seconds-minutes-hours-and-days-ago/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed034</guid><category><![CDATA[android]]></category><category><![CDATA[basics]]></category><category><![CDATA[days ago]]></category><category><![CDATA[months ago]]></category><category><![CDATA[relative time]]></category><category><![CDATA[time]]></category><category><![CDATA[today]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Wed, 08 Mar 2017 23:23:20 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>Many a time, we shall be dealing with time in a number of varied DateTime formats. We have discussed about some of the ways to standardize DateTime in a previous article. In this article, we shall learn how to get the time relative to current time.</p>
<p>Without further adieu, lets jump into the code. We shall be working with the input time in milliseconds (Refer this article on how to parse the date and get time in milliseconds). we then get the current time in milliseconds using System.currentTimeMillis().</p>
<pre class="brush: java; title: ; notranslate" title>
long now = System.currentTimeMillis();
</pre>
<p>Then we check if currentTime is greater than inputTime, meaning the inutTime is in the past, and then find the difference between the inputTime and currentTime. We convert the difference to seconds, minutes, hours, days, months and years to determine its relativity. Check out the entire code below:</p>
<pre class="brush: java; title: ; notranslate" title>
// inputTime in milliseconds
public static String getRelativeTime(long inputTime) {
    long difference = 0;
    // Get the current time in milli seconds
    long currentTime = System.currentTimeMillis();

    if (currentTime &gt; inputTime) {
        difference = currentTime - inputTime;
        final long seconds = difference / 1000;
        final long minutes = seconds / 60;
        final long hours = minutes / 60;
        final long days = hours / 24;
        final long months = days / 31;
        final long years = days / 365;

        if (seconds &lt; 60) {
            return seconds == 1 ? &quot;one second ago&quot; : seconds + &quot; seconds ago&quot;;
        } else if (seconds &lt; 120) {
            return &quot;a minute ago&quot;;
        } else if (seconds &lt; 2700) { // 45 * 60
            return minutes + &quot; minutes ago&quot;;
        } else if (seconds &lt; 5400) { // 90 * 60
            return &quot;an hour ago&quot;;
        } else if (seconds &lt; 86400) { // 24 * 60 * 60
            return hours + &quot; hours ago&quot;;
        } else if (seconds &lt; 172800) { // 48 * 60 * 60
            return &quot;Yesterday&quot;;
        } else if (seconds &lt; 2592000) { // 30 * 24 * 60 * 60
            return days + &quot; days ago&quot;;
        } else if (seconds &lt; 31104000) { // 12 * 30 * 24 * 60 * 60
            return months &lt;= 1 ? &quot;One month ago&quot; : days + &quot; months ago&quot;;
        } else {
            return years &lt;= 1 ? &quot;One year ago&quot; : years + &quot; years ago&quot;;
        }
    }
    return null;
}
</pre>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[Links that you must follow while developing for Android]]></title><description><![CDATA[<!--kg-card-begin: html--><p>While developing for android, getting an idea of the design to choose or what&#xA0;functionality to implement is a hassle. So below are a &#xA0;set of links that you can use to make your life easier when developing for android:</p>
<ol>
<li><a href="https://developer.android.com/index.html">Android Official Developers site</a>: The official Android developers</li></ol>]]></description><link>https://ghostcode.in/links-that-you-must-follow-while-developing-for-android/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed031</guid><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Thu, 12 Jan 2017 12:46:12 GMT</pubDate><media:content url="https://ghostcode.in/content/images/wordpress/2017/01/HEX-LINKS-TRANSPARENT-BACKGROUND-DOUBLE-HEIGHT-LIGHT.jpg" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: html--><img src="https://ghostcode.in/content/images/wordpress/2017/01/HEX-LINKS-TRANSPARENT-BACKGROUND-DOUBLE-HEIGHT-LIGHT.jpg" alt="Links that you must follow while developing for Android"><p>While developing for android, getting an idea of the design to choose or what&#xA0;functionality to implement is a hassle. So below are a &#xA0;set of links that you can use to make your life easier when developing for android:</p>
<ol>
<li><a href="https://developer.android.com/index.html">Android Official Developers site</a>: The official Android developers site is one of the best resources for Android development. With updates about&#xA0;the latest version of the android OS as well as tutorials for the newest features, this site is a very useful resource. You can also find the documentation of all the Java classes that are available with each Android version, grouped via API. The best thing about this site is it comes bundled with your SDK installation, so that you can also use it offline.<img loading="lazy" class="aligncenter size-full wp-image-48621" src="https://ghostcode.in/wp-content/uploads/2017/03/android-developers@GhostCode.png" alt="Links that you must follow while developing for Android" width="1280" height="520" srcset="https://ghostcode.in/content/images/wordpress/2017/03/android-developers@GhostCode.png 1280w, https://ghostcode.in/content/images/wordpress/2017/03/android-developers@GhostCode-300x122.png 300w, https://ghostcode.in/content/images/wordpress/2017/03/android-developers@GhostCode-768x312.png 768w, https://ghostcode.in/content/images/wordpress/2017/03/android-developers@GhostCode-1024x416.png 1024w" sizes="(max-width: 1280px) 100vw, 1280px"></li>
<li><a href="http://stackoverflow.com">Stack Overflow</a>: If you have developed before, you would have surely come across stack overflow. You can find answers to a wide range of issues that you come across while developing here&#xA0;and also post questions in case you can&#x2019;t find a solution.<img loading="lazy" class="aligncenter size-full wp-image-48623" src="https://ghostcode.in/wp-content/uploads/2017/03/so-logo.png" alt="Links that you must follow while developing for Android" width="1000" height="298" srcset="https://ghostcode.in/content/images/wordpress/2017/03/so-logo.png 1000w, https://ghostcode.in/content/images/wordpress/2017/03/so-logo-300x89.png 300w, https://ghostcode.in/content/images/wordpress/2017/03/so-logo-768x229.png 768w" sizes="(max-width: 1000px) 100vw, 1000px"></li>
<li><a href="https://material.io">Material Design</a>: The official Material design site contains all the specs of the new Material design that was introduced with Android 5.0, which are constantly updated. The material design site also contains guidelines, which in their words: &#x201C;This spec is a living document that will be updated as we continue to develop the tenets and specifics of material design.&#x201D;<img loading="lazy" class="aligncenter size-full wp-image-48622" src="https://ghostcode.in/wp-content/uploads/2017/03/material-design@GhostCode.png" alt="Links that you must follow while developing for Android" width="1280" height="658" srcset="https://ghostcode.in/content/images/wordpress/2017/03/material-design@GhostCode.png 1280w, https://ghostcode.in/content/images/wordpress/2017/03/material-design@GhostCode-300x154.png 300w, https://ghostcode.in/content/images/wordpress/2017/03/material-design@GhostCode-768x395.png 768w, https://ghostcode.in/content/images/wordpress/2017/03/material-design@GhostCode-1024x526.png 1024w" sizes="(max-width: 1280px) 100vw, 1280px"></li>
<li><a href="https://android-developers.googleblog.com">The Android Developer&#x2019;s Blog</a>: Whether it is a new official update or a new feature tutorial, the Android developer blog is the best place to get the information. With inside info and latest news updates regarding Android, this blog is must to be followed.<img loading="lazy" class="aligncenter size-full wp-image-48625" src="https://ghostcode.in/wp-content/uploads/2017/01/04_blog_3banner.png" alt="Links that you must follow while developing for Android" width="960" height="194" srcset="https://ghostcode.in/content/images/wordpress/2017/01/04_blog_3banner.png 960w, https://ghostcode.in/content/images/wordpress/2017/01/04_blog_3banner-300x61.png 300w, https://ghostcode.in/content/images/wordpress/2017/01/04_blog_3banner-768x155.png 768w" sizes="(max-width: 960px) 100vw, 960px"></li>
<li><a href="http://github.com">Github</a>: Github contains a wide range of repositories of projects, tools and libraries that you can use in your app. Github is also a very useful version control tool for your app. Check out <a href="https://ghostcode.in/2016/12/14/how-to-enable-version-control-in-android-studio-using-git-github/">this article</a> for a way to setup Android Studio with Github.<img loading="lazy" class="aligncenter size-full wp-image-48628" src="https://ghostcode.in/wp-content/uploads/2017/01/github-logo.png" alt="Links that you must follow while developing for Android" width="573" height="248" srcset="https://ghostcode.in/content/images/wordpress/2017/01/github-logo.png 573w, https://ghostcode.in/content/images/wordpress/2017/01/github-logo-300x130.png 300w" sizes="(max-width: 573px) 100vw, 573px"></li>
<li><a href="https://android-arsenal.com/">Android arsenal</a>: Android arsenal, just like Github contains a categorized directory of libraries, tools and apps that you can use for in your app or as a reference for development.</li>
<li><a href="http://google.com">Google:</a>&#xA0;Last but the best of them all, Google is one of the best places to find solutions to your problems. All you have to do is ask the right question.<img loading="lazy" class="aligncenter size-full wp-image-48627" src="https://ghostcode.in/wp-content/uploads/2017/01/google-doodle-main.jpg" alt="Links that you must follow while developing for Android" width="633" height="356" srcset="https://ghostcode.in/content/images/wordpress/2017/01/google-doodle-main.jpg 633w, https://ghostcode.in/content/images/wordpress/2017/01/google-doodle-main-300x169.jpg 300w" sizes="(max-width: 633px) 100vw, 633px">What do you think of this list? Do you have any other link that you think can be added? Comment it below.</li>
</ol>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[How to enable Version Control in Android Studio using Git & Github?]]></title><description><![CDATA[<!--kg-card-begin: html--><p>Github is one of the most widely used web-based version control systems, based on <strong>Git</strong>. It is a useful source code management tool, where you can keep track of versions of your app and all the changes between it.</p>
<p>Version control helps you keep a track of changes and rollback</p>]]></description><link>https://ghostcode.in/how-to-enable-version-control-in-android-studio-using-git-github/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed030</guid><category><![CDATA[basics]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Wed, 14 Dec 2016 16:22:34 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>Github is one of the most widely used web-based version control systems, based on <strong>Git</strong>. It is a useful source code management tool, where you can keep track of versions of your app and all the changes between it.</p>
<p>Version control helps you keep a track of changes and rollback to a previous version if there are any errors in the current version. Github makes this easier by providing a means to compare the code between commits and also preview parts of the code online. Code uploaded to github are stored in public repositories (accessible to everyone). Private repositories are available at $7/month.</p>
<p>Android Studio comes inbuilt with a number of choices for Version Control Systems, with options to use Git as well as Github. To make use of Github, signup for&#xA0;an account at <a href="http://github.com">github.com</a>. If you are a student, make sure to sign up for the <a href="https://education.github.com/pack">Student developer pack</a>, where you are eligible to use private repos.</p>
<p>Below are the steps on how to setup the version control using Git &amp; github for your project:</p>
<ol>
<li>Once you have signed into your Github account, click on the plus icon next to your profile icon and choose new repository.
<p><img loading="lazy" class="aligncenter wp-image-48587" src="https://ghostcode.in/wp-content/uploads/2017/12/1-github-new-repo@GhostCode.png" width="600" height="375" srcset="https://ghostcode.in/content/images/wordpress/2017/12/1-github-new-repo@GhostCode.png 1280w, https://ghostcode.in/content/images/wordpress/2017/12/1-github-new-repo@GhostCode-300x188.png 300w, https://ghostcode.in/content/images/wordpress/2017/12/1-github-new-repo@GhostCode-768x480.png 768w, https://ghostcode.in/content/images/wordpress/2017/12/1-github-new-repo@GhostCode-1024x640.png 1024w" sizes="(max-width: 600px) 100vw, 600px"></p></li>
<li>In the following page,&#xA0;&#xA0;enter a repository name and description. You can choose the repo to be private or public. Be careful not to select the Initialize this repository with a README (otherwise you will not be able to push your code into the repo. You will then have to pull the code first and then push it).
<p><img loading="lazy" class="aligncenter wp-image-48604" src="https://ghostcode.in/wp-content/uploads/2016/09/2-github-create-new-repo@GhostCode.png" width="600" height="342" srcset="https://ghostcode.in/content/images/wordpress/2016/09/2-github-create-new-repo@GhostCode.png 1280w, https://ghostcode.in/content/images/wordpress/2016/09/2-github-create-new-repo@GhostCode-300x171.png 300w, https://ghostcode.in/content/images/wordpress/2016/09/2-github-create-new-repo@GhostCode-768x438.png 768w, https://ghostcode.in/content/images/wordpress/2016/09/2-github-create-new-repo@GhostCode-1024x584.png 1024w" sizes="(max-width: 600px) 100vw, 600px"></p></li>
<li>Once the repo has been created, you will then get a link to access it. Make a note of that link. So in this case, the link to the repo I created is: <a href="https://github.com/TheCoffee/alertdialogs.git">https://github.com/TheCoffee/alertdialogs.git
<p></p></a><img loading="lazy" class="aligncenter wp-image-48589" src="https://ghostcode.in/wp-content/uploads/2017/12/3-github-repo-link@GhostCode.png" width="600" height="375" srcset="https://ghostcode.in/content/images/wordpress/2017/12/3-github-repo-link@GhostCode.png 1280w, https://ghostcode.in/content/images/wordpress/2017/12/3-github-repo-link@GhostCode-300x188.png 300w, https://ghostcode.in/content/images/wordpress/2017/12/3-github-repo-link@GhostCode-768x480.png 768w, https://ghostcode.in/content/images/wordpress/2017/12/3-github-repo-link@GhostCode-1024x640.png 1024w" sizes="(max-width: 600px) 100vw, 600px"></li>
<li>Now head over to Android Studio. In your project, select VCS -&gt; Import into Version Control -&gt; Create Git Repository.
<p><img loading="lazy" class="aligncenter wp-image-48605 size-large" src="https://ghostcode.in/wp-content/uploads/2016/09/4-Import-to-VCS-Android-studio-1024x598.png" width="840" height="491" srcset="https://ghostcode.in/content/images/wordpress/2016/09/4-Import-to-VCS-Android-studio-1024x598.png 1024w, https://ghostcode.in/content/images/wordpress/2016/09/4-Import-to-VCS-Android-studio-300x175.png 300w, https://ghostcode.in/content/images/wordpress/2016/09/4-Import-to-VCS-Android-studio-768x448.png 768w, https://ghostcode.in/content/images/wordpress/2016/09/4-Import-to-VCS-Android-studio.png 1280w" sizes="(max-width: 840px) 100vw, 840px"></p></li>
<li>In the window that popups, select the project directory for git init. This is the directory that will be synced with the git repo. So in my case, I have chosen my project AlertDialogs.&#xA0;Once you click on this, all the files in the Project pane will become red.
<p><img loading="lazy" class="aligncenter  wp-image-48619" src="https://ghostcode.in/wp-content/uploads/2016/12/5-Select-git-directory.png" alt width="366" height="433" srcset="https://ghostcode.in/content/images/wordpress/2016/12/5-Select-git-directory.png 423w, https://ghostcode.in/content/images/wordpress/2016/12/5-Select-git-directory-253x300.png 253w" sizes="(max-width: 366px) 100vw, 366px"></p></li>
<li>Add your project directory to your local git repo. You can do this by right clicking on your project folder and selecting Git -&gt; Add. Once you click on this, all the files in the Project pane will become green.
<p><img loading="lazy" class="aligncenter  wp-image-48607" src="https://ghostcode.in/wp-content/uploads/2016/09/6-Add-directory-to-git.png" alt width="437" height="392" srcset="https://ghostcode.in/content/images/wordpress/2016/09/6-Add-directory-to-git.png 779w, https://ghostcode.in/content/images/wordpress/2016/09/6-Add-directory-to-git-300x270.png 300w, https://ghostcode.in/content/images/wordpress/2016/09/6-Add-directory-to-git-768x690.png 768w" sizes="(max-width: 437px) 100vw, 437px"></p></li>
<li>Right click on your project and select Git -&gt; Commit Directory&#x2026; On committing, the files in the Project pane will return to their original color (black).
<p><img loading="lazy" class="aligncenter wp-image-48608" src="https://ghostcode.in/wp-content/uploads/2016/09/7-Commit-directory.png" width="440" height="413" srcset="https://ghostcode.in/content/images/wordpress/2016/09/7-Commit-directory.png 717w, https://ghostcode.in/content/images/wordpress/2016/09/7-Commit-directory-300x282.png 300w" sizes="(max-width: 440px) 100vw, 440px"></p></li>
<li>Add a commit message.&#xA0;Click on Commit and select Commit&#x2026;
<p><img loading="lazy" class="aligncenter size-full wp-image-48610" src="https://ghostcode.in/wp-content/uploads/2016/09/9-Commit.png" alt width="780" height="658" srcset="https://ghostcode.in/content/images/wordpress/2016/09/9-Commit.png 780w, https://ghostcode.in/content/images/wordpress/2016/09/9-Commit-300x253.png 300w, https://ghostcode.in/content/images/wordpress/2016/09/9-Commit-768x648.png 768w" sizes="(max-width: 780px) 100vw, 780px"></p></li>
<li>Confirm the commit. You can also review the warnings and errors if any and correct them before committing the git repo.
<p><img loading="lazy" class="aligncenter size-full wp-image-48611" src="https://ghostcode.in/wp-content/uploads/2016/09/10-Confirm-Commit-or-Review-warnings.png" alt width="706" height="576" srcset="https://ghostcode.in/content/images/wordpress/2016/09/10-Confirm-Commit-or-Review-warnings.png 706w, https://ghostcode.in/content/images/wordpress/2016/09/10-Confirm-Commit-or-Review-warnings-300x245.png 300w" sizes="(max-width: 706px) 100vw, 706px"></p></li>
<li>On committing your project, right click on it. Select Git -&gt;Repository-&gt;Push&#x2026; This is to push the local git repository to Github.
<p><img loading="lazy" class="aligncenter size-full wp-image-48612" src="https://ghostcode.in/wp-content/uploads/2016/09/11-Push.png" alt width="947" height="671" srcset="https://ghostcode.in/content/images/wordpress/2016/09/11-Push.png 947w, https://ghostcode.in/content/images/wordpress/2016/09/11-Push-300x213.png 300w, https://ghostcode.in/content/images/wordpress/2016/09/11-Push-768x544.png 768w" sizes="(max-width: 947px) 100vw, 947px"></p></li>
<li>In the new popup, select <span style="text-decoration: underline;">Define remote</span>. A window will popup asking for the Name and URL&#xA0;to the github repository. Paste the url of the git repository that you had copied in Step 3:&#xA0;<a href="https://github.com/TheCoffee/alertdialogs.git">https://github.com/TheCoffee/alertdialogs.git</a>
<p><img loading="lazy" class="aligncenter size-full wp-image-48613" src="https://ghostcode.in/wp-content/uploads/2016/09/12-Define-remote.png" alt width="593" height="554" srcset="https://ghostcode.in/content/images/wordpress/2016/09/12-Define-remote.png 593w, https://ghostcode.in/content/images/wordpress/2016/09/12-Define-remote-300x280.png 300w" sizes="(max-width: 593px) 100vw, 593px"></p></li>
<li>On clicking OK, the git repo will be verified and you will now be connected to the <span style="text-decoration: underline;">master</span> branch. You can choose to push your repo to any other branch of your repo by selecting <span style="text-decoration: underline;">master</span> and changing it&#xA0;here.
<p><img loading="lazy" class="aligncenter size-full wp-image-48614" src="https://ghostcode.in/wp-content/uploads/2016/09/13-Push-to-master-branch.png" alt width="593" height="554" srcset="https://ghostcode.in/content/images/wordpress/2016/09/13-Push-to-master-branch.png 593w, https://ghostcode.in/content/images/wordpress/2016/09/13-Push-to-master-branch-300x280.png 300w" sizes="(max-width: 593px) 100vw, 593px"></p></li>
<li>Push the repository to Github. You will get the following message on successful push. If the push fails, check that the github repo is empty. If not (if there is a README.md file), then right clicking on your project directory, choose Git-&gt;Repository-&gt;Pull. Then, repeat the process from Step 10.
<p><img loading="lazy" class="aligncenter size-full wp-image-48600" src="https://ghostcode.in/wp-content/uploads/2017/12/14-Success.png" alt width="304" height="64" srcset="https://ghostcode.in/content/images/wordpress/2017/12/14-Success.png 304w, https://ghostcode.in/content/images/wordpress/2017/12/14-Success-300x63.png 300w" sizes="(max-width: 304px) 100vw, 304px"></p></li>
<li>Now you can view your repository in your Github account. you will also be able to see the Commit message that you specified.
<p><img loading="lazy" class="aligncenter size-full wp-image-48615" src="https://ghostcode.in/wp-content/uploads/2016/09/15-View-at-github.png" alt width="1279" height="730" srcset="https://ghostcode.in/content/images/wordpress/2016/09/15-View-at-github.png 1279w, https://ghostcode.in/content/images/wordpress/2016/09/15-View-at-github-300x171.png 300w, https://ghostcode.in/content/images/wordpress/2016/09/15-View-at-github-768x438.png 768w, https://ghostcode.in/content/images/wordpress/2016/09/15-View-at-github-1024x584.png 1024w" sizes="(max-width: 1279px) 100vw, 1279px"></p></li>
</ol>
<p>So now, you have a version control system in place for your project. With this system, keep track of the changes in your project. This system makes it easy to collaborate with others so that review your code and assist in the development process.</p>
<!--kg-card-end: html-->]]></content:encoded></item><item><title><![CDATA[App Rating popup: Creating a Rate My App Alert Dialog]]></title><description><![CDATA[<!--kg-card-begin: html--><p>We have already seen the Alert Dialog used to give the users a warning in a simple dialog and for the About and Feedback Dialog. This article illustrates the use of the AlertDialog for requesting the user to rate your app.</p>
<p><img loading="lazy" class="aligncenter  wp-image-48573" src="https://ghostcode.in/wp-content/uploads/2016/11/rate-app-dialog@GhostCode.png" alt width="256" height="455" srcset="https://ghostcode.in/content/images/wordpress/2016/11/rate-app-dialog@GhostCode.png 720w, https://ghostcode.in/content/images/wordpress/2016/11/rate-app-dialog@GhostCode-169x300.png 169w, https://ghostcode.in/content/images/wordpress/2016/11/rate-app-dialog@GhostCode-576x1024.png 576w" sizes="(max-width: 256px) 100vw, 256px"></p>
<p>The RateAppUtil keeps track of the number of times</p>]]></description><link>https://ghostcode.in/app-rating-popup-creating-a-rate-my-app-alert-dialog/</link><guid isPermaLink="false">639afa5b1e4dab02af8ed02d</guid><category><![CDATA[basics]]></category><dc:creator><![CDATA[Gaurav]]></dc:creator><pubDate>Sat, 03 Dec 2016 21:32:42 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: html--><p>We have already seen the Alert Dialog used to give the users a warning in a simple dialog and for the About and Feedback Dialog. This article illustrates the use of the AlertDialog for requesting the user to rate your app.</p>
<p><img loading="lazy" class="aligncenter  wp-image-48573" src="https://ghostcode.in/wp-content/uploads/2016/11/rate-app-dialog@GhostCode.png" alt width="256" height="455" srcset="https://ghostcode.in/content/images/wordpress/2016/11/rate-app-dialog@GhostCode.png 720w, https://ghostcode.in/content/images/wordpress/2016/11/rate-app-dialog@GhostCode-169x300.png 169w, https://ghostcode.in/content/images/wordpress/2016/11/rate-app-dialog@GhostCode-576x1024.png 576w" sizes="(max-width: 256px) 100vw, 256px"></p>
<p>The RateAppUtil keeps track of the number of times the app has been opened and the number of days since the app has been opened and then accordingly shows the Rate App AlertDialog.</p>
<p>Have a look at the code that has been use to achieve this.</p>
<p>Final Code:</p>
<pre class="brush: java; title: RateAppUtil.java; notranslate" title="RateAppUtil.java">
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.support.v7.app.AlertDialog;

public class RateAppUtil {
    private final static String APP_TITLE = &quot;MechByte&quot;;

    // Package name of the app as uploaded in the play store
    private final static String APP_NAME = &quot;com.coffee.mechanicalbyte&quot;;

    // No of days until the app rater is shown
    private final static int DAYS_UNTIL_PROMPT = 2;
    // No of app launches until the app rater is shown
    private final static int LAUNCHES_UNTIL_PROMPT = 4;

    private Context mContext;

    public RateAppUtil(Context context) {
        mContext = context;
    }

    public void appLaunched() {
        SharedPreferences prefs = mContext.getSharedPreferences(&quot;appRater&quot;, 0);
        if (prefs.getBoolean(&quot;dontShowAgain&quot;, false)) {
            return;
        }

        SharedPreferences.Editor editor = prefs.edit();

        // Increment launch counter
        long launchCount = prefs.getLong(&quot;launchCount&quot;, 0) + 1;
        editor.putLong(&quot;launchCount&quot;, launchCount);

        // Get date of first launch
        Long dateFirstlaunch = prefs.getLong(&quot;dateFirstLaunch&quot;, 0);
        if (dateFirstlaunch == 0) {
            dateFirstlaunch = System.currentTimeMillis();
            editor.putLong(&quot;dateFirstLaunch&quot;, dateFirstlaunch);
        }

        // Wait at least n days before opening
        if (launchCount &gt;= LAUNCHES_UNTIL_PROMPT &amp;&amp; 
                System.currentTimeMillis() &gt;= dateFirstlaunch + (DAYS_UNTIL_PROMPT * 24 * 60 * 60 * 1000)) {
            showRateDialog(editor);
        }
        editor.apply();
    }

    public void showRateDialog(final SharedPreferences.Editor editor) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle(&quot;Rate &quot; + APP_TITLE);
        builder.setMessage(&quot;If you enjoy using &quot; + APP_TITLE + &quot;, please take a moment to rate it. Thanks for your support!&quot;);
        builder.setPositiveButton(&quot;No&quot;, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                editor.putBoolean(&quot;dontShowAgain&quot;, true);
                editor.apply();
                dialogInterface.dismiss();
            }
        });

        builder.setNegativeButton(&quot;Remind me later&quot;, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                // Reset days and app launch count
                editor.putLong(&quot;launchCount&quot;, 0);
                editor.putLong(&quot;dateFirstLaunch&quot;, 0);
                editor.apply();
                dialogInterface.dismiss();
            }
        });

        builder.setNeutralButton(&quot;OK&quot;, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                mContext.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(&quot;market://details?id=&quot; + APP_NAME)));
                editor.putBoolean(&quot;dontShowAgain&quot;, true);
                editor.apply();
            }
        });
        builder.show();
    }
}
</pre>
<p>We have to call the appLaunched() method in the MainActivity in the onCreate() method so that it can perform the launch count check every time the app is launched.</p>
<pre class="brush: java; title: ; notranslate" title>
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private RateAppUtil mRateAppUtil;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mRateAppUtil = new RateAppUtil(this);
        mRateAppUtil.appLaunched();
    }
}
</pre>
<p>Access the code for the Rate App in the Alert Dialogs demo at <a href="https://github.com/TheCoffee/alertdialogs/">Github</a>.</p>
<!--kg-card-end: html-->]]></content:encoded></item></channel></rss>