This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bind(self, method): | |
| def new_method(new_self, *args, **kwargs): | |
| new_self.data = method(self.data, *args, **kwargs) | |
| return new_self | |
| setattr(self, method.__name__, types.MethodType(new_method, self)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json, requests, time | |
| import datetime | |
| import pickle | |
| from collections import Counter | |
| from pyquery import PyQuery | |
| from readability import Document | |
| from lxml.etree import XMLSyntaxError, LxmlError | |
| from readability.readability import Unparseable | |
| from requests.adapters import MaxRetryError | |
| from requests.exceptions import ConnectionError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from IPython.core.display import display, HTML, clear_output | |
| from ipywidgets import widgets, Layout | |
| import math | |
| PAGESIZE=10 | |
| class Paginator: | |
| def __init__(self, df, pagesize = PAGESIZE, start_page = 0): | |
| self.df = df | |
| self.pagesize = pagesize | |
| self.page = start_page |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # After Ubuntu 16.04, Systemd becomes the default. | |
| # It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd | |
| [Unit] | |
| Description=Jupyter Notebook | |
| [Service] | |
| Type=simple | |
| PIDFile=/run/jupyter.pid | |
| ExecStart=/home/nokados/anaconda3/bin/jupyter-notebook --config=/home/nokados/.jupyter/jupyter_notebook_config.py --no-browser |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| %matplotlib inline | |
| def parallel_shuffle(*arrays): | |
| length = arrays[0].shape[0] | |
| for arr in arrays: | |
| assert arr.shape[0] == length | |
| p = np.random.permutation(length) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests | |
| def download_file_from_google_drive(id, destination): | |
| def get_confirm_token(response): | |
| for key, value in response.cookies.items(): | |
| if key.startswith('download_warning'): | |
| return value | |
| return None |
OlderNewer