<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
>

<channel>
	<title>Classic Tutorials</title>
	<atom:link href="https://classictutorials.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://classictutorials.com</link>
	<description>Joy of daily hacks</description>
	<lastBuildDate>
	Sat, 26 May 2018 15:07:32 +0000	</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.1</generator>

<image>
	<url>https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2014/12/favicon1.png?fit=32%2C32&#038;ssl=1</url>
	<title>Classic Tutorials</title>
	<link>https://classictutorials.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">146978875</site>	<item>
		<title>How to choose between Native vs React Native vs HTML5 Hybrid</title>
		<link>https://classictutorials.com/2017/07/how-to-choose-between-native-vs-react-native-vs-html5-hybrid/</link>
				<comments>https://classictutorials.com/2017/07/how-to-choose-between-native-vs-react-native-vs-html5-hybrid/#respond</comments>
				<pubDate>Sat, 29 Jul 2017 03:17:47 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[ReactNative]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[reactnative]]></category>
		<category><![CDATA[showcase]]></category>

		<guid isPermaLink="false">https://classictutorials.com/?p=2045</guid>
				<description><![CDATA[The favourite question of 2017 for the developer world i guess 🙂 I have been asked this at least once on every project i have&#8230;]]></description>
								<content:encoded><![CDATA[<p>The favourite question of 2017 for the developer world i guess <img src="https://s.w.org/images/core/emoji/11.2.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p>I have been asked this at least once on every project i have worked on and so for the last time, i will create this and forward this url who ever asks, ha ha.. Feel free to add your view in comments. Cheers!</p>
<p><strong>I will take a use case here since based on the app you build your need will be different. If you want to build spotify this is not your matrix ;0</strong></p>
<p><strong>Use Case:</strong> Building a service or utility app, cross platform with support for low end devices, targeted for country like India and Indonesia. User experience is important for the app as well as cost of building and maintaining. Client probably don&#8217;t have a development team and reached out to you for a solution.</p>
<p>You can find the matrix here:</p>
<p><a href="https://github.com/kaushikdas0/native-react-native-cordova">https://github.com/kaushikdas0/native-react-native-cordova</a></p>
<p>The funny part ( * totally unintended and coincidental * ) if you sum up the points you will find that RN and HTML5 hybrid app scores the same, but then i would suggest choosing RN in that case because your overall app will be a better performing app when compared to the Hybrid app.</p>
<p>&nbsp;</p>
<p>You can use the same matrix for any other use case. Just revalidate the points to support your use case. Until next time. Cheers!</p>
<p>&nbsp;</p>
]]></content:encoded>
							<wfw:commentRss>https://classictutorials.com/2017/07/how-to-choose-between-native-vs-react-native-vs-html5-hybrid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
						<post-id xmlns="com-wordpress:feed-additions:1">2045</post-id>	</item>
		<item>
		<title>Social Authentication with Firebase on React Native</title>
		<link>https://classictutorials.com/2017/01/social-authentication-with-firebase-on-react-native-android/</link>
				<pubDate>Tue, 31 Jan 2017 15:16:50 +0000</pubDate>
		<dc:creator><![CDATA[Admin]]></dc:creator>
				<category><![CDATA[ReactNative]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[firebase]]></category>
		<category><![CDATA[hybrid_app]]></category>
		<category><![CDATA[reactnative]]></category>

		<guid isPermaLink="false">https://classictutorials.com/?p=2029</guid>
				<description><![CDATA[Objective: An android app where i can login using Facebook and connect the login information with Firebase Authentication. Step 1: Create and Run a basic React Native&#8230;]]></description>
								<content:encoded><![CDATA[<p class="p1"><span class="s1"><strong>Objective:</strong></span></p>
<p class="p1"><span class="s1">An android app where i can login using <strong>Facebook </strong></span><span class="s1">and connect the login information with <strong>Firebase Authentication</strong>.</span></p>
<p class="p2"><strong>Step 1: Create and Run a basic React Native app.</strong></p>
<p class="p3"><span class="s2">(You can just follow this for Step 1: <a href="https://facebook.github.io/react-native/docs/getting-started.html#content"><span class="s3">https://facebook.github.io/react-native/docs/getting-started.html#content</span></a> )</span></p>
<p class="p1"><span class="s1">Navigate to any folder where you want to create the project and use react native init.</span></p>
<p class="p2"><span class="s1"><a href="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_1.png?ssl=1"><img src="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_1.png?resize=639%2C122&#038;ssl=1" width="639" height="122" class="alignnone wp-image-2015 size-full" srcset="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_1.png?w=639&amp;ssl=1 639w, https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_1.png?resize=300%2C57&amp;ssl=1 300w" sizes="(max-width: 639px) 100vw, 639px" data-recalc-dims="1" /></a></span></p>
<p class="p2"><a href="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_2.png?ssl=1"><img src="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_2.png?resize=819%2C270&#038;ssl=1" width="819" height="270" class="alignnone wp-image-2016 size-full" srcset="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_2.png?w=907&amp;ssl=1 907w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_2.png?resize=300%2C99&amp;ssl=1 300w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_2.png?resize=768%2C253&amp;ssl=1 768w" sizes="(max-width: 819px) 100vw, 819px" data-recalc-dims="1" /></a></p>
<p class="p2"><span class="s1">Yarn ye! No world didnt changed for me… yet!!</span></p>
<p class="p1"><span class="s1">For this tutorial we will focus on <strong>Android</strong>, but iOS is kind of similar.</span></p>
<p class="p1"><span class="s1">cd to project folder and</span></p>
<p></p><pre class="crayon-plain-tag">╰─$ react-native run-android</pre><p></p>
<p class="p2"><a href="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_3.png?ssl=1"><img src="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_3.png?resize=341%2C608&#038;ssl=1" width="341" height="608" class="alignnone wp-image-2017 size-full" srcset="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_3.png?w=341&amp;ssl=1 341w, https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_3.png?resize=168%2C300&amp;ssl=1 168w" sizes="(max-width: 341px) 100vw, 341px" data-recalc-dims="1" /></a></p>
<p class="p2"><span class="s1"><strong>Step 2: Creating a less ugly screen</strong></span></p>
<p class="p1"><strong><span class="s1">index.android.js</span></strong></p>
<p></p><pre class="crayon-plain-tag"> &lt;View style={styles.container}&gt;

        &lt;View style={styles.top}&gt;

          &lt;Text style={styles.textheader}&gt;

            Social Login

          &lt;/Text&gt;

        &lt;/View&gt;

        &lt;View style={styles.bottom}&gt;

            &lt;Text&gt; Button will come here &lt;/Text&gt;

        &lt;/View&gt;

      &lt;/View&gt;

//Styling:

const styles = StyleSheet.create({

  container: {

    flex: 1,

    backgroundColor: '#1C2833',

 

    alignItems: 'center',

    flexDirection:'column',

    justifyContent: 'center', 

  },

  top:{

    flex:1,

    justifyContent: 'center', 

  },

  bottom:{

    flex:1,

  },

  textheader:{

    color:'white',

    fontSize: 50

  }

});</pre><p></p>
<p class="p1"><span class="s1"><strong>Step 3: Facebook SDK</strong></span></p>
<p class="p1"><span class="s1">Execute following on your project folder, we will use official fb repo:</span></p>
<p></p><pre class="crayon-plain-tag">react-native install react-native-fbsdk</pre><p></p><pre class="crayon-plain-tag">react-native link react-native-fbsdk</pre><p>Should take sometime based on n/w speed.</p>
<p class="p5"><strong><em><span class="s1">Assume you have Android Studio, else highly suggest you install it now.</span></em></strong></p>
<p class="p5"><em><span class="s1"> Open the Android folder as android project in Android Studio. I will be using Android studio 2.2</span></em></p>
<p class="p4"><span class="s1">In <strong>MainApplication.java</strong> add an instance of CallbackManager with getter; CallbackManager manages the callback to FB SDK.</span></p>
<p class="p5"><span class="s1"> </span></p>
<p></p><pre class="crayon-plain-tag">private static CallbackManager mCallbackManager = CallbackManager.Factory.create();

protected static CallbackManager getCallbackManager() {
  return mCallbackManager;
}</pre><p><span class="s1">than under getPackages pass the newly created callback manager to FBSDK package.</span></p><pre class="crayon-plain-tag">@Override
protected List&lt;ReactPackage&gt; getPackages() {
    return Arrays.&lt;ReactPackage&gt;asList(
        new MainReactPackage(),
          new FirestackPackage(),
          new FBSDKPackage(mCallbackManager)
    );
}
};</pre><p><span class="s1">In <strong>MainActivity.java </strong>make sure you already have the following method. The SDK react link should have created this.</span></p><pre class="crayon-plain-tag">import android.content.Intent;</pre><p></p><pre class="crayon-plain-tag">@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
MainApplication.getCallbackManager().onActivityResult(requestCode, resultCode, data);
}</pre><p></p>
<p class="p4"><span class="s1">Now we will create an FB app which will handle our login flow.</span></p>
<p class="p7"><span class="s2">Navigate to <a href="https://developers.facebook.com/quickstarts/?platform=android">https://developers.facebook.com/quickstarts/?platform=android</a> </span><span class="s2">and follow the onscreen instruction.</span></p>
<p class="p5"><a href="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_4.png?ssl=1"><img src="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_4.png?resize=819%2C485&#038;ssl=1" alt="" width="819" height="485" class="alignnone size-full wp-image-2018" srcset="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_4.png?w=919&amp;ssl=1 919w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_4.png?resize=300%2C178&amp;ssl=1 300w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_4.png?resize=768%2C455&amp;ssl=1 768w" sizes="(max-width: 819px) 100vw, 819px" data-recalc-dims="1" /></a></p>
<p class="p5"><span class="s1">You can either do the remaining few steps from FB or just read below instructions. Both are kind of same.</span></p>
<p class="p4"><span class="s1">in <strong>android/build.gradle </strong>add </span></p>
<p></p><pre class="crayon-plain-tag">mavenCentral()</pre><p>So it should look like this.</p><pre class="crayon-plain-tag">allprojects {
    repositories {
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
        mavenCentral()
    }
}</pre><p><span>in </span><strong>android/app/build.gradle </strong><span>add the following for Facebook SDK </span></p><pre class="crayon-plain-tag">compile 'com.facebook.android:facebook-android-sdk:[4,5)'</pre><p></p>
<p class="p5"><span>So it should look like,</span></p>
<p></p><pre class="crayon-plain-tag">dependencies {
    compile project(':react-native-firestack')
    compile project(':react-native-fbsdk')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+"  // From node_modules
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}</pre><p><span>Now sync your Gradle files on Android Studio.</span></p>
<p class="p5"><span class="s1">Now open <strong>String.xml </strong>and add<strong> facebook_app_id. </strong>You can find the id from facebook page.</span></p>
<p class="p5"><span class="s1"><strong>app/res/values/String.xml </strong></span></p>
<p></p><pre class="crayon-plain-tag">&lt;resources&gt;
    &lt;string name="app_name"&gt;SocialLoginApp&lt;/string&gt;
    &lt;string name="facebook_app_id"&gt;%%%%6071338448%%&lt;/string&gt;
&lt;/resources&gt;</pre><p><span class="s1">Open <strong>AndroidManifest.xml</strong> and add a meta-data element to the application element:</span></p><pre class="crayon-plain-tag">&lt;meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/&gt;</pre><p><span>Should look something like this.</span></p><pre class="crayon-plain-tag">&lt;/activity&gt;
  &lt;activity android:name="com.facebook.react.devsupport.DevSettingsActivity" /&gt;
  &lt;meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/&gt;
&lt;/application&gt;</pre><p><span>Then update the android project info on FB console.</span></p>
<p class="p8"><a href="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_5.png?ssl=1"><img src="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_5.png?resize=819%2C312&#038;ssl=1" alt="" width="819" height="312" class="alignnone size-full wp-image-2019" srcset="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_5.png?w=982&amp;ssl=1 982w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_5.png?resize=300%2C114&amp;ssl=1 300w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_5.png?resize=768%2C292&amp;ssl=1 768w" sizes="(max-width: 819px) 100vw, 819px" data-recalc-dims="1" /></a></p>
<p class="p8"><span class="s1">Click next, it will ask for hash key, on your terminal execute this:</span></p>
<p></p><pre class="crayon-plain-tag">keytool -exportcert -alias YOUR_RELEASE_KEY_ALIAS -keystore YOUR_RELEASE_KEY_PATH | openssl sha1 -binary | openssl base64</pre><p></p>
<p class="p8"><span class="s1">You can close the Android studio now. Moving to react project:</span></p>
<p class="p8"><span class="s1">Now open <strong>index.android.js</strong></span></p>
<p class="p6"><span class="s1">Add the following to import FB SDK.</span></p>
<p></p><pre class="crayon-plain-tag">const FBSDK = require('react-native-fbsdk');

const {

  LoginButton,

  AccessToken

} = FBSDK;</pre><p></p>
<p class="p6"><span>and then replace “ <strong>Button will come here</strong> ” text component section with the following code.</span></p>
<p></p><pre class="crayon-plain-tag">&lt;LoginButton

              onLoginFinished={

              (error, result) =&gt; {

              if (error) {

                console.log("login has error: " + result.error);

              } else if (result.isCancelled) {

                console.log("login is cancelled.");

              } else {

                AccessToken.getCurrentAccessToken().then(

                  (data) =&gt; {

                    console.log(data);

                  }

                )

              }

            }

          }

          onLogoutFinished={() =&gt; console.log("logout.")}/&gt;</pre><p>Think the code is pretty self explanatory</p>
<p class="p4"><span class="s1"><span>Stop the React project and re run it again to load all libs etc.</span></span></p>
<p class="p5"><span class="s1">Click on the button and make sure its log-in in and showing you the logout button. If thats working all set. (Alternatively check the chrome console for the console log of data)</span></p>
<p class="p5"><a href="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_6.png?ssl=1"><img src="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_6.png?resize=342%2C609&#038;ssl=1" alt="" width="342" height="609" class="alignnone size-full wp-image-2020" srcset="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_6.png?w=342&amp;ssl=1 342w, https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_6.png?resize=168%2C300&amp;ssl=1 168w" sizes="(max-width: 342px) 100vw, 342px" data-recalc-dims="1" /></a></p>
<p class="p5"><span class="s1"><strong>Step 4: Firebase integration</strong></span></p>
<p class="p5"><span class="s1">For firebase integration we will use Firestack.</span></p>
<p class="p5"><span class="s1">Within the main react project folder run the following&gt;</span></p>
<p></p><pre class="crayon-plain-tag">npm install react-native-firestack --save</pre><p>followed by</p><pre class="crayon-plain-tag">react-native link react-native-firestack</pre><p></p>
<p class="p5"><span class="s1">Now keep your android studio open while navigate to <a href="https://console.firebase.google.com/">https://console.firebase.google.com/</a> </span></p>
<p class="p5"><a href="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_7.png?ssl=1"><img src="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_7.png?resize=455%2C469&#038;ssl=1" alt="" width="455" height="469" class="alignnone size-full wp-image-2021" srcset="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_7.png?w=455&amp;ssl=1 455w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_7.png?resize=291%2C300&amp;ssl=1 291w" sizes="(max-width: 455px) 100vw, 455px" data-recalc-dims="1" /></a></p>
<p class="p5"><span class="s1">Click ADD APP and download the <strong>google-service.json</strong></span></p>
<p class="p5"><span class="s1">Now in Firebase under Authentication enable Facebook. All FB related info like app id and secret key you will get it from FB console from the app previously created.</span></p>
<p class="p5"><a href="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_8.png?ssl=1"><img src="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_8.png?resize=819%2C404&#038;ssl=1" alt="" width="819" height="404" class="alignnone size-full wp-image-2022" srcset="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_8.png?w=979&amp;ssl=1 979w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_8.png?resize=300%2C148&amp;ssl=1 300w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_8.png?resize=768%2C379&amp;ssl=1 768w" sizes="(max-width: 819px) 100vw, 819px" data-recalc-dims="1" /></a></p>
<p class="p5"><span class="s1">Add the JSON file under the main project. </span></p>
<p class="p4"><span class="s1">Under <strong>React Project/android/app</strong></span></p>
<p class="p4"><span class="s1">You can see it on android project.</span></p>
<p class="p5"><a href="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_9.png?ssl=1"><img src="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_9.png?resize=285%2C299&#038;ssl=1" alt="" width="285" height="299" class="alignnone size-full wp-image-2023" data-recalc-dims="1" /></a></p>
<p class="p5"><span class="s1">Now under <strong>android/build.gradle</strong></span></p>
<p class="p4"><span class="s1">under dependency add this.</span></p>
<p></p><pre class="crayon-plain-tag">classpath 'com.google.gms:google-services:3.0.0'</pre><p><span class="s1">and under <strong>android/app/build.gradle</strong></span></p>
<p class="p4"><span class="s1">add the following at the extreme end of the file.</span></p>
<p></p><pre class="crayon-plain-tag">apply plugin: 'com.google.gms.google-services'</pre><p><span class="s1">Try a project clean on android studio (Build&gt;Project Clean)to make sure everything is in right order.</span></p>
<p class="p5"><span class="s1">Cool done with Android Studio. Moving to <strong>React project</strong> now.</span></p>
<p class="p5"><span class="s1">add the import;</span></p>
<p></p><pre class="crayon-plain-tag">import Firestack from 'react-native-firestack';</pre><p></p>
<p class="p6">and add the initializations just after that:</p>
<p></p><pre class="crayon-plain-tag">const firestack = new Firestack();</pre><p></p>
<p class="p5"><span class="s1">Now where we received the access token from facebook we will pass the access token to Firebase.</span></p>
<p class="p4"><span class="s1">So under</span></p>
<p></p><pre class="crayon-plain-tag">AccessToken.getCurrentAccessToken().then(

                  (data) =&gt; {</pre><p></p>
<p class="p4"><span class="s1"> add the following:</span></p>
<p></p><pre class="crayon-plain-tag">firestack.auth.signInWithProvider('facebook', data.accessToken, '') // facebook will need only access token. 

 .then((user)=&gt;{

 console.log("Inside ");

 console.log(user); 

 })</pre><p></p>
<p class="p5"><span class="s1">Thats it. Run the app.  Note that Android requires the Google Play services to installed for authentication to function. So you may want to try running on a real device or configure simulator for Google Play service</span></p>
<p class="p5"><a href="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_10.png?ssl=1"><img src="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_10.png?resize=819%2C271&#038;ssl=1" alt="" width="819" height="271" class="alignnone size-full wp-image-2024" srcset="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_10.png?w=1326&amp;ssl=1 1326w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_10.png?resize=300%2C99&amp;ssl=1 300w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_10.png?resize=768%2C254&amp;ssl=1 768w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2017/01/React_native_post_10.png?resize=1024%2C339&amp;ssl=1 1024w" sizes="(max-width: 819px) 100vw, 819px" data-recalc-dims="1" /></a></p>
<p class="p4"><span class="s1">For your reference here is my final <strong>index.android.js</strong> file.</span></p>
<p></p><pre class="crayon-plain-tag">/**

 * Sample React Native App

 * https://github.com/facebook/react-native

 * @flow

 */

 

import React, { Component } from 'react';

import {

  AppRegistry,

  StyleSheet,

  Text,

  View

} from 'react-native';

 

const FBSDK = require('react-native-fbsdk');

const {

  LoginButton,

  AccessToken

} = FBSDK;

 

import Firestack from 'react-native-firestack'; 

 

const firestack = new Firestack();

 

export default class SocialLoginApp extends Component {

  render() {

    return (

      &lt;View style={styles.container}&gt;

        &lt;View style={styles.top}&gt;

          &lt;Text style={styles.textheader}&gt;

            Social Login

          &lt;/Text&gt;

        &lt;/View&gt;

        &lt;View style={styles.bottom}&gt;

            &lt;LoginButton

              onLoginFinished={

              (error, result) =&gt; {

              if (error) {

                console.log("login has error: " + result.error);

              } else if (result.isCancelled) {

                console.log("login is cancelled.");

              } else {

                AccessToken.getCurrentAccessToken().then(

                  (data) =&gt; {

                    firestack.auth.signInWithProvider('facebook', data.accessToken, '') 

                          .then((user)=&gt;{

                            console.log("Inside ");

                            console.log(user); 

                      }) 

                  }

                )

              }

            }

          }

          onLogoutFinished={() =&gt; console.log("logout.")}/&gt;

        &lt;/View&gt;

      &lt;/View&gt;

    );

  }

}

 

const styles = StyleSheet.create({

  container: {

    flex: 1,

    backgroundColor: '#1C2833',

 

    alignItems: 'center',

    flexDirection:'column',

    justifyContent: 'center', 

  },

  top:{

    flex:1,

    justifyContent: 'center', 

  },

  bottom:{

    flex:1,

  },

  textheader:{

    color:'white',

    fontSize: 50

  }

});

 

AppRegistry.registerComponent('SocialLoginApp', () =&gt; SocialLoginApp);</pre><p>Publishing to git hub if you need?</p>
]]></content:encoded>
									<post-id xmlns="com-wordpress:feed-additions:1">2029</post-id>	</item>
		<item>
		<title>Designing a Conversational Intelligent Bot which can cook</title>
		<link>https://classictutorials.com/2016/12/designing-a-conversational-intelligent-bot-which-can-cook/</link>
				<pubDate>Mon, 12 Dec 2016 06:17:54 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Bot]]></category>
		<category><![CDATA[ai]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[presentation]]></category>
		<category><![CDATA[showcase]]></category>
		<category><![CDATA[slides]]></category>

		<guid isPermaLink="false">https://classictutorials.com/?p=1987</guid>
				<description><![CDATA[Solving a real life problem with bot. Introducing Samantha, a bot who can cook for you 😉 A fun practical presentation to create a bot&#8230;]]></description>
								<content:encoded><![CDATA[<p>Solving a real life problem with bot. Introducing Samantha, a bot who can cook for you <img src="https://s.w.org/images/core/emoji/11.2.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
A fun practical presentation to create a bot which integrates with sophisticated services.</p>
<p><iframe allowfullscreen="true" allowtransparency="true" frameborder="0" height="642" id="talk_frame_372345" mozallowfullscreen="true" src="//speakerdeck.com/player/4d85baea459f42c8acbce59c63237d55" style="border:0; padding:0; margin:0; background:transparent;" webkitallowfullscreen="true" width="819"></iframe></p>
<p>Demo of the final bot: <a href="https://www.youtube.com/watch?v=V_us1GSz4TI" rel="nofollow">https://www.youtube.com/watch?v=V_us1GSz4TI</a></p>
]]></content:encoded>
									<post-id xmlns="com-wordpress:feed-additions:1">1987</post-id>	</item>
		<item>
		<title>Play Pokemon Go at any place in the world &#124; IOS only</title>
		<link>https://classictutorials.com/2016/07/play-pokemon-go-at-any-place-in-the-world-ios-only/</link>
				<pubDate>Sun, 24 Jul 2016 10:11:27 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Tricks and Tips]]></category>
		<category><![CDATA[pokemon]]></category>

		<guid isPermaLink="false">http://classictutorials.com/?p=1886</guid>
				<description><![CDATA[Simple weekend trick. Check the video below where i tried playing in Central Park. People who already use xcode just fake your phone location with inbuilt location&#8230;]]></description>
								<content:encoded><![CDATA[<h2><span style="color: #ff0000"><strong></strong></span></h2>
<p>Simple weekend trick. Check the video below where i tried playing in <a href="https://www.google.com.sg/maps/place/Central+Park/@40.7828647,-73.9675438,17z/data=!3m1!4b1!4m5!3m4!1s0x89c2589a018531e3:0xb9df1f7387a94119!8m2!3d40.7828647!4d-73.9653551">Central Park</a>.</p>
<div class="jetpack-video-wrapper"><iframe class='youtube-player' type='text/html' width='819' height='461' src='https://www.youtube.com/embed/OntXJxAE3Q4?version=3&#038;rel=1&#038;fs=1&#038;autohide=2&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' allowfullscreen='true' style='border:0;'></iframe></div>
<p>People who already use xcode just fake your phone location with inbuilt location simulator , run a test project and you are done.</p>
<p><strong>For others this is what you need to do. 3 easy steps:</strong></p>
<ol>
<li>Download official Pokemon Go from any store you want. If you don&#8217;t know how to change store google for it.</li>
<li>Plug your iphone to your mac. You need to keep it connected to move around in virtual world.</li>
<li>Now download the git hub code from this repo: <a href="https://github.com/kaushikdas0/pok-mon_location_faker">https://github.com/kaushikdas0/pok-mon_location_faker</a>  (OR if you want create your own project and just use my GPX file.)</li>
<li>Find the place where you want to play pokemon in google map. Get the lat and long and put it on the GPX file. Run the default app once. Now switch to Pokemon Go. Now on the xcode just changing the GPX with new lat long will make you walk on Pokemon go.</li>
</ol>
<p>Ya thats it.</p>
<p>You can always disconnect the phone from mac or sometime restart the phone to remove fake locations</p>
<h2><span><strong>DO AT YOUR OWN RISK.  </strong></span></h2>
<h4><span><strong>THOUGH I DONT THINK ANYTHING WILL HAPPEN UNLESS YOU KEEP CHANGING COUNTRY. JUST SIMULATE ONE COUNTRY</strong></span></h4>
<h2><span style="color: #ff6600">One more warning. </span></h2>
<h2><span style="color: #ff6600">You know people are using several faker apps by side loading apps from various URL. Remember those can sniff your account info and other mobile information as they install certificate. Beware of such stuffs. This process is the most safe process you will ever have. This doesn&#8217;t do anything to the app. Just fakes location.</span></h2>
]]></content:encoded>
									<post-id xmlns="com-wordpress:feed-additions:1">1886</post-id>	</item>
		<item>
		<title>Raspberry Pi 3 (Rpi3) WIFI setting for OSMC (Headless)</title>
		<link>https://classictutorials.com/2016/06/connect-to-wifi-on-raspberry-pi-3-rpi31-with-osmc-headless/</link>
				<pubDate>Sat, 11 Jun 2016 13:42:30 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[IOT]]></category>
		<category><![CDATA[raspberrypi]]></category>

		<guid isPermaLink="false">http://classictutorials.com/?p=1868</guid>
				<description><![CDATA[So i got a Rpi3 and installed OSMC only to realize i dont have a physical remote to control it. I want to connect and&#8230;]]></description>
								<content:encoded><![CDATA[<p>So i got a Rpi3 and installed OSMC only to realize i dont have a physical remote to control it. I want to connect and control it but wirelessly (Since my LAN is not placed near by TV).</p>
<p>So this is how you can do it:</p>
<ol>
<li>Install OSMC from the steps provided on their website.</li>
<li>Connect the Rpi3 to WLAN directly.</li>
<li>This will give the Rpi3 a ip address. Find this ip address from your router</li>
<li>SSH to Rpi3 from mac/windows. Default id/password is osmc/osmc</li>
<li>Now since the Rpi3 has a wifi inbuilt all i need to do is connect the wifi. You can use the utility called <strong>connmanctl</strong> to do this. Follow the steps below.</li>
</ol>
<p>Type the following on terminal:</p><pre class="crayon-plain-tag"> $connmanctl</pre><p>Then type:</p><pre class="crayon-plain-tag">$technologies</pre><p>This should displays list of technologies. Something similar you will see:</p><pre class="crayon-plain-tag">/net/connman/technology/p2p
Name = P2P
Type = p2p
Powered = False
Connected = False
Tethering = False
/net/connman/technology/ethernet
Name = Wired
Type = ethernet
Powered = True
Connected = True
Tethering = False
/net/connman/technology/wifi
Name = WiFi
Type = wifi
Powered = True
Connected = True
Tethering = False</pre><p>This will show if the WIFI is enabled or now. Above shows Wifi enabled.<br />
If you want to enable wifi use this:</p><pre class="crayon-plain-tag">$enable wifi</pre><p>Now scan for available wifi</p><pre class="crayon-plain-tag">$scan wifi</pre><p>Then</p><pre class="crayon-plain-tag">$agent on</pre><p></p><pre class="crayon-plain-tag">$services</pre><p></p><pre class="crayon-plain-tag">$connect &lt;PSK from list displayed by the above command&gt;</pre><p>Now it will ask for Pass key, enter your wifi password.</p>
<p>Its a one time setup and in future it will remember this setting.</p>
<p>Enjoy!!</p>
]]></content:encoded>
									<post-id xmlns="com-wordpress:feed-additions:1">1868</post-id>	</item>
		<item>
		<title>An Arduino Project for Halloween &#8211; Scare the shit out</title>
		<link>https://classictutorials.com/2016/02/an-arduino-project-for-halloween-scare-the-shit-out/</link>
				<comments>https://classictutorials.com/2016/02/an-arduino-project-for-halloween-scare-the-shit-out/#respond</comments>
				<pubDate>Mon, 22 Feb 2016 13:08:13 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[IOT]]></category>
		<category><![CDATA[showcase]]></category>

		<guid isPermaLink="false">http://classictutorials.com/?p=1818</guid>
				<description><![CDATA[Best Halloween Arduino project you can ever make. This is really scary when placed in the right place and setup.]]></description>
								<content:encoded><![CDATA[<p>So last halloween (2015) we (<a href="https://twitter.com/thekaushik" target="_blank">@Me</a> + <a href="https://twitter.com/nikokin6" target="_blank">@Niko</a>) made this for our office Halloween party. We did some online research to find what can be really scary and figured out it cannot be one, but a combination of multiple thing will make this scary.</p>
<p><a href="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/ezgif.com-video-to-gif.gif?ssl=1"><img src="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/ezgif.com-video-to-gif.gif?resize=480%2C360&#038;ssl=1" alt="ezgif.com-video-to-gif" width="480" height="360" class="size-full wp-image-1826 aligncenter" data-recalc-dims="1" /></a></p>
<p><strong>So what does this do?</strong></p>
<ol>
<li>Detects someone coming nearby,</li>
<li>Turns it&#8217;s head towards the person coming,</li>
<li>Eyes glow</li>
<li>Screams!!!</li>
</ol>
<p><strong>Items needed for this build:</strong></p>
<p><em>Electronics Items:</em></p>
<ol>
<li>Arduino Uno R3 (Or raspberry pi, you can use the same concept but write your own code)</li>
<li>Diffused Red LED 10mm &#8211; <strong>2</strong> &#8211; <a href="http://www.sgbotic.com/index.php?dispatch=products.view&amp;product_id=1615" target="_blank">Link</a></li>
<li>Adafruit Wave Shield &#8211; 1</li>
<li>Resistors &#8211; 10k Ohm &#8211; Bundle</li>
<li>NPN Transistors &#8211; P2N2222A &#8211; 5</li>
<li>Breadboard, Wires, Power supply and regular stuffs.</li>
<li>Ultrasonic Module &#8211; 1 &#8211; <a href="http://www.sgbotic.com/index.php?dispatch=products.view&amp;product_id=1713" target="_blank">Link</a></li>
<li>Servo Medium Size Motor &#8211; 1 &#8211; <a href="http://www.sgbotic.com/index.php?dispatch=products.view&amp;product_id=856" target="_blank">Link</a></li>
</ol>
<p><em>Props:</em></p>
<ol>
<li>Halloween skull, better if made of soft plastic</li>
<li>Some black nets to get the feel.</li>
<li>Go crazy anything you want to add</li>
<li>A solid base where you can put the motor on which the skull will move.</li>
<li>A DIY cardboard base on which you can stick the skull to move.</li>
</ol>
<p>&nbsp;</p>
<p><strong>Steps:</strong></p>
<p><em>Step 1:</em></p>
<p>First thing, the Wave Shield needs to be assembled. Its going to take around 15min. Follow the soldering instruction in the manual.</p>
<p>This is how unassembled it came. Seriously WTF when i got the order without a clue that it has to be assembled.</p>
<p><a href="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0301.jpg?ssl=1" rel="attachment wp-att-1855"><img src="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0301.jpg?resize=300%2C225&#038;ssl=1" alt="IMG_0301" width="300" height="225" class="aligncenter wp-image-1855 size-medium" srcset="https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0301.jpg?resize=300%2C225&amp;ssl=1 300w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0301.jpg?resize=768%2C576&amp;ssl=1 768w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0301.jpg?resize=1024%2C768&amp;ssl=1 1024w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0301.jpg?w=1638&amp;ssl=1 1638w, https://i1.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0301.jpg?w=2457&amp;ssl=1 2457w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>And then after 15min mission accomplished.</p>
<p><a href="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0302.jpg?ssl=1" rel="attachment wp-att-1854"><img src="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0302.jpg?resize=300%2C225&#038;ssl=1" alt="IMG_0302" width="300" height="225" class="aligncenter wp-image-1854 size-medium" srcset="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0302.jpg?resize=300%2C225&amp;ssl=1 300w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0302.jpg?resize=768%2C576&amp;ssl=1 768w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0302.jpg?resize=1024%2C768&amp;ssl=1 1024w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0302.jpg?w=1638&amp;ssl=1 1638w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0302.jpg?w=2457&amp;ssl=1 2457w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<div class="jetpack-video-wrapper"><iframe class='youtube-player' type='text/html' width='819' height='461' src='https://www.youtube.com/embed/WH5BXQoOepM?version=3&#038;rel=1&#038;fs=1&#038;autohide=2&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' allowfullscreen='true' style='border:0;'></iframe></div>
<p>&nbsp;</p>
<p><em>Step 2:</em></p>
<p>Connect the ultra sound module and the motor now.</p>
<p>Once done you should test it working.</p>
<div class="jetpack-video-wrapper"><iframe class='youtube-player' type='text/html' width='819' height='461' src='https://www.youtube.com/embed/tUMr62nYFh8?version=3&#038;rel=1&#038;fs=1&#038;autohide=2&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' allowfullscreen='true' style='border:0;'></iframe></div>
<p>&nbsp;</p>
<p><em>Step 3: </em></p>
<p>Load the code</p><pre class="crayon-plain-tag">/*
 * This example plays every .WAV file it finds on the SD card in a loop
 */
#include &lt;WaveHC.h&gt;
#include &lt;WaveUtil.h&gt;

SdReader card;    // This object holds the information for the card
FatVolume vol;    // This holds the information for the partition on the card
FatReader root;   // This holds the information for the volumes root directory
WaveHC wave;      // This is the only wave (audio) object, since we will only play one at a time

uint8_t dirLevel; // indent level for file/dir names    (for prettyprinting)
dir_t dirBuf;     // buffer for directory reads

const int trigPin = 7;
const int echoPin = 8;

SoftwareServo myservo; 
/*
 * Define macro to put error messages in flash memory
 */
#define error(msg) error_P(PSTR(msg))

// Function definitions (we define them here, but the code is below)
void play(FatReader &amp;dir);

//////////////////////////////////// SETUP
void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps for debugging
  
  putstring_nl("\nWave test!");  // say we woke up!
  
  putstring("Free RAM: ");       // This can help with debugging, running out of RAM is bad
  Serial.println(FreeRam());

  //  if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you
  if (!card.init()) {         //play with 8 MHz spi (default faster!)  
    error("Card init. failed!");  // Something went wrong, lets print out why
  }
  
  // enable optimize read - some cards may timeout. Disable if you're having problems
  card.partialBlockRead(true);
  
  // Now we will look for a FAT partition!
  uint8_t part;
  for (part = 0; part &lt; 5; part++) {   // we have up to 5 slots to look in
    if (vol.init(card, part)) 
      break;                           // we found one, lets bail
  }
  if (part == 5) {                     // if we ended up not finding one  :(
    error("No valid FAT partition!");  // Something went wrong, lets print out why
  }
  
  // Lets tell the user about what we found
  putstring("Using partition ");
  Serial.print(part, DEC);
  putstring(", type is FAT");
  Serial.println(vol.fatType(), DEC);     // FAT16 or FAT32?
  
  // Try to open the root directory
  if (!root.openRoot(vol)) {
    error("Can't open root dir!");      // Something went wrong,
  }
  
  // Whew! We got past the tough parts.
  putstring_nl("Files found (* = fragmented):");

  // Print out all of the files in all the directories.
  root.ls(LS_R | LS_FLAG_FRAGMENTED);
}

//////////////////////////////////// LOOP
void loop() {
	Serial.print("Looping started ********************************************");
	  // establish variables for duration of the ping, 
  // and the distance result in inches and centimeters:
  long duration, inches, cm;

  // The sensor is triggered by a HIGH pulse of 10 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  pinMode(trigPin, OUTPUT);
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
	
	  // Read the signal from the sensor: a HIGH pulse whose
  // duration is the time (in microseconds) from the sending
  // of the ping to the reception of its echo off of an object.
  pinMode(echoPin, INPUT);
  duration = pulseIn(echoPin, HIGH);
Serial.print(duration);
  // convert the time into a distance
  inches = microsecondsToInches(duration);
  cm = microsecondsToCentimeters(duration);
  
    Serial.print(inches);
  Serial.print("in, ");
  Serial.print(cm);
  Serial.print("cm");
  Serial.println();
  
  
  if (cm &lt; 30 &amp;&amp; cm != 0)
  {

 Serial.print("Playing sound ###################################");
  root.rewind();
  play(root);
  }
  
  delay(100);
}

/////////////////////////////////// HELPERS
/*
 * print error message and halt
 */
void error_P(const char *str) {
  PgmPrint("Error: ");
  SerialPrint_P(str);
  sdErrorCheck();
  while(1);
}
/*
 * print error message and halt if SD I/O error, great for debugging!
 */
void sdErrorCheck(void) {
  if (!card.errorCode()) return;
  PgmPrint("\r\nSD I/O error: ");
  Serial.print(card.errorCode(), HEX);
  PgmPrint(", ");
  Serial.println(card.errorData(), HEX);
  while(1);
}
/*
 * play recursively - possible stack overflow if subdirectories too nested
 */
void play(FatReader &amp;dir) {
  FatReader file;
  while (dir.readDir(dirBuf) &gt; 0) {    // Read every file in the directory one at a time
  
    // Skip it if not a subdirectory and not a .WAV file
    if (!DIR_IS_SUBDIR(dirBuf)
         &amp;&amp; strncmp_P((char *)&amp;dirBuf.name[8], PSTR("WAV"), 3)) {
      continue;
    }

    Serial.println();            // clear out a new line
    
    for (uint8_t i = 0; i &lt; dirLevel; i++) {
       Serial.write(' ');       // this is for prettyprinting, put spaces in front
    }
    if (!file.open(vol, dirBuf)) {        // open the file in the directory
      error("file.open failed");          // something went wrong
    }
    
    if (file.isDir()) {                   // check if we opened a new directory
      putstring("Subdir: ");
      printEntryName(dirBuf);
      Serial.println();
      dirLevel += 2;                      // add more spaces
      // play files in subdirectory
      play(file);                         // recursive!
      dirLevel -= 2;    
    }
    else {
      // Aha! we found a file that isnt a directory
      putstring("Playing ");
      printEntryName(dirBuf);              // print it out
      if (!wave.create(file)) {            // Figure out, is it a WAV proper?
        putstring(" Not a valid WAV");     // ok skip it
      } else {
        Serial.println();                  // Hooray it IS a WAV proper!
        wave.play();                       // make some noise!
        
        uint8_t n = 0;
        while (wave.isplaying) {// playing occurs in interrupts, so we print dots in realtime
          putstring(".");
          if (!(++n % 32))Serial.println();
          delay(100);
        }       
        sdErrorCheck();                    // everything OK?
        // if (wave.errors)Serial.println(wave.errors);     // wave decoding errors
      }
    }
  }
}

long microsecondsToInches(long microseconds)
{
  // According to Parallax's datasheet for the PING))), there are
  // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  // second).  This gives the distance travelled by the ping, outbound
  // and return, so we divide by 2 to get the distance of the obstacle.
  // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds)
{
  // The speed of sound is 340 m/s or 29 microseconds per centimeter.
  // The ping travels out and back, so to find the distance of the
  // object we take half of the distance travelled.
  return microseconds / 29 / 2;
}</pre><p>Find it on Codebender here. <a href="https://codebender.cc/sketch:174116" target="_blank">https://codebender.cc/sketch:174116</a></p>
<p><em>Step 4:  </em></p>
<p>Assemble the LED and sound board together. Found some scary sound and add it to the sound board.</p>
<p>The final assembly should look something similar.</p>
<p><a href="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0314.jpg?ssl=1" rel="attachment wp-att-1856"><img src="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0314.jpg?resize=300%2C225&#038;ssl=1" alt="IMG_0314" width="300" height="225" class="aligncenter wp-image-1856 size-medium" srcset="https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0314.jpg?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0314.jpg?resize=768%2C576&amp;ssl=1 768w, https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0314.jpg?resize=1024%2C768&amp;ssl=1 1024w, https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0314.jpg?w=1638&amp;ssl=1 1638w, https://i0.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0314.jpg?w=2457&amp;ssl=1 2457w" sizes="(max-width: 300px) 100vw, 300px" data-recalc-dims="1" /></a></p>
<p>&nbsp;</p>
<p><em>Step 5:</em></p>
<p>With the electronics been set, you need to find out a way (DIY) to setup the skull. Insert the LEDs and make sure it has a base to rotate.</p>
<p>We literally tried various bottles and boxes to find the right base to make it work.</p>
<div class="jetpack-video-wrapper"><iframe class='youtube-player' type='text/html' width='819' height='461' src='https://www.youtube.com/embed/_2Tvf7LuxlM?version=3&#038;rel=1&#038;fs=1&#038;autohide=2&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' allowfullscreen='true' style='border:0;'></iframe></div>
<p>&nbsp;</p>
<p>And finally we succeed.</p>
<p>Here is how the final product looks like:</p>
<p><a href="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0322-copy.jpg?ssl=1" rel="attachment wp-att-1857"><img src="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0322-copy.jpg?resize=580%2C607&#038;ssl=1" alt="IMG_0322 copy" width="580" height="607" class="aligncenter wp-image-1857 size-large" srcset="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0322-copy.jpg?resize=978%2C1024&amp;ssl=1 978w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0322-copy.jpg?resize=286%2C300&amp;ssl=1 286w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0322-copy.jpg?resize=768%2C804&amp;ssl=1 768w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0322-copy.jpg?w=1638&amp;ssl=1 1638w, https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/IMG_0322-copy.jpg?w=2457&amp;ssl=1 2457w" sizes="(max-width: 580px) 100vw, 580px" data-recalc-dims="1" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
							<wfw:commentRss>https://classictutorials.com/2016/02/an-arduino-project-for-halloween-scare-the-shit-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
						<post-id xmlns="com-wordpress:feed-additions:1">1818</post-id>	</item>
		<item>
		<title>Horizontal Scrolling &#8211; Stack of cards &#8211; using Swift 2</title>
		<link>https://classictutorials.com/2016/02/card-like-horizontal-scrolling-using-swift-2/</link>
				<comments>https://classictutorials.com/2016/02/card-like-horizontal-scrolling-using-swift-2/#comments</comments>
				<pubDate>Fri, 12 Feb 2016 15:09:00 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[showcase]]></category>
		<category><![CDATA[swift]]></category>
		<category><![CDATA[swift2]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://classictutorials.com/?p=1806</guid>
				<description><![CDATA[So looks like cards like layout and horizontal scrolling is really getting some tractions and many apps have started using it. Offcourse there are several&#8230;]]></description>
								<content:encoded><![CDATA[<p>So looks like cards like layout and horizontal scrolling is really getting some tractions and many apps have started using it. Offcourse there are several ways to do it but i found a nifty easy trick to build this using UICollectionViewController with least amount of code.</p>
<p>Here is how it looks like.</p>
<p><a href="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/gify.gif?ssl=1" rel="attachment wp-att-1807"><img src="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/02/gify.gif?resize=385%2C673&#038;ssl=1" alt="gify" width="385" height="673" class="aligncenter wp-image-1807 size-full" data-recalc-dims="1" /></a></p>
<p>&nbsp;</p>
<p>Fancy right <img src="https://s.w.org/images/core/emoji/11.2.0/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /> But no clue about why i came up with &#8220;Swappy Dagger&#8221;</p>
<p>&nbsp;</p>
<p>Anyways the whole magic is in this secret sauce:</p><pre class="crayon-plain-tag">func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer&lt;CGPoint&gt;) {
        
        let pageWidth:Float = 310 + 25;
        
        let currentOffSet:Float = Float(scrollView.contentOffset.x)
        
        print(currentOffSet)
        let targetOffSet:Float = Float(targetContentOffset.memory.x)
        
        print(targetOffSet)
        var newTargetOffset:Float = 0
        
        if(targetOffSet &gt; currentOffSet){
            newTargetOffset = ceilf(currentOffSet / pageWidth) * pageWidth
        }else{
            newTargetOffset = floorf(currentOffSet / pageWidth) * pageWidth
        }
        
        if(newTargetOffset &lt; 0){
            newTargetOffset = 0;
        }else if (newTargetOffset &gt; Float(scrollView.contentSize.width)){
            newTargetOffset = Float(scrollView.contentSize.width)
        }
        
        targetContentOffset.memory.x = CGFloat(currentOffSet)
        scrollView.setContentOffset(CGPointMake(CGFloat(newTargetOffset), 0), animated: true)
        
    }</pre><p>Without that you won&#8217;t get the feel.</p>
<p>Anyways to get the code you can download it from my <a href="https://github.com/kaushikdas0/flat-cards-layout-ios" target="_blank">Git Repo</a>.  If this is useful spread the love by sharing.</p>
<p>Cheers!</p>
]]></content:encoded>
							<wfw:commentRss>https://classictutorials.com/2016/02/card-like-horizontal-scrolling-using-swift-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
						<post-id xmlns="com-wordpress:feed-additions:1">1806</post-id>	</item>
		<item>
		<title>Starter kit for NodeJS, Express with handlebarsjs</title>
		<link>https://classictutorials.com/2016/01/starter-pack-for-nodejs-express-with-handlebarsjs/</link>
				<comments>https://classictutorials.com/2016/01/starter-pack-for-nodejs-express-with-handlebarsjs/#comments</comments>
				<pubDate>Wed, 27 Jan 2016 03:07:37 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Node]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[handlebars]]></category>
		<category><![CDATA[kit]]></category>
		<category><![CDATA[node]]></category>

		<guid isPermaLink="false">http://classictutorials.com/?p=1773</guid>
				<description><![CDATA[So i have been using NodeJS and Handlebars for all my node projects and so here is my starter kit.]]></description>
								<content:encoded><![CDATA[<p>So i have been using NodeJS and Handlebars for all my node projects and so uploading a starter kit which can be handy.</p>
<p>Make sure Node, NPM and nodemon(optional) is already installed.</p>
<p><strong>How to use? (As if you need one <img src="https://s.w.org/images/core/emoji/11.2.0/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /> )</strong></p>
<ol>
<li>Extract the zip to a folder.</li>
<li>Navigate to the folder using Terminal and type &#8220;npm install&#8221;. This will deploy all the modules needed. In this case express and express-handlebars</li>
<li>Then start the server, &#8220;nodemon app.js&#8221;</li>
<li>Access on port 3000.</li>
</ol>
<p>Cheers!</p>
<p>Download the starter kit below:</p>
<p><a href="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/01/pay-with-a-tweet.jpg?ssl=1" rel="attachment wp-att-1801" target="_blank"><img src="https://i2.wp.com/classictutorials.com/blog/wp-content/uploads/2016/01/pay-with-a-tweet.jpg?resize=247%2C81&#038;ssl=1" width="247" height="81" class="alignnone wp-image-1801 size-full" data-recalc-dims="1" /></a></p>
]]></content:encoded>
							<wfw:commentRss>https://classictutorials.com/2016/01/starter-pack-for-nodejs-express-with-handlebarsjs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
						<post-id xmlns="com-wordpress:feed-additions:1">1773</post-id>	</item>
		<item>
		<title>Swift 2.0 substringWithRange</title>
		<link>https://classictutorials.com/2015/11/swift-2-0-substringwithrange/</link>
				<comments>https://classictutorials.com/2015/11/swift-2-0-substringwithrange/#respond</comments>
				<pubDate>Mon, 09 Nov 2015 06:34:23 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[ios8]]></category>
		<category><![CDATA[swift]]></category>
		<category><![CDATA[swift2]]></category>
		<category><![CDATA[xcode7]]></category>

		<guid isPermaLink="false">http://classictutorials.com/?p=1737</guid>
				<description><![CDATA[Ah finally solved. This was so much drama for a small thing to do. Problem: I have a string; SINCGKXXXYY . [Say these are 2 airport&#8230;]]></description>
								<content:encoded><![CDATA[<p>Ah finally solved. This was so much drama for a small thing to do.</p>
<p><strong>Problem:</strong></p>
<p>I have a string; <strong>SINCGKXXXYY </strong>. [Say these are 2 airport destinations + some junk text and i want to separate the airports out of the string in the easiest possible way!]</p>
<p>&nbsp;</p>
<p><strong>Use the following extension:</strong></p><pre class="crayon-plain-tag">extension String {
    
    subscript (i: Int) -&gt; Character {
        return self[self.startIndex.advancedBy(i)]
    }
    
    subscript (i: Int) -&gt; String {
        return String(self[i] as Character)
    }
    
    subscript (r: Range&lt;Int&gt;) -&gt; String {
        return substringWithRange(Range(start: startIndex.advancedBy(r.startIndex), end: startIndex.advancedBy(r.endIndex)))
    }
}</pre><p>Once done you can use it using this</p>
<p>&nbsp;</p><pre class="crayon-plain-tag">var myCrappyJunkText:String = "SINCGKXXXYY"

var firstCode = myCrappyJunkText[0...2]  //Should hold SIN

var 2ndCode = myCrappyJunkText[3...5]  //Should hold CGK</pre><p>Cheers!</p>
]]></content:encoded>
							<wfw:commentRss>https://classictutorials.com/2015/11/swift-2-0-substringwithrange/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
						<post-id xmlns="com-wordpress:feed-additions:1">1737</post-id>	</item>
		<item>
		<title>&#8220;hello world&#8221; steps to start coding with MondoDB, NodeJS and Mongoose</title>
		<link>https://classictutorials.com/2015/09/jump-start-code-to-integrate-mondodb-with-nodejs/</link>
				<comments>https://classictutorials.com/2015/09/jump-start-code-to-integrate-mondodb-with-nodejs/#respond</comments>
				<pubDate>Fri, 11 Sep 2015 12:37:00 +0000</pubDate>
		<dc:creator><![CDATA[Kaushik Das]]></dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[express]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[node]]></category>

		<guid isPermaLink="false">http://classictutorials.com/?p=1729</guid>
				<description><![CDATA[This steps will use Mongoose Object data model. Just so that i don&#8217;t forget the simple syntax i will keep it posted here. Installation:  (Skip&#8230;]]></description>
								<content:encoded><![CDATA[<p>This steps will use Mongoose Object data model. Just so that i don&#8217;t forget the simple syntax i will keep it posted here.</p>
<p>Installation:  (Skip steps which are already done)</p>
<p><strong>Mongodb</strong> &#8211;</p><pre class="crayon-plain-tag">$ brew update
$ brew install mongodb</pre><p>Then navigate to your project folder and install express, node, bla bla bla stuffs.. Guessing we did that already.Next..</p>
<p>Add mongoose to the project</p><pre class="crayon-plain-tag">$ npm install mongoose</pre><p>Now coding.</p>
<p>Add Mongoose dependency:</p><pre class="crayon-plain-tag">var mongoose = require('mongoose');</pre><p>Add MongoDB connection</p><pre class="crayon-plain-tag">var db = mongoose.connect('mongodb://localhost/users123');</pre><p>Define a schema. This is like table structure but in a different format.</p><pre class="crayon-plain-tag">//New Schema Object
var Schema = mongoose.Schema;

//Schema Definition
var UserSchema = new Schema({
name: String
})

//Register schema to Mongoose
mongoose.model('User', UserSchema);</pre><p>The above code is good enough to display if you have any data in your database, but you will need the below code to display it.</p>
<p>To display use this:</p><pre class="crayon-plain-tag">/* GET home page. */
router.get('/', function(req, res, next) {
mongoose.model('User').find(function(err, users) {
res.send(users);
});
});</pre><p>To add data, once the schema is defined add the following:</p><pre class="crayon-plain-tag">//User model using User schema available in Mongoose.
var UserModel = mongoose.model('User');

//Create a new User Object
var user = new UserModel();

//Add the info to the attributes
user.name = "Kaushik1";

//Save it
user.save(function(){

//Do stuffs after save if you want to.
console.log("Saved");
});</pre><p>Add good reference tutorial is this: <a href="http://cdnjs.com/libraries/backbone.js/tutorials/nodejs-restify-mongodb-mongoose">http://cdnjs.com/libraries/backbone.js/tutorials/nodejs-restify-mongodb-mongoose</a></p>
]]></content:encoded>
							<wfw:commentRss>https://classictutorials.com/2015/09/jump-start-code-to-integrate-mondodb-with-nodejs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
						<post-id xmlns="com-wordpress:feed-additions:1">1760</post-id>	</item>
	</channel>
</rss>
