Skip to content

Instantly share code, notes, and snippets.

View benrudolph's full-sized avatar
💭
🤸‍♂️

Ben Rudolph benrudolph

💭
🤸‍♂️
View GitHub Profile
@benrudolph
benrudolph / python_types.py
Last active September 23, 2019 16:42
Python Types
# Resources
# - https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html
# - https://mypy.readthedocs.io/en/latest/introduction.html
#
# Typing None is useful because mypy default to dynamic typing and a return value of Any when the return value is left off. Therefore, calling something like `1 + hello()` where hello returns `None` will result in an error:
#
# demo.py:5: error: "hello" does not return a value
def hello() -> None:
print('Hello')
@benrudolph
benrudolph / README.md
Last active February 24, 2018 19:34
Starting new React projects

Start a new typescript react project

create-react-app <app_name> --scripts-version=react-scripts-ts

Basic deps

# For building css and js in the same command
yarn add npm-run-all
@benrudolph
benrudolph / guest_post.md
Last active October 3, 2017 15:02
Guest Post

Reddit is a treasure trove for excellent product recommendations. The site promotes unbiased product recommendations and bans posts from promoting products. On the downside, these recommendations are often ephemeral and you have to be monitoring Reddit often to get in on the recommendations. I looked through 100s of GBs of Reddit comment data to find some of the best recommendations that Reddit has to offer.

What type of products is Reddit recommending? Well, of the almost 100,000 products mentioned on Reddit since 2015, 30,081 are books. Unsurprisingly, almost all subreddits on Reddit recommend books. However, there are a few that stand out as subreddits that recommend a particularly large number of books. The top 5 subreddits are:

  1. AskHistorians (704 book mentions)
  2. comicbooks (621 book mentions)
  3. todayilearned (595 book mentions)
  4. politics (415 book mentions)
  5. Christianity (373 book mentions)
@benrudolph
benrudolph / projects.md
Last active September 27, 2017 06:46
Projects

ThingsOnReddit

ThingsOnReddit is a website to allow users to view amazon products found on different Reddit subreddits. It allows users to find unique recommendations that would not otherwise be discoverable. It also allows users to sign up for a newsletter with curated products that are the best of the month. Lastly, ThingsOnReddit allows users to view trends in the products being posted to Reddit to gain further insights, such as what type of products are people posting to Reddit and how often.

Current infrastructure

Filters

Rendering

Filters are defined on the report on the fields attribute. Every filter is injected into the report context and then in a template they are looped over and rendered:

{% for field in report_filters %}
 
apps/session_middleware.js entities/cc_app.js entities/sessions.js spec/hq.events_spec.js users/user_controller.js
apps/session_nav.js entities/globals.js models/user.js spec/menu_list_test.js users/utils.js
collections/user.js entities/menu.js spec/fixtures.js spec/user_spec.js users/views.js
apps/list:
list_controller.js list_view.js
apps/menus:
menu_controller.js menu_view.js query_view.js
select *, REGEXP_REPLACE(REGEXP_REPLACE(word, r'^[^:]*:', ''), r':[^:]*$', '') as emoticon from (
SELECT type, repo.name, actor.login, org.login,JSON_EXTRACT(payload, '$.comment.id') as comment_id, JSON_EXTRACT(payload, '$.comment.url') as url, SPLIT(JSON_EXTRACT(payload, '$.comment.body'), ' ') as word, MONTH(TIMESTAMP(REGEXP_REPLACE(JSON_EXTRACT(JSON_EXTRACT(payload, '$.comment'), '$.created_at'), r'"|T.*', ''))) as m
FROM (TABLE_DATE_RANGE([githubarchive:day.events_],
TIMESTAMP('2015-03-01'),
TIMESTAMP('2015-03-10')
))
WHERE (type = 'IssueCommentEvent' OR type = 'PullRequestReviewCommentEvent' OR type = 'CommitCommentEvent') AND org.login = 'dimagi' AND actor.login <> 'dimagimon'
)
author emoji
benrudolph 100
benrudolph astonished
benrudolph balloon
benrudolph bear
benrudolph bird
benrudolph birthday
benrudolph blowfish
benrudolph boat
benrudolph bomb
month author count
1 benrudolph 1
1 biyeun 1
1 czue 4
1 esoergel 3
1 millerdev 1
1 snopoke 4
2 benrudolph 1
2 czue 13
2 dannyroberts 1