Hidden Features of Red Dwarf

Posted in red dwarf and tagged , , , on by Rick Viscomi.

Red Dwarf

Red Dwarf is a project of mine that uses a Google Maps heatmap to visualize the locations of users who “star” a given GitHub repository. The code is naturally open source and can be seen visualizing itself in the image above. While the application is mostly a one trick pony, there are some cool hidden features to explore.

Embedded Button Red Dwarf Button

If you have a web page for your GitHub project, embed this button to take users to the heatmap. The code is bundled in a small iframe and is straightforward to customize:

<iframe src="//jrvis.com/red-dwarf/api/button?user=rviscomi&repo=red-dwarf&type=map&count=true" allowtransparency="true" frameborder="0" scrolling="0"></iframe>

This button leverages the GitHub Buttons project.

Turn Caching Off

Red Dwarf caches stargazer data (as it’s called) on the server. With all of the rate limitations of the GitHub and Google Maps APIs, caching is a necessary part of the application. Sometimes, though, you may want to bypass the cache and reload all of the data from scratch. There is a special querystring parameter and value that you can provide to instruct Red Dwarf to write to the cache, but not read from it. Especially if the cache is corrupted for whatever reason, this gives you the ability to regenerate the data and save it back to the server. The syntax for disabling the cache is cache=off. In the context of a full URL, it looks like this:

http://jrvis.com/red-dwarf/?user=rviscomi&repo=red-dwarf&cache=off

Replay Animation

This is my favorite of the hidden features. Part of the intrigue of the heatmap is watching it get put together, one star at a time. Unless the cache is outdated or you manually disable it, the heatmap will be displayed all at once. Even with a disabled cache, you’re still restricted by API rate limiting. So what can you do? By including the replay querystring parameter, Red Dwarf will clear the map, but instead of making the API requests over again it will iterate through the location data in the cache and paint them onto the heatmap one by one. If you supply a non-negative integer as the value of the replay parameter, this will be treated as the number of milliseconds to wait between paints (useful for slowing down the animation).

http://jrvis.com/red-dwarf/?user=rviscomi&repo=red-dwarf&replay

Watch it in action:

Are there any Red Dwarf features that you would like to see implemented? Leave a comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>