Last week I published the Hacker Top program and promised to explain how it was made. Before I do that, let me publish another similar program for Reddit. It's the Reddit Top program.
As I mentioned in the Hacker Top post, Reddit is my favorite source for news because of the great programmer community it has. I actually unsubscribed from all the default subreddits (politics, pics, etc.) and subscribed to some 20 - 30 programming subreddits (like python, erlang, compsci and many others).
Reddit Top was actually derived from Hacker Top. Hacker Top was made in such a manner that it required me just to write a new parser for Reddit to create the new program. The program is written in Python programming language and uses ncurses interface for displaying the stories.
Download
Download link: catonmat.net/ftp/reddit-top.tgz
I'll describe the process of creating the program in one of the next posts.
If you want to read about that, I suggest you subscribe to my rss feed.
Note - this program is released under GNU GPL.
How to run the program?
1) Make sure you are running a Unix type operating system.
2) Make sure you have Python installed. Any recent version will do.
3) Download and unpack the hacker top program archive.
$ wget 'https://catonmat.net/ftp/reddit-top.tgz' $ tar -xvzf reddit-top.tgz
4) Change to 'reddit-top' directory which was created by unpacking the archive.
$ cd reddit-top
5) Give the 'reddit_top.py' program execute permissions.
$ chmod u+x reddit_top.py
6) Run the reddit_top.py program.
$ ./reddit_top.py
(If that does not work out, try running 'python ./reddit_top.py')
Make sure that your terminal is at least 80 columns wide, otherwise the program won't be able to display the results nicely.
Command Line Options
If you run the program with '--help' argument, it will display the possible command line options:
Usage: ./reddit_top.py [-h|--help] - displays this Usage: ./reddit_top.py [-s|--subreddit subreddit] [-i|--interval interval] [-n|--new] [-u|--utf8 <on|off>]
As the help message suggests, the four main options are:
- -s or --subreddit, which specifies the subreddit to monitor.
The default is reddit's front page (http://www.reddit.com).
At the moment it is not possible to specify multiple subreddits. I'll add the feature in the future. Here are a few examples of valid subreddits - 'programming', 'wtf', 'python', 'politics', and others. - -i or --interval, which specifies refresh interval.
The default refresh interval is 1 minutes. Here are a few examples: 10s (10 seconds), 12m (12 minutes), 2h (2 hours). - -u or --utf8, turns on utf8 output mode.
Default: off. Use this if you know for sure that your terminal supports it, otherwise you might get gibberish. - -n or --new, which follows only the newest reddit stories on a given subreddit or front page.
Default: follow front page stories.
Keyboard Shortcuts
There are several keyboard shortcuts which you should know about when using the Reddit Top program:
- q - quits the program.
- u - forces an update of the news.
- up arrow/down arrow (or alternatively j/k keys) - scrolls the news list up or down.
- m - changes the display mode. There are 5 different display modes for your taste.
Download Reddit Top Program
Download link: reddit-top.tgz
Next, I'll write a detailed post about how this program works. See you then!