Archive
Become a Reddit power user
Goal
You want to become a Reddit power user.
Tip
Install the Reddit Enhancement Suite Firefox add-on. The result will be a Reddit on steroids :)
Links
- RES @firefoxfacts (with a short description)
- RES @mozilla.org (install)
- RES HQ (read more)
- RES @reddit (discussion, feature requests)
Let’s go back to the 80s
I always think of the 80s as the best decade of my life. I guess it’s because that’s when I was a child :) Now we can go back in time with reddit’s timeline: http://www.reddit.com/t/1980s/.
Browse all pages of a subreddit
Problem
When you visit a subreddit on reddit.com, for instance http://www.reddit.com/r/python, at the bottom of the page you will find just a “next” link to the next page. Needless to say, browsing older entries like that is a PITA…
Solution
I made a simple script that generates a static HTML page with links to all the older pages: [1] [2] [3]…
Download
You can find the script reddit_get_all_pages.py in my Bash-Utils collection, in the reddit/ folder.
Usage
Customize the constant REDDIT in the header of the script and execute it:
./reddit_get_all_pages.py
Limitation
This script made me figure out that reddit lists only the last 1000 posts! Older posts are hidden. If you have a direct link to them, fine, otherwise they are gone :( So this script will only list 40 pages. This is a limitation of reddit.
More info:
Browse your favorite subreddits painlessly
Problem
You visit your favorite subreddit and you notice that it’s full of new posts. If you want to check them all, you need to click on each post. How to open all these posts in new tabs?
Solution
I made a little Python script for solving this problem (available here, in the folder “reddit”). Just specify a subreddit and what to extract (comment links [-c switch] or direct URLs [-u switch]). The script will list the available links. With another script of mine you can open these links in Firefox.
Basic usage
./reddit_get_posts.py -c /r/earthporn
Get links to comments of subreddit “earthporn”.
./reddit_get_posts.py -u /r/earthporn
Get links to direct URLs of subreddit “earthporn”.
./reddit_get_posts.py -u http://www.reddit.com/r/earthporn
You can specify the complete URL of the subreddit.
./reddit_get_posts.py -u http://www.reddit.com/r/EarthPorn/?count=25&after=t3_jffyd
You can even browse pages on reddit.com.
./reddit_get_posts.py -u
Extract links of your favourite subreddit (specify it with the constant DEFAULT_REDDIT).
Advanced usage
This script can be used together with another script of mine called open_in_tabs.py, which
is part of this Bash-Utils project too. open_in_tabs.py can open the extracted links in
your Firefox instance. Example:
./reddit_get_posts.py -u /r/earthporn | open_in_tabs -s
This will open the links simultaneously (-s switch) in Firefox.
Pretty print a JSON file
This post is based on the following SO threads: one; two.
Problem
You have an unreadable JSON file from which you want to extract some data… How to prettify it, i.e. how to make it human readable?
Solution
There are web-based and command-line solutions. As an extra, we show you how to do it in Vim too.
Web-based prettifiers
- http://chris.photobooks.com/json/default.htm (it can show you the path of a tag too)
- http://pretty-print.org/
- http://jsonviewer.stack.hu/
- http://www.shell-tools.net/index.php?op=json_format
- http://jsonlint.com/
- http://jsonformatter.curiousconcept.com/ (formatter and validator)
Command-line beautifiers
curl -s http://www.reddit.com/r/nsfw/.json | python -mjson.toolsudo apt-get install edit-json; prettify_json myfile.json
Vim :)
This tip is based on this post: Editing json files in vim.
In my .vimrc file I had to add the following lines:
" pretty-print JSON files autocmd BufRead,BufNewFile *.json set filetype=json " json.vim is here: http://www.vim.org/scripts/script.php?script_id=1945 autocmd Syntax json sou ~/.vim/syntax/json.vim " json_reformat is part of yajl: http://lloyd.github.com/yajl/ autocmd FileType json set equalprg=json_reformat
When opening a .json file, it will be colored using the json.vim syntax file. Selecting a text and pressing the “=” button will indent the marked text using json_reformat.
Firefox add-on
There are several JSON visualizer add-ons for Firefox, e.g. JSONView.
Wallpaper Downloader and Rotator for Gnome
Update (20110915): The project has changed a lot since its first release, thus the original post here got completely outdated. I rewrote this blog entry to reflect the current state of the project.
Description
The goal of this project is twofold. First, download images from a wallpaper site. Second, rotate the downloaded images as wallpapers.
Here is the list of changes that I added to the original version:
- New! XML support is dropped. For setting the images as wallpapers, use the script
02_wallpaper_rotator.py. - New! Support for 4walled.org is added!
- New! Support for wallbase.cc is added!
- Large images can be resized to fit your screen resolution. By default, the maximum width of images can be 1920 pixels. You can customize it in the config file. It’s recommended, this way the images will occupy much less space on your hard drive.
- You can specify several categories and the downloader will grab images from all these sites. The same is true for rotator: you can specify several categories and it will pick a random image from the whole list. See the config file for more details.
- The project includes an automatic wallpaper changer script called
02_wallpaper_rotator.py. You don’t need any third-party managers anymore. - You can choose from several categories. You can also specify your favorite category.
- Screen scraping is done with the BeautifulSoup library.
- The most important change is the filtering of images that are unsuitable as wallpapers, i.e. small images, portrait images, and images with strange ratio are removed from the list.
- Support for Flickr images (zioyero’s patch).
- The URLs of the downloaded images are strored in an SQLite database. This way an already fetched image (either good or bad) won’t be downloaded again.
Supported wallpaper sites
Usage
First, you might want to customize some settings in the config.py file. The most important thing is the PHOTO_DIR directory, i.e. where to store the downloaded images. Create this directory if it doesn’t exist. Then, simply launch the script:
./01_wallpaper_downloader.py
You can also add it to your crontab:
$ crontab -e 10 */2 * * * /absolute_path_to/01_wallpaper_downloader.py
Add the second line to the end of the crontab list. Here the script is called at every two hours (at 0h10, 2h10, etc.).
For setting the images as wallpapers:
./02_wallpaper_rotator.py &
That is, just launch it in the background. It uses the same config file as the wallpaper downloader. I put it among my startup applications, thus it starts automatically.
Download
You can download the script from https://github.com/jabbalaci/Wallpaper-Downloader-and-Rotator-for-Gnome.
Related posts
Notes about reddit
I started to use reddit (wikipedia entry) a few days ago and I find it amazing. How could I live so far without it? :) As there are lots of things to discover, I’ll make some notes here.
For a list of subreddits, visit http://www.reddit.com/reddits/. Help, FAQ.
For finding reddits easily, try metareddit.com, very useful. Here is an older post with the Top 10 subreddits that can give an idea what reddits are the most popular.
For posting images, use imgur.com.
Here is a post about Reddit’s (secret) API. In a comment there it is pointed out that you can add “.json” to any reddit address to get the content in JSON format! Example: http://www.reddit.com/r/EarthPorn/.json. This way, screen scraping is not necessary.
Update (20110518)
Some useful links:
- FAQ
- help on formatting comments
- find subreddits (metareddit, subredditfinder, subreddits)
- new reddits
- reddits with FAQs
- reddpics (browse images of subreddits)
- University of Reddit
Update (20121003)
What is reddit? (in Hungarian)
Cool wallpapers
I will collect here some links with cool wallpapers:
- http://www.desktoppr.co/ (NEW)
- http://wallbase.cc (awesome)
- http://4walled.org/
- wallpaper and wallpapers on wordpress.com
- http://www.geekwallpapers.com/, http://www.sciencewallpaper.com/, http://www.knifewallpapers.com/
- Gnome wallpapers
Cool images on reddit (don’t be afraid of the ‘Porn’ titles, it’s not what it seems to be):
- EarthPorn: Mother Nature in all of her succulent beauty. (great)
- CityPorn: Oh pedobear, it’s not that kind of CP, silly! (great)
- SpacePorn: High Res Images of Space, Stargazer’s Delight (great)
- MachinePorn: Check out the headlights on that porsche. I think my driveshaft just got torqued.
- Human Porn: Beauty is in the eye of the beholder
- AnimalPorn: High quality animal photography will make you shiver and moan (great)
- BotanicalPorn: Feed me Seymour. Feeeed meeeeeee! (nice)
- DestructionPorn: Burn Baby Burn!
- GeekPorn
- AdPorn: Where’s the beef?
- *Porn: all the previous together
Related
