<?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[Faodail Technology - Medium]]></title>
        <description><![CDATA[Faodail Technology provides smarter &amp; innovative solutions for web &amp; mobile applications to bring ideas to life. (https://www.faodailtechnology.com) - Medium]]></description>
        <link>https://medium.com/faodail-technology?source=rss----c651a7400885---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Faodail Technology - Medium</title>
            <link>https://medium.com/faodail-technology?source=rss----c651a7400885---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:47:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/faodail-technology" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Step by step guide to consuming Webhooks with Rails Application]]></title>
            <link>https://medium.com/faodail-technology/step-by-step-guide-to-consuming-webhooks-with-rails-application-3952acf15832?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/3952acf15832</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[webhooks]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[faodailtechnology]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Chandan Jhunjhunwal]]></dc:creator>
            <pubDate>Mon, 19 Jun 2017 22:25:32 GMT</pubDate>
            <atom:updated>2017-06-19T22:54:21.232Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*_FFkggB4Hg_zqJE3bx1wuQ.gif" /><figcaption>1. Webhook Pirate, credit: blog.mailchimp.com</figcaption></figure><p>These days many service providers (<a href="https://stripe.com/">stripe</a>, <a href="http://www.mailchimp.com/">mailchimp</a>, <a href="http://www.sendgrid.com/">sendgrid</a>, <a href="http://www.superfeedr.com/">superfeedr</a> etc) provides webhooks, which can push an event(usually a post request) with appropriate payload to your web application whenever a certain event occurs. This is pretty handy as you don’t have to keep polling or implement a service, which will keep asking for update from these third party services.</p><h3>Use-cases:</h3><ol><li>You want to update a subscription, whenever your customer makes a payment via a third party payment service(e.g. stripe).</li><li>You want to parse a email reply from a user and display it’s content on your web application something like Basecamp. (e.g. SendGrid, Mailchimp webhooks)</li><li>You want to consume RSS feeds generated by several feed sources using a third party service (e.g. Superfeedr)</li><li>And many more…(Right now, I could recall only above 3 use-cases from our past projects ;-)</li></ol><h3>In this tutorial, we’ll learn:</h3><ol><li><em>What is webhook?</em></li><li><em>How to develop a secure callback end-points?</em></li><li><em>How to consume webhook calls in development environment?</em></li></ol><h3><strong>What is webhook?</strong></h3><blockquote>A webhook can be considered as inverted API endpoint, where instead of your application calling an API endpoint, you provide a callback URL to the third party service for a particular event. The third party service will make a post request to your callback URL with payload whenever the event occurs, which can be consumed by your application.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*BI1EX_zB2OWD_bE8Acy57A.png" /></figure><p>Let’s say whenever someone makes a payment via Stripe, you want to update subscription in your application database. Thus you <a href="https://stripe.com/docs/webhooks">setup a callback URL on stripe</a> for all successful subscription. Whenever user makes a successful payment, stripe will post a request to your predefined callback URL with appropriate payload, thus enabling you to update the payment in your database. The setup of webhooks might involve a few more steps depending upon your service provider. For example, <a href="https://sendgrid.com/docs/API_Reference/Webhooks/inbound_email.html">inbound email parsing with sendgrid</a> involves adding MX record with your DNS provider. Thus, you must refer your service provider documentation for the webhook setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/861/1*CE_sgRiaj-iDY8YCZtCFsA.png" /><figcaption>2. Webhook and Callback Triggering</figcaption></figure><h3><strong><em>How to develop a secure callback end-points?</em></strong></h3><p>Since your callback URL is exposed to public, thus you must ensure the requests to your callback URL is secure. While registering your callback URL, many service provider also gives you an option to provide a secure token, so that your application will process the callback request if and only if the request contains the valid token. Another good way to secure your callback URL is by obscurity.</p><p><strong>Security by Obscurity: </strong>Let’s say we’re using a subscription model payment service FaodailPayments, where user will be subscribed with individual callback end-point. The payment service will be pushing all events triggered by a user to the callback end-point assigned to the user at the time of subscription with a payload with required details about the event. The service also provides an API end-point to register the user with them.</p><p><strong>Step 1: Subscription</strong></p><p>We’ll store subscriptions in <em>Subscription</em> model. At the time of subscribing each user via service provider API end-point, we’ll generate an obscure token as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95c4c6d418246c49e42ae0e81eea28ff/href">https://medium.com/media/95c4c6d418246c49e42ae0e81eea28ff/href</a></iframe><p>Please note that, we’ve used <em>FaodailPayment</em> namespace for the model, as you might already have another <em>Subscription</em> model in your application. It’s always a good practice to namespace external services, even if you don’t have a model with same name.</p><p>The <em>FaodailPayment::Base </em>class will look something like below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16e134f42c4bc190853953504f4c23b8/href">https://medium.com/media/16e134f42c4bc190853953504f4c23b8/href</a></iframe><p><strong>Step 2: Create routes and action</strong></p><p>Now we have an obscure <em>webhook_token</em> associated with each user, we’ll create a route to consume the callback requests.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4476b268709b42562edafe51131c0354/href">https://medium.com/media/4476b268709b42562edafe51131c0354/href</a></iframe><p>Here we’re consuming the service provider callbacks on <em>faodail</em> subdomain. Now we’re free to consume the webhook callbacks via following controller:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bac049459af4fd8c143dd122c8102c87/href">https://medium.com/media/bac049459af4fd8c143dd122c8102c87/href</a></iframe><blockquote><strong>Best practices while developing callback end-points</strong></blockquote><ol><li>Use different sub-domain for each service provider. If you’re using send-grid, you might want to all of your end-point hitting <em>sendgrid.example.com</em></li><li>Wherever possible, set obscure token for each endpoint while registering callback URL with service providers.</li><li>Wherever possible, create obscure end-points for callback URLs</li><li>Namespace each services independently.</li></ol><h3><em>How to consume webhook calls in development environment?</em></h3><p>When we integrate such external services, we need a way to consume the service callback requests on our development machine. There are many tools (<a href="http://www.ngrok.com/">ngrok</a>, <a href="https://pagekite.net/">pagekite</a>, <a href="http://www.zipidoo.com/">zipidoo</a> etc) which can help you tunnel your localhost to external web. I’ve used <em>ngrok</em> and did not find any reason to switch away from it.</p><p>You can download ngrok from <a href="https://ngrok.com/download">here</a>. You can start ngrok with following command <em>from the directory where you’ve downloaded ngrok</em>:</p><blockquote><strong>./ngrok http 3000</strong></blockquote><p>If your server is running on other port than 3000, you must change the port number in above command. If you want a subdomain, you can execute:</p><blockquote><strong>./ngrok http 3000 -subdomain=faodail</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*GmJkji048DxGYtjM_4ZvHw.png" /><figcaption>ngrok localhost tunnelling</figcaption></figure><p>You can share the above URL with anyone and they’ll be able to view what’s running on your localhost :)</p><p>Congratulations! You’ve successfully integrated a secure webhook :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3952acf15832" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/step-by-step-guide-to-consuming-webhooks-with-rails-application-3952acf15832">Step by step guide to consuming Webhooks with Rails Application</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reading Standard Input (StdIn) in Swift]]></title>
            <link>https://medium.com/faodail-technology/reading-standard-input-stdin-in-swift-45f81b3caf2c?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/45f81b3caf2c</guid>
            <category><![CDATA[hackerrank]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[stdin]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Javal Nanda]]></dc:creator>
            <pubDate>Thu, 01 Jun 2017 11:51:40 GMT</pubDate>
            <atom:updated>2019-12-24T07:16:48.505Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*oHFjnr385zGspFP2.png" /></figure><p>Hello! Swifty Buddies. If you have tried out some of the challenges on Hackerrank using Swift as a preferred language, you might have came across this situation of reading input from StdIn because that is how the Test case inputs are provided on Hackerrank.</p><p>For most of the languages, you will get a boilerplate code and you just need to write your logic but as soon as you select swift as a language, you will get this:</p><pre>import Foundation;</pre><pre>// Enter your code here</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/0*Pw-1XlvWtiz8geLt.gif" /></figure><p>Yeah, that’s all you got 🙂</p><p><strong>How to read Standard Input?</strong></p><p>To read standard input in swift you will need to use <a href="https://developer.apple.com/reference/swift/1641199-readline">readLine()</a> function.</p><p>Ok, where to write code?</p><p>One option is to create MacOS –&gt;Command Line Tool application but if you are used to only iOS applications, this will take some time to figure it out. Let us stick with Playgrounds only which is fun to work with for us.</p><p>But, readLine() always return nil in the playground. How do I test it? Don’t worry, I will come to that part. First, let us look at the logic that we will need to read inputs for Hackerrank.</p><h4>Reading string</h4><blockquote>let string = readLine(strippingNewline: true)!</blockquote><p>It is ok to use force wrap over here since on Hackerrank input values are always present. But, don’t do this in production code.</p><h4>Reading Int</h4><blockquote>let number = Int(readLine(strippingNewline: true)!)!</blockquote><h4>Reading array of string</h4><p>For inputs sample as below:</p><blockquote>a b c d b</blockquote><p>You can ready string array by splitting using the space character as below:</p><blockquote>let stringArray = readLine(strippingNewline: true)!.characters<br>.split {$0 == ” “}<br>.map (String.init)</blockquote><h4>Writing to standard output</h4><p>You can write the final output using the same way we print to console using print() function.</p><h3>Example</h3><p>Let us take one of the existing example from Hackerrank.</p><p><strong>Problem Description:</strong> <em>Given two strings, and , that may or may not be of the same length, determine the minimum number of character deletions required to make and anagrams. Any characters can be deleted from either of the strings.</em></p><p><strong>Sample Input:</strong></p><pre>cde<br>abc</pre><p>Write your solution in playground. Note that the playground will show error as it will encounter nil for readLine(). You can guard it or provide default value for coming up with the solution and can change it back to readLine() code when it is ready to paste it in Hackerrank’s editor.</p><p>Here is the solution which I came up with for this problem:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/605735c852a77bb6c8e0aa74fde8347f/href">https://medium.com/media/605735c852a77bb6c8e0aa74fde8347f/href</a></iframe><h3>Testing</h3><p>Now, to test it save it as Anagram.swift file at your preferred location. Go to that location on terminal and type:</p><blockquote>swift Anagram.swift</blockquote><p>Now, you are ready to give inputs and test it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NlksEhSi5hM2YVa1.png" /></figure><p>Voila!! You are ready to paste your code in Hackerrank now. Test with few different inputs and once you are ready, make sure to comment all the print logs except the final answer one and paste it in Hackerrank to run and test it.</p><p>This might get you through most of the challenges by writing in swift.</p><p>Let me know your feedbacks and what solution did you come up with for this problem? 🙂</p><p><em>Originally written on </em><a href="http://sharingtechbits.com/hackerrank-swift-language-stdin-stdout/"><em>sharingtechbits.com</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=45f81b3caf2c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/reading-standard-input-stdin-in-swift-45f81b3caf2c">Reading Standard Input (StdIn) in Swift</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Redis Abstract Data types and it’s usages Part — I]]></title>
            <link>https://medium.com/faodail-technology/getting-started-with-redis-i-ed55578f36d1?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed55578f36d1</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Chandan Jhunjhunwal]]></dc:creator>
            <pubDate>Sun, 21 May 2017 19:45:24 GMT</pubDate>
            <atom:updated>2017-05-21T21:32:24.861Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*ngGAAMf8Sw4jCJ_nP2Qt5A.png" /><figcaption>Redis</figcaption></figure><p>In this tutorial, we’ll explore different data types in Redis and their usages.</p><h3>What is Redis?</h3><p>As per <a href="https://redis.io/">Redis website</a>:</p><blockquote>Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries.</blockquote><p>In simple words:</p><blockquote>Redis is <strong>a very fast non-relational in-memory key-value pair database</strong></blockquote><p>If you come from RDBMS background, you can consider <em>key</em> as <em>ID</em> of the record in database. In RDBMS, you perform CRUD on a record based on it’s ID. Since Redis is a NoSQL database, you don’t have notion of <em>ID</em>. Thus you’ll have to rely on KEY to perform all kind of operations.</p><p><strong>NOTE: KEYs in Redis are case-sensitive.</strong></p><h3>Installation:</h3><p>On Mac, you can install <em>Redis</em> via <em>brew:</em></p><blockquote>$&gt; brew install redis</blockquote><p>You can install the latest version (3.2.9) on ubuntu with following commands:</p><blockquote>$ wget <a href="http://download.redis.io/releases/redis-3.2.9.tar.gz">http://download.redis.io/releases/redis-3.2.9.tar.gz</a></blockquote><blockquote>$ tar xzf redis-3.2.9.tar.gz</blockquote><blockquote>$ cd redis-3.2.9</blockquote><blockquote>$ make</blockquote><p>Alternatively, you can download binary directly from <a href="https://redis.io/download">Redis download page</a>.</p><p><strong>Tip:</strong> Redis has a very nice <a href="http://try.redis.io/">online Interactive tutorial here</a>, where you can experiment different commands on browser without any kind of installation.</p><h3>Redis Data Types:</h3><p>In Redis, we store everything as key-value pairs. In this tutorial, we’ll discuss five primary data types:</p><ol><li>STRINGs</li><li>LISTs</li><li>SETs</li><li>HASHes</li><li>ZSETs</li></ol><p>Let’s get started with exploring these data types. Fire up <em>redis-server </em>and run <em>redis-cli:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JhBX9ZiPU-7O3GtgcRuaSQ.png" /><figcaption>redis-server and redis-cli</figcaption></figure><p><strong>NOTE:</strong> For each of the data-types Redis offers a large set of commands. We’ll be exploring most used commands. If you want to refer the complete list of available commands, you can refer Redis commands <a href="https://redis.io/commands">here</a>.</p><ol><li><strong>STRING:</strong></li></ol><p>We store STRING as a value of a key(ID) as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*IZwakfisVBrXmZRJdOM4UQ.png" /></figure><p>We have three widely used commands for STRING data types.</p><blockquote><strong>SET</strong> : Sets the value stored for the given key</blockquote><blockquote><strong>GET</strong> : Retrieves the data stored at the given key</blockquote><blockquote><strong>DEL</strong> : Deletes the value stored at the given key</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07f9fa38136803c719ca837eae27b8fb/href">https://medium.com/media/07f9fa38136803c719ca837eae27b8fb/href</a></iframe><p><strong>2. LIST:</strong></p><p>Redis supports <a href="https://en.wikipedia.org/wiki/Linked_list">linked-list</a> structure and offers all the basic commands(LPUSH, RPUSH, LPOP, RPOP etc) we expect with a linked-list. We can consider values as a list of items. Please note, lists can have duplicate items in value as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*t7vfurGRattRnQprFUH_6Q.png" /></figure><p>Following commands are widely used for Redis LIST:</p><blockquote><strong>RPUSH : </strong>Push item on right side of list/initialize a list</blockquote><blockquote><strong>LPUSH : </strong>Push item on left side of list/initialize a list</blockquote><blockquote><strong>LPOP : </strong>Pop an item from left side of list</blockquote><blockquote><strong>RPOP : </strong>Pop an item from right side of list</blockquote><blockquote><strong>LRANGE</strong> : Fetches all the data from a list for a given range of index</blockquote><blockquote><strong>LINDEX</strong> : Fetches data from a list at a given index</blockquote><p><strong>TIP:</strong> All commands starts with <strong>L</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/98d680ddc2038025fc088f9e05890d99/href">https://medium.com/media/98d680ddc2038025fc088f9e05890d99/href</a></iframe><p><strong>3. SET:</strong></p><p>SET is very similar LIST, but the <strong>items in a SET has to be unique.</strong> SETs stores a set of items in un-ordered fashion. Thus, we can’t have PUSH or POP commands with SETs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*AaUDQbMqxYTYRRMVvWn_GQ.png" /><figcaption><strong>Redis SET</strong></figcaption></figure><p>Following commands are widely used for Redis SET:</p><blockquote><strong>SADD : </strong>Add an item to SET/initialize SET</blockquote><blockquote><strong>SMEMBERS : </strong>Fetches all items for a key in SET</blockquote><blockquote><strong>SISMEMBER : </strong>Checks if an item is in a SET</blockquote><blockquote><strong>SREM : </strong>Removes an item from SET, if exists</blockquote><p><strong>TIP:</strong> All commands starts with <strong>S</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a72d5b790cf91bca34f1ed09a75ca29/href">https://medium.com/media/5a72d5b790cf91bca34f1ed09a75ca29/href</a></iframe><p><strong>4. HASH</strong></p><p>Hash is one of the most widely used data structure in Ruby. LIST and SET stores the sequence of items, whereas Redis HASH gives us a true flavor of Hashes(Dictionary) we use in our day to day programming.</p><p><strong>NOTE:</strong> <strong>1.</strong> Even HASH are stored with a KEY identifiers. You can think of it as ID or variable name to hold the HASH. In Ruby we define a HASH variable as:</p><blockquote>2.4.0 :001 &gt; my_hash = { key1: ‘value1’, key2: ‘value2’ }<br> =&gt; {:key1=&gt;”value1&quot;, :key2=&gt;”value2&quot;}<br>2.4.0 :002 &gt; my_hash[:key1]<br> =&gt; “value1”</blockquote><p>This variable my_hash is the variable, which holds the HASH. Similarly, in Redis, we define HASH with a name(Main key) and add the sub key-value pair to this HASH.</p><p><strong>NOTE: 2. </strong>The value of sub key-value (i.e. actual hash) is always a String. Though it can be interpreted as numbers and can be incremented/decremented.</p><p>Following commands are widely used for Redis HASH:</p><blockquote><strong>HSET </strong>: Stores the value at the key for a given hash/initializes a HASH</blockquote><blockquote><strong>HGET </strong>: Retrieves the value at a given hash key for a given HASH</blockquote><blockquote><strong>HGETALL </strong>: Retrieves the entire HASH for a given HASH name</blockquote><blockquote><strong>HDEL </strong>: Deletes a key from a given hash, if it exists</blockquote><p><strong>TIP:</strong> <a href="https://redis.io/commands#hash">All commands</a> for HASH starts with <strong>H</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16c0040cb315d8887ba66111c17ac5e6/href">https://medium.com/media/16c0040cb315d8887ba66111c17ac5e6/href</a></iframe><p><strong>5. ZSET or Ordered SET</strong></p><p>ZSET is an ordered key-value pair data-structure. The keys are called members and the values(limited to floating point numbers) are called scores. Think of this as class rooms in a school. Class 1(Main Key for ZSET) has many members (students). Each student scored between 0 to 100 in Math tests. You can add/remove students from the Class 1. You can fetch all the students for a given score range.</p><p>A few commands which can be used with ZSET:</p><blockquote><strong>ZADD </strong>: Add one/more member for a given score to ZSET/initialize a ZSET with one/more member</blockquote><blockquote><strong>ZRANGE </strong>: Fetches all the items in the ZSET from their position in sorted order</blockquote><blockquote><strong>ZRANGEBYSCORE </strong>: Fetches items in the ZSET based on range of scores</blockquote><blockquote><strong>ZREM </strong>: Removes an item from the ZSET, if exists</blockquote><p><strong>TIP:</strong> <a href="https://redis.io/commands#sorted_set">All commands</a> for ZSET starts with <strong>Z</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f265362049737467c09c29e7c0812a22/href">https://medium.com/media/f265362049737467c09c29e7c0812a22/href</a></iframe><p>As you can see, ZSET gives us a lot of abilities for Ranking, Querying and perform basic CRUD over ordered dataset.</p><p>With these data-types, you can perform a gamut of operations. Due to this variety of data-types, Redis is preferred tool for caching tool for many developers.</p><h3>Persistence:</h3><p>Since Redis is in-memory database, you might worry about the situation, when your server gets down. Redis offers two ways to persist your data:</p><ol><li>Dumping in-memory data to disk in compact format.</li><li>Write/append a file with every commands which alters the data on Redis</li></ol><p>Hope you enjoyed this post. In future series, I’ll build a few application, where you can utilize these data-types in real.</p><p><strong>References:</strong></p><ol><li><a href="https://redis.io/">Redis Website</a></li><li><a href="https://redislabs.com/resources/ebook/">Redis in Action</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed55578f36d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/getting-started-with-redis-i-ed55578f36d1">Understanding Redis Abstract Data types and it’s usages Part — I</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step by step guide to integrating DynamoDB with Ruby on Rails Application — I]]></title>
            <link>https://medium.com/faodail-technology/step-by-step-guide-to-using-dynamodb-with-rails-application-i-a676cb9ba4df?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/a676cb9ba4df</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Chandan Jhunjhunwal]]></dc:creator>
            <pubDate>Thu, 18 May 2017 20:03:04 GMT</pubDate>
            <atom:updated>2017-05-19T07:25:39.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uv8pKncDfahZH5l4N5ZodQ.png" /><figcaption>DynamoDB with Rails</figcaption></figure><p>A typical <a href="http://rubyonrails.org/">Ruby on Rails</a> application comes with ActiveRecord, which makes using RDBMS (such as MySQL, PostgreSQL etc) cake walk. There are times, when we want to leverage power of NoSQL with our Rails application. There are many NoSQL database available such as <a href="http://cassandra.apache.org/">Cassandra</a>, <a href="https://www.mongodb.com/">MongoDB</a>, <a href="https://aws.amazon.com/dynamodb/">DynamoDB</a> etc. In this tutorial we’ll explore integrating DynamoDB with Ruby on Rails.</p><h3>Prerequisites:</h3><ol><li><strong>AWS Credentials: </strong>You’ll need the AWS Access Key Id and AWS Secret Access Key. If you don’t have one, you can follow <a href="https://blog.faodailtechnology.com/step-by-step-guide-to-setting-up-aws-account-and-using-iam-policies-624894c496c9">this article</a> to create one for you.</li><li><strong>DynamoDB Setup for Development: </strong>For development purpose you might want to download DynamoDB setup from <a href="http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.Download.html">here</a>.</li></ol><p>After downloading the DynamoDB setup archive, extract it in a folder and navigate to that directory. To run the local DynamoDB instance, execute the following command on your terminal:</p><blockquote>$&gt; java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -inMemory</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v50RAdBmbFPoaUuc6pHT5A.png" /><figcaption>Running DynamoDB on local Machine</figcaption></figure><blockquote><strong>Important Notes:</strong> <br>1. To run DynamoDB on your computer, you’ll need Java Runtime Environment (JRI) version 6.x or newer. <br>2. DynamoDB uses port 8000 by default. If the port 8000 is unavailable, you can use <strong>-port </strong>option to assign another port. <br>3. For all available options, refer AWS documentation <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html#DynamoDBLocal.CommandLineOptions">here</a>.</blockquote><blockquote>4.<strong>You don’t need AWS Credentials to run a local DynamoDB instance. But, you’ll certainly need one to use AWS DynamoDB Web service.</strong></blockquote><h3>Step 1: Install AWS-SDK</h3><p>AWS provides a really nice SDK for for Ruby as <a href="https://github.com/aws/aws-sdk-ruby"><em>aws-sdk</em> gem</a>. Add <em>aws-sdk </em>in your <em>Gemfile </em>and execute <em>bundle install</em></p><blockquote><strong>gem ‘aws-sdk’, ‘~&gt; 2’ # Add this line to your Gemfile</strong></blockquote><blockquote>$&gt; <strong>bundle install</strong></blockquote><h3>Step 2: Configure DynamoDB Client</h3><p><strong>I. Firstly, we’ll need to setup AWS credentials. We must not commit AWS Credentials inside our code repository. </strong>Instead we can use <em>secrets.yml</em> as shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc89adf70456fadf61d3c56ab6f2fe16/href">https://medium.com/media/bc89adf70456fadf61d3c56ab6f2fe16/href</a></iframe><blockquote>Ensure you’ve right AWS credentials available as <em>Environment Variables</em> on your remote server instance. You can setup these environment variables manually or via some tools.</blockquote><blockquote><strong>DYNAMODB_ACCESS_KEY_ID</strong></blockquote><blockquote><strong>DYNAMODB_SECRET_ACCESS_KEY</strong></blockquote><blockquote><strong>DYNAMODB_REGION</strong></blockquote><p><strong>Tip:</strong> One tool I’ve been using lately to setup environment variables is <a href="https://github.com/bkeepers/dotenv">dotenv-rails</a>. With dotenv-rails, the <em>.env</em> file which is used to setup these variable, will look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*0ZPKwtqSxFiwUQE5xuDGiA.png" /><figcaption>.env file with Environment Varilables</figcaption></figure><p><strong>II. Second, we need to create a DynamoDB client.</strong> Create a dynamodb_client.rb file inside config/initializers. Since we want to connect to local DynamoDB in development environment and to the AWS DynamoDB web service in test/staging/production environment. So the dynamodb_client.rb will be:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/841d9876f64b07db40c100d249ddc7f1/href">https://medium.com/media/841d9876f64b07db40c100d249ddc7f1/href</a></iframe><p>Please note that, instead of creating a new instance of client for each AWS service call, I’m using a class variable for client, which will be initialized only once(singleton behavior) at the time of application boot. Now we can access our DynamoDB client from <em>rails console</em>. Go ahead and give it a try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*uDd5Mx2YQRUVpgF0mgBbXw.png" /><figcaption>DynamoDB Client</figcaption></figure><h3>Step 3: Creating DynamoDB table</h3><p>Since there is no explicit migration supported by Rails for NoSQL, we’ll have to create table manually. We developer are really lazy to do the manual tasks. :) So we can create rake task to do this for us.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/394f905caa3c607e91ccf4889b7e25e2/href">https://medium.com/media/394f905caa3c607e91ccf4889b7e25e2/href</a></iframe><p>Running the above rake task will create <em>activities</em> table for the current environment.</p><h3>See it in Action:</h3><p>Let’s see the whole DynamoDB setup in action via Rails console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ixSFSWwOJyCmtQSeFhWgkg.png" /><figcaption>Interacting with DynamoDB Client</figcaption></figure><p>Point (1): Setting a DynamoDB client.</p><p>Point (2): Checking the different available methods with this <em>client.</em></p><p>Point (3): <em>client.list_tables</em> shows no <em>available table</em> in console output.</p><p>Point (4): Executing rake task explained in step 3, to create a DynamoDB table.</p><p>Point (5): Now <em>client.list_tables</em> shows <em>activities</em> table in output.</p><p><strong><em>Congratulations!</em> You’ve successfully configured and used DynamoDB with your Rails Application.</strong></p><p><strong>Recommended References:</strong></p><ol><li><a href="https://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB.html">AWS Ruby SDK Documentation</a>: Complete reference of available commands</li><li><a href="http://docs.aws.amazon.com/amazondynamodb/latest/gettingstartedguide/GettingStarted.Ruby.html">AWS DynamoDB Documentation</a>: Ruby + DynamoDB simple programs</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a676cb9ba4df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/step-by-step-guide-to-using-dynamodb-with-rails-application-i-a676cb9ba4df">Step by step guide to integrating DynamoDB with Ruby on Rails Application — I</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step by step guide to setting up AWS Web services user and using IAM user policies]]></title>
            <link>https://medium.com/faodail-technology/step-by-step-guide-to-setting-up-aws-account-and-using-iam-policies-624894c496c9?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/624894c496c9</guid>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[faodail-technology]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Chandan Jhunjhunwal]]></dc:creator>
            <pubDate>Thu, 18 May 2017 15:29:19 GMT</pubDate>
            <atom:updated>2017-05-18T20:38:25.766Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*0frUaLJOAr69UbA1-AnyAw.png" /></figure><p>Amazon AWS offers a wide variety of tools as services. It has been widely used by many companies across the world. In this tutorial, we’ll learn:</p><ol><li>How to setup AWS account</li><li>How to create root credentials</li><li>How to setup IAM policies</li></ol><h3>Step 1: Creating AWS account and selecting region</h3><p>Sign up for an AWS account <a href="https://aws.amazon.com/"><em>here</em></a>. On new signup, AWS offers a lot of services in <a href="https://aws.amazon.com/free/">free-tier</a> to explore their services completely free for 1 year.</p><p><strong><em>Tip:</em></strong> Before you start using a particular service, you should select a <a href="https://aws.amazon.com/about-aws/global-infrastructure/">appropriate region</a> based on your application user base to ensure lower latency. Currently, AWS offers following regions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*lFRKhHV0OKRzss9ojwVIlw.png" /><figcaption>1. AWS Regions</figcaption></figure><h3>Step 2: Creating root credentials</h3><p>To create root credentials, go to <em>My Security Credentials </em>as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*T_QdB0UHMMdkXFzsnydNkA.png" /><figcaption>2. AWS Credential Page</figcaption></figure><p>AWS strongly recommends using IAM users. If you decide to use root credentials, you can click <em>Continue to Security Credentials:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*lFi8kSG3XAD1ehrFfzGIZw.png" /><figcaption>3. Getting AWS Root Credentials</figcaption></figure><p>To create a new Access key, click on <em>Create New Access Key </em>as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*cnoJUpb1lvo5m9UB3YOPFg.png" /><figcaption>4. Create New Access Key</figcaption></figure><p>Once you create the Root key, download and store it at a secure place. Please note, once a key is lost, there is no way to recover it. Instead, you’ll have to delete the old key and create a new access key. Also, the Root key has all kind of permission to create/update/delete any AWS services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*4fmJwlypC7Sg287gW2L87w.png" /><figcaption>5. Download AWS Access Key</figcaption></figure><p><strong><em>If you’re just experimenting with AWS services, you don’t need to setup IAM users. You can conveniently skip the next section.</em></strong></p><p>— — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><h3>Step 3: Creating IAM users</h3><p>AWS recommends IAM users, so that you can grant and revoke access to the required services to each IAM users as per your needs. Thus, ensuring limited access and more control when you’ve to distribute your keys to developers.</p><p><strong><em>Create IAM User: </em></strong>To create IAM users, you can click on <em>Get Started with IAM users </em>as shown in image <em>3.Getting AWS Root Credentials</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U4eUiRya2hkhJkRnkzwpAw.png" /><figcaption>6. Add IAM User</figcaption></figure><p>Now you can setup the following for your new IAM user:</p><ol><li>username for this IAM user</li><li>Programmatic Access: If you want AWS Access Key Id and AWS Secret Access Key(Recommended if the IAM user has to access AWS resources via these token in the application)</li><li>AWS Management Console Access: If you want to allow IAM user to AWS Management console and work with the resources they had been granted access to.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3X3g5IiU8z3FweY8yKr4Tg.png" /><figcaption>7. Setting up new IAM User</figcaption></figure><p><strong><em>Grant Permissions: </em></strong>Now you can grant permissions to the new IAM user by:</p><ol><li>Adding IAM user to a group, so that IAM user’ll will be granted all the permissions granted to the group.</li><li>Copying permissions from existing user</li><li>Attaching existing policies directly</li></ol><p>In the image below, I’ve assigned AWS S3 Full access to this IAM user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*RmdDwVcr6FjTYbRPCc3pkA.png" /><figcaption>8. Granting access to AWS Services</figcaption></figure><p>Now you can review the policies and other details of the new IAM user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*rb3kHzRvLaCFy9qFgffNgA.png" /><figcaption>9. Review IAM User</figcaption></figure><p><strong><em>Congratulations! </em></strong><em>You have created your IAM user with necessary privileges.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*9ZkI3FkhSRLmFHuXVmX33A.png" /><figcaption>10. IAM User Credentials</figcaption></figure><p>Now the new IAM user can login on AWS console using the <em>Login URL </em>as shown in image<em> 9. IAM User Credentials. </em>You can download the <em>Download.csv with </em>secret Access Key and Password and share it with your developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=624894c496c9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/step-by-step-guide-to-setting-up-aws-account-and-using-iam-policies-624894c496c9">Step by step guide to setting up AWS Web services user and using IAM user policies</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating optional protocol method in swift]]></title>
            <link>https://medium.com/faodail-technology/creating-optional-protocol-method-in-swift-e34ae7f37d52?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/e34ae7f37d52</guid>
            <category><![CDATA[protocol]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[optional-method]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Javal Nanda]]></dc:creator>
            <pubDate>Thu, 18 May 2017 05:29:03 GMT</pubDate>
            <atom:updated>2017-05-18T05:29:02.691Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are coming from Obj-C to Swift, you might have realized that there is no optional keyword available in Swift to define an optional protocol method in Swift Protocols.</p><p>We can achieve it via @objc attribute. But in this post, I will discuss the alternative way of achieving it in a purely swift way using the power of extension.</p><p>Using protocol extension we can provide a default implementation of the method we want to treat as optional. This will allow user to opt out the implementation of the method as there is a default implementation provided for it.</p><p>Let us take following example from <a href="https://github.com/javalnanda/JNDropDownMenu">JNDropDownMenu</a> library:</p><pre>public protocol JNDropDownMenuDataSource: class {<br>    func numberOfRows(in column: NSInteger, for menu: JNDropDownMenu) -&gt; Int<br>    func titleForRow(at indexPath: JNIndexPath, for menu: JNDropDownMenu) -&gt; String<br>    func numberOfColumns(in menu: JNDropDownMenu) -&gt; NSInteger<br>    func titleFor(column: Int, menu: JNDropDownMenu) -&gt; String<br>}</pre><p>In above protocol, I wanted to keep the last two methods optional. To do that I can provide a default implementation of it in the protocol extension as follow:</p><pre>public extension JNDropDownMenuDataSource {<br>    func numberOfColumns(in menu: JNDropDownMenu) -&gt; NSInteger {<br>        return 1<br>    }<br>    func titleFor(column: Int, menu: JNDropDownMenu) -&gt; String {<br>        return menu.datasource?.titleForRow(at: JNIndexPath(column: column, row: 0), for: menu) ?? &quot;&quot;<br>    }<br>}</pre><p>Due to this default implementation, you are now allowed to opt out these methods in the class conforming to this protocol and can implement it only if you want to override the default implementation and provide your own value.</p><p>Hope this helps you to achieve the optional behavior in a pure Swift way.</p><p>Happy Coding! 🙂</p><p><em>Originally posted at </em><a href="http://sharingtechbits.com/optional-protocol-method-swift/"><em>sharingtechbits.com</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e34ae7f37d52" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/creating-optional-protocol-method-in-swift-e34ae7f37d52">Creating optional protocol method in swift</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use AlamofireObjectMapper?]]></title>
            <link>https://medium.com/faodail-technology/how-to-use-alamofireobjectmapper-c0d9820779bf?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/c0d9820779bf</guid>
            <category><![CDATA[alamofireobjectmapper]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[alamofire]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Javal Nanda]]></dc:creator>
            <pubDate>Wed, 10 May 2017 13:27:39 GMT</pubDate>
            <atom:updated>2017-05-10T13:27:38.685Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are using Alamofire for Networking in Swift, this article will be helpful for you.</p><p><a href="https://github.com/tristanhimmelman/AlamofireObjectMapper">AlamofireObjectMapper</a> is an extension to Alamofire which automatically converts JSON response data into swift objects using <a href="https://github.com/Hearst-DD/ObjectMapper/">ObjectMapper</a></p><h3>Usage</h3><p>AlamofireObjectMapper can be installed via <a href="https://cocoapods.org/">Cocoapods</a> or <a href="https://github.com/Carthage/Carthage">Carthage</a></p><p>Consider following sample JSON returned from an API</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f7cd7bc4ade3e863eb15199b77b9c59/href">https://medium.com/media/6f7cd7bc4ade3e863eb15199b77b9c59/href</a></iframe><p>It returns an array of Projects along with some data relevant to it. Now I want to map this response directly to an array of custom object of type Project.</p><p>To map this response to our model class, we need our model class Project to conform to the Mappable protocol. Please find below how I defined Project model class. I have defined only relevant information I want to map.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbeeb506af8b1d6f0e2f6d6a63f62725/href">https://medium.com/media/bbeeb506af8b1d6f0e2f6d6a63f62725/href</a></iframe><p>Note: You can use this <a href="https://github.com/Ahmed-Ali/JSONExport">JSONExport</a> utility application available for mac which helps to auto-generate model classes for various formats.</p><p>AlamofireObjectMapper extension provides various ways to access response data.</p><ol><li>Directly map response to your model object if you wish to map entire response</li></ol><pre>Alamofire.request(URL).responseObject { (response: DataResponse&lt;ProjectResponse&gt;) in<br>     let projectResponse = response.result.value<br>}</pre><p>Here ProjectResponse will be your model object which will conform to the mappable protocol to map the entire response mentioned about.</p><p>2. Using <strong>Keypath</strong> to access required data. For e.g we want to access the result array. So, we can use keypath along with the <strong>responseArray </strong>function of AlamofireObjectMapper extension as follow:</p><pre>Alamofire.request(URL).responseArray(keyPath: &quot;result&quot;) { (response: DataResponse&lt;[Project]&gt;) in<br>    let projects = response.result.value<br>}</pre><p>You can find below working snippet of the function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b9164ff9ace556266c8ffc2b95c116e/href">https://medium.com/media/1b9164ff9ace556266c8ffc2b95c116e/href</a></iframe><p>Don’t get confused by `.validate()` in above code. It is Alamofire function which validates the success or failure of a request based on HTTP Code.</p><h3>AlamofireObjectMapper Vs SwiftyJSON</h3><p>Now you might be confused whether to use AlamofireObjectMapper of SwiftyJSON? In fact, you can use both together also. SwiftyJSON is still helpful for you where you don’t want to create model classes and just want to retrieve values on demand from the response for e.g. checking status, error or getting pageSize of the response.</p><p>You can find the sample project for above example over <a href="https://github.com/javalnanda/AlamofireObjectMapperSample">here</a></p><p>Do comment if you have any questions or suggestions.</p><p><em>This post was originally posted on </em><a href="http://sharingtechbits.com/how-to-use-alamofireobjectmapper/"><em>SharingTechBits</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0d9820779bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/how-to-use-alamofireobjectmapper-c0d9820779bf">How to use AlamofireObjectMapper?</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get final redirect URL in Ruby]]></title>
            <link>https://medium.com/faodail-technology/get-final-redirect-url-in-ruby-29cdf512b9f0?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/29cdf512b9f0</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[rubygems]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[finalredirecturl]]></category>
            <dc:creator><![CDATA[Chandan Jhunjhunwal]]></dc:creator>
            <pubDate>Mon, 08 May 2017 18:11:22 GMT</pubDate>
            <atom:updated>2017-05-08T20:04:33.436Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*rMd2U2Q2WSu3OfkiiopU-A.png" /><figcaption>HTTP Redirection</figcaption></figure><p>While building a web-crawler application, we faced a lot of issue of redirection. To solve this issue, we built a custom script, which can handle multiple redirection and give us final redirected url. Since there was no obvious library available on <a href="http://www.rubygems.org/">RubyGems</a> which could be utilized to solve this issue, we decided to build a gem <a href="https://github.com/indyarocks/final_redirect_url">final_redirect_url</a> and share it with everyone, so that everyone can benefit from it.</p><h4>How to use final_redirect_url gem</h4><p>Add following lines to your application Gemfile and execute <em>bundle install</em></p><blockquote><strong>gem ‘final_redirect_url’</strong></blockquote><p>Alternatively, you can install this gem using following command:</p><blockquote>gem install final_redirect_url</blockquote><p>You can find the detailed documentation on <a href="https://github.com/indyarocks/final_redirect_url">our github page</a>.</p><p>Here is the core of the logic:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d9594717642debff3212cc313384ce9/href">https://medium.com/media/1d9594717642debff3212cc313384ce9/href</a></iframe><h4>Uses examples:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92de9136b59b17808f8b7199edf14fbb/href">https://medium.com/media/92de9136b59b17808f8b7199edf14fbb/href</a></iframe><h3>Explanation:</h3><p>Let’s try to understand the basic components of the <a href="https://github.com/indyarocks/final_redirect_url">final_redirect_url</a>.</p><h4>Check if a URL is a valid URL</h4><p>To check if a supplied URL is a valid URL, we’re using Ruby <a href="https://ruby-doc.org/stdlib-2.1.1/libdoc/uri/rdoc/URI.html">URI Module</a>.</p><blockquote>url.to_s =~ /<strong>\A</strong>#{URI::regexp([‘http’, ‘https’])}<strong>\z</strong>/</blockquote><p>The above regex match will return <em>nil </em>if the URL is invalid.</p><h4><strong>Redirection Handling</strong></h4><p>Since a URL can have multiple redirection, we have a recursive method <em>get_final_redirect_url, </em>which by default will check for maximum of 10 redirections. You can provide an optional argument to go even deeper in case redirection exceeds the default 10. Lines 27–41 implements this method.</p><h4>Getting URL string from URI</h4><p>From line 43–49, we’re reconstructing the URL string using different components of a <a href="https://ruby-doc.org/stdlib-2.1.1/libdoc/uri/rdoc/URI.html">URI</a>. It’ll ensure the right scheme, host, query string and fragment of the URL.</p><h4>Exception handling</h4><p>The whole logic is encapsulated to catch any kind of error. The lines 15–16 will ensure that you get to see the exception in your logs.</p><p>We do love perfection, but at the same time, we strongly believe in not doing over-engineering unless it’s really required. Thus gem may not cover unforeseen edge-cases, but it served our purpose to fulfill the need of current application we’re building.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29cdf512b9f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/get-final-redirect-url-in-ruby-29cdf512b9f0">Get final redirect URL in Ruby</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step by step guide to building your first Ruby gem]]></title>
            <link>https://medium.com/faodail-technology/step-by-step-guide-to-publish-your-first-ruby-gem-bae3291aeab4?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/bae3291aeab4</guid>
            <category><![CDATA[open-source-software]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[rubygems]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Chandan Jhunjhunwal]]></dc:creator>
            <pubDate>Mon, 08 May 2017 04:10:11 GMT</pubDate>
            <atom:updated>2017-05-18T20:41:12.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*vDfPnrjjPBJTP1xQwLT8wA.png" /><figcaption>RubyGems</figcaption></figure><p>If you had been thinking of publishing a gem since long time, I’ll recommend stop thinking and get your hands dirty today. Even if you develop a small functionality, which can be useful to others, just go ahead and package it as a gem and share it. If you’re holding back because you feel the code can be refactored, made more modular etc, you probably won’t be able to make it.</p><p>Here is how I published my first gem <a href="https://rubygems.org/gems/final_redirect_url">final_redirect_url</a>.</p><h3>TL;DR;</h3><p>Just execute the quoted command in bold format in the detailed steps section below, and you’ll be good to go :)</p><h3>Detailed Steps</h3><p><strong><em>Prerequisites:</em></strong></p><ol><li>Ruby installation. If you don’t have one, I strongly recommend using <a href="https://rvm.io/rubies/installing">RVM package manager</a> to install one.</li><li><em>bundler</em> gem</li></ol><blockquote><strong>$ gem install bundler</strong></blockquote><p>3. A name for your new gem. I’ll use <a href="https://rubygems.org/gems/final_redirect_url">final_redirect_url</a> for the demonstration purpose.</p><h3><strong><em>STEP 1: Bootstrap your gem</em></strong></h3><p>Your new gem can be bootstrapped using following <em>bundler</em> command:</p><blockquote><strong>$ bundle gem final_redirect_url</strong></blockquote><p>Executing this command will do a heavy lifting for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*MbxEugTPW-3ykJgFH-P_ow.png" /><figcaption>Bootstrapping using bundler</figcaption></figure><p>Note the directory structure of the gem skeleton below. Also note, the VERSION of gem has a strong significance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*ces1fh4cuRksHkLzHBhF_Q.png" /><figcaption>Gem directory and VERSION</figcaption></figure><p>From <a href="http://semver.org/">Semantic Versioning</a>, Given a version number <em>MAJOR.MINOR.PATCH</em>, increment the:</p><blockquote>1. MAJOR version when you make incompatible API changes,</blockquote><blockquote>2. MINOR version when you add functionality in a backwards-compatible manner, and</blockquote><blockquote>3. PATCH version when you make backwards-compatible bug fixes.</blockquote><blockquote>Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.</blockquote><p>You should add a few details such as <em>version, authors, summary etc </em>in <em>final_redirect_url.gemspec </em>file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*hUS5Dw8Oce9ZdK6zuomLvQ.png" /><figcaption>.gemspec file</figcaption></figure><h3>STEP 2: Implement the functionality/test coverage</h3><p>This section will be mostly driven by the functionality you want to build. However, there are few caveats you must care about:</p><ol><li>Namespace your classes/modules, preferably with the same as gem</li><li>Provide a clearly defined public interface. Define internal methods as private methods.</li><li>Specify your gem’s dependencies in G<em>emfile </em>file</li><li>Update the ReadMe file with the setup and usages instructions</li></ol><p>Here is the first version of <a href="https://github.com/indyarocks/final_redirect_url">final_redirect_url</a> module:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1d9594717642debff3212cc313384ce9/href">https://medium.com/media/1d9594717642debff3212cc313384ce9/href</a></iframe><h3>STEP 3: Generate build for your Gem</h3><p>Based on the details available in <em>.gemspec </em>file, you can create an installable build using following command(from gem root directory):</p><blockquote><strong>gem build final_redirect_url.gemspec</strong></blockquote><p>You can install your gem locally by:</p><blockquote><strong>gem install ./final_redirect_url-0.1.0.gem</strong></blockquote><p>Now you can try your gem using <em>irb</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/92de9136b59b17808f8b7199edf14fbb/href">https://medium.com/media/92de9136b59b17808f8b7199edf14fbb/href</a></iframe><h3>STEP 4: Publishing your gem</h3><p>You can host your gem on your own server as well as on <a href="https://rubygems.org/">rubygems</a>. Publishing it on rubygems.org is a always a good idea if you want to share your gem publicly.</p><ol><li>Signup on <a href="https://rubygems.org/">rubygems</a></li><li>Setup your machine with the credentials:</li></ol><blockquote>chandan@ ○ ➜ <strong>curl -u indyarocks </strong><a href="https://rubygems.org/api/v1/api_key.yaml"><strong>https://rubygems.org/api/v1/api_key.yaml</strong></a><strong> &gt; ~/.gem/credentials; chmod 0600 ~/.gem/credentials</strong></blockquote><blockquote>Enter host password for user ‘indyarocks’:</blockquote><p>Do not forget to replace your username in this command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f1hsO2cUivm8nKbXkVosGQ.png" /></figure><p>Now you can publish your gem using following command:</p><blockquote><strong>$ gem push final_redirect_url-0.1.0.gem</strong></blockquote><p>You may face following error, if you did not pay attention to <a href="https://cdn-images-1.medium.com/max/800/1*hUS5Dw8Oce9ZdK6zuomLvQ.png">.gemspec</a> in STEP 1.</p><blockquote>ERROR: While executing gem … (URI::InvalidURIError)</blockquote><blockquote>bad URI(is not URI?): TODO: Set to ‘http://mygemserver.com&#39;</blockquote><p>Just comment the line as indicated in STEP 1(.gemspec file image) and you should be good to go :)</p><p>I hope you enjoyed building your first gem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bae3291aeab4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/step-by-step-guide-to-publish-your-first-ruby-gem-bae3291aeab4">Step by step guide to building your first Ruby gem</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use Xcode Code Snippet Library?]]></title>
            <link>https://medium.com/faodail-technology/how-to-use-xcode-code-snippet-library-8cd621028f0b?source=rss----c651a7400885---4</link>
            <guid isPermaLink="false">https://medium.com/p/8cd621028f0b</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[libraries]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Javal Nanda]]></dc:creator>
            <pubDate>Sun, 30 Apr 2017 09:45:51 GMT</pubDate>
            <atom:updated>2017-05-01T09:19:24.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*YmJ_m0SWBbBSzAI5YXy8ig.png" /></figure><p>Xcode Code Snippet Library is very useful and handy library of reusable code snippets.</p><p>For developers who are starting out iOS development and yet to explore all the features of Xcode, this article is for you.</p><p>Xcode Code Snippet Library is accessible from the second tab beside the Object Library from where we grab all the UI components to drag and drop on Storyboard.</p><p>It already has some pre-defined code snippets which you can simply drag and drop on your source code and use it by editing as per your needs. You can search for available snippets from the Filter search bar available at the bottom of the library.</p><p>For e.g You can use a predefined snippet for swift for statement from the library as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3b9JMBDdhpgSf1Ck5MJP8A.gif" /><figcaption>predefined code snippet from library</figcaption></figure><p>Pretty hand right? But it is not just limited to predefined snippets available in the library. You can define your own code snippet and save it inside this library.</p><p>For e.g the most used snippets we might need are table view delegate methods. Let us see how we can add them to a library:</p><p><a href="http://screencast-o-matic.com/watch/cbfblwXhB4">Adding custom code snippet to Xcode snippet library</a></p><p>As seen in above video, you can simply drag and drop the snippet on Xcode Code Snippet Library and it will prompt a window to add a name for your snippet and there you go. You created your own custom snippet to reuse later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*SDXWxVp976MKi-Q-.gif" /></figure><p>Wait! There is more to it :] Did you notice there were few other fields when you gave a name for your code snippets?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*G4QB7FtZVuUIapR9.png" /></figure><p>Double click on the snippet you just created and go to edit mode. You will see the window same as above screenshot. Here you can add more information like the summary, platform(ios, macOS, etc), Completion Shortcut and Completion Scopes.</p><p><strong>Completion Shortcut:</strong></p><p>This will help you to autocomplete your code snippet without the need of drag and drop from the library. Completion Scopes define where the completion shortcut will work. Let us see this in action based on values I have set as per above screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3b9JMBDdhpgSf1Ck5MJP8A.gif" /><figcaption>snippet auto-completion</figcaption></figure><p>As you can see, I defined the completion shortcut within Class Implementations Scope hence it is not available at Top Level scope but can be easily accessed at the class level.</p><p>If you find this useful, share with other fellow developers and spread the knowledge 🙂</p><p>Happy Coding!</p><p><em>Originally shared at </em><a href="http://sharingtechbits.com/use-xcode-code-snippet-library-speed-development/"><em>sharingtechbits</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cd621028f0b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/faodail-technology/how-to-use-xcode-code-snippet-library-8cd621028f0b">How to use Xcode Code Snippet Library?</a> was originally published in <a href="https://medium.com/faodail-technology">Faodail Technology</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>