<?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 Guilherme Graca on Medium]]></title>
        <description><![CDATA[Stories by Guilherme Graca on Medium]]></description>
        <link>https://medium.com/@ggraca?source=rss-8e93697e29f3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*70gmv747fB5SEVEL4-DLvA.jpeg</url>
            <title>Stories by Guilherme Graca on Medium</title>
            <link>https://medium.com/@ggraca?source=rss-8e93697e29f3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 13:45:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ggraca/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[Building a scalable popularity algorithm with Ruby on Rails]]></title>
            <link>https://ggraca.medium.com/building-a-scalable-popularity-algorithm-with-ruby-on-rails-c395d7dfb0b1?source=rss-8e93697e29f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c395d7dfb0b1</guid>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[reddit]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[algorithms]]></category>
            <dc:creator><![CDATA[Guilherme Graca]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 14:50:47 GMT</pubDate>
            <atom:updated>2021-03-31T15:08:01.112Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*88sEPANjTghizO8qaM5V6w.png" /></figure><p>Recently I had to implement a popularity/hotness algorithm for our discovery pages at <a href="https://ripplr.io/">Ripplr</a>. I had never done this before but I implemented fancier algorithms in the past, how hard could this be?</p><p>Harder than expected actually. All of my attempts depended, one way or another, on the current_time (e.g. total_points_in_the_last_hour, points / time_since_created, etc). But how can we order and read from the database in a performant way if the current_time is different each time?</p><h4>Use created_at as your base score</h4><p>I stumbled upon a gist of Reddit’s <a href="https://gist.github.com/jrochkind/2636355">algorithm</a> and <a href="https://medium.com/hacking-and-gonzo/how-reddit-ranking-algorithms-work-ef111e33d0d9">some</a> <a href="https://www.reddit.com/r/math/comments/vmxvf/how_is_this_algorithm_for_the_reddit_hot_ranking/">articles</a> discussing it and a possible solution started to take shape.</p><p>At its core, what Reddit does is storing the created_at timestamp as the base score for each new post. From there, they can manipulate how the votes shift this score up or down and by how much.</p><p>This is what the most basic score method could look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/135b3e3da551dc651b79e38f7edf48d8/href">https://medium.com/media/135b3e3da551dc651b79e38f7edf48d8/href</a></iframe><p>In this example, a post with 100 upvotes will need around 16h (100 * 10 minutes) to be overtaken by a new post with 0 upvotes. Or instead, 8h to be overtaken by a new one with 50 upvotes.</p><p>The big improvement is that this score only needs to be calculated in two scenarios: when a post is created and when a vote is submitted. That means it can be saved in the database and used for querying. As a bonus, we can add an index to make reading almost instantaneously.</p><h4>Benchmarking 1M records</h4><p>To illustrate the benefits, I ran 4 scenarios with 1M records to see how they would perform:</p><p>A. Load all records sort them and return the top 10 results;<br>B. (small optimization on A) Pluck values from the database, sort them and then load the top 10 results;<br>C. Load the top 10 results using the score for ordering;<br>D. Load the top 10 results using the score for ordering (with an index).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7ce206584fef6092b303ebffb290631/href">https://medium.com/media/f7ce206584fef6092b303ebffb290631/href</a></iframe><p>As expected, A &amp; B fall short of an acceptable standard in the real world. Letting the database handle the ordering and on top of that adding an index to the specific column brings the query time to less than a millisecond — making it very easy to scale from there.</p><p>We ended up shipping a variation of the method above. For our use case, we added a third variable to the score (# comments) and used a logarithm to smooth the impact of each of these variables.</p><p>Hopefully, this post helps other people explore alternative scoring techniques so that they can make their queries as fast as possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c395d7dfb0b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ripplr Devlog #3]]></title>
            <link>https://medium.com/ripplr/ripplr-devlog-3-7dee20ed70ef?source=rss-8e93697e29f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dee20ed70ef</guid>
            <category><![CDATA[devlog]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[bots]]></category>
            <dc:creator><![CDATA[Guilherme Graca]]></dc:creator>
            <pubDate>Mon, 22 Feb 2021 12:00:58 GMT</pubDate>
            <atom:updated>2021-02-22T12:18:47.651Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ripplr Devlog #3 — Content Bots, Inboxes and more</h3><p>It has been a while since I posted one of these. Most of our work since then has been under the radar but hopefully, we now have a few things to show.</p><h3>Content Bots</h3><p>One of the problems we identified before starting <a href="https://ripplr.io/">Ripplr</a> was about dealing with noise on social platforms. So we went ahead and built some solutions and released them with the MVP. However, the problem doesn’t really exist in a new platform with a few new posts every day. So how can we validate our solutions if there’s not enough content being shared?</p><p>Luckily, our posts are all based on URLs — content that exists on the internet.</p><p>We created a way to find and group content from the web into a single profile that users can follow and subscribe to as if it was another user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*_uUCWQ7QBVj4C2QQHtvPJg.png" /></figure><p>We are releasing new Content Bots every day and we’re encouraging people to get in touch with new sources (Youtube/Medium profiles, news websites, etc.).</p><h3>Multiple Inboxes</h3><p>Inboxes are a new concept we’re introducing. While we think a single feed has offered a lot of positive experiences, there are times people need more control over when and how they view their content.</p><p>When following someone, our users can also choose to subscribe and decide to what inboxes that content should be delivered. Then, on each Inbox, they can further customize filters and notifications (and digests soon?).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RoNGd168lRhY4llOeYv5nA.png" /></figure><h3>Youtube player and emojis 🎉</h3><p>We’ve been making the user experience more pleasant with a new youtube embed played and fun with the addition of emojis to comments.</p><h3>Open signup</h3><p>It’s also time to announce that we’ve opened the signups, so <a href="https://ripplr.io/auth/register">go ahead</a> and secure your username and try out the new features!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dee20ed70ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ripplr/ripplr-devlog-3-7dee20ed70ef">Ripplr Devlog #3</a> was originally published in <a href="https://medium.com/ripplr">Ripplr</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 DigitalOcean’s Container Registry for Continuous Deployment]]></title>
            <link>https://ggraca.medium.com/how-to-use-digitaloceans-container-registry-for-continuous-deployment-7e1bc3d19e0a?source=rss-8e93697e29f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e1bc3d19e0a</guid>
            <category><![CDATA[digitalocean]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[container-registry]]></category>
            <dc:creator><![CDATA[Guilherme Graca]]></dc:creator>
            <pubDate>Sat, 05 Dec 2020 17:38:17 GMT</pubDate>
            <atom:updated>2020-12-05T17:38:17.894Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5fEC0ohfWCo-rYsVCpW8Fw.jpeg" /></figure><p>At <a href="https://ripplr.io/">Ripplr</a>, we iterate fast and ship fast. When a feature is ready for the public, it doesn’t stick around waiting for the next official <em>release</em>, we just merge it.</p><p>We can do this with great confidence and little risk because our deployment pipeline ensures that the tests pass and that the new version is healthy before it’s made available to users. If the worst happens — we have a 1-click rollback that only takes a few seconds to perform.</p><p>All this flexibility is only possible thanks to containerization and automatic image versioning. Our images are all tagged based on the commit SHA.</p><h4>Tagging Images in Github Actions:</h4><p>To tag images, we use two marketplace actions:</p><ul><li><a href="https://github.com/digitalocean/action-doctl">action-doctl</a> — To install doctl and authenticate with DigitalOcean</li><li><a href="https://github.com/ripplr-io/docr-docker-publish">docr-docker-publish</a> — To build, tag and upload the images to DigitalOcean’s Container Registry.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdabf65a2eff05c63b05ec4d20ddf06d/href">https://medium.com/media/bdabf65a2eff05c63b05ec4d20ddf06d/href</a></iframe><h4>Removing older tags from the Container Registry:</h4><p>We also remove older images as part of our deployment. It’s improbable that we’ll need something older than the last 10 versions. We do this using <a href="https://github.com/ripplr-io/docr-image-remove">docr-image-remove</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16f18db15fd842ef1cd1a9bf6d3ae751/href">https://medium.com/media/16f18db15fd842ef1cd1a9bf6d3ae751/href</a></iframe><h4>Using the new image version:</h4><p>If you need to perform some tasks with the new image, <a href="https://github.com/ripplr-io/docr-docker-publish">docr-docker-publish</a> also generates some outputs that we can use on later jobs.</p><p>This is what the whole job would look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2a038bdfb0b3b32f0971b61e228206a/href">https://medium.com/media/d2a038bdfb0b3b32f0971b61e228206a/href</a></iframe><p>We currently only use this flow in our deploy phase but we expect to extend it to other sections like CI as well as generating staging environments on the fly. Hopefully, these snippets help other devs with a similar stack to ours.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7e1bc3d19e0a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ripplr Development #2]]></title>
            <link>https://ggraca.medium.com/ripplr-development-2-a8fd62355e15?source=rss-8e93697e29f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8fd62355e15</guid>
            <dc:creator><![CDATA[Guilherme Graca]]></dc:creator>
            <pubDate>Mon, 30 Nov 2020 18:47:08 GMT</pubDate>
            <atom:updated>2020-11-30T18:47:08.154Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*6yAcPD3VR7AqxsRi67idjg.png" /></figure><p>Our beta program started 2 weeks ago and we now have around 30 registered accounts. We continue to onboard users daily but we already found some takeaways.</p><p><strong>Improving the app</strong></p><p>Even though we had a working app and we tested it the best we could, problems eventually showed up — this was where we spent most of our time these two weeks.</p><p>Our feedback feature has been vital for finding, understanding and fixing edge-cases. We also received some exciting feature requests, but we’re adding these to the backlog for future prioritization.</p><p><strong>Improving the first experience</strong></p><p>We kept a continuous chat with most people we invited and the feedback has been great. However, actions speed louder than words and we noticed that a lot of people were not coming back or not interacting as much as we wanted.</p><p>While the number of Signups keeps increasing steadily, new Posts and new Subscriptions remain low. These numbers are critical for us to understand supply and demand in our platform.</p><p>We’ll be working on improving the first experience (to get users to perform some key actions right after signup) and removing blockers that are preventing users from subscribing.</p><p>To stay up to date with this series you can subscribe to <a href="https://ripplr.io/u/ggraca">ggraca</a> on <a href="https://ripplr.io/">Ripplr</a>. Or subscribe to our <a href="https://ripplr.io/">newsletter</a> if you haven’t received an invite yet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8fd62355e15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ripplr Development #1]]></title>
            <link>https://ggraca.medium.com/ripplr-development-1-eb8a4d455ae7?source=rss-8e93697e29f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb8a4d455ae7</guid>
            <dc:creator><![CDATA[Guilherme Graca]]></dc:creator>
            <pubDate>Thu, 19 Nov 2020 16:28:14 GMT</pubDate>
            <atom:updated>2020-11-20T14:39:29.396Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YL6O3kkKZMuoi5Wn_vejDw.png" /></figure><p>We have finally started inviting users to join <a href="https://ripplr.io/">Ripplr</a>! 🎉 🎉</p><p>I’m so proud of the progress we achieved so far. Back in June, <a href="https://medium.com/u/8a2e90bd149e">Mário Balça</a> approached me with a working prototype and an amazing vision for what this project could be and, from there, we started casually discussing the idea and forming a team, alongside <a href="https://medium.com/u/5e2385be718e">Filipe Mendes</a>.</p><p>The chatting and working intensified after I visited Portugal in the summer and that culminated with me quitting my job in October to be able to work for <a href="https://ripplr.io/">Ripplr</a> full-time. Now, about a month in, we’re starting to share our work with the outside world and the early feedback has been great!</p><p>We’re not sharing it as a finished product though, we’re aware some parts could be more polished and people will find the occasional bug now and then. We chose to do this so that we can take the next steps with the community and to understand what people find valuable.</p><p>We also want to experiment with being transparent in our development process. This will be the first post of a series and I expect the following ones to start being a bit more technical. We believe doing this could be insightful to others wanting to start their business. It also creates the opportunity to integrate the community in the process and get some honest feedback on what we’re building and any future plans.</p><p>A big thank you to the early adopters!</p><p>If you haven’t been invited yet, head to <a href="https://ripplr.io/">ripplr.io</a> and subscribe to be notified when we invite the next batch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb8a4d455ae7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>