brew install mongodb
mkdir -p /data/dbEnsure that user account running mongod has correct permissions for the directory:
| from collections import namedtuple | |
| def convert(dictionary): | |
| return namedtuple('GenericDict', dictionary.keys())(**dictionary) | |
| """ | |
| >>> d = dictionary(a=1, b='b', c=[3]) | |
| >>> named = convert(d) | |
| >>> named.a == d.a | |
| True | |
| >>> named.b == d.b |
| #!/usr/bin/env python | |
| from pocket import Pocket | |
| import webbrowser, sys | |
| # Get consumer key from cmd line | |
| consumer_key = sys.argv[1] | |
| request_token = Pocket.get_request_token( | |
| consumer_key=consumer_key, |
| # pylint: disable=W0612 | |
| import time | |
| import pandas as pd | |
| import numpy as np | |
| import iopro | |
| import gc |
| import pandas as pd | |
| import numpy as np | |
| from datetime import datetime | |
| # generate some fake tick data with 1 million observations | |
| n = 1000000 | |
| df = pd.DataFrame({ | |
| "timestamp": [datetime.now() for t in range(n)], | |
| "value": np.random.uniform(-1, 1, n) | |
| }) |
| from dateutil.parser import parse | |
| import pandas as pd | |
| # monthly slaughter records since 1921 | |
| df = pd.read_csv("http://bit.ly/119792b") | |
| # parse the data (we could also use pd.to_datetime) | |
| df.date = df.date.apply(parse) | |
| # sort the data frame by date | |
| df = df.sort(['date']) | |
| # create an index |
| // Word cloud layout by Jason Davies, http://www.jasondavies.com/word-cloud/ | |
| // Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf | |
| (function(exports) { | |
| function cloud() { | |
| var size = [256, 256], | |
| text = cloudText, | |
| font = cloudFont, | |
| fontSize = cloudFontSize, | |
| rotate = cloudRotate, | |
| padding = cloudPadding, |
| import nltk | |
| with open('sample.txt', 'r') as f: | |
| sample = f.read() | |
| sentences = nltk.sent_tokenize(sample) | |
| tokenized_sentences = [nltk.word_tokenize(sentence) for sentence in sentences] | |
| tagged_sentences = [nltk.pos_tag(sentence) for sentence in tokenized_sentences] | |
| chunked_sentences = nltk.batch_ne_chunk(tagged_sentences, binary=True) |
| #!/usr/bin/env python | |
| from pocket import Pocket | |
| import webbrowser, sys | |
| # Get consumer key from cmd line | |
| consumer_key = sys.argv[1] | |
| request_token = Pocket.get_request_token( | |
| consumer_key=consumer_key, |
| """ | |
| Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ] | |
| Modified from remove_output by Minrk | |
| """ | |
| import sys | |
| import io | |
| import os | |
| from IPython.nbformat.current import read, write |