Using the <source> element:
| """ | |
| Imagine you have several Jupyter notebooks containing figure you would like to convert to Markdown. | |
| # Using the notebook server: | |
| If you use File->Download as Markdown you get: | |
| Downloads/ | |
| notebook.zip | |
| from flask import Flask | |
| app = Flask(__name__) | |
| # Register core.utils with all template contexts | |
| import utils | |
| @app.context_processor | |
| def utils_context(): | |
| return utils.registry |
| """ | |
| Remove *all* default, hard-coded, CSS classes and inline styling attached to tables when calling df.to_html(), | |
| and add your own classes to each tag ad hoc. | |
| This will probably be extremely simple in the future when the styling API is more mature. For now, we bleach it. | |
| May need to `conda install bleach` or `pip install bleach` | |
| """ | |
| import pandas as pd |
How to get almost equivalent Porter stemmers between Java and Python.
One remaining difference is how they handle non-dictionary words ending in "s":
Assuming you tokenize the following string after lowercase normalization using [a-z]\w+...
"EMI"s request for an appeal should be denied until a final judgment is entered. Document filed by Michael Robertson. (js) (Entered: 02/01/2012)"
| # You've got a Python dict in the driver program or shell | |
| x = {"a":1,"b":2} | |
| # You want to write it to a single HDFS file in JSON format | |
| sc.parallelize([x]).toDF().coalesce(1).write.mode('append').json(/hdfs/path/...) |
| #!/bin/bash | |
| # Usage string | |
| usage() { | |
| cat << USAGE | |
| This script exists to serialize a local conda environment. | |
| The output files produced by this script are version-controllable, allowing | |
| for the local conda env definition to included with the repository, distributed, | |
| and recreated on other hosts using either conda *or* pip. |
| // An array of discrete values (possibly dynamically generated) | |
| var discreteValues = ['John', 'Jack', 'Jill', 'Jane', 'Jim', 'Joan']; | |
| // 1st scale establishes relationship between continuous [0,1] and | |
| // the array index of the discrete values | |
| var preColor = d3.scaleLinear() | |
| .domain([0, discreteValues.length - 1]) | |
| .range([0, 1]); | |
| console.log(preColor(discreteValues.indexOf('John'))) // 0 | |
| console.log(preColor(discreteValues.indexOf('Jack'))) // 0.2 | |
| console.log(preColor(discreteValues.indexOf('Joan'))) // 1.0 |