This file contains 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
""" | |
Python script showing how html diffs of Jupyter notebooks can be created | |
non-interactively (e.g. from the command-line in CI) using nbdime | |
(https://github.com/jupyter/nbdime) in combination with nbdime PR #744: | |
https://github.com/jupyter/nbdime/pull/744 | |
Usage: | |
$ python test-nbdime-html-diff.py NB_PATH1 NB_PATH2 |
This file contains 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 asyncio | |
import random | |
NO_READERS_EVENT = asyncio.Event() | |
NO_WRITERS_EVENT = asyncio.Event() | |
WRITE_LOCK = asyncio.Lock() | |
class State: |
This file contains 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
""" | |
This module illustrates a difference in exception handling between | |
generator functions and context managers. | |
This script should be run with **Python 3.4.2** or higher (which is what | |
it was originally run with). | |
To witness what is illustrated in this module, run the following two | |
commands from the command-line. |
This file contains 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
#!/usr/bin/env python | |
""" | |
Python Pandoc filter [1] for converting a GitHub markdown file to a Python | |
reST long_description (suitable for display on PyPI). | |
Sample usage: | |
$ pandoc --filter ./md2rst.py --write=rst --output=long_description.rst README.md |
This file contains 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
// This is an example of using the Selenium WebDriver's Javascript API | |
// to connect to Sauce Labs (using the remote web driver) and doing | |
// a simple test. | |
// | |
// To run from the command-line: | |
// | |
// $ node drive.js | |
// | |
// You need to have selenium-webdriver installed with npm. |
This file contains 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
# Call virtualenvwrapper's "workon" if .venv exists. This is modified from-- | |
# http://justinlilly.com/python/virtualenv_wrapper_helper.html | |
# which is linked from-- | |
# http://virtualenvwrapper.readthedocs.org/en/latest/tips.html#automatically-run-workon-when-entering-a-directory | |
check_virtualenv() { | |
if [ -e .venv ]; then | |
env=`cat .venv` | |
echo "Found .venv in directory. Calling: workon ${env}" | |
workon $env | |
fi |
This file contains 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
# Back up environments from chef server to a git repo. | |
# Run this from the top of your chef repo. | |
envs=`knife environment list` | |
for env in $envs | |
do | |
path="environments/${env}.json" | |
knife environment show $env -F json > $path | |
git add $path | |
done |
This file contains 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
""" | |
An example of decorating a built-in type with another object. | |
Attributes and methods on the built-in type delegate to the other object. | |
""" | |
class WrappedInt(int): | |
""" |
This file contains 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
""" | |
A simple mixin example. | |
This script illustrates using a mixin to impart a "foo" method to other | |
class definitions. | |
""" | |
class FooMixin(object): |
This file contains 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
# Bash shell script to strip a fixed-length prefix from the | |
# names of directories in a directory. | |
dir_names=`ls -d` | |
for dir_name in $dir_names | |
do | |
mv $dir_name ${dir_name:7} | |
done |
NewerOlder