<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Carlos Del Real on Medium]]></title>
        <description><![CDATA[Stories by Carlos Del Real on Medium]]></description>
        <link>https://medium.com/@carloshdelreal?source=rss-92295ecc4a05------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*lLNlVheJarWIxFDt.jpg</url>
            <title>Stories by Carlos Del Real on Medium</title>
            <link>https://medium.com/@carloshdelreal?source=rss-92295ecc4a05------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 19:02:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carloshdelreal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Debugging an SSL certificate]]></title>
            <link>https://carloshdelreal.medium.com/debugging-an-ssl-certificate-b030d330aaa8?source=rss-92295ecc4a05------2</link>
            <guid isPermaLink="false">https://medium.com/p/b030d330aaa8</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[ssl-certificate]]></category>
            <dc:creator><![CDATA[Carlos Del Real]]></dc:creator>
            <pubDate>Fri, 19 Jul 2024 22:34:45 GMT</pubDate>
            <atom:updated>2024-07-19T22:34:45.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*Y153vgvJ-afleLUXTpQ8_w.jpeg" /></figure><p>The Water Peace and Security (<a href="https://waterpeacesecurity.org/">WPS</a>) application is currently deployed on a Linux machine that runs Ruby on Rails on an NGINX server and PUMA.</p><p>We are currently using Capistrano, and eventually, we SSH the machine to run some scripts to feed the database.</p><h4>Installing an SSL Certificate</h4><p>Like any other nginx server, the installation of the SSL certificate has to be done as the <a href="https://nginx.org/en/docs/http/configuring_https_servers.html">nginx documentation </a>mentions, with a <em>ssl_certificate</em> and a <em>ssl_certificate_key</em>.</p><p>The process of generating the certificate might vary depending on the provider, but, commonly, they require the generation of the key and a certificate request. That process is achieved by running on any Linux machine with OpenSSL the following script:</p><p>openssl req -newkey rsa:2048 -keyout PRIVATEKEY.key -out MYCSR.csr</p><p>Then you can use the certificate request to generate the SSL certificate that you have to use in your nginx server.</p><h4>The Problem</h4><p>This process is pretty straightforward and should not generate problems, however, the certificate generated for the provider might require an additional step.</p><p>The SSL certificate generated by the provider was a .pem file that looked something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fc6a0bfc658ab02823edef91c8efd0c/href">https://medium.com/media/5fc6a0bfc658ab02823edef91c8efd0c/href</a></iframe><p>and our private key should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/904e834bc1a8fb5b032d5f8b2601468b/href">https://medium.com/media/904e834bc1a8fb5b032d5f8b2601468b/href</a></iframe><p>however, when we tried to start the server an error occurred.</p><h3>Debugging</h3><p>To debug this issue we started to use the following script:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/950876ea12496f0e1932b34f4f91af59/href">https://medium.com/media/950876ea12496f0e1932b34f4f91af59/href</a></iframe><p>the output for this script was something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e3a44f6f432e2c7d0f13229876cd9d5/href">https://medium.com/media/5e3a44f6f432e2c7d0f13229876cd9d5/href</a></iframe><p>Meaning that the key and the certificate were not compatible, therefore the server was not going to work. The reason for this is the incorrect ordering of the certificate sections in the <em>.crt/.pem</em> file. to fix it we just had to test every of the sections of the certificate individually. After a bit of trial and error, we figured out that the correct section of the certificate was the last one, so we had to use as the certificate:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc276b0062e7a79bf7f1d30e6a08ce09/href">https://medium.com/media/dc276b0062e7a79bf7f1d30e6a08ce09/href</a></iframe><p>with the same key.</p><p>After that modification of the certificate, the output of the testing script was:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0af50ee7a67f6699d673a7b2b046a40/href">https://medium.com/media/f0af50ee7a67f6699d673a7b2b046a40/href</a></iframe><p>Confirming the compatibility of the key and the certificate. finally, we updated the certificate and the server worked correctly.</p><p>Nginx reads only the first certificate and that is the one that is used for SSL, so you can list the others in the same document without affecting the certificate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b030d330aaa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Never judge a Netflix Movie/Series from its Thumbnail]]></title>
            <link>https://carloshdelreal.medium.com/never-judge-a-netflix-movie-series-from-its-thumbnail-b056c2a59496?source=rss-92295ecc4a05------2</link>
            <guid isPermaLink="false">https://medium.com/p/b056c2a59496</guid>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[movies]]></category>
            <category><![CDATA[my-octopus-teacher]]></category>
            <category><![CDATA[netflix]]></category>
            <dc:creator><![CDATA[Carlos Del Real]]></dc:creator>
            <pubDate>Wed, 03 Feb 2021 01:13:49 GMT</pubDate>
            <atom:updated>2021-02-03T01:13:49.426Z</atom:updated>
            <content:encoded><![CDATA[<p>Everybody has faced that horrible situation in which you don’t know which is going to be your next movie/series on Netflix. You start passing and passing titles trying to choose which is going to worth your time.</p><p>First, you try to choose based on the time you have, probably if it is Sunday 8 pm or so, and you don’t want to stay up late at the night, you try to choose a movie whose length is not greater than two hours. Why the Netflix AI is just showing me a bunch of series? I want quick entertainment to get sleep, not another life compromise.</p><p>This gets worse if you are with your partner and he/she has the remote control and just discards some titles that you were considering, among so few choices, just saying “I already watched that one”.</p><p>Why Netflix keeps showing you the movies that you already watched? Please Netflix, give us the possibility to customize the searching.</p><p>I was in this weird situation and saw this silly title, with a thumbnail that could be part of a sushi documentary, a no sense title and a evaluation conclusion that told me neeeext.</p><p>Since I had spent too many valuable minutes of my life, I just said, ok let’s try this one.</p><p><strong>My Octopus Teacher </strong>(Mi maestro el Pulpo) is not just another documentary. It is proof that there are remarkable histories that are waiting to be told, that one of the most incredible gifts in an individualistic society is empathy. that curiosity is a colossal force of human beings, and that there are extraordinary people in this world.</p><p>This experience leaves me with a few conclusions:</p><ul><li>Netflix should have better customizable filters; I am a developer, so Netflix should hire me to implement that.</li><li>Never judge a Netflix movie or series from its thumbnail</li><li>Stop wasting your time choosing, choose one!!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/0*72p2H9h7BHpIsPpV.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b056c2a59496" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up a Bookstore Project. Quick Start to learn Active Record Query Interface]]></title>
            <link>https://carloshdelreal.medium.com/setting-up-a-bookstore-project-quick-start-to-learn-active-record-query-interface-300e79e72fa6?source=rss-92295ecc4a05------2</link>
            <guid isPermaLink="false">https://medium.com/p/300e79e72fa6</guid>
            <category><![CDATA[activerecord]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Carlos Del Real]]></dc:creator>
            <pubDate>Fri, 15 Jan 2021 14:14:15 GMT</pubDate>
            <atom:updated>2021-01-15T14:14:15.573Z</atom:updated>
            <content:encoded><![CDATA[<p>#Ruby on Rails, #ActiveRecord, #webdevelopment, #backend, #api.</p><p>Starting a Ruby on Rails project requires a bunch of commands that you have to be familiar with to be effective. This is an example of the most common ones.</p><p>On the Ruby on Rails guide, it is proposed a Bookstore project to be used for presenting the <a href="https://guides.rubyonrails.org/active_record_querying.html">Active Record Query Interface</a>.</p><p>Since I spend some time creating the same project, I think is going to be a good idea to document the process.</p><p>To start is worth mentioning that you have to have installed on your system ruby along with ruby on rails. If you haven’t, here you can find a couple of articles about how to do it.</p><ul><li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-18-04">How To Install Ruby on Rails with rbenv on Ubuntu 18.04</a></li><li><a href="https://gorails.com/setup/ubuntu/20.10">Install Ruby On Rails on 20.10 Groovy Gorilla</a></li></ul><p>To double-check that you have installed ruby and Ruby on Rails on your system just type:</p><pre>ruby -v<br>rails -v</pre><p>This is what you will get, the installed ruby and Ruby on Rails versions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*3KvbIM8JPyrxRVyOsPs7Tw.png" /></figure><h3>Start Building the project!</h3><p>To start your project run the rails new Bookstore -T command.</p><p>This is going to create a new Ruby on Rails project on the <strong>Bookstore</strong>folder, the -T flag is going to be used to generate it without the testing suite, later we are going to use <a href="https://rspec.info/">RSpec</a> as the testing suite.</p><p>As you can check, a folder <strong>Bookstore</strong>was created within the workspace that you ran the command into. this folder contains all the files that your ruby on rails project uses.</p><p>Now your project does not have a single model and we are going to tackle that soon but for now, we are going to install RSpec. to do that add the gem ‘rspec&#39; line into your Bookstore/Gemfile file. double-check that you insert it inside the test group block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*Rxh_7AOyb4cxeXg3LamFSA.png" /></figure><p>navigate into the Bookstore folder by cd Bookstore/ and run bundle exec rspec --init this is going to generate a Bookstore/spec folder and some RSpec configuration files.</p><blockquote>Up to this point, your project is ready to add the models and perform the corresponding migrations.</blockquote><h3>The Project Goal</h3><p>To build the table structure is absolutely necessary to have clarity about the table relationships. to serve that purpose is presented the following <strong><em>Bookstore Diagram</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CjMbetUXdboMAj9wg5aSBw.png" /><figcaption>The <strong>created_at </strong>and <strong>updated_at </strong>columns exist for each table but are not shown to simplify this diagram.</figcaption></figure><h3>Generating the models</h3><p>On each of the following segments are presented the terminal commands to generate the table relationships and the models.</p><p><em>Author</em></p><pre>rails generate model author first_name:string last_name:string title:string</pre><p><em>Book</em></p><pre>rails generate model book title:string year_published:integer isbn:string &#39;price:decimal{10,2}&#39; out_of_print:boolean views:integer supplier:references author:references</pre><p><em>Customer</em></p><pre>rails generate model customer first_name:string last_name:string title:string email:string visits:integer orders_count:integer lock_version:integer</pre><p><em>Order</em></p><pre>rails generate model order date_submitted:time status:integer &#39;subtotal:decimal{10,2}&#39; &#39;shipping:decimal{10,2}&#39; &#39;tax:decimal{10,2}&#39; &#39;total:decimal{10,2}&#39; customer:references</pre><p><em>Review</em></p><pre>rails generate model review title:string body:text rating:integer state:integer customer:references book:references</pre><p><em>Supplier</em></p><pre>rails generate model supplier name:string</pre><p>Each one of these commands generates a migration file within the Bookstore/app/db/migrate folder, whose purpose in life is to generate the corresponding tables in the database. At the same time in the folderapp/models are generated the model files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tPNn50nY_a3x8ZPCOEjMLA.png" /><figcaption>migration files created on the migration folder</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N-F_oc6RGVyRn280WMFDaQ.png" /><figcaption>model files created on the model&#39;s folder</figcaption></figure><p>Notice that not all the model&#39;s code is automatically generated and the model’s logic for each of the models has to be updated to the code that is presented in the <a href="https://guides.rubyonrails.org/active_record_querying.html">Ruby on Rails Guides</a> to achieve the intended behavior</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*VCzERM9ZrCVdBy9h9drd6A.png" /><figcaption>This is the Bookstore project goal taken from the RailGuides Active Record Query Interface</figcaption></figure><h3>Run the migrations</h3><p>Finally, run the commandrails db:migrate</p><p>This will migrate the database, in simpler words is going to generate the database tables, fields, and relationships that meet the described behavior in the models.</p><p>If everything is fine you will see something like this in your terminal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*SzUQ1GoauR7abOy6-HKDDA.png" /><figcaption>successfully running the migrations.</figcaption></figure><p>You can download this code at <a href="https://github.com/carloshdelreal/Bookstore">The Bookstore Project</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=300e79e72fa6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Coding Bad Practices]]></title>
            <link>https://carloshdelreal.medium.com/stop-coding-bad-practices-d976ce05dbc6?source=rss-92295ecc4a05------2</link>
            <guid isPermaLink="false">https://medium.com/p/d976ce05dbc6</guid>
            <category><![CDATA[good-practices]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Carlos Del Real]]></dc:creator>
            <pubDate>Tue, 21 Jan 2020 14:22:02 GMT</pubDate>
            <atom:updated>2020-01-21T14:22:02.581Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xt3_hv9CSFw8qaVvOX0UzA.png" /></figure><p>I created a tic tac toe video game that runs in the console using ruby, the game works fine but at the time to add some testing, a big problem appeared.</p><p>The game requires input from the user in the console, and to test the validation to that input it was necessary to use a weird StringIO.new()<em> </em>function. It seems like an easy task, but as I didn’t know some fundamentals of Object Oriented Programing, I committed errors in the design that made it difficult to test the application up to the point that the testing was completely horrid.</p><p>When you are learning testing It is natural that you want to test every single line of code you write, and that is good for learning purposes but its a very bad practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*mbO14l_sWO0FAHaF5ZtLgQ.png" /></figure><p>when I got this bunch of lines in the RSpec testing I realized that what I was doing was wrong but I didn’t know why.</p><p>The fundamental problem is that I was calling a function that writes to the console and that’s why the output appears in the console. 😑</p><p>I left this problem for a while, It took me a long time to feel comfortable about writing this article because I didn’t know how to explain what was wrong and the fundamental errors that I committed when coded this project. it’s the kind of situation that you don’t know how to tackle and you have to give space to your mind to rethink it again and again.</p><h3>The Actual Problem</h3><p>As this project was created to learn OOP in ruby I was asked to organize the code into classes, so I created a class called Boardto put all the code related to the board object, that’s object-oriented programming! well, that’s not all.</p><p>let’s dive into the code, thechoose method takes a number and a symbol to emulate a user marking a cell in the Tic Tac Toe, then loops through @board_numbers a two-dimensional array until finds the given number to the function, then changes that number in the actual @board , prints the board in the console, returns true or displays to the user “Already Chosen”.</p><p>To summarize the choose method:</p><ol><li>validates if the provided number is valid</li><li>looks for the chosen number in the board and changes it with the provided symbol</li><li>Prints out the board</li><li>returns true if the number is valid</li><li>if the input is invalid displays ‘Already Chosen’ into the console</li></ol><p>Charging all this functionality to one method is in essence too complex and breaks a fundamental OOP principle called <strong>The Single Responsibility </strong>which states that a module, class, object or method, should only have one responsibility. The choose method seems to do a task to the game but is achieving many small tasks; writes to the console loops through an array and changes the @board etc.</p><p>Ok, this code is bad but what I should think about to make a better structure?</p><h3>Object-Role Stereotypes</h3><p>As the objects should have a single responsibility it is very easy to get lost at that idea, as a clue you can think of certain roles that an object can assume consistently in your program.</p><ul><li><strong>Information holder</strong> — an object designed to know certain information and provide that information to other objects.</li><li><strong>Structurer</strong> — an object that maintains relationships between objects and information about those relationships.</li><li><strong>Service provider</strong> — an object that performs specific work and offers services to others on demand.</li><li><strong>Controller</strong> — an object designed to make decisions and control a complex task.</li><li><strong>Coordinator</strong> — an object that doesn’t make many decisions but, in a rote or mechanical way, delegates work to other objects.</li><li><strong>Interfacer</strong> — an object that transforms information or requests between distinct parts of a system.</li></ul><blockquote>Further information on Design Rules check this book two books <a href="https://www.amazon.com/Object-Design-Roles-Responsibilities-Collaborations/dp/0201379430"><em>https://www.amazon.com/Object-Design-Roles-Responsibilities-Collaborations/dp/0201379430</em></a> and <a href="https://www.amazon.com/Practical-Object-Oriented-Design-Agile-Primer/dp/0134456475"><em>https://www.amazon.com/Practical-Object-Oriented-Design-Agile-Primer/dp/0134456475</em></a></blockquote><p>before continuing, be aware that these are guidelines, not rules.</p><p>To answer that I strongly recommend this article, explains the SOLID principles, an acronym for the first five object-oriented design principles by Robert C Martin, popularly known as uncle bob</p><p><a href="http://aspiringcraftsman.com/2011/12/08/solid-javascript-single-responsibility-principle/">SOLID JavaScript: The Single Responsibility Principle</a></p><h3>Structuring The Code</h3><p>look how simple and elegant is this refactored code, the choose method takes a number as an argument to mark it as chosen in the board, calls the valid_number? method that checks if the number is valid and whether has been already chosen, then adds that number to the played array.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9b6828a026028a1af496cdbe4e3f6e07/href">https://medium.com/media/9b6828a026028a1af496cdbe4e3f6e07/href</a></iframe><p>If you read every one of these seven lines of code so that’s why this implementation is best, I bet that you didn’t read the first example.</p><p>To make this implementation possible I have to change other parts of the Board class and off course I broke 60% of the tests that I did write, Even though this change is positive.</p><p>one of the fundamental changes was to change the board_numbers from a two-dimensional array to a single array, the main Idea of the two-dimensional array was to emulate the 3x3 matrix of the tic tac toe but that is not necessary. one can use a simple array and at the moment of printing the array to the console convert it to a 3x3 matrix. the gain of that play is that at the moment to search for a number or put a number I have to do it on a simpler data structure.</p><h3>Testing</h3><p>Do you remember that I mention above that I broke 60% of the tests, well I have to say that I end up deleting at least half of them.</p><p>As I tested almost every line of code, my tests were tied to a single implementation, so It was not possible to refactor the code without breaking the tests, so I just delete them.</p><p>After that, I had to write some tests, not many but smarter. following certain basics.</p><p>Objects are black boxes, we do not have to tests everything that happens inside an object, we better have to focus on testing the inputs and outputs, that way we are not going to be tied to a single implementation.</p><p>In the Rails Conf 2013 called The Magic Tricks of Testing By Sandi Metz she describes that principle as testing the messages from a space capsule. you should check that wonderful speech here.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FURSWYvyc42M%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DURSWYvyc42M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FURSWYvyc42M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ecc948a3c9ff992465ebf45e738a73cc/href">https://medium.com/media/ecc948a3c9ff992465ebf45e738a73cc/href</a></iframe><p>I have to say that I decided to write this article because I did not like the output of the testing, and I wanted to document a super-specific ruby maneuver to solve that.</p><p>In the end, I just realized that I have to delete those silly tests that were not testing anything, and highlight the practices and principles that for sure are going to make me and you a better programmer, testing and writing smarter code.</p><h3>Pure Functions</h3><p>The last idea I want to share is the concept of pure functions, Pure functions are functions that have the following properties</p><p>1) Don’t alter a variable or object — create new variables and objects and return them if need be from a function.</p><p>2) Declare function arguments — any computation inside a function depends only on the arguments, and not on any global object or variable.</p><p>It is a good practice to write just pure functions and avoid the temptation of declaring global variables as much as possible, however, all the time is not possible, even so, try, there is no easier thing to tests than a pure function because they just depend on the inputs.</p><h3>Conclusions</h3><ul><li>Test The interfacing of your objects, not the inner implementation</li><li>Try to write just pure functions</li><li>You do not have to test the puts method or the console output</li><li>learn and apply the SOLID design principles</li><li>The code is not just for the computer is for people too!!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d976ce05dbc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A solution to The Height Problem?]]></title>
            <link>https://carloshdelreal.medium.com/a-solution-to-the-height-problem-13084327005a?source=rss-92295ecc4a05------2</link>
            <guid isPermaLink="false">https://medium.com/p/13084327005a</guid>
            <category><![CDATA[sticky]]></category>
            <category><![CDATA[height-problem]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[sticky-top]]></category>
            <category><![CDATA[position-sticky]]></category>
            <dc:creator><![CDATA[Carlos Del Real]]></dc:creator>
            <pubDate>Fri, 19 Jul 2019 22:30:48 GMT</pubDate>
            <atom:updated>2019-07-19T22:30:48.916Z</atom:updated>
            <content:encoded><![CDATA[<p>I needed to scroll columns at different rates to avoid blank space. I didn’t know how to call this or even how to browse properly for the solution.</p><p>while working on a clone for the website I found a particular feature that I didn’t know how to call.</p><p>The site was <a href="https://www.newsweek.com/">https://www.newsweek.com</a> a magazine that uses bootstrap.</p><p>Basically, the problem was that the site has tree columns and each of them had a different number of items. That caused the columns to have different heights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*bUDO0RJuBKvliGd-bPYXaw.png" /><figcaption>The site consists of three columns with different heights given their contents, the goal is to get rid of that empty space.</figcaption></figure><p>As I have to continue with more content, I didn’t want to leave that blank space, so I started googling for the solution.</p><p>In the beginning, the solution was not clear and I spent a lot of time.</p><p>To get the behavior I wanted to achieve, so, I decided to write this article.</p><p>The solution, if you have done some research until now is by using the position: sticky property. If you are using bootstrap, the sticky-top class.</p><p>Using either it is not intuitive and actually is not well documented, here I will explain all the details.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fcarloshdelreal%2Fembed%2Fpreview%2FagaqZd%3Fheight%3D600%26slug-hash%3DagaqZd%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2Fcarloshdelreal%2Fpen%2FagaqZd&amp;image=https%3A%2F%2Fscreenshot.codepen.io%2F3061438.agaqZd.small.081ae21e-8ad8-4e07-ba81-44689467e4e4.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/7359e8dee24e7794001587fcbbb75194/href">https://medium.com/media/7359e8dee24e7794001587fcbbb75194/href</a></iframe><p>In this pen, you can see that we have one row and tree nested columns. The row is a flex container and the columns flex-items. that’s the same if you are using bootstrap, and apply the class row, then define the columns.</p><pre>&lt;div class=&quot;row&quot;&gt;<br> &lt;div class=&quot;col1&quot;&gt;.&lt;/div&gt;<br> &lt;div class=&quot;col2&quot;&gt;.&lt;/div&gt;<br> &lt;div class=&quot;col3&quot;&gt;.&lt;/div&gt;<br>&lt;/div&gt;</pre><p>Inside each column are many items, of course. the space in the column is much greater than the required for the items and that’s what we want to fix.</p><p>Once you apply the positon: sticky<strong><em> </em></strong>and<strong><em> </em></strong>top: 0<strong><em> </em></strong>properties to an item, you will notice that float over the others. hiding the content.</p><p>The solution is to create a container that wraps the items and apply the positon: sticky and top: 0 to the wrapper. (one common mistake is to forget to apply the top: 0 property).</p><p>If you use Bootstrap, the sticky-top class applies both properties. so, you don’t have to worry about that issue.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2Fcarloshdelreal%2Fembed%2Fpreview%2FJQagqo%3Fheight%3D600%26slug-hash%3DJQagqo%26default-tabs%3Dhtml%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io&amp;url=https%3A%2F%2Fcodepen.io%2Fcarloshdelreal%2Fpen%2FJQagqo%3Feditors%3D1100&amp;image=https%3A%2F%2Fscreenshot.codepen.io%2F3061438.JQagqo.small.08e2c789-efb1-472a-9c3f-4fafc9cb2b1c.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/b09ef35de34648cee147fe7b30902456/href">https://medium.com/media/b09ef35de34648cee147fe7b30902456/href</a></iframe><p>Finally, you can see the effect working. At first, the behavior it seems like the columns scrolls at different velocities or rates. The content moves to fit the space. Is natural to begin searching for “column scrolling” or “move items while scrolling”.</p><p>I found that confusing and at first didn’t come to my mind the “sticky idea”.</p><h3>How Sticky works?</h3><p>(adapted from the article “<a href="https://medium.com/@elad/css-position-sticky-how-it-really-works-54cd01dc2d46">CSS Position Sticky — How It Really Works!</a>”)</p><p>In the article: “<a href="https://medium.com/@elad/css-position-sticky-how-it-really-works-54cd01dc2d46">CSS Position Sticky — How It Really Works!</a>”, it is explained the sticky property. but, I would like to make a correction.</p><p>CSS position sticky has two main parts, <strong>sticky item </strong>&amp; <strong>sticky container.</strong></p><p><strong>Sticky Item</strong> — is the element that we defined with the position: sticky. The element will float when the viewport position matches the position definition. for example: top: 0px .</p><p>Example</p><pre>.wrapper{<br>    position: sticky;<br>    top: 0px;<br>}</pre><p><strong>Sticky Container</strong> — is the HTML element which wraps the <strong>sticky item. </strong>This is the area that the sticky item can float in.</p><p><strong>When you set </strong>position: sticky<strong> you’re automatically defining the parent element as a sticky container. This is very important to remember! The container is the scope of the sticky item, and the item can’t get out of its sticky container.</strong></p><blockquote><strong>This is the Correction. </strong>The reason why the sticky property could not work is that there is not available space in the sticky container. thus, an <strong>sticky item </strong>can be alone in the <strong>sticky containiner. </strong>but, to the property to work there must to be available space in the <strong>sticky container.</strong></blockquote><h4>Lastly the property support.</h4><p>You have to know that this property has wide support, and there are some scenarios in which you could use it. The footer, the navbar (of course), etc.</p><p>Part of to be innovative is to have the capacity to apply the available tricks in different situations, this is one of those situations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/1*mvBAQtyuxBAu7ZMaYcsVbA.png" /><figcaption>Browser support for the <strong>position: sticky</strong> property source: <a href="https://caniuse.com/#search=sticky">can I use</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13084327005a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>