Skip to content

Instantly share code, notes, and snippets.

@sripathikrishnan
Last active February 28, 2018 01:54
Show Gist options
  • Select an option

  • Save sripathikrishnan/623adf30e1806daa56478dbd217bbb29 to your computer and use it in GitHub Desktop.

Select an option

Save sripathikrishnan/623adf30e1806daa56478dbd217bbb29 to your computer and use it in GitHub Desktop.
Solutions to RedisOverflow assignment
Build Page: https://datascience.stackexchange.com/questions/694/best-python-library-for-neural-networks
1. Get Question Details
hgetall questions:694
2. Get tags for this question
smembers questions:694:tags
3. Get all comments for this question:
lrange posts:694:comments 0 -1
# in a for loop with pipeline enabled
hgetall comments:1733
hgetall comments:2291
hgetall comments:6758
hgetall comments:6781
hgetall comments:6791
hgetall comments:6807
hgetall comments:6826
hgetall comments:6829
hgetall comments:8833
hgetall comments:9032
hgetall comments:24898
hgetall comments:27621
4. Get linked questions for this question
smembers questions:694:linked_questions
# in a for loop with pipeline enabled
hmget questions:9179 title score
hmget questions:9457 title score
hmget questions:12919 title score
5. Get answers for this question:
smembers questions:694:answers
# in a for loop with pipeline enabled
hgetall answers:695
hgetall answers:703
hgetall answers:771
hgetall answers:794
hgetall answers:5389
hgetall answers:6399
hgetall answers:8773
hgetall answers:8786
hgetall answers:8908
hgetall answers:9240
hgetall answers:9576
hgetall answers:10166
hgetall answers:14770
hgetall answers:15682
hgetall answers:16581
6. Get all the userid to username for all users on this page:
TODO: write python code
Build User Profile Page https://datascience.stackexchange.com/users/8820/martin-thoma
7. Get user details
hgetall users:8820
8. Get number of questions asked by this user
zcard users:8820:questions_by_score
9. Get number of answers answered by this user
zcard users:8820:answers_by_score
10. Get top 20 questions asked by this user, along with title, score and date the question was asked
zrevrange users:8820:questions_by_score 0 20
# in a for loop with pipeline enabled
hmget questions:6107 title score creation_date
hmget questions:9302 title score creation_date
hmget questions:9818 title score creation_date
hmget questions:12830 title score creation_date
hmget questions:12851 title score creation_date
hmget questions:9175 title score creation_date
hmget questions:10000 title score creation_date
hmget questions:9233 title score creation_date
hmget questions:18583 title score creation_date
hmget questions:16045 title score creation_date
hmget questions:9195 title score creation_date
hmget questions:17079 title score creation_date
hmget questions:15328 title score creation_date
hmget questions:10204 title score creation_date
hmget questions:9832 title score creation_date
hmget questions:9528 title score creation_date
hmget questions:9406 title score creation_date
hmget questions:10127 title score creation_date
hmget questions:24728 title score creation_date
hmget questions:20271 title score creation_date
hmget questions:18414 title score creation_date
11. View all badges this user has earned
smembers users:8820:badges
12. Get the rank of user https://datascience.stackexchange.com/users/84/rubens
zrevrank users_by_reputation 84
13. Get 5 users above and below user 84
zrevrange users_by_reputation 8 18
Build Users page: https://datascience.stackexchange.com/users?tab=Reputation&filter=all
14. Show list of users sorted by all time reputation
zrevrange users_by_reputation 0 100
... then fetch user details by hgetall
Set Intersections
15. Get questions that are tagged python and keras, ordered by votes
https://datascience.stackexchange.com/questions/tagged/python+keras
zinterstore random1323 2 tags:python:questions_by_score tags:keras:questions_by_score
Then fetch all the questions
Finally, delete the key random1323
Interactions
============
16. Upvote a question
17. Add a comment
18. Upvote a comment
19. Add an answer
20. Add a tag to a question
Lua Script
==========
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment