<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Faisal Abid on Medium]]></title>
        <description><![CDATA[Stories by Faisal Abid on Medium]]></description>
        <link>https://medium.com/@faisalabid?source=rss-4edc5030bfcb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Ix9FsuYOx1ppJP6p20r9FQ.jpeg</url>
            <title>Stories by Faisal Abid on Medium</title>
            <link>https://medium.com/@faisalabid?source=rss-4edc5030bfcb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:21:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@faisalabid/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Traffic Debugger: Debug production API traffic in real-time.]]></title>
            <link>https://medium.com/dydxdev/traffic-debugger-debug-production-api-traffic-in-real-time-e6f54ae763d9?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6f54ae763d9</guid>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[api-monitoring]]></category>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Sat, 06 Jul 2019 22:32:46 GMT</pubDate>
            <atom:updated>2019-07-06T22:32:46.232Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve added some powerful new changes to dy/dx to help you learn more about your API.</p><p>Introducing <strong>Traffic Debugger</strong>. Debug API traffic live in development or production! It won’t impact your users and you will get deeper insights into what is happening on your system!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oDnUOCrLm3cJWCIy.png" /></figure><p>​<strong>Traffic Debugger</strong> lets you search through your traffic in realtime to find and debug any issues that you are facing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bDYFxHnRmh-k5vpZ.png" /></figure><p>​Give it a try and let us know what you think!</p><p>Request an invite to join dy/dx at www.dydx.dev</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6f54ae763d9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dydxdev/traffic-debugger-debug-production-api-traffic-in-real-time-e6f54ae763d9">Traffic Debugger: Debug production API traffic in real-time.</a> was originally published in <a href="https://medium.com/dydxdev">dy/dx blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hear Google Now’s Audio History of your spoken searches]]></title>
            <link>https://medium.com/@faisalabid/hear-google-now-s-audio-history-of-your-spoken-searches-7c5b29a55914?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c5b29a55914</guid>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Mon, 09 Nov 2015 17:42:46 GMT</pubDate>
            <atom:updated>2015-11-09T17:42:46.720Z</atom:updated>
            <content:encoded><![CDATA[<p>Google now is great, and I depend on it every day. Despite the voice search feature being mostly accurate, there are times where it picks up background audio or random conversations and makes a search for you.</p><p>Something I recently discovered is all these audio clips are logged to your Google Activity Dashboard and you can play them back anytime! The best audio clips are the ones where it randomly picks up on-going conversations.</p><p>Check out your audio history here <a href="https://history.google.com/history/audio?hl=en">https://history.google.com/history/audio?hl=en</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rzDDspMKZVSw81LQSndNrw.png" /></figure><p>My first audio clip dates back to 2014!</p><p>Am I going to turn this off? Nah. It doesn’t bother me, and it helps make Google Voice search better. I also think there is a setting in the past where I’ve explicitly turned Audio History on?</p><p>Most of the searches are stuff I’ve spoken into the mic. It’s just the false positives ones that make for some good hearing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c5b29a55914" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Video] Moving from Node.js to Dart]]></title>
            <link>https://medium.com/@faisalabid/video-moving-from-node-js-to-dart-a16b31858433?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a16b31858433</guid>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Fri, 12 Jun 2015 23:35:34 GMT</pubDate>
            <atom:updated>2015-06-12T23:37:07.089Z</atom:updated>
            <content:encoded><![CDATA[<p></p><h3>[Video] Moving from Node.js to Dart</h3><p>The talk I gave at Dart Summit, Moving from Node.js to Dart.</p><p>Slides below the video</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNHsmiY0rFS8%3Ffeature%3Doembed&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNHsmiY0rFS8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNHsmiY0rFS8%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d374ef32030ef7d429a7ed1aa64f5f2/href">https://medium.com/media/0d374ef32030ef7d429a7ed1aa64f5f2/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fspeakerdeck.com%2Fplayer%2Ff5de1a4404e44b94aac3783bbf729b00&amp;url=https%3A%2F%2Fspeakerdeck.com%2Ffaisalabid%2Fmoving-from-node-dot-js-to-dart&amp;image=https%3A%2F%2Fspeakerd.s3.amazonaws.com%2Fpresentations%2Ff5de1a4404e44b94aac3783bbf729b00%2Fslide_0.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=speakerdeck" width="710" height="463" frameborder="0" scrolling="no"><a href="https://medium.com/media/f066679b322e671814939750d08e2a17/href">https://medium.com/media/f066679b322e671814939750d08e2a17/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a16b31858433" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart tooling options]]></title>
            <link>https://medium.com/@faisalabid/dart-tooling-options-9ca4dbcc4d94?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ca4dbcc4d94</guid>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Wed, 10 Jun 2015 17:12:35 GMT</pubDate>
            <atom:updated>2015-06-11T03:22:08.165Z</atom:updated>
            <content:encoded><![CDATA[<p>At Dart Summit, the Dart team announced they will be deprecating eclipse support in favor of WebStorm.</p><p>This led to the following common misconception</p><blockquote>“Wait a minute, WebStorm costs $. I have to pay to develop Dart?”.</blockquote><p>Yes, WebStorm does cost money, but <strong>this is NOT your only option and NO you do not have to pay to develop Dart applications.</strong></p><p>WebStorm is actually a version of IntelliJ IDEA. The only difference is that Webstorm has a few different features built in optimized for web development. But these features have nothing to do with Dart and you could really care less about them.</p><p>According to their documentation</p><p>“IntelliJ IDEA remains JetBrains’ flagship product and IntelliJ IDEA provides full JavaScript support along with *all* other features of WebStorm via bundled or downloadable plugins. The only thing missing is the simplified project setup.”</p><p>The cool thing here is <strong>IntelliJ IDEA has a community edition</strong> which has all the features WebStorm has and all the features you need to build Dart apps, just install the Dart plugin. See: <a href="https://www.jetbrains.com/idea/download/">https://www.jetbrains.com/idea/download/</a></p><p>The pro version of IntelliJ IDEA has features like UML diagrams, but really, are you doing UML diagrams these days? ☺. See: <a href="https://www.jetbrains.com/idea/features/editions_comparison_matrix.html">https://www.jetbrains.com/idea/features/editions_comparison_matrix.html</a></p><p>The other option is Sublime &amp; Atom. Both are solid editors and both have really great support for Dart. See: <a href="https://github.com/guillermooo/dart-sublime-bundle">https://github.com/guillermooo/dart-sublime-bundle</a></p><p>Developing Dart applications does not cost money and it’s more accessible now than before!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ca4dbcc4d94" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Dart onto Google Compute Engine with continuous integration and deployment using Codeship.]]></title>
            <link>https://medium.com/google-cloud/deploying-dart-onto-google-compute-engine-with-continuous-integration-and-deployment-using-codeship-90cc45d6652e?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/90cc45d6652e</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[google-compute-engine]]></category>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Thu, 04 Jun 2015 16:59:24 GMT</pubDate>
            <atom:updated>2015-06-04T17:00:47.541Z</atom:updated>
            <content:encoded><![CDATA[<p>Wow what a mouthful of a title. Try saying that 10x.</p><p>You’ll notice that there aren’t a lot of documented ways to deploy Dart onto Google’s cloud. App Engine has no support and Managed Vm while technically supports Dart, it’s not out of beta yet, so I don’t trust it.</p><p>One way to deploy Dart to your server is to install Dart, FTP stuff over and run dart bin/server.dart.</p><p>I personally hate this method, I like having everything automated and tested before it’s deployed.</p><p>I want to commit stuff to the master branch 100x a day, run 100 unit tests for each of those commits, and if all pass, then I want the code to automatically be deployed to production.</p><p>How do we achieve this Dart deployment nirvana? Lets assume you have your Dart server app ready and have some sort of unit tests in place (even if you don’t it’s OK!, just skip the continuous integration part of this tutorial)</p><p>This tutorial is lengthy, if you get lost please leave some feedback on where I can make this better!</p><p>The first step is to get some sort of CI (Continuous Integration) system running. This will run your tests whenever you push to your github or bitbucket repository.</p><p>One of the best CI tool’s I’ve used in recent times is Codeship.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sodwATXn9cERe9fwLCDt4w.png" /><figcaption>Codeship.com</figcaption></figure><h3><strong>Setting up Dart on Codeship</strong></h3><p>When you signup to Codeship, connect your Github or Bitbucket account. When it comes time to configure your project, select Dart as the technology.</p><p>Be warned that the current Codeship SDK is outdated, so you’ll have to install a recent version of Dart during configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9m-zNF73Vmu48c2Bpw53Yw.png" /></figure><pre>wget <a href="https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/dartsdk-linux-x64-release.zip">https://storage.googleapis.com/dart-archive/channels/stable/release/latest/sdk/dartsdk-linux-x64-release.zip</a><br>unzip -o dartsdk-linux-x64-release.zip -d ~<br>pub get</pre><p>This is just telling Codeship to download the latest sdk, unzip it and run pub get on it.</p><p>Next if you have unit tests, you can tell Codeship to run them in the Test Configuration Pipeline section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocrKvaZM13ceL32RH_-rRg.png" /></figure><p>For now all I have here is dart test/all.dart which runs my Dart unit tests.</p><p>Click save, go to dashboard and follow the on-boarding steps to push your project. Ignore any deployment options it may ask you, we will revisit that shortly.</p><p>Do a git push to your master branch and let codeship do it’s magic. If all works well you’ll see this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u4OqsnD7ujFJLz1B5VVnJQ.png" /></figure><p>If it fails, see what test is failing and fix it. This is the first (if not last) line of defense before going production so make sure it passes!</p><h4><strong>Great, CI is now setup!</strong></h4><p>Cool, so now CI is setup and good to go. You write code, you push, your tests run, if all goes well Codeship gives you the green and you are in the clear.</p><p>Now what? How do I deploy this to Google Compute Engine (GCE)</p><h3><strong>Setting up GCE for Dart</strong></h3><p>I’m going to assume you don’t have a GCE server setup. Lets walk you through this.</p><p>Go to console.developers.com and create a new project for your Dart application. Click the blue New Project button top left.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*d2A-0DhE4fbcgJF532q9UQ.png" /></figure><p>In the sidebar on the left, click on VM Instances.</p><p>And click on New Instance.</p><p>Setup your new instance by following the screenshot below. For testing purposes we will use the micro instance with ubuntu 14.04LTS.</p><p>Don’t hit create just yet! follow along after the screenshot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*UAjesF9d0kjLyD3zXjq_6A.png" /></figure><p>Before you hit Create, click on the Management Disk, networking, access &amp; security options blue link.</p><p>Then click on Access &amp; Security and add in your public ssh key here.</p><p>To get your ssh key on mac try the command below. It should typically show your public key</p><pre>cat ~/.ssh/id_rsa.pub</pre><p>Once you have it, put it in the box and the username box will automatically populate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*z7Otg8mv__zw1q1Ck13Tqg.png" /></figure><p>After this, you are good to go. Your username to login to ssh with is shown. Click create and watch it go!</p><p>After a minute or two and you will see your dashboard with your awesome new GCE server running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yt3hWgpMaPjogL5WpkinSQ.png" /></figure><h3><strong>Setting up Docker on your GCE machine</strong></h3><p>Docker is an easy way to run your application inside virtualized secure containers. Gone are the days where you pollute the host system with software, now you just have a single contained Docker instance that contains your application and all of it’s dependencies.</p><p>Installing Docker on your GCE machine is straight forward.</p><p>SSH into your machine,</p><pre>ssh (username)@ip</pre><p>and follow the steps below</p><h4>Installing Docker on Ubuntu</h4><p>Make sure you have installed the prerequisites for your Ubuntu version. Then, install Docker using the following steps taken from <a href="https://docs.docker.com/installation/ubuntulinux/">https://docs.docker.com/installation/ubuntulinux/</a></p><p>Verify that you have wget installed.</p><pre>$ which wget</pre><p>If wget isn’t installed, install it after updating your manager:</p><pre>$ sudo apt-get update $ sudo apt-get install wget</pre><p>Get the latest Docker package.</p><pre>$ wget -qO- <a href="https://get.docker.com/">https://get.docker.com/</a> | sh</pre><p>The system prompts you for your sudo password. Then, it downloads and installs Docker and its dependencies.</p><p>Verify docker is installed correctly.</p><pre>$ sudo docker run hello-world</pre><p>This command downloads a test image and runs it in a container.</p><p>Perfect. if you followed along and all this works, you are doing great!</p><h4><strong>Preparing GCE to accept Codeship Deployments</strong></h4><p>Now before we leave ssh land, go to your home directory (~/) and create a folder called dart. (mkdir dart)</p><p>In a new tab, go back to Codeship, go to project settings and click on general.</p><p>Grab Codeship’s public ssh key from here. This will let Codeship deploy to your server easily.</p><p>Then back in your terminal, open up allowed_hosts in .ssh and paste that key from codeship in</p><pre>vim ~/.ssh/allowed_hosts</pre><p>Boom!</p><p>To recap, you’ve setup Docker and allowed Codeship to access your GCE. This will let it do continuous deployments, which we will setup next.</p><h3>Setting up your Dart app to support Docker</h3><p>In order to let Docker know about your application, you need to setup a Dockerfile. A Dockerfile is a simple script which tells Docker what to install, how to run your application, and what ports to expose. Create a Dockerfile at the root of your project directory.</p><p>Our Dart specific Dockerfile looks like the following.</p><pre>FROM google/dart</pre><pre>WORKDIR /app</pre><pre>ADD pubspec.* /app/</pre><pre>RUN pub get</pre><pre>ADD . /app</pre><pre>RUN pub get — offline</pre><pre>CMD []</pre><pre>EXPOSE 3030</pre><pre>ENTRYPOINT [“/usr/bin/dart”, “bin/server.dart”]</pre><p><strong>FROM google/dart</strong> is telling Docker that we want to use the google/dart docker base image. More details about that can be found here <a href="https://registry.hub.docker.com/u/google/dart/">https://registry.hub.docker.com/u/google/dart/</a></p><p><strong>WORKDIR /app </strong>is creating a directory called app in your Docker container.</p><p><strong>ADD pubspec.* /app/ </strong>is adding the pubspec file to the app folder.</p><p><strong>RUN pub get</strong> is running pub get.</p><p><strong>ADD . /app</strong> is adding the rest of your files to the app directory</p><p>We run pub twice, find out why <a href="https://registry.hub.docker.com/u/google/dart/">https://registry.hub.docker.com/u/google/dart/</a></p><p>next we <strong>expose port 3030</strong>. If your application is using a different port, then change it here.</p><p>Lastly we tell Docker how to run our app via <strong>ENTRYPOINT</strong>. By executing the dart command with the file as the argument.</p><p>Commit this and push it. Since we haven’t made any code changes, your unit tests should pass and Codeship should give you a green.</p><p>Next up, time to deploy this!</p><h3>Continuous deployment to GCE with Codeship</h3><p>In Codeship, go to project settings and deployment.</p><p>Click custom script as your deployment pipeline</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-6vgWWajVRkXIPGWWNz_NQ.png" /></figure><p>Here you will see a box to type in your deployment script. The script is easy, contains just a few commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8s3g6HMM2C-KqqxhuOPVw.png" /></figure><p>First, <strong>rsync -av</strong> copies all the files from the clone directory which Codeship creates on every push, into your dart folder that we previous created on your host GCE system.</p><p>Next we run some commands over ssh. The commands are we run basically cd into the dart directory, build the docker image, stop all previously running docker instances and run the docker app on port 3030 binding to port 3030 inside the image.</p><pre>rsync -av ~/clone/ username@ip:dart</pre><pre>ssh username@ip ‘cd dart &amp;&amp; docker build -t app . &amp;&amp; docker stop $(docker ps -a -q) &amp;&amp; docker run -d -p 3030:3030 app’</pre><p>Command summary</p><pre>cd dart <br>#change into the dart folder that has all the source code</pre><pre>docker build -t app .  <br>#build the current folder into an image called app</pre><pre>docker stop $(docker ps -a -q) <br>#stop all currently running docker instances</pre><pre>docker run -d -p 3030:3030 app <br>#run the newly created app image. binding to port 3030 on host system to port 3030 in docker image</pre><p>Remember if you used a different port, or want to bind to a different port on your host system, change that in the script.</p><h3>Testing it all together now</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MkeJD9yLge3DC1NHHM7ggQ.jpeg" /></figure><p>It’s time we test the whole flow now. The easiest way to do that is just hit restart build in Codeship.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*kL_vSFLi-e2FVxEtsUnsPw.png" /></figure><p>Hitting restart will run all your unit tests. If they pass, it’ll run your deployment workflow and voila! Visit your ip:port and you’ll see your Dart application running!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*taurI7Wyfd14jdl0azlhbA.png" /></figure><h3>Summary</h3><p>A bit lengthy but a worthwhile process. This will save you countless hours in the future when you are making quick changes to your system friday night and want to deploy it. Codeship makes it easy to ensure that your code won’t blow up in production, and Dart combined with the power of GCE will make your applications fly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*mHB3OhZDUgUYcsuxDAH6wg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90cc45d6652e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/google-cloud/deploying-dart-onto-google-compute-engine-with-continuous-integration-and-deployment-using-codeship-90cc45d6652e">Deploying Dart onto Google Compute Engine with continuous integration and deployment using Codeship.</a> was originally published in <a href="https://medium.com/google-cloud">Google Cloud - Community</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using RethinkDB with Dart]]></title>
            <link>https://medium.com/@faisalabid/using-rethinkdb-with-dart-22aeb10b4768?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/22aeb10b4768</guid>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Thu, 19 Mar 2015 14:31:21 GMT</pubDate>
            <atom:updated>2015-03-19T14:31:21.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9YBzli3tQnUnB2erUuoKzQ.png" /><figcaption>Dart meets RethinkDB</figcaption></figure><p>30 second quickstart in Dart</p><p>Dart isn’t just for the front-end, it’s also a powerful server-side platform to build api’s and command line tools.</p><p>One great example of how powerful Dart is on the server-side is by using it with an equally powerful database RethinkDB.</p><p>Yes, you can use RethinkDB with Dart!</p><p>The driver is updated to support the latest version of RethinkDB and using it is very simple.</p><p>I’ll be using Webstorm in this tutorial, which I think is the best IDE for Dart.</p><p>First, you’ll need to create a new project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Lz-pA3WX9akaj-mOMyhXqQ.png" /></figure><p>We’re going to use a console application for this, since the driver is intended to run on a server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*VhSyTqoWN0cA-89o5tT0UQ.png" /></figure><p>Next you want to add the dependency to pub.yaml. You can find the github repo for the driver if you ever want to contribute or build from source. <a href="https://github.com/billysometimes/rethinkdb">https://github.com/billysometimes/rethinkdb</a>. Props to BillySometimes for building this.</p><p>The current version is 0.7.0 and works with the latest version of RethinkDB, which at the time of writing is 1.16</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*GkH94ztmqNp6NOllHuvGPA.png" /><figcaption>Notice the rethinkdb_driver entry under dependecies</figcaption></figure><p>Now that all the boring stuff is out of the way, it’s <strong>time to write some code.</strong></p><p>To keep things simple lets take the Javascript driver example and see how we do the same in Dart. This will give you an easy understanding of how to write RethinkDB queries in Dart when looking at RethinkDB’s documentation and examples.</p><p><a href="http://rethinkdb.com/docs/install-drivers/javascript/">http://rethinkdb.com/docs/install-drivers/javascript/</a></p><pre>r = require(&#39;rethinkdb&#39;)<br>r.connect({ host: &#39;localhost&#39;, port: 28015 }, <strong>function</strong>(err, conn) {<br>  <strong>if</strong>(err) <strong>throw</strong> err;<br>  r.db(&#39;test&#39;).tableCreate(&#39;tv_shows&#39;).run(conn, <strong>function</strong>(err, res) {<br>    <strong>if</strong>(err) <strong>throw</strong> err;<br>    console.log(res);<br>    r.table(&#39;tv_shows&#39;).insert({ name: &#39;Star Trek TNG&#39; }).run(conn, <strong>function</strong>(err, res)<br>    {<br>      <strong>if</strong>(err) <strong>throw</strong> err;<br>      console.log(res);<br>    });<br>  });<br>});</pre><p>Typical Javascript, nothing fancy or new.</p><p>Lets see how we can acheive the same in Dart.</p><p>First you’ll need to import the Dart driver in your main.dart file.</p><pre><strong>import </strong>&#39;package:rethinkdb_driver/rethinkdb_driver.dart&#39;;</pre><p>Next to keep things aligned with the recommended RethinkDB patterns, create a variable r and assign it to the RethinkDB object</p><pre>Rethinkdb r = <strong>new </strong>Rethinkdb();</pre><p>Excellent. We’re making progress.</p><p>Next create a method called connectToDriverAndQuery. You can and should come up with a better name but for the sake of the demo we’ll stick to this.</p><pre>connectToDriverAndQuery(){}</pre><p>Straight forward Dart.</p><p>One thing I want to add though is async/await support. If you want to learn more about how async/await works, check out <a href="https://www.dartlang.org/articles/await-async/">https://www.dartlang.org/articles/await-async/</a></p><p>To make a method support async/await, just add the async keyword after the method declaration.</p><pre>connectToDriverAndQuery() <strong>async {}</strong></pre><p>Boom. It’s that simple.</p><p>Next up, we want to connect to our RethinkDB server. Since the method is async enabled, we can connect to our server like such.</p><pre><strong>var </strong>connection = <strong>await </strong>r.connect(db:&quot;test&quot;);</pre><p>No need for callbacks.</p><p>The connection variable is important as it will be passed into all our queries. You can also add host: and port: parameters to the method like such</p><pre><strong>var </strong>connection = <strong>await </strong>r.connect(db:&quot;test&quot;, host:&quot;192.168.99.100&quot;, port:49154);</pre><p>That funky port is thanks to the docker instance I run with RethinkDB. www.kitematic.com</p><p>Next up, staying true to the 30 second javascript example above, we want to create a table called tv_shows.</p><pre><strong>var </strong>tableCreate = <strong>await </strong>r.tableCreate(&quot;tv_shows&quot;).run(connection);</pre><p>Notice that we pass in the connection variable from above.</p><p>Not only is RethinkDB’s syntax clear, but async/await makes it too easy.</p><p>Lastly, following the Javascript example, we want to insert a tv show.</p><pre><strong>var </strong>insertRow = <strong>await </strong>r.table(&quot;tv_shows&quot;).insert({ &quot;name&quot;: &#39;Star Trek TNG&#39; }).run(connection);</pre><p>It is that simple. No need for messy callbacks and it’s all asynchrnous.</p><p>If you print(insertRow) you’ll see the same output as you would in the javascript driver.</p><pre>print(insertRow);</pre><pre>{deleted: 0, errors: 0, generated_keys: [f6690740-cb9f-4901-9b2f-243f67744418], inserted: 1, replaced: 0, skipped: 0, unchanged: 0}</pre><p>Lets take a look at the entire main.dart for reference.</p><pre><strong>import </strong>&#39;package:rethinkdb_driver/rethinkdb_driver.dart&#39;;<br><br>Rethinkdb r = <strong>new </strong>Rethinkdb();<br><br>main() {<br>  connectToDriver();<br>}<br><br>connectToDriver() <strong>async </strong>{</pre><pre>  <strong>var </strong>connection = <strong>await </strong>r.connect(db:&quot;test&quot;, host:&quot;192.168.99.100&quot;, port:49154);</pre><pre>  <strong>var </strong>insertRow = <strong>await </strong>r.table(&quot;tv_shows&quot;).insert({ &quot;name&quot;: &#39;Star Trek TNG&#39; }).run(connection);</pre><pre>  print(insertRow);</pre><pre> }</pre><p>Dart and RethinkDB work great together. Using Dart’s async/await syntax, I personally find it much better to develop in than the Node.js driver.</p><p>Want to learn more? Check out the docs at <a href="http://rethinkdb.com/docs/">http://rethinkdb.com/docs/</a> and the great documentation at Dart <a href="https://www.dartlang.org/docs/">https://www.dartlang.org/docs/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22aeb10b4768" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dart & Polymer at OSCON 2014]]></title>
            <link>https://medium.com/@faisalabid/dart-polymer-at-oscon-2014-53f7fb98122f?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/53f7fb98122f</guid>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Sat, 12 Jul 2014 14:34:01 GMT</pubDate>
            <atom:updated>2014-07-12T14:34:01.382Z</atom:updated>
            <content:encoded><![CDATA[<h4>Migrating to the web just got easier.</h4><p>I’ll be presenting Migrating to the web with Dart and Polymer at OSCON next week. If you’re attending the conference, be sure to check out the talk! It’s filled with neat info to get you started building powerful Dart &amp; Polymer based web apps.</p><p><a href="http://www.oscon.com/oscon2014/public/schedule/detail/33451">www.oscon.com/oscon2014/public/schedule/detail/33451</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5JShFwDkUvNiATY9Avx4cw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53f7fb98122f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 tips for the Dart & Polymer.dart Padawan.]]></title>
            <link>https://medium.com/@faisalabid/5-tips-for-the-dart-polymer-dart-padawan-14c6eb67df3e?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/14c6eb67df3e</guid>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Thu, 27 Mar 2014 14:51:02 GMT</pubDate>
            <atom:updated>2014-03-27T14:51:02.265Z</atom:updated>
            <content:encoded><![CDATA[<h4>Or how I just write these things to show off some lego star wars</h4><p>Dart is pretty awesome. I’ve been playing with it for a few months now and I must say that it’s really changed the way I develop web apps.</p><p>One of the great things about Dart is that it’s very easy to build and manage large scale web apps. The Dart language is — dare i say it — perfect. It’s the perfect mix between Javascript and something like Java. The type system is awesome, the toolset is amazing (though I use Sublime still), and lastly the performance you get from the JS it spits out is outstanding.</p><p>You might have a different opinion on this, but I think building large front end apps with javascript can get a bit tedious. With Dart, you never run into the problems you would run into with Javascript.</p><p>One of the cooler things in Dart is it’s integration with Polymer and web components. Polymer has dramatically changed the way I write web apps. Coming from a strong AngularJS background, and wanting to try something other than Angular.dart, I opted to build my startups web app in Dart &amp; Polymer with custom routing. *Note you can use Angular.dart with polymer using the bridge component, but thats for another article*</p><p>Polymer is essentially a wicked cool abstraction over web components. <a href="https://www.dartlang.org/polymer-dart/">https://www.dartlang.org/polymer-dart/</a></p><p>Web components are a great way to break up your app into bite sized chunks for ease of development. <a href="http://www.w3.org/TR/components-intro/">http://www.w3.org/TR/components-intro/</a></p><p>During the past few months I’ve learned a whole bag full of tricks and tips that should be helpful when developing Dart &amp; Polymer apps. Some of the tips you might just know through reading the documents, and some take a bit of googling and fiddling with.</p><p>So without any order, here are 5 tips that should help you, young padawan.</p><p><strong>Tip 1: Shadow DOM is your friend.</strong></p><p>Shadow Dom keeps your CSS styles away from your polymer component. If you want to let your main css affect your polymer components, then remember to set.</p><p>I mostly always do this.</p><pre>getShadowRoot(“component-name”).applyAuthorStyles = true;</pre><p><strong>Tip 2: Wrap it all up!</strong>:</p><p>Best practice is to wrap your entire app into a polymer component. i.e</p><pre>&lt;body&gt;&lt;my-app&gt;&lt;/my-app&gt;&lt;/body&gt;</pre><p>It will make your life super easy when you want to communicate with other polymer components.</p><p><strong>Tip 3: Post runnable Polymer: </strong>This one is thanks to Günter Zöchbauer,</p><p>Sometimes there could be a delay in init’ing your polymer components. So be sure to run the code that calls methods on it in a post runnable.</p><p>In my case its</p><pre>main() =&gt; initPolymer().run(() =&gt; new RoutesController());</pre><p><strong>Tip 4</strong>: <strong>MirrorsUsed: </strong>When getting your template to loop over a list comprised of a custom object, be sure to indicate <a href="http://twitter.com/MirrorsUsed">@MirrorsUsed</a> in the object, otherwise when compiling to JS, polymer won’t read properties from your object.</p><p>Example.</p><pre><a href="http://twitter.com/MirrorsUsed">@MirrorsUsed</a>(targets: Persona)<br>import ‘dart:mirrors’;</pre><pre>class Persona { String name; int age; String location; String statsString; Persona(this.name, this.age, this.location, this.statsString);<br>}</pre><pre>&lt;template repeat=”{{person in personas}}”&gt; &lt;span&gt;{{person.name}}, {{person.age}}&lt;/span&gt;<br>&lt;/template&gt;</pre><p><strong>Tip 5</strong>: <strong>onEnteredView:</strong> For your Polymer element. Do any dom manipulation in onEnteredView and not the constructor. Otherwise Dart won’t be able to get a reference to the shadow dom. Be sure to always super the method implementation.</p><pre><a href="http://twitter.com/override">@override</a> void enteredView() {                   super.enteredView();<br>// do dom here<br>}</pre><p><strong>Final thoughts.</strong></p><p>I recommend everyone check out Dart. I think its a game changer for web development and I can’t wait to see what the future has in store for Dart.</p><p>If you don’t want to check out Dart, then at least check out Polymer.js.</p><p>Seriously, this is the future of web development.</p><p>Need Node.js or Dart consulting? Contact us at Dynamatik <a href="http://www.dynamatik.com/">http://www.dynamatik.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14c6eb67df3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 tips for a Node.js padawan]]></title>
            <link>https://medium.com/@faisalabid/7-tips-for-a-node-js-padawan-e7c0b0e5ce3c?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7c0b0e5ce3c</guid>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Wed, 11 Sep 2013 14:08:13 GMT</pubDate>
            <atom:updated>2014-08-13T19:35:13.414Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nNzetjdpjXO6ITRO.jpeg" /><figcaption>the padawan menace || Property of lego and lucasfilm. hey guys don’t sue me.</figcaption></figure><h4>Or stuff I wish I knew when I started.</h4><p>Node.js development is extremely fun and satisfying. There are over 35k modules to choose from, and overall node is very easy to develop a working application that can scale easily.</p><p>However for developers just starting off with Node.js development, there are a few bumps along the road. In this short post I cover a few of the things I questioned and ran into while learning Node.js.</p><p><strong>Tip 1: Use nodemon for development. pm2 for production.</strong></p><p>When you first get started with Node.js development, one of the things that will stick out like a sore thumb is having to run node [file].js over and over again. When I got started with node, this was extremely frustrating and painful. Especially having to control C every time I modified something.</p><p>Luckily I discovered a great tool called Nodemon <a href="https://github.com/remy/nodemon">https://github.com/remy/nodemon</a>. Install it by running npm install -g nodemon.</p><p>Nodemon is an awesome tool, once you install it globally you can run your node.js scripts via nodemon [file].js. Doing so will tell nodemon to monitor your script and all the scripts that it depends on for changes. This is an awesome way to do Node.js development and speeds everything up.</p><p>What about production? Unless you are using Heroku, Nodejitsu or other great Node.js hosting providers, chances are you will be using EC2 or another cloud provider to run your Node.js app. How do you properly run a Node.js app to make sure it’s always running?</p><p>The answer to that question is a great tool called PM2 <a href="https://github.com/Unitech/pm2">https://github.com/Unitech/pm2</a>. PM2 is a tool like nodemon which is intended to run your node app in production. Like Nodemon it will monitor your app for changes and redeploy them, but unlike Nodemon, if PM2 encounters a crash, it will restart your node.js app right away.</p><p>Where PM2 excels though is when you need to scale your app to multiple cores. PM2 comes with a built in “load balancer” that lets you easily specify how many instances of your Node app to run.</p><p>pm2 start app.js -i max</p><p>The -i parameters lets you specify how many instances to run, in this case PM2 comes with a built in constant called max which auto scales your app to the amoutn of cores you have. Remember Node runs only on one core!</p><p><strong>Tip 2: Async or Q</strong></p><p>The more you start to write node.js apps, the sooner you’ll realize the pain of callback hell. If you don’t know what callback hell is, here is an example:</p><pre> function register(name, password, cb){<br>  checkIfNameExists(name, function(err, result){<br>   if(err){<br>    return cb(“error”);<br>   }<br>   checkIfPasswordGood(password, function(err, result){<br>    if(err){<br>     return cb(“error”);<br>    }<br>    <br>    createAccount(name,password, function(err,result){<br>     if(err){<br>      return cb(“error”);<br>     }<br>     createBlog(name, function(err, result){<br>      sendEmail(name, function(err, result){<br>       callback(result);<br>      });<br>     });<br>    });<br>   });<br>  });<br> }</pre><p>While not a very useful or amazing block of code, it should get the point across that callback hell is a very real thing. But how do you avoid this?</p><p>One simple way is to use events. I personally don’t like using events because then you are using events to call private functions which have only one purpose, which defeats the point of a function.</p><p>How do you do this then? There are two competing libraries out there, async.js and Q. Both offer their own take on how callback hell should be prevents.</p><p>Async.js <a href="https://github.com/caolan/async">https://github.com/caolan/async</a> or “async” allows you to easily execute functions in series or parallel without the need of nesting them back to back.</p><p>Below are some of the patterns that Async supports taken from their readme. For a list of all the patterns async supports check out their repo.</p><pre> async.map([‘file1&#39;,’file2&#39;,’file3&#39;], fs.stat, function(err, results){<br>  // results is now an array of stats for each file<br> });<br> <br> async.filter([‘file1&#39;,’file2&#39;,’file3&#39;], fs.exists, function(results){<br> // results now equals an array of the existing files<br>});<br> <br> async.parallel([<br>  function(){ … },<br>  function(){ … }<br>  ], callback);<br> <br> async.series([<br>  function(){ … },<br>  function(){ … }<br>  ]);<br> <br> async.waterfall([<br>  function(callback){<br>   callback(null, ‘one’, ‘two’);<br>  },<br>  function(arg1, arg2, callback){<br>   callback(null, ‘three’);<br>  },<br>  function(arg1, callback){<br> // arg1 now equals ‘three’<br> callback(null, ‘done’);<br> }<br> ], function (err, result) {<br> // result now equals ‘done’ <br>});</pre><p>If we take what we did previously with register, we can apply the waterfall pattern in async. The result of this is a very readable code pattern that doesn’t involve the pyramid of doom.</p><p>Another great library is Q <a href="https://github.com/kriskowal/q]%28https://github.com/kriskowal/q%29">https://github.com/kriskowal/q</a>. This library is exposes the concept of promises. A promise is basically an object that is returned from a method with the “promise” that it will eventually provide a return value. This ties is very neatly with the asynchronous nature of javascript and node.js.</p><p>For example, taken from Q’s repo page.</p><pre> promiseMeSomething()<br> .then(function (value) {<br> }, function (reason) {<br> });</pre><p>The promise me function returns an object right away. Calling <strong>then</strong> on the object will call the function you pass in with the value you want returned. Then also takes an additional callback which is run when the object fails to return the value.</p><p>This is a very neat way to avoid the insanity of callback hell. If we take our registration example, you can easily make it so that each of those functions is called when then is executed.</p><pre> Q.fcall(checkIfNameExists)<br> .then(checkIfPasswordIsGood)<br> .then(createAccount)<br> .then(createBlog)<br> .then(function (result) {<br> // Do something with the result<br>})<br> .catch(function (error) {<br> // Handle any error from all above steps<br>})<br> .done();<br> </pre><p>As I said previously, I dislike creating single purpose functions. Instead of passing in the function name to “then”, I would just create an anonymous inner function and pass that in, however the choice is yours.</p><p>In summary, if you start to realize you’re creating callback hell for yourself then it’s time to look into async.js or Q.</p><blockquote>My personal fav? Q all the way!</blockquote><p><strong>Tip 3: Debugging Node.js apps easily</strong></p><p>Debugging Node.js apps will be confusing if you are coming from a language with heavy IDE integration like Java or C#. Most new node developers adopt the “flow” debugging pattern, where your best friend becomes console.log.</p><p>However there are still alternatives that are more convention to debugging. Node.js comes with a built in debugger that you can run by calling node debug, however the one I love is node-inspector.</p><p>Taken from their github repo “Node Inspector is a debugger interface for node.js using the Blink Developer Tools (former WebKit Web Inspector).”</p><p>In a nutshell node-inspector lets you debug your applications using whatever editor of your choice and chrome web tools. That is sexy.</p><p>Node-inspector lets you do some really cool things like live code changing, step debugging, scope injection and a bunch of other cool stuff.</p><p>It’s bit involved to setup, so I’ll let you follow the instructions over at</p><p><a href="https://github.com/node-inspector/node-inspector">https://github.com/node-inspector/node-inspector</a></p><p><strong>Tip 4: Nodefly</strong></p><p>Once you have your application up and running, you might ask yourself how you could monitor it’s performance and profile it to make sure your app is running at optimum speed. The simplest answer to that is a great service I use called Nodefly.</p><p>Nodefly with a simple line of code starts to monitor your application for memory leaks, measure how long it takes for redis, mongo queries and a bunch of other cool stuff.</p><p><a href="http://www.nodefly.com/">http://www.nodefly.com</a></p><p><strong>Tip 5: Module management with NPM.</strong></p><p>One of the most common things to do in node is installing packages via NPM. Node has an amazing package manager which installs all the modules specified in your package.json manifest file. However one thing all beginers run into is keeping this package.json file updated with all the modules you are using.</p><p>It seems like a pain to always be opening your package.json to update the dependcies property with the new module you just installed, but what many don’t know is npm will do this for you!</p><p>Simple run npm install — save module_name and npm will automaticly update your package.json with the correct module and version name.<strong> </strong><em>npm install —save module_name</em></p><p><strong>Tip 6: Don’t check in your node_modules folder</strong></p><p>While we are on the topic of modules and npm, not many know that you shouldn’t check in your node_modules folder. The biggest reason behind this is there is no need for you to check this folder in. Whenever someone checks your source out they can just run npm install and download all the modules required.</p><p>You might say that it’s not a big deal if you check in node_modules, but what if the person checking out your source is using an operating system other than yours and one of the modules that your app uses is compiled when it’s installed via npm? Your app will crash and the person that checked out your source will have no idea why!</p><p>For example modules like bcrypt and sentimental are compiled on the host system when you install them because they have native components written in C.</p><p>The best way to avoid checking in your node_modules folder is by adding it to .gitignore.</p><blockquote>// .gitignore node_modules/*</blockquote><p><strong>Tip 7: Don’t forget to return</strong></p><p>A common mistake made by all early node developers is forgetting to return after a callback. While some times this has no implications, there are many times where you’ll run into odd issues because your callback is being called twice.</p><p>Lets take a look at a quick example</p><pre> function do(err,result, callback){<br> if(err){<br> callback(“error”);<br> }<br> callback(“good”);<br> }</pre><p>At first glance, this snippet makes sense. If there is an error, send “error” in the callback, if not send good. But calling the callaback is not stopping the method from completing the execution. It will just move on to calling callback(“good”).</p><p>Inside long and complex lines of code, doing this will save you hours and hours of debugging.</p><p>Node.js is great platform to develop on. If you keep these 7 things in mind while developing, debugging and deploying to production you can save your time and prevent your hair from graying out.</p><p>Need help with a Node, Dart, Angular, or Android project? Connect with me <a href="http://linkedin.com/in/faisalabid">http://linkedin.com/in/faisalabid</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7c0b0e5ce3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Interview at OSCON]]></title>
            <link>https://medium.com/@faisalabid/my-interview-at-oscon-8a37e770d478?source=rss-4edc5030bfcb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a37e770d478</guid>
            <dc:creator><![CDATA[Faisal Abid]]></dc:creator>
            <pubDate>Fri, 02 Aug 2013 02:50:17 GMT</pubDate>
            <atom:updated>2013-08-02T02:49:58.658Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6pNt-OJgCOnfWlZ7.png" /><figcaption>my screenshot tool on mac</figcaption></figure><h4>Or how OSCON was the best conference I’ve ever attended.</h4><p>OSCON was awesome. I think it is the single most important conference a developer should attend. It’s a great experience and everyone should go.</p><p>Anyways, as many know I spoke there and the folks at OSCON were kind enough to interview me about it.</p><p>Here it is!</p><p><a href="http://www.youtube.com/watch?v=ao_C6RmVGAs">http://www.youtube.com/watch?v=ao_C6RmVGAs</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a37e770d478" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>