<?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[BrewedByte - Medium]]></title>
        <description><![CDATA[Solving real world problems through programming - Medium]]></description>
        <link>https://medium.com/techintoo?source=rss----5bc5deacdd09---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>BrewedByte - Medium</title>
            <link>https://medium.com/techintoo?source=rss----5bc5deacdd09---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 13 Nov 2026 17:39:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/techintoo" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Timing wheels: how Kafka schedules millions of timers without melting]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/techintoo/timing-wheels-how-kafka-schedules-millions-of-timers-without-melting-337389a48584?source=rss----5bc5deacdd09---4"><img src="https://cdn-images-1.medium.com/max/1601/1*O30t3_ZBnlsSQcGcfWBfCA.jpeg" width="1601"></a></p><p class="medium-feed-snippet">A pinboard with 60 slots</p><p class="medium-feed-link"><a href="https://medium.com/techintoo/timing-wheels-how-kafka-schedules-millions-of-timers-without-melting-337389a48584?source=rss----5bc5deacdd09---4">Continue reading on BrewedByte »</a></p></div>]]></description>
            <link>https://medium.com/techintoo/timing-wheels-how-kafka-schedules-millions-of-timers-without-melting-337389a48584?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/337389a48584</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Thu, 07 May 2026 16:41:24 GMT</pubDate>
            <atom:updated>2026-05-07T16:41:24.647Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Demystify Shadow DOM and how to use it?]]></title>
            <link>https://medium.com/techintoo/demystify-shadow-dom-and-how-to-use-it-f2eacdefb889?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/f2eacdefb889</guid>
            <category><![CDATA[shadow-dom]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Fri, 31 Jul 2020 16:17:34 GMT</pubDate>
            <atom:updated>2019-10-22T05:47:25.860Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*MLtBzdluMmBfDxvjRkCDIA.jpeg" /></figure><p>Many of us have come across the term called Shadow DOM either in some tutorials, docs or in the latest JS frameworks. Let&#39;s demystify this today…</p><h3>What shadow dom really is?</h3><p>Shadow DOM refers to the ability of the browser to include a subtree of DOM elements into the rendering of a document, but not into the main document DOM tree. In very simple terms, <strong>“It is DOM within a DOM”</strong></p><p>Shadow DOM is a new DOM feature that helps you build components. You can think of shadow DOM as a <strong>scoped subtree</strong> inside your element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*39J_UNn6H4GolE6TI9dhEA.png" /><figcaption>Visual Representation</figcaption></figure><h3>Creating shadow DOM?</h3><blockquote>Normally, you create DOM nodes and append them as children of another element. With shadow DOM, you create a scoped DOM tree that’s attached to the element, but separate from its actual children. This scoped subtree is called a <strong>shadow tree</strong>. The element it’s attached to is its <strong>shadow host</strong>. Anything you add in the shadows becomes local to the hosting element, including &lt;style&gt;. This is how shadow DOM achieves CSS style scoping.</blockquote><h4><strong>Enough theory, lets code a shadow dom</strong></h4><p>=============================</p><p>We start by creating <strong>Shadow Root (</strong>A <strong>shadow root</strong> is a document fragment that gets attached to a “host” element )</p><pre>const div = document.createElement(&#39;div&#39;);<br>const shadowRoot = div.attachShadow({mode: &#39;open&#39;});<br>shadowRoot.innerHTML = &#39;&lt;h1&gt;This is a shadow DOM&lt;/h1&gt;&#39;;</pre><p>The value of mode key of attachShadow can be either “open” or “colsed”.</p><p>It is basically a string specifying the <em>encapsulation mode</em> for the shadow DOM tree.</p><p>Eg. If mode: “closed” , element.shadowRoot return null else it will return ShadowRoot obj.</p><h3>Use of a Shadow DOM</h3><p>As stated earlier it helps in abstracting the shadow tree from the actual tree.</p><p>Let&#39;s see how…</p><p>We have an HTML file with a div #divInDom and a ‘p’ tag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/0*JLbxT3rcNQ8-h-cz.png" /></figure><p>Now we attach a shadow room to the div #divInDom</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/60/0*s1x99RK0Y5JlUxSb" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/0*XLrAEtoeuVU14TSt.png" /></figure><p>We have added a p tag to the shadow DOM which now looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/60/0*X9adasmIlxSfoI7f" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/0*vslPFYWNcLVwkULD.png" /></figure><p>The output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/60/0*IEG2f0RAGpvr5WdV" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/0*LeaNMnMtw8SoNpQA.png" /></figure><p>Now let’s try to see the Shadow DOM in action ✨</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/60/0*iThttFXBuGk3eO_2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/207/0*VS4v0HLblUUYhTbU.png" /></figure><p>We add a style for ‘p’ tag, if you remember from above we have 2 ‘p’ tags now — one as part of the DOM and one as part of the Shadow DOM.</p><p>Let’s see what happens in the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/60/0*EcQay_p4nJBZfnP_" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/0*h9LMkPguJUt1u2TJ.png" /></figure><p>As you saw the styling did not affect the Shadow DOM element.</p><p>The reverse is also true, the styles defined within a shadow DOM do not affect the root DOM.</p><h3>Conclusion</h3><p>For the first time ever, we have an API primitive that does proper CSS scoping, DOM scoping, and has true composition. Combined with other web component APIs like custom elements, shadow DOM provides a way to author truly encapsulated components without hacks or using older baggage like &lt;iframe&gt;s.</p><p>Don’t get me wrong. Shadow DOM is certainly a complex beast! But it’s a beast worth learning. Spend some time with it. Learn it and ask questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2eacdefb889" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/demystify-shadow-dom-and-how-to-use-it-f2eacdefb889">Demystify Shadow DOM and how to use it?</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Realtime Updates With GraphQL Subscriptions ( SERVER SIDE )(V2.8)]]></title>
            <link>https://medium.com/techintoo/realtime-updates-with-graphql-subscriptions-server-side-v2-8-9781b3457173?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/9781b3457173</guid>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[graphql-apollo-server]]></category>
            <category><![CDATA[apollo]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Tue, 10 Dec 2019 09:04:50 GMT</pubDate>
            <atom:updated>2020-07-31T16:16:56.731Z</atom:updated>
            <content:encoded><![CDATA[<p>There can be many scenarios where people may want to add Real-Time feature to their project.</p><p>Consider below scenario —</p><p>You are building a realtime news feed that updates data whenever there is any change or addition without refreshing the whole page.</p><h3>Main Implementation Idea</h3><p>The main technology used for this purpose is Websocket. They allow a long-held single TCP socket connection to be established between the client and server which allows for bi-directional, full-duplex, messages to be instantly distributed with little overhead resulting in a very low latency connection.</p><h3>Enough Theory! Let&#39;s implement it</h3><ul><li>We are mainly using ApolloServer version 2.9 that is the latest while writing this blog.</li><li>As there are many breaking changes from ApolloServer version 1.* to version 2.*, this implementation may not work in older Apollo version ( &lt; 2.*)</li></ul><p>Let&#39;s add important package first</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a850aa760ce6fa13424f59c091d5e852/href">https://medium.com/media/a850aa760ce6fa13424f59c091d5e852/href</a></iframe><p>Now we will add a simple type definition</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/21a60565e4fbcc8e1efb489a7fa894e7/href">https://medium.com/media/21a60565e4fbcc8e1efb489a7fa894e7/href</a></iframe><p>Let’s add the resolver now</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e82c986af19adca230d64611ef5c4567/href">https://medium.com/media/e82c986af19adca230d64611ef5c4567/href</a></iframe><p>Here comes the final piece of code that starts the server with WebSocket based subscription</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/963867d0f2e30243f615cb226445f548/href">https://medium.com/media/963867d0f2e30243f615cb226445f548/href</a></iframe><p>This configuration creates a GraphQL server with Mutation, Query and Subscription. It also creates a WebSocket connection automatically that typically opens a connection on this address <a href="http://localhost:4000/graphql">ws://localhost:4000/graphql</a></p><h4>Full Code Here</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ca382218e8eec806a339b87003f1644/href">https://medium.com/media/4ca382218e8eec806a339b87003f1644/href</a></iframe><h3>PubSub Implementations</h3><p>The Apollo Server implementation of PubSub can be replaced by another implementations of <a href="https://github.com/apollographql/graphql-subscriptions/blob/master/src/pubsub-engine.ts">PubSubEngine interface</a>. The community has created the following integrations:</p><ul><li><a href="https://github.com/davidyaha/graphql-redis-subscriptions">Redis</a></li><li><a href="https://github.com/axelspringer/graphql-google-pubsub">Google PubSub</a></li><li><a href="https://github.com/davidyaha/graphql-mqtt-subscriptions">MQTT enabled broker</a></li><li><a href="https://github.com/cdmbase/graphql-rabbitmq-subscriptions">RabbitMQ</a></li><li><a href="https://github.com/ancashoria/graphql-kafka-subscriptions">Kafka</a></li><li><a href="https://github.com/GraphQLCollege/graphql-postgres-subscriptions">Postgres</a></li><li><a href="https://github.com/MrBoolean/graphql-firestore-subscriptions">Google Cloud Firestore</a></li><li><a href="https://github.com/apollographql/apollo-server/pull/new/master">Add your implementation…</a></li></ul><p>You can implement a PubSub of your own, using the exported PubSubEngine interface from apollo-server or another integration.</p><p>Check below link for more details</p><p><a href="https://www.apollographql.com/docs/apollo-server/data/subscriptions/">Subscriptions in Apollo Server</a></p><p>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9781b3457173" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/realtime-updates-with-graphql-subscriptions-server-side-v2-8-9781b3457173">Realtime Updates With GraphQL Subscriptions ( SERVER SIDE )(V2.8)</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</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 Pass The AWS Certified Developer Associate Exam]]></title>
            <link>https://medium.com/techintoo/how-to-pass-the-aws-certified-developer-associate-exam-57588d558ade?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/57588d558ade</guid>
            <category><![CDATA[aws-certification]]></category>
            <category><![CDATA[aws-certified-developer]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 20:08:27 GMT</pubDate>
            <atom:updated>2019-03-10T20:11:00.135Z</atom:updated>
            <content:encoded><![CDATA[<h3>Pass The AWS Certified Developer Associate Exam</h3><h4>Recently passed the AWS Certified Developer — Associate exam (June 2018 version) on March 8th, 2019 with 891 marks.</h4><p>No Doubt AWS CDA (June 2018) is one of the most valuable cloud certifications for developers. But wait! It’s not so easy at all to pass it without proper preparation. It’s full of tricky, scenario based questions.</p><p>From the June 2018 version, they made the certification exam in a way that whoever passes the exam, has sound knowledge on AWS Services and Best Practices.</p><p>It validates an examinee’s ability to:</p><ul><li>Demonstrate an understanding of core AWS services, uses, and basic AWS architecture best practices.</li><li>Demonstrate proficiency in developing, deploying, and debugging cloud-based applications using AWS.</li></ul><p>Earlier, people used to get a lot of marks in the AWS CDA exam. But it’s not happening now because AWS Exam paper setters restricted the certification to those who really understand AWS and its components properly.</p><p>Being certified recently with good marks, I will love to share my experience and tips that might help you to pass the exam in a single attempt.</p><p>— — — — — — — — — — — — — — — —</p><h4>Preparing for the exam</h4><p>I started studying for the certification from <strong><em>acloud.guru </em></strong>website. It gave me important understandings on exam topics as well as practical labs on many important AWS Service. But then I realized, tutorial given by <strong><em>acloud.guru</em></strong> was not enough to pass the exam as they are full of tricky questions.</p><p>I started searching a good exam preparation course on Udemy and found one made by Stephane. It helped me clarify my concept with respect to the new exam version.</p><p>But prior to that, I have used AWS for more than 1.5 years, so I must say developing live projects with AWS services helped me a lot.</p><p>So, it will be always my first recommendation to use AWS as much as you can with its security best practices kept in mind.</p><p>I have also given many practice tests, tried flashcards and quiz.</p><h4>Important topics of the exam</h4><ul><li>Study and practice S3, DynamoDB, SQS, KMS, Beanstalk, lambda a lot</li><li>Understand SQS with visibility timeouts, message delivery, errors and security</li><li>SQS limits and long polling</li><li>Practice CloudFormation</li><li>Remember CodeDeploy and CodeBuild hooks</li><li>Concepts of ALB, NLB, and ASG with EC2 and Beanstalk</li><li>Optimizing DynamoDB and S3 queries for performance</li><li>Dynamo partition keys, local/global secondary indexes</li><li>Understand Beanstalk and it’s best practices</li><li>S3 CORS and encryption</li><li>S3 limits and important APIs</li><li>Use of Kinesis Stream and Kinesis Firehose</li><li>Kinesis shards and how to optimize them.</li><li>IAM users, groups, roles, and inline policies</li><li>Different methods of restricting access to resources (policies, ACLs)</li><li>HTTP error codes (4xx, 5xx)</li><li>Web identity federation, User Pool, Identity Pool, and STS</li><li>Encryption mechanism (SSE, KMS, Client Side Encryptions, In Flight Encryption)</li><li>EBS basics</li><li>Understand the concept of SAM (Serverless Application Model)</li></ul><h4>You might skip (If you do not have enough time)</h4><ul><li>EC2 instance types</li><li>Questions on every single AWS service (focus on the main ones)</li><li>EC2 options (Reserved, On-Demand, Spot, Dedicated-Host)</li><li>OLTP (Online Transaction Processing) vs OLAP (Online Analytic Processing)</li><li>Questions about shared responsibility</li><li>Complex questions on setting up Route53</li><li>Complex questions on Network Load Balancers</li><li>CloudFormation template ()configuration in advance (Just study important keys like Resources, parameters, Intrinsic Functions etc.)</li><li>S3 storage tiers (Glacier, Infrequently Accessed, RRS) and Snowball</li><li>S3 storage gateways</li><li>EBS storage types</li><li>In-depth RDS Questions</li></ul><h4>What you must know about</h4><p>In addition to the above tips, you should also practice provision <strong>EC2+EBS </strong>instances of your own with various options and security best practices, <strong>Security Groups</strong> and how they control connection and network flow in a VPC.</p><p>Deploy your own configuration with <strong>Beanstalk</strong> and provision EC2 instance and <strong>Docker Container</strong> with the help of <strong>ECR</strong> and <strong>ECS</strong> and also remember what are the resources that Beanstalk can provision.</p><p>Remember how to calculate read and write throughput (<strong>RCU</strong>, <strong>WCU</strong>) for DynamoDB.</p><p>Practice encryption with API gateway, Lambda, S3, Beanstalk, DynamoDB, EBS, SQS with the help of KMS, SSL/HTTPS</p><p>Remember important API calls of S3, SQS, Beanstalk, STS, KMS, ECS</p><h4><strong>Wrapping up tips</strong></h4><p>— — — — — — — — — — — -</p><ol><li>Take good rest at night before the exam</li><li>Don’t be nervous even if you see tricky questions</li><li>Prepare notes to refer before the exam</li><li>Read AWS FAQ and White Papers</li><li>Give practice tests</li><li>There are no negative marking, so answer all</li><li>Start by eliminating wrong answers</li><li>If you see questions with more than one correct answer, think of best practice and cost efficiency</li><li>If you have practiced well and invested time, be confident as its not hard at all to pass if you know basic concepts</li></ol><p><strong><em>Take a look at AWS certification website</em></strong></p><p><a href="https://aws.amazon.com/certification/certified-developer-associate/">AWS Certified Developer - Associate Certification</a></p><p>And all the best for your exam :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57588d558ade" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/how-to-pass-the-aws-certified-developer-associate-exam-57588d558ade">How To Pass The AWS Certified Developer Associate Exam</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Prototypal inheritance in Javascript]]></title>
            <link>https://medium.com/techintoo/prototypal-inheritance-in-javascript-4b1efbdc893b?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/4b1efbdc893b</guid>
            <category><![CDATA[prototype]]></category>
            <category><![CDATA[inheritance]]></category>
            <category><![CDATA[oopjs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 13:38:42 GMT</pubDate>
            <atom:updated>2019-01-09T05:28:38.790Z</atom:updated>
            <content:encoded><![CDATA[<p>In programming we often want to take something and extend it.Inheritance in javascript is long discussed feature as we know javascript was lacking behind fully featured object oriented Programming Patterns.</p><p>However javascript gives as many powerful object oriented programming patterns, prototype inheritance is one of them.</p><h4>What is PROTOTYPE in JS ?</h4><p>Almost all objects in JavaScript have the <em>prototype</em> property. By using it and more specifically the <em>prototype chain </em>we can <em>mimic</em> inheritance.</p><p><em>The prototype is a reference to another object and it is used whenever JS can’t find the property you’re looking for on the current object.</em></p><h4>Prototypal Inheritance</h4><p>Suppose we have an object called <strong><em>users</em></strong><em> </em>with all its properties and methods and there are <strong>student</strong> and <strong>teacher</strong> that is slightly different from it, not copy/reimplement its methods, just build a new object on top of it.</p><p><em>Prototypal inheritance</em> is a language feature that helps in that.</p><h3><a href="https://javascript.info/prototype-inheritance#prototype">[[Prototype]]</a></h3><p>In JavaScript, objects have a special hidden property [[Prototype]] (as named in the specification), that is either null or references another object. That object is called “a prototype”.</p><p>When we want to read a property from object, and it’s missing, JavaScript automatically takes it from the prototype.In programming, such thing is called “<em>prototypal inheritance</em>”. Many cool language features and programming techniques are based on it.</p><p>The property [[Prototype]] is internal and hidden, but there are many ways to set it.</p><p>One of them is to use __proto__, like this:</p><pre>let users = {<br>  alive: true<br>};<br>let teachers = {<br>  class_admin: true<br>};<br><br>teachers.__proto__ = users;</pre><p>Please note that __proto__ is <em>not the same</em> as [[Prototype]]. That’s a getter/setter for it. We’ll talk about other ways of setting it later, but for now __proto__ will do just fine.</p><p>If we look for a property in teachers, and it’s missing, JavaScript automatically takes it from users.</p><pre>et users = {<br>   alive: true<br>};<br>let teachers = {<br>  class_admin: true<br>};<br><br>teachers.__proto__ = users;<br><br>// we can find both properties in teachers now:<br>alert( teachers.alive ); // true<br>alert( teachers.class_admin ); // true</pre><h3>The value of “this”</h3><p>That is actually a super-important thing, because we may have a big object with many methods and inherit from it. Then we can run its methods on inherited objects and they will modify the state of these objects, not the big one.</p><p>For instance, here animal represents a “method storage”, and rabbit makes use of it.</p><h3>Summary</h3><ul><li>In JavaScript, all objects have a hidden [[Prototype]] property that’s either another object or null.</li><li>We can use obj.__proto__ to access it (there are other ways too, to be covered soon).</li><li>The object referenced by [[Prototype]] is called a “prototype”.</li><li>If we want to read a property of obj or call a method, and it doesn’t exist, then JavaScript tries to find it in the prototype. Write/delete operations work directly on the object, they don’t use the prototype (unless the property is actually a setter).</li><li>If we call obj.method(), and the method is taken from the prototype, this still references obj. So methods always work with the current object even if they are inherited.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b1efbdc893b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/prototypal-inheritance-in-javascript-4b1efbdc893b">Prototypal inheritance in Javascript</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image Lazy Loading]]></title>
            <link>https://medium.com/techintoo/image-lazy-loading-562156838a1?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/562156838a1</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[lazy-loading]]></category>
            <category><![CDATA[image-loading]]></category>
            <category><![CDATA[vue]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 13:38:34 GMT</pubDate>
            <atom:updated>2019-01-15T11:51:13.315Z</atom:updated>
            <content:encoded><![CDATA[<h3>Image Lazy Loading in Vue With Plain JS</h3><p>We often use images in our website. Typically in e-commerce websites use list of images with long scroll. In most of the cases these images come with heavy weight and size that ends up slowing down DOM load speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oZrTbt6XBQisC59bmNBffA.png" /><figcaption>Image Loading Example</figcaption></figure><p>This is an example of uneven image loading that can lead to bad user experience.</p><p>In this type of scenario we load all the images in the page at a time and this leads to bad site performance.</p><p>Fortunately, lazy loading is a solution that lowers initial page payload <em>and</em> load time, but doesn’t skimp on content.</p><h3>What is lazy loading?</h3><p>Lazy loading is technique that defers loading of non-critical resources at page load time. Instead, these non-critical resources are loaded at the moment of need. Where images are concerned, “non-critical” is often synonymous with “off-screen”.</p><p>An example of lazy image loading can be found on the popular publishing platform <a href="https://medium.com/">Medium</a>, which loads lightweight placeholder images at page load, and replaces them with lazily-loaded images as they’re scrolled into the viewport.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DBV0rf1m6CjzQSKRwjMW8Q.jpeg" /></figure><h3>Ways of Lazy loading images with Plain JS</h3><p>There are two vanilla js ways to implement lazy load images</p><ol><li>Intersection Observer</li><li>Using Event Handlers ( most compatible way )</li></ol><p>We will talk about the second method because this is most compatible way and can be used in all browsers.</p><h4>Lazy Loading Images with event handler in Vue Component</h4><p>In this mechanism we check if the image component is in viewport on every scroll. We use a method called <a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect"><em>getBoundingClientRect</em></a><em> </em>to check the above use case.</p><p>Add an image tag in your component with class name eg. class=”lazy”.</p><pre>&lt;img src=&quot;/images/place-holder.png&quot; class=&quot;lazy&quot; data-src=&quot;real-image.png&quot;/&gt;</pre><p>The <strong><em>src</em></strong> property initially holds a placeholder image that is very small in size. The <strong><em>data-src </em></strong>property holds the actual image. On page load the placeholder image is loaded not the image that is defined in data-src.</p><p>Now we will check if our image component reaches the viewport or not. For this we will use <strong><em>window scroll event listener</em></strong>. Scroll event listener should be initialised on dom load that in our <strong><em>mounted</em></strong> method.</p><p>See below code…</p><pre>mounted() {<br>  window.scrollTo(0, 0);<br>  window.addEventListener(&quot;scroll&quot;, <strong>this</strong>.lazyLoad);<br>},</pre><p>Now lets write the main logic</p><pre>methods: {<br>  lazyLoad: <strong>function </strong>() {<br>    <strong>let </strong>lazyImages = [].slice.call(document.querySelectorAll(&quot;img.lazy&quot;));<br>    <strong>let </strong>active = <strong>false</strong>;<br>    <strong>if </strong>(active === <strong>false</strong>) {<br>      active = <strong>true</strong>;<br>      setTimeout(() =&gt; {<br>        lazyImages.forEach(<strong>function </strong>(lazyImage) {<br>          <strong>if </strong>((lazyImage.getBoundingClientRect().top &lt;= window.innerHeight &amp;&amp; lazyImage.getBoundingClientRect().bottom &gt;= 0) &amp;&amp; getComputedStyle(lazyImage).display !== &quot;none&quot;) {<br>            lazyImage.src = lazyImage.dataset.src;<br>            lazyImage.classList.remove(&quot;lazy&quot;);<br>            lazyImages = lazyImages.filter(<strong>function </strong>(image) {<br>              <strong>return </strong>image !== lazyImage;<br>            });<br><br>            <strong>if </strong>(lazyImages.length === 0) {<br>              window.removeEventListener(&quot;scroll&quot;, <strong>this</strong>.lazyLoad);<br>            }<br>          }<br>        });<br>        active = <strong>false</strong>;<br>      }, 200)<br><br>    }<br>  },<br>}</pre><p>This code uses getBoundingClientRect in a scroll event handler to check if any of img.lazyelements are in the viewport. A setTimeout call is used to delay processing, and an active variable contains the processing state which is used to throttle function calls. As images are lazy loaded, they&#39;re removed from the elements array. When the elements array reaches a length of 0, the scroll event handler code is removed.</p><p>That is pretty much it. You can even use intersectionObserver to get same result but make sure your browser supports it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=562156838a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/image-lazy-loading-562156838a1">Image Lazy Loading</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting Up Auth0 with React+NextJS]]></title>
            <link>https://medium.com/techintoo/setting-up-auth0-with-react-nextjs-4346c303bb5b?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/4346c303bb5b</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[auth0]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 13:38:25 GMT</pubDate>
            <atom:updated>2019-01-18T05:28:47.304Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Authenticating a user in a single page can be complicated for developers. They might need to create auth tokens, refresh tokens over time, fraud detection, using multiple openID providers like Google or GitHub and much more.</blockquote><p>To avoid these complications we can use <a href="https://auth0.com/"><strong><em>Auth0</em></strong></a>, an AAS or Authentication as Service provider and make our life easier while logging in or registering the user.</p><p>We will create a simple boilerplate step by step using <em>React+NextJS</em> and implement an authentication mechanism using <em>Auth0. </em>So lets start…</p><p>Let’s start by <a href="https://auth0.com/"><em>Logging in / Registering to Auth0</em></a><em> by clicking </em><a href="https://auth0.com/"><em>here</em></a><em>.</em></p><p>Now while you are in dashboard page, click on <strong>New Application </strong>on<strong> </strong>top right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q1k5jEDANm1yR1G1SVIozw.png" /></figure><ul><li>Give a name to your app (MyTestApp)</li><li>Choose application type as <strong>Single Page Web App</strong></li><li>Click CREATE Button</li></ul><p>Great! Your Auth0 App is created</p><p>Now lets configure auth0 dashboard for our App</p><ol><li>Give a name to your app eg. MyTestApp</li><li>Application Type : Single Page Application</li><li>Allowed Callback Url : <a href="http://localhost:3000/auth/callback">http://localhost:3000/auth/callback</a></li><li>Allowed Web Origins : <a href="http://localhost:3000/">http://localhost:3000</a></li><li>Copy the client id</li><li>Save Changes</li></ol><p>Now lets write the code with React+Next</p><p>Lets start with installing <a href="https://www.npmjs.com/package/create-next-app"><strong><em>create-next-app</em></strong></a><strong><em> in </em></strong>terminal</p><pre>npm install -g create-next-app</pre><pre>create-next-app MyTestApp</pre><pre>cd MyTestApp/</pre><pre>npm run dev</pre><p>This will start a node server on port 3000 by default. You can click <a href="http://localhost:3000/"><strong><em>here</em></strong></a> to see your project running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*ToOeo4RTS04GXP4POxcGww.png" /><figcaption>Final Project Boilerplate Folder Structure</figcaption></figure><p>The folder structure created by next itself. You can <a href="https://nextjs.org/"><em>see details here</em></a>. The code for this section will be available in github.</p><p>We need to change the component <strong><em>nav.js</em></strong> little bit. Here the code…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd1d978578a94b5b655a6da3f08745a2/href">https://medium.com/media/fd1d978578a94b5b655a6da3f08745a2/href</a></iframe><p>The above file should be created by nextJS cli. If not, you can clone my repo.</p><p>Update the existing code and add a button where user will click and login. Button should have an event handler for clicks, we will add an <em>onClick </em>event handler and trigger a function called <em>handleLogin</em>.</p><blockquote>&lt;a onClick={()=&gt;this.handleLogin()}&gt;Login / Register&lt;/a&gt;</blockquote><p>I have used an es6 method so that <strong>it binds ‘this’</strong> with the function.</p><p>Now lets create auth function in side folder called ‘<strong><em>lib’</em></strong></p><p>Lets first download the authjs code as our dependency</p><blockquote>npm install — save auth0-js</blockquote><p>We also need jwt-decode to decode the jwt token sent by auth0 service</p><blockquote>npm install — save jwt-decode</blockquote><p>Lets create a file inside /lib/Auth.js that will contain all our business logic. Below is the code…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16db05b7c6eb0ffa4d52ebc4e48acadb/href">https://medium.com/media/16db05b7c6eb0ffa4d52ebc4e48acadb/href</a></iframe><p>After success login “handleAuthentication()” will be called where token will be parsed from url hash and save it in localstorage.</p><p>Now we need to set the credentials that we got <strong><em>Auth0 Dashboard.</em></strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe75de445fbfc93ab0266d6977f2e7fe/href">https://medium.com/media/fe75de445fbfc93ab0266d6977f2e7fe/href</a></iframe><p>This file location should be /lib/auth0-variables.js</p><p>All these values will be available in Auth0 application section&gt;Settings</p><p>Now we will create the callback page. This is a page where users are redirected once they are successfully signed in. Check the code below…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bca90172330ea9f8fff6c8ca10569a10/href">https://medium.com/media/bca90172330ea9f8fff6c8ca10569a10/href</a></iframe><p>The above should be inside /pages/auth/callback.js. If you change the location, you might need to change redirection url under auth0 dashboard.</p><p>In callback.js we call handleAuthentication() function which is inside /lib/Auth.js, which will extract auth token, auth state and accessToken from url hash and verify them. If verified, we will store <strong>user_details</strong> ( Decoded from token ) and<strong> isLoggedIn = true </strong>in<strong> localStorage.</strong></p><p>Finally we will create a page called secure_page.js, which will be a secure page where user can enter only when logged in. Below is the code…</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/942a95a5ef54612b60580124ce1cd621/href">https://medium.com/media/942a95a5ef54612b60580124ce1cd621/href</a></iframe><p>We will check if the user is logged in or not by validating <strong><em>user_details</em></strong> and <strong><em>isLoggedIn </em></strong>from<strong><em> </em></strong>localStorage. If not validated we will redirect user to home page.</p><p>That is pretty much it… If you want complete code, here is the <a href="https://github.com/Subhajit1993/Auth0-NextJS.git"><strong><em>github url</em></strong></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4346c303bb5b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/setting-up-auth0-with-react-nextjs-4346c303bb5b">Setting Up Auth0 with React+NextJS</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Memoization in Javascript]]></title>
            <link>https://medium.com/techintoo/memoization-in-javascript-462645e2c58?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/462645e2c58</guid>
            <category><![CDATA[fibonacci]]></category>
            <category><![CDATA[memoization]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 13:38:09 GMT</pubDate>
            <atom:updated>2019-02-04T16:05:28.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iadxGDx-8Cp7Ckuh-4bN2g.jpeg" /></figure><p>Functions can use objects to remember the results of previous operations, making it possible to avoid unnecessary work. This optimisation is called <strong><em>memoization</em></strong>. JavaScript’s objects and arrays are very convenient for this.</p><p>Let’s understand this by writing a programme to compute a fibonacci numbers.</p><pre>var fibonacci = function (n) {<br>    return n &lt; 2 ? n : fibonacci(n − 1) + fibonacci(n − 2);<br>};<br><br>for (var i = 0; i &lt;= 10; i += 1) {<br>    console.log(&#39;// &#39; + i + &#39;: &#39; + fibonacci(i));<br>}</pre><blockquote>In the above scenario, the computation of fibonacci is not optimised because the <em>fibonacci </em>function is executed more than required times.</blockquote><blockquote>It is called by us 11 times inside the for loop and all the times by itself returning values that were probably already recently computed.</blockquote><p>We will keep our memoized results in a memo array that we can hide in a closure. When our function is called, it first looks to see if it already knows the result.If it does, it can immediately return it:</p><pre>var fibonacci = (function (  ) {<br>    var memo = [0, 1];<br>    var fib = function (n) {<br>        var result = memo[n];<br>        if (typeof result !== &#39;number&#39;) {<br>            result = fib(n − 1) + fib(n − 2);<br>            memo[n] = result;<br>        }<br>        return result;<br>    };<br>    return fib;<br>}( ));</pre><p>In this case, functions will be called by itself only 29 times and 11 times by for loop. Let’s see one more easy example of memoization:</p><pre>// a simple function to add something<br>let addNum = (n) =&gt; (n + 1);<br>addNum(10);</pre><pre>// a simple memoized function to add something<br>let cachedAddNum = () =&gt; {<br>  let cache = {};<br>  return (n) =&gt; {<br>    if (n in cache) {<br>      console.log(&#39;Fetching from cache&#39;);<br>      return cache[n];<br>    }<br>    else {<br>      console.log(&#39;Calculating result&#39;);<br>      let result = n + 10;<br>      cache[n] = result;<br>      return result;<br>    }<br>  }<br>}</pre><pre>// returned function from memoizedAdd<br>const add = cachedAddNum();<br>console.log(add(10)); // calculated<br>console.log(add(10)); // cached<br></pre><h3>Note: Only a pure function can be memoized.</h3><p>A Pure Function is the one that</p><ul><li><em>Returns same output for the same input, every time.</em></li><li><em>Doesn’t depend on and doesn’t modify the state of the variables out of its scope.</em></li></ul><p>Using above concept you can write a generalised memoizer that accepts function that needed to be memoized and a formula that will compute the result and return it to the caller.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=462645e2c58" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/memoization-in-javascript-462645e2c58">Memoization in Javascript</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Load Balancing Node JS]]></title>
            <link>https://medium.com/techintoo/load-balancing-node-js-51b854fb4f4f?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/51b854fb4f4f</guid>
            <category><![CDATA[load-balancer]]></category>
            <category><![CDATA[scaling-microservices]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 13:37:52 GMT</pubDate>
            <atom:updated>2019-12-11T06:38:56.519Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*Mgrhryt4agUB2CMiGjyJNQ.png" /></figure><p>While deploying a NodeJS app in production we always think about scalability. In fact, we know node being an asynchronous single threaded io, it blocks events loop while processing a request.</p><p>To avoid those type of performance bottlenecks, we often use a concept called load balancing to create a distributed architecture.</p><h4>A load balancer is a process that takes in HTTP requests and forwards these HTTP requests to one of a collection of servers.</h4><h3>Implementing Load balancer with node js</h3><p>— — — — — — — — — — — — — — — — — — — — — — — — —</p><p>There are many ways to achieve this…</p><h4>1. With help of your PaaS or IaaS</h4><ul><li>If deploy you app on App Engine in Google Cloud Platform, you’ll find it extremely easy to load balance your app and dividing traffic into one or more instances.</li><li>AWS EC2 also has a service called Application Load Balancer to distribute traffic to one or more EC2 instances.</li></ul><h4>2. Using NGINX</h4><p>Nginx is actually a pretty darn solid choice for load balancing Node.js processes. Here is an example how we can achieve this…</p><pre>upstream my_http_servers {<br>    server 127.0.0.1:444;      # httpServer1 listens to port 444<br>    server 127.0.0.1:445;      # httpServer2 listens to port 445<br>    server 127.0.0.1:446;      # httpServer3 listens to port 446<br>    server 127.0.0.1:447;      # httpServer4 listens to port 447<br>}</pre><pre>server {<br>    listen 80;<br>    server_name your-domain.com www.your-domain.com;<br>    location / {<br>        proxy_set_header   X-Real-IP $remote_addr;<br>        proxy_set_header   Host      $http_host;<br>        proxy_pass         http://my_http_servers;<br>    }<br>}</pre><h4>3. Using Express Web Server</h4><p>We can also create a load balancer using Express JS in this way…</p><pre><strong>const</strong> body = require(&#39;body-parser&#39;);<br><strong>const</strong> express = require(&#39;express&#39;);<br><br><strong>const</strong> app1 = express();<br><strong>const</strong> app2 = express();<br><br><em>// Parse the request body as JSON</em><br>app1.use(body.json());<br>app2.use(body.json());<br><br><strong>const</strong> handler = serverNum =&gt; (req, res) =&gt; {<br>  console.log(`server ${serverNum}`, req.method, req.url, req.body);<br>  res.send(`Hello from server ${serverNum}!`);<br>};<br><br><em>// Only handle GET and POST requests</em><br>app1.get(&#39;*&#39;, handler(1)).post(&#39;*&#39;, handler(1));<br>app2.get(&#39;*&#39;, handler(2)).post(&#39;*&#39;, handler(2));<br><br>app1.listen(3000);<br>app2.listen(3001);<br></pre><blockquote>The above code basically creates two Express Servers to handle the request</blockquote><h4>4. Using HAProxy</h4><p><a href="http://www.haproxy.org/">HAProxy</a> or “High Availability Proxy” is an open source Proxy server. It is pretty much built solely to load balance lots of machines. Unlike Nginx it cannot serve up static files. It comes with all the great load balancing features of Nginx — weighted processes, failover, horizontal scaling, plus loads more settings and features</p><p>There are other methods also to create a load balancer with node js and its up to you to find most effective way to implement it, that is best fit for your app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51b854fb4f4f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/load-balancing-node-js-51b854fb4f4f">Load Balancing Node JS</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serving static files using Google Cloud CDN + Storage Bucket]]></title>
            <link>https://medium.com/techintoo/serving-static-files-using-google-cloud-cdn-storage-bucket-db1287cb5e40?source=rss----5bc5deacdd09---4</link>
            <guid isPermaLink="false">https://medium.com/p/db1287cb5e40</guid>
            <category><![CDATA[cloud-storage]]></category>
            <category><![CDATA[cloud-cdn]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[load-balancing]]></category>
            <category><![CDATA[cdn]]></category>
            <dc:creator><![CDATA[Subhajit Dutta]]></dc:creator>
            <pubDate>Sun, 10 Mar 2019 13:37:07 GMT</pubDate>
            <atom:updated>2019-02-13T07:37:34.981Z</atom:updated>
            <content:encoded><![CDATA[<p>Google cloud CDN is — low latency, distributed content delivery solution. It has more than 100 POP (Point of presence) to make your assets highly available.</p><blockquote>The Cloud CDN content delivery network works with <a href="https://cloud.google.com/load-balancing/docs/https/">HTTP(S) load balancing</a> to deliver content to your users. The HTTP(S) load balancing configuration specifies the frontend IP addresses and ports on which Cloud CDN receives requests and the backends that originate responses to those requests.</blockquote><p>We will see how the above definition works step and step, and also we will configure a cdn using GCloud Platform with SSL ( HTTPS) support.</p><h3>Prerequisites</h3><p>— — — — — — — —</p><p>Before proceeding further, lets see what are the initial steps to be taken to start configuring cdn according to this tutorial…</p><ol><li>You should have knowledge on configuring DNS records.</li><li>You must already have an active domain and access to its control panel</li><li>A GCloud Project</li></ol><h3>A. Create a Storage Bucket</h3><p>— — — — — — — — — — — — — — — —</p><ol><li>Go to Google Cloud Platform ( <a href="https://console.cloud.google.com/">https://console.cloud.google.com) </a>and select your project.</li><li>Search for “Storage” and click on “Storage” from the drop down or click on storage from left nav bar -&gt; browse or check this link <a href="https://console.cloud.google.com/storage">https://console.cloud.google.com/storage</a>.</li><li>Click on “CREATE BUCKET” button from top.</li><li>Choose bucket name -&gt; Select multi-regional -&gt; your preferred bucket location.</li><li>Click on “Create”</li></ol><h3>B. Creating Load Balancer</h3><p>— — — — — — — — — — — — — — — —</p><ol><li>Search for <strong>Network Services</strong> -&gt; Click on <strong>Load Balancing </strong>from left navigation drawer( See under <strong>Networking</strong> section ) or search from top search bar.</li><li>Click on CREATE LOAD BALANCER -&gt; Select HTTP(S) Load Balancing -&gt; Start Configuring.</li><li>Select <strong>Backend Configuration</strong></li><li>From right side select <strong>Backend Buckets</strong> -&gt; Select your previously created bucket</li><li>Select <strong>Frontend Configuration.</strong></li><li>From right side <strong>Name</strong> section -&gt; Give name to your New Frontend IP and Port</li><li>Select protocol HTTPS ( make sure you have an active domain or subdomain )</li><li>From Certificate section, click on <strong>Create a New Certificate.</strong></li><li>Give a name to your new SSL certificate</li><li>Select <strong>Create Google-managed certificate </strong>as create mode( Google mainly uses Lets Encrypt as CA )</li><li>In domain section, give a subdomain*** name (eg. assets.example.com) that you will use for static assets serving. *** Assuming you currently does not have that sub-domain and you have access to domain provider to create one.</li><li>Click on create</li><li>Once created, again click on <strong>Load Balancing</strong> from left navigation</li><li>Now you will see Load Balancers created by you. Click on <strong>Frontends</strong> tab</li><li>Search for previously created config and note down the IP ADDRESS.</li><li>*** Now go to your domain provider’s site and create a subdomain that should point to previously created frontend ip address. This subdomain can be served over https because google has already activated ssl for this.</li></ol><h3>C. Adding Load Balancer to CDN</h3><ol><li>Go to <strong>Cloud CDN </strong>under <strong>Network Services</strong> from left nav</li><li>Click on ADD ORIGIN</li><li>Select your previously created Load Balancer</li><li>Click on Add</li></ol><p>Now you have successfully created a fully managed cloud cdn that is served over https.</p><p>To see if your domain ssl is successfully verified…</p><ol><li>Go to Load Balancing section from left bar -&gt; Under Load Balancers tab and Name Column -&gt; click on your previously created LB</li><li>This will open <strong><em>Load balancer details </em></strong>section</li><li>Under <strong>Frontend</strong> Section -&gt; Click on your certificate under <strong>Certificate</strong> column.</li><li>Check this image</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*Vl-OKczPedy2mqUS06WsfA.png" /></figure><p>To see what these statuses mean, check this link <a href="https://cloud.google.com/load-balancing/docs/ssl-certificates?hl=en_GB&amp;_ga=2.131299983.-1697683271.1535389579&amp;_gac=1.229135598.1549389793.Cj0KCQiAheXiBRD-ARIsAODSpWP6ccw-mH7igkjw7pYZdPpVsAbB9ceVWE7ed3bQfD-PT4KSVWfNwFsaAnY3EALw_wcB#domain-status">https://cloud.google.com/load-balancing/docs/ssl-certificates?hl=en_GB&amp;_ga=2.131299983.-1697683271.1535389579&amp;_gac=1.229135598.1549389793.Cj0KCQiAheXiBRD-ARIsAODSpWP6ccw-mH7igkjw7pYZdPpVsAbB9ceVWE7ed3bQfD-PT4KSVWfNwFsaAnY3EALw_wcB#domain-status</a></p><h3>Final Steps:</h3><p>Add some images or static files to your bucket and access them using your subdomain. Eg. <a href="https://assets.example/">https://assets.example</a>.com/my_image.jpg</p><h4>Note: Assets in bucket might not be available publicly. To make an asset public, go to permissions for that asset -&gt; Add Entity User -&gt; allUsers as Name.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*wOHYYHxMrLy_cm1Qwe02Wg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db1287cb5e40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/techintoo/serving-static-files-using-google-cloud-cdn-storage-bucket-db1287cb5e40">Serving static files using Google Cloud CDN + Storage Bucket</a> was originally published in <a href="https://medium.com/techintoo">BrewedByte</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>