Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
**: Browse reddit from the command line (you'll have to change the location of your python *reddit*: Bindings to use reddipy from within the acme text editor from plan9ports (Plan 9 from User Space) reddit assumes is in the same folder. Change it to suit your tastes. To read a little more about the shell reddit script that drive…
import urllib,json
import argparse
parser = argparse.ArgumentParser()
parser.add_argument( 'subreddit', nargs=1,help="Subreddit to browse, f.e. programming")
args= parser.parse_args()
subreddit = args.subreddit[0]
a = urllib.urlopen(''+str(subreddit)+'/.json')
k = json.load(a)
except KeyError:
print "Problem reading reddit data. Please, try again in a few seconds"
storieslist = j['children']
for x in storieslist[0:9]:
title = x['data']['title']
URL = x['data']['url']
shortened = urllib.urlopen(""+URL).read()
votes = x['data']['score']
longer="..." if len(URL)>35 else "\t"
print str(counter)+"\t"+str(votes)+"\t"+title.encode("utf-8", "ignore")[0:35]+"..."
print "\t\t"+URL.encode("utf-8", "ignore")[0:35]+longer+ "\t" + shortened
./ $1 | 9p write acme/new/body
last=$(9p ls acme | sort -g | tail -n 1)
echo "name$1" | 9p write acme/$last/ctl
echo -n "clean" | 9p write acme/$last/ctl
echo -n "0,0" | 9p write acme/$last/addr
echo -n "dot=addr" | 9p write acme/$last/ctl
echo -n "show" | 9p write acme/$last/ctl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment