Skip to content

Instantly share code, notes, and snippets.

import string
import random
import time
chars = string.digits + string.ascii_letters + string.punctuation + ' '
iterations_per_character_revealed = 2
update_delay = 0.05
choices = ['Edmond To', 'Tu Yong Tan', 'Clement Chua', 'Wei Quan Ng']
import random
import re
def parse_text(text):
"""Returns a list of sentence chains extracted from text."""
text = text.strip()
sentences = []
for line in text.splitlines():
import praw
CLIENT_ID = 'YOUR_CLIENT_ID'
CLIENT_SECRET = 'YOUR_CLIENT_SECRET'
REDDIT_USERNAME = 'your reddit username'
# https://www.reddit.com/r/singapore/comments/8eoesx/rsingapore_random_discussion_and_small_questions/
submission_id = '8eoesx'
reddit = praw.Reddit(client_id=CLIENT_ID, client_secret=CLIENT_SECRET,
import argparse
import re
import sys
import time
import praw
CLIENT_ID = 'YOUR_CLIENT_ID'
CLIENT_SECRET = 'YOUR_CLIENT_SECRET'
REDDIT_USERNAME = 'your Reddit username'
import argparse
import sys
import markovify
def main(files, n):
text = ''
for f in files:
@yi-jiayu
yi-jiayu / submissions.csv
Created May 20, 2018 14:51
Data used to analyse Reddit submissions for Benford's law
tab subreddit id score num_comments
hot gaming 8ks3o4 15084 213
hot aww 8krvk4 13202 203
hot NatureIsFuckingLit 8ks1sn 6366 172
hot worldnews 8krdwg 17227 1940
hot PrequelMemes 8krmxy 10996 74
hot gifs 8kr91u 28793 597
hot FortNiteBR 8krn5p 10476 202
hot MadeMeSmile 8krwsu 4905 55
hot technology 8krbip 10103 772
select
  p.web_name,
  t.name                as club,
  r.singular_name_short as position,
  max(p.total_points)   as total_points
from players p left join teams t on p.team = t.id
  left join roles r on p.element_type = r.id
group by p.team;
@yi-jiayu
yi-jiayu / benford.ipynb
Last active June 12, 2018 15:51
Analysing Reddit submissions for Benford's Law https://blog.jiayu.co/2018/05/benfords-law-and-reddit/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yi-jiayu
yi-jiayu / README.md
Last active June 16, 2018 02:42
The SUTD logo as a PBM file

SUTD logo in PBM format

Using ImageMagick, you can render a PBM file into some other format, for example PNG:

Command

convert SUTD.pbm -scale 4000% -transparent white SUTD.png
@yi-jiayu
yi-jiayu / book.ipynb
Created July 30, 2018 16:35
NLB book info
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.