The Blog

Posts from January 2011

Jan 14

Brightcove::API.new(:home => BrightcoveOS)

By David Czarnecki

I am pleased to announce the brightcove-api gem that I maintain has a new home at the Brightcove Open Source portal.

In June 2010, I wrote the brightcove-api gem to interact with the Brightcove media APIs. We’ve used it to build sites like MLG.tv. Last night I attended the NY Brightcove User’s Group meeting and found out about their Brightcove Open Source portal. So, I wrote to the good folks behind the Open Source @ Brightcove effort to get the brightcove-api gem added to their third party projects. They offered me door #2 and a chance to make it the officially “official” library for interacting with the Brightcove Media API from Ruby.

And so here we are, the brightcove-api gem now lives alongside the other open source libraries for interacting with Brightcove. I’ll still be the maintainer of the library and since it’s open source, you can and always will be able to contribute to its continued development.

You can find more hilarity over on my Twitter account, CzarneckiD.

Jan 11

Thumbs Up

By David Czarnecki

In the process of investigating the potential use of the thumbs_up gem (enable voting in your Rails 3 application) on a project today, I came across 2 opportunities to contribute back to the project.

Those opportunities are now realities in that: I forked the project on GitHub, made my changes, and generated a pull request for those changes to be integrated back into the thumbs_up project. So, what did I change?

  • My first commit was a simple change to the documentation clarifying the use of one method. No brainer right?

  • My second commit was a bit more involved and wasn’t necessarily a change I thought had to be there, but might be nice to be included. It involved getting into some of the internals in how the database migration and model file are generated. If this commit isn’t integrated, I won’t lose any sleep over it. It was a great opportunity to learn about some of the internals of Rails 3 generators and Thor. I’m not going to lie in that before all was said and done, I wanted to shoot myself into the sun on a rocketship, but I’m over it now.

Why am I writing this blog post? It just gives me a warm and fuzzy feeling (apart from the scotch), to know that I can contribute my day-to-day work back to the development community for others to benefit. So, thumbs up to that right?

UPDATE: My changes (that now encompass the start of a test suite, have now been integrated into the thumbs_up gem. So d ‘ _ ’ b to open source!

You can find more hilarity over on my Twitter account, CzarneckiD.

Jan 5

Follow The Leader - Leaderboards with Ruby/Redis

By David Czarnecki1

Leaderboard: A board showing the ranking of leaders in a competition.

Do you need to create leaderboards for your application? Do you use Redis? Do you use Ruby? If you’ve answered yes to any or all of these questions, you might want to take a look at the leaderboard gem I am releasing today.

At Agora Games, one of the things we think a lot about is leaderboards. As they’re a small, but important part of the work we do, I’m looking for ways to improve leaderboard generation for various situations. This effort was really the logical next step to my blog post, Creating high score tables (leaderboards) using Redis. All of the information you’d probably be interested in as a developer in terms of working with the gem can be found on the leaderboard gem page. Here’s a quick rundown of some of the gem’s capabilities:

  • Attach to a new or existing leaderboard

  • Add and remove members from a leaderboard

  • Return information about a leaderboard such as total members, total pages

  • Return information about a member in the leaderboard such as their rank or score

  • Update score information about a member in the leaderboard

  • Retrieve the leaders from a leaderboard with ability to page within the leaderboard

  • Retrieve the leaders around a given member in a leaderboard, also known as an “Around Me” leaderboard

  • Retrieve information for an arbitrary list of members in a leaderboard, e.g. How do my friends compare against me?

I believe that this covers most of the interaction you might have with a leaderboard. But, if not, this code is open source, so feel free to contribute to its development.

You can find more hilarity over on my Twitter account, CzarneckiD.

Jan 2

Creating high score tables (leaderboards) using Redis

By David Czarnecki

To my other colleagues at Agora Games, I have one word: FIRST!

Now that I’ve got that out of my system, down to the business at hand. I’ve read a number of articles on Redis that mention how it could be used for high score tables (leaderboards), but I didn’t see any examples that would walk you through exactly how to do that. Time to rectify that since it’s 2011 and we still don’t have flying cars … so ,,|, future.

UPDATE: Please use the original post for any comments/feedback. This post is a placeholder.

UPDATE: All of this has been packaged up in the leaderboard gem on GitHub.

Leaderboards are a small, but important part of the engineering we do at Agora Games. As such, when not riding the short bus, I’m looking for ways to improve leaderboard generation for various situations. So, here’s how I might approach creating leaderboards using Redis.

I offer the following gist. Here’s the jist of the gist:

  • The following was prototyped using the redis CLI. You can obviously port the logic to your favorite language binding for Redis, *cough* Ruby *cough*.

  • You will be using the Sorted Set commands in Redis.

  • You will need to be running at least Redis 2.1.6 to use the ZREVRANGEBYSCORE method.

  • Add players to the HIGHSCORES “table” using the ZADD method.

  • Print out the players (with a given page size) from the HIGHSCORES “table” using the ZREVRANGEBYSCORE method to show scores from highest to lowest.

  • There is some bookkeeping code that you would do at the application level in terms of tracking what page you are on, dividing the total # of leaderboard entries into pages for a given page size, etc.

  • Create an “Around Me” leaderboard with scores of individuals above and below an individual player using a combination of the ZREVRANK and ZREVRANGEBYSCORE methods.

  • Again, there is some bookkeeping code that you would do at the application level in terms of tracking how many players above or below to show and taking into account offsets.

  • The data that you store for a given player could be richer than just the player name or player ID. This is probably a larger design consideration if you are considering the “Around Me” leaderboard situation.

{% gist 762065 %}

UPDATE: 1/3/2011: I updated the gist to do the “Around Me” leaderboard in 2 calls.

You can find more hilarity over on my Twitter account, CzarneckiD.

Jan 1

Creating high score tables (leaderboards) using Redis

By David Czarnecki

To my other colleagues at Agora Games, I have one word: FIRST!

Now that I’ve got that out of my system, down to the business at hand. I’ve read a number of articles on Redis that mention how it could be used for high score tables (leaderboards), but I didn’t see any examples that would walk you through exactly how to do that. Time to rectify that since it’s 2011 and we still don’t have flying cars … so ,,|, future.

UPDATE: All of this has been packaged up in the leaderboard gem on GitHub.

Leaderboards are a small, but important part of the engineering we do at Agora Games. As such, when not riding the short bus, I’m looking for ways to improve leaderboard generation for various situations. So, here’s how I might approach creating leaderboards using Redis.

I offer the following gist. Here’s the jist of the gist:

  • The following was prototyped using the redis CLI. You can obviously port the logic to your favorite language binding for Redis, *cough* Ruby *cough*.

  • You will be using the Sorted Set commands in Redis.

  • You will need to be running at least Redis 2.1.6 to use the ZREVRANGEBYSCORE method.

  • Add players to the HIGHSCORES “table” using the ZADD method.

  • Print out the players (with a given page size) from the HIGHSCORES “table” using the ZREVRANGEBYSCORE method to show scores from highest to lowest.

  • There is some bookkeeping code that you would do at the application level in terms of tracking what page you are on, dividing the total # of leaderboard entries into pages for a given page size, etc.

  • Create an “Around Me” leaderboard with scores of individuals above and below an individual player using a combination of the ZREVRANK and ZREVRANGEBYSCORE methods.

  • Again, there is some bookkeeping code that you would do at the application level in terms of tracking how many players above or below to show and taking into account offsets.

  • The data that you store for a given player could be richer than just the player name or player ID. This is probably a larger design consideration if you are considering the “Around Me” leaderboard situation.

{% gist 762065 %}

UPDATE: 1/3/2011: I updated the gist to do the “Around Me” leaderboard in 2 calls.

You can find more hilarity over on my Twitter account, CzarneckiD.