<?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[Dan Delaney - Medium]]></title>
        <description><![CDATA[Writing by Dan Delaney, covering a variety of topics like gaming, politics, cryptocurrency, soccer, and web development. - Medium]]></description>
        <link>https://medium.com/dan-delaney?source=rss----334d38f8d8a1---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Dan Delaney - Medium</title>
            <link>https://medium.com/dan-delaney?source=rss----334d38f8d8a1---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:03:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dan-delaney" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Assigning a real-time ranking/order/index to a sorted list using the MongoDB Aggregation framework]]></title>
            <link>https://medium.com/dan-delaney/assigning-a-real-time-ranking-order-index-to-a-sorted-list-using-the-mongodb-aggregation-framework-1c072b2aa550?source=rss----334d38f8d8a1---4</link>
            <guid isPermaLink="false">https://medium.com/p/1c072b2aa550</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[mongo]]></category>
            <category><![CDATA[aggregation]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Dan Delaney]]></dc:creator>
            <pubDate>Fri, 20 Jan 2017 20:39:39 GMT</pubDate>
            <atom:updated>2017-01-20T20:39:38.507Z</atom:updated>
            <content:encoded><![CDATA[<p>After a couple hours of Googling and experimentation, I figured out a solution to a weird problem I was having with MongoDB, so I’d like to share that in case anyone else is having the same issue.</p><p>I was working on a new algorithm for <a href="https://playerslounge.co/">Players’ Lounge</a> where we needed to display the overall ranking on the website of each player on their profile page. Players are ranked by their Players’ Lounge Rating (or PLR), which can change at any time as matches are played on the site. If I were displaying all users in order of their ranking, this would be easy - I could just grab all users, sort by PLR (saved into their user document), and display in order on some sort of Leaderboard. This was different though - I had to pick out an individual user’s rank out of everyone else, relatively quickly, without pulling out all users and looping through until I found the user in question.</p><p><strong>Essentially, I needed to assign some sort of ranking/order number to a sorted list of users. Let me explain my solution using MongoDB’s aggregation framework.</strong></p><p>Each user has a PLR which ranges from 1 to 100. Here’s an example of a user document in the database:</p><pre>{<br>    &quot;_id&quot;: 1234567890,<br>    &quot;username&quot;:&quot;dandelaney8&quot;,<br>    &quot;plr&quot;: 78,<br>    ...<br>}</pre><p>So the first order of business is to sort the users by their “plr” value, highest to lowest. Here’s the pipeline operation for the aggregation framework:</p><pre>{<br>    &quot;$sort&quot;: { <br>        &quot;plr&quot;: -1<br>    }<br>}</pre><p>Once sorted, I then used $push to add the information about each user into an array. This is key in the next step, when we need to get an array key for each user, but we’ll come back to that. Here’s the pipeline operation:</p><pre>{<br>    &quot;$group&quot;: {<br>        &quot;_id&quot;: false,<br>        &quot;users&quot;: {<br>            &quot;$push&quot;: {<br>                &quot;_id&quot;: &quot;$_id&quot;,<br>                &quot;username&quot;: &quot;$username&quot;,<br>                &quot;plr&quot;: &quot;$plr&quot;<br>            }<br>        }<br>    }<br>}</pre><p>At this stage, the users are grouped into a “users” array. Once in this form, we can break it back out using the <a href="https://docs.mongodb.com/manual/reference/operator/aggregation/unwind/">$unwind operator</a> which gives an individual document for each element in the specified array. This brings the information back to a similar form it was before the previous step, BUT (since MongoDB 3.2) there’s a feature of $unwind that allows you to keep track of what array index each element had in the specified array. Since the array was already sorted by rating, this is key for us to figure out overall ranking.</p><p>Here’s the pipeline operation to complete this step:</p><pre>{<br>    &quot;$unwind&quot;: {<br>        &quot;path&quot;: &quot;$users&quot;,<br>        &quot;includeArrayIndex&quot;: &quot;ranking&quot;<br>    }<br>}</pre><p>After this step, each element will hold a “ranking” field, which will be 1 less than their ranking overall. After this I simply grabbed the specific user I wanted to know the ranking of using the $match operator:</p><pre>{<br>    &quot;$match&quot;: {<br>        &quot;users._id&quot;: 1234567890<br>    }<br>}</pre><p>Once this is done, we just grab the “ranking” value from the result and add 1 to it. With that, we have successfully grabbed an individual user’s overall rank on the site, in real time.</p><p>I hope this method is of use to someone else out there that runs into a similar problem! Feel free to reach out to me on Twitter (@dan_delaney8) if you have any questions about this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c072b2aa550" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dan-delaney/assigning-a-real-time-ranking-order-index-to-a-sorted-list-using-the-mongodb-aggregation-framework-1c072b2aa550">Assigning a real-time ranking/order/index to a sorted list using the MongoDB Aggregation framework</a> was originally published in <a href="https://medium.com/dan-delaney">Dan Delaney</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Reasons To Not Let This Election Divide Us]]></title>
            <link>https://medium.com/dan-delaney/3-reasons-to-not-let-this-election-divide-us-4a756c3dbf97?source=rss----334d38f8d8a1---4</link>
            <guid isPermaLink="false">https://medium.com/p/4a756c3dbf97</guid>
            <category><![CDATA[trump]]></category>
            <category><![CDATA[vote]]></category>
            <category><![CDATA[2016-election]]></category>
            <category><![CDATA[clinton]]></category>
            <category><![CDATA[politics]]></category>
            <dc:creator><![CDATA[Dan Delaney]]></dc:creator>
            <pubDate>Mon, 07 Nov 2016 19:55:52 GMT</pubDate>
            <atom:updated>2016-11-07T19:55:51.550Z</atom:updated>
            <content:encoded><![CDATA[<p>This election has pitted Americans against each other more than any other election I&#39;ve witnessed in my life, or even read about. There have been far more political posts on social media this year than ever before, because Americans are so upset about the opposing candidate. It really sickens me to see people ending friendships, starting fights, and even turning to violence at rallies, all because of these two divisive candidates.</p><p>I want to encourage everyone to not let the election hysteria to divide us as a nation. Don’t allow the media to stir up such a frenzy among us.</p><p>Try to remember these 3 things:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V_35o8dtZjwWyB9qP10o0Q.jpeg" /></figure><p>1) <strong>Sure it matters who gets elected, but not <em>that</em> much.</strong> We have the separation of powers in our system of government for a reason: to prevent abuse of power by any of the 3 branches. You can argue that the presidencies of George W. Bush and Barrack Obama have resulted in more power being taken by the executive branch, but I believe there is a bright side here: we have more voices than ever, in journalism and in Congress, speaking out about these abuses of power. Rand Paul, Justin Amash, and Thomas Massie regularly defend the Constitution in the House and Senate, talking about how we need to go to war only after a Congressional vote. We have countless people on the internet bringing this to light as well. As a nation we can, and will, continue to speak out and hold our executive branch accountable.</p><p><strong>2) Your Trump/Clinton supporting friend is not a bad person.</strong> For the most part, we all have the same goals as a people. We want our economy to succeed, we want to be a free country, we want to defend ourselves, and we want to be prosperous, both individually, and as a country. It is rare that someone actually wishes ill will on other Americans, so our differences really come down to disagreements on how we best implementation solutions to arrive at the agreed upon goal.</p><p>The next time you find yourself arguing over a pair of political candidates, or about a political issue, please try to do the following:</p><ol><li>Take a step back, and realize that we’re in this together</li><li>Do your research, and try to have a civilized, informed discussion on strategy to arrive at the goal</li><li>Don’t get angry or caught up in emotions when someone disagrees with you. Rather, present your evidence debate back and forth, and come to an understanding together of why you both believe the things you do.</li></ol><p>3) <strong>If your candidate doesn’t win, it’s not the end of the world.</strong> Plenty of elections have gone by where the media has preached that there would be fire and brimstone if a candidate got elected. And then they did get elected. And we’re still here, not doing too poorly as a nation. Sure things could be better, but casting your one vote for President isn’t going to make a whole lot of difference in the grand scheme of things. If you really care about a certain issue or cause, put your heart and soul into doing whatever you can to help, other than just voting. If you do this, you can, and will, make a difference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a756c3dbf97" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dan-delaney/3-reasons-to-not-let-this-election-divide-us-4a756c3dbf97">3 Reasons To Not Let This Election Divide Us</a> was originally published in <a href="https://medium.com/dan-delaney">Dan Delaney</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Welcome!]]></title>
            <link>https://medium.com/dan-delaney/welcome-151a04fea389?source=rss----334d38f8d8a1---4</link>
            <guid isPermaLink="false">https://medium.com/p/151a04fea389</guid>
            <dc:creator><![CDATA[Dan Delaney]]></dc:creator>
            <pubDate>Sun, 23 Oct 2016 06:52:33 GMT</pubDate>
            <atom:updated>2016-10-23T06:52:32.579Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey everyone, welcome to my new blog/website. I’m hoping to post a variety of content on here, basically whatever I think could be valuable to put out there to the world, with the occasional rambling of thoughts from my head on a certain subject.</p><p>Stay tuned!</p><p>-Dan</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=151a04fea389" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dan-delaney/welcome-151a04fea389">Welcome!</a> was originally published in <a href="https://medium.com/dan-delaney">Dan Delaney</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>