List of helpful shortcuts for faster coding
If you have any other helpful shortcuts, feel free to add in the comments of this gist :)
| import pandas as pd | |
| import requests | |
| import json | |
| def getPushshiftData(after, sub): | |
| url = 'https://api.pushshift.io/reddit/search/submission?&size=1000&after='+str(after)+'&subreddit='+str(sub) | |
| r = requests.get(url) | |
| data = json.loads(r.text) | |
| return data['data'] |
| #!/usr/bin/env python | |
| # -*- coding: UTF-8 -*- | |
| # Roughly based on: http://stackoverflow.com/questions/11443302/compiling-numpy-with-openblas-integration | |
| from __future__ import print_function | |
| import numpy as np | |
| from time import time |
| """Simple example on how to log scalars and images to tensorboard without tensor ops. | |
| License: BSD License 2.0 | |
| """ | |
| __author__ = "Michael Gygli" | |
| import tensorflow as tf | |
| from StringIO import StringIO | |
| import matplotlib.pyplot as plt | |
| import numpy as np |
| import sys | |
| CAFFE_ROOT = '../../' | |
| sys.path.insert(0, CAFFE_ROOT + 'python/') | |
| import caffe | |
| import numpy as np | |
| if len(sys.argv) != 3: | |
| print "Usage: python protomean_to_npy.py proto.mean out.npy" | |
| sys.exit() |
| These commands are based on a askubuntu answer http://askubuntu.com/a/581497 | |
| To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below. | |
| USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING. | |
| ABSOLUTELY NO WARRANTY. | |
| If you are still reading let's carry on with the code. | |
| sudo apt-get update && \ | |
| sudo apt-get install build-essential software-properties-common -y && \ | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \ |
| # use the following snippet in your ipython notebook shell | |
| import argparse | |
| import tensorflow as tf | |
| tf.app.flags.FLAGS = tf.python.platform.flags._FlagValues() | |
| tf.app.flags._global_parser = argparse.ArgumentParser() |