Converted notebook to v3.

This commit is contained in:
Donne Martin 2015-04-12 18:33:21 -04:00
parent ed0fe8c6aa
commit 2b043c6c50

View File

@ -1,358 +1,374 @@
{ {
"metadata": { "cells": [
"name": "",
"signature": "sha256:c39bbf32494020a300d424ed24cb9891d891ab8e67fe4c3162296bad4385c933"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{ {
"cells": [ "cell_type": "markdown",
{ "metadata": {},
"cell_type": "markdown", "source": [
"metadata": {}, "# Misc Commands\n",
"source": [ "\n",
"# Misc Commands\n", "* Anaconda\n",
"\n", "* IPython Notebook\n",
"* Anaconda\n", "* Git\n",
"* IPython Notebook\n", "* Ruby\n",
"* Git\n", "* Jekyll\n"
"* Ruby\n", ]
"* Jekyll\n" },
] {
}, "cell_type": "markdown",
{ "metadata": {},
"cell_type": "markdown", "source": [
"metadata": {}, "<h2 id=\"anaconda\">Anaconda</h2>"
"source": [ ]
"<h2 id=\"anaconda\">Anaconda</h2>" },
] {
}, "cell_type": "markdown",
{ "metadata": {},
"cell_type": "markdown", "source": [
"metadata": {}, "[Anaconda](https://store.continuum.io/cshop/anaconda/) is a scientific python distribution containing Python, NumPy, SciPy, Pandas, IPython, Matplotlib, Numba, Blaze, Bokeh, and other great Python data analysis tools."
"source": [ ]
"[Anaconda](https://store.continuum.io/cshop/anaconda/) is a scientific python distribution containing Python, NumPy, SciPy, Pandas, IPython, Matplotlib, Numba, Blaze, Bokeh, and other great Python data analysis tools." },
] {
}, "cell_type": "code",
{ "execution_count": null,
"cell_type": "code", "metadata": {
"collapsed": false, "collapsed": false
"input": [ },
"# See Anaconda installed packages\n", "outputs": [],
"!conda list\n", "source": [
"\n", "# See Anaconda installed packages\n",
"# Create Python 3 environment\n", "!conda list\n",
"!conda create -n py3k python=3 anaconda\n", "\n",
"\n", "# Create Python 3 environment\n",
"# Activate Python 3 environment\n", "!conda create -n py3k python=3 anaconda\n",
"!source activate py3k\n", "\n",
"\n", "# Activate Python 3 environment\n",
"# Deactivate Python 3 environment\n", "!source activate py3k\n",
"!source deactivate\n", "\n",
"\n", "# Deactivate Python 3 environment\n",
"# Update Anaconda\n", "!source deactivate\n",
"!conda update conda\n", "\n",
"\n", "# Update Anaconda\n",
"# Update a package with Anaconda\n", "!conda update conda\n",
"!conda update ipython" "\n",
], "# Update a package with Anaconda\n",
"language": "python", "!conda update ipython"
"metadata": {}, ]
"outputs": [] },
}, {
{ "cell_type": "markdown",
"cell_type": "markdown", "metadata": {},
"metadata": {}, "source": [
"source": [ "<h2 id=\"ipython-notebook\">IPython Notebook</h2>"
"<h2 id=\"ipython-notebook\">IPython Notebook</h2>" ]
] },
}, {
{ "cell_type": "markdown",
"cell_type": "markdown", "metadata": {},
"metadata": {}, "source": [
"source": [ "[IPython Notebook](http://ipython.org/notebook.html) is a \"web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document.\""
"[IPython Notebook](http://ipython.org/notebook.html) is a \"web-based interactive computational environment where you can combine code execution, text, mathematics, plots and rich media into a single document.\"" ]
] },
}, {
{ "cell_type": "code",
"cell_type": "code", "execution_count": null,
"collapsed": false, "metadata": {
"input": [ "collapsed": false
"# Start IPython Notebook\n", },
"ipython notebook\n", "outputs": [],
"\n", "source": [
"# Start IPython Notebook with built-in mode to work cleanly \n", "# Start IPython Notebook\n",
"# with matplotlib figures\n", "ipython notebook\n",
"ipython notebook --pylab inline\n", "\n",
"\n", "# Start IPython Notebook with built-in mode to work cleanly \n",
"# Start IPython Notebook with a profile\n", "# with matplotlib figures\n",
"ipython notebook --profile=dark-bg\n", "ipython notebook --pylab inline\n",
"\n", "\n",
"# Load the contents of a file\n", "# Start IPython Notebook with a profile\n",
"%load dir/file.py\n", "ipython notebook --profile=dark-bg\n",
"\n", "\n",
"# Time execution of a Python statement or expression\n", "# Load the contents of a file\n",
"%timeit\n", "%load dir/file.py\n",
"%%time\n", "\n",
"\n", "# Time execution of a Python statement or expression\n",
"# Activate the interactive debugger\n", "%timeit\n",
"%debug\n", "%%time\n",
"\n", "\n",
"# Write the contents of the cell to a file\n", "# Activate the interactive debugger\n",
"%writefile\n", "%debug\n",
"\n", "\n",
"# Run a cell via a shell command\n", "# Write the contents of the cell to a file\n",
"%%script\n", "%writefile\n",
"\n", "\n",
"# Run cells with bash in a subprocess\n", "# Run a cell via a shell command\n",
"# This is a shortcut for %%script bash\n", "%%script\n",
"%%bash\n", "\n",
"\n", "# Run cells with bash in a subprocess\n",
"# Run cells with python2 in a subprocess\n", "# This is a shortcut for %%script bash\n",
"%%python2\n", "%%bash\n",
"\n", "\n",
"# Run cells with python3 in a subprocess\n", "# Run cells with python2 in a subprocess\n",
"%%python3" "%%python2\n",
], "\n",
"language": "python", "# Run cells with python3 in a subprocess\n",
"metadata": {}, "%%python3"
"outputs": [] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"| Command | Description |\n", "| Command | Description |\n",
"|-----------|------------------------------------------|\n", "|-----------|------------------------------------------|\n",
"| ? | Intro and overview of IPython's features |\n", "| ? | Intro and overview of IPython's features |\n",
"| %quickref | Quick reference |\n", "| %quickref | Quick reference |\n",
"| help | Python help |\n", "| help | Python help |\n",
"| object? | Object details, also use object?? |" "| object? | Object details, also use object?? |"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"<h2 id=\"git\">Git</h2>" "<h2 id=\"git\">Git</h2>"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"[Git](http://git-scm.com/) is a distributed revision control system." "[Git](http://git-scm.com/) is a distributed revision control system."
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"collapsed": false, "execution_count": null,
"input": [ "metadata": {
"# Configure git\n", "collapsed": false
"!git config --global user.name 'First Last'\n", },
"!git config --global user.email 'name@domain.com'\n", "outputs": [],
"!git init\n", "source": [
"\n", "# Configure git\n",
"# View status and log\n", "!git config --global user.name 'First Last'\n",
"!git status\n", "!git config --global user.email 'name@domain.com'\n",
"!git log\n", "!git init\n",
"\n", "\n",
"# Add or remove from staging area\n", "# View status and log\n",
"!git add [target]\n", "!git status\n",
"!git reset [target file or commit]\n", "!git log\n",
"!git reset --hard origin/master\n", "\n",
"\n", "# Add or remove from staging area\n",
"# Automatically stage tracked files, including deleting the previously tracked files\n", "!git add [target]\n",
"!git add -u\n", "!git reset [target file or commit]\n",
"\n", "!git reset --hard origin/master\n",
"# Delete files and stage them\n", "\n",
"!git rm [target]\n", "# Automatically stage tracked files, including deleting the previously tracked files\n",
"\n", "!git add -u\n",
"# Commit\n", "\n",
"!git commit -m \u201cAdd commit message here\u201d\n", "# Delete files and stage them\n",
"\n", "!git rm [target]\n",
"# Add new origin\n", "\n",
"!git remote add origin https://github.com/donnemartin/ipython-data-notebooks.git\n", "# Commit\n",
"\n", "!git commit -m “Add commit message here”\n",
"# Set to new origin\n", "\n",
"!git remote set-url origin https://github.com/donnemartin/pydatasnippets.git\n", "# Add new origin\n",
" \n", "!git remote add origin https://github.com/donnemartin/ipython-data-notebooks.git\n",
"# Push to master, -u saves config so you can just do \"git push\" afterwards\n", "\n",
"!git push -u origin master\n", "# Set to new origin\n",
"!git push\n", "!git remote set-url origin https://github.com/donnemartin/pydatasnippets.git\n",
"\n", " \n",
"# Diff files\n", "# Push to master, -u saves config so you can just do \"git push\" afterwards\n",
"!git diff HEAD\n", "!git push -u origin master\n",
"!git diff --staged\n", "!git push\n",
"!git diff --cached\n", "\n",
"\n", "# Diff files\n",
"# Undo a file that has not been added\n", "!git diff HEAD\n",
"!git checkout \u2014 [target]\n", "!git diff --staged\n",
"\n", "!git diff --cached\n",
"# Create a branch\n", "\n",
"!git branch [branch]\n", "# Undo a file that has not been added\n",
"\n", "!git checkout — [target]\n",
"# Check branches\n", "\n",
"!git branch\n", "# Create a branch\n",
"\n", "!git branch [branch]\n",
"# Switch branches\n", "\n",
"!git checkout [branch]\n", "# Check branches\n",
"\n", "!git branch\n",
"# Merge branch to master\n", "\n",
"!git merge [branch]\n", "# Switch branches\n",
"\n", "!git checkout [branch]\n",
"# Delete branch\n", "\n",
"!git branch -d [branch]\n", "# Merge branch to master\n",
"\n", "!git merge [branch]\n",
"# Clone\n", "\n",
"!git clone git@github.com:repo folder-name\n", "# Delete branch\n",
"!git clone https://donnemartin@bitbucket.org/donnemartin/tutorial.git\n", "!git branch -d [branch]\n",
" \n", "\n",
"# Update a local repository with changes from a remote repository\n", "# Clone\n",
"# (pull down from master)\n", "!git clone git@github.com:repo folder-name\n",
"!git pull origin master\n", "!git clone https://donnemartin@bitbucket.org/donnemartin/tutorial.git\n",
"\n", " \n",
"# Configuring a remote for a fork\n", "# Update a local repository with changes from a remote repository\n",
"!git remote -v\n", "# (pull down from master)\n",
"!git remote add upstream [target]\n", "!git pull origin master\n",
"!git remote -v\n", "\n",
"\n", "# Configuring a remote for a fork\n",
"# Syncing a fork\n", "!git remote -v\n",
"!git fetch upstream\n", "!git remote add upstream [target]\n",
"!git checkout master\n", "!git remote -v\n",
"!git merge upstream/master\n", "\n",
"\n", "# Syncing a fork\n",
"# Create a file containing a patch\n", "!git fetch upstream\n",
"# git format-patch are like normal patch files, but they also carry information \n", "!git checkout master\n",
"# about the git commit that created the patch: the author, the date, and the \n", "!git merge upstream/master\n",
"# commit log message are all there at the top of the patch.\n", "\n",
"!git format-patch origin/master\n", "# Create a file containing a patch\n",
"\n", "# git format-patch are like normal patch files, but they also carry information \n",
"# GitHub tutorial:\n", "# about the git commit that created the patch: the author, the date, and the \n",
"!http://try.github.io/levels/1/challenges/9\n", "# commit log message are all there at the top of the patch.\n",
"\n", "!git format-patch origin/master\n",
"# BitBucket Setup\n", "\n",
"!cd /path/to/my/repo\n", "# GitHub tutorial:\n",
"!git init\n", "!http://try.github.io/levels/1/challenges/9\n",
"!git remote add origin https://donnemartin@bitbucket.org/donnemartin/repo.git\n", "\n",
"!git push -u origin --all # pushes up the repo and its refs for the first time\n", "# BitBucket Setup\n",
"!git push -u origin --tags # pushes up any tags\n", "!cd /path/to/my/repo\n",
"\n", "!git init\n",
"# Open Hatch missions\n", "!git remote add origin https://donnemartin@bitbucket.org/donnemartin/repo.git\n",
"!git clone https://openhatch.org/git-mission-data/git/dmartin git_missions" "!git push -u origin --all # pushes up the repo and its refs for the first time\n",
], "!git push -u origin --tags # pushes up any tags\n",
"language": "python", "\n",
"metadata": {}, "# Open Hatch missions\n",
"outputs": [] "!git clone https://openhatch.org/git-mission-data/git/dmartin git_missions"
}, ]
{ },
"cell_type": "markdown", {
"metadata": {}, "cell_type": "markdown",
"source": [ "metadata": {},
"<h2 id=\"ruby\">Ruby</h2>" "source": [
] "<h2 id=\"ruby\">Ruby</h2>"
}, ]
{ },
"cell_type": "markdown", {
"metadata": {}, "cell_type": "markdown",
"source": [ "metadata": {},
"[Ruby](https://www.ruby-lang.org/en/) is used to interact with the AWS command line and for Jekyll, a blog framework that can be hosted on GitHub Pages." "source": [
] "[Ruby](https://www.ruby-lang.org/en/) is used to interact with the AWS command line and for Jekyll, a blog framework that can be hosted on GitHub Pages."
}, ]
{ },
"cell_type": "code", {
"collapsed": false, "cell_type": "code",
"input": [ "execution_count": null,
"# Update Ruby\n", "metadata": {
"!rvm get stable\n", "collapsed": false
"\n", },
"# Reload Ruby (or open a new terminal)\n", "outputs": [],
"!rvm reload\n", "source": [
"\n", "# Update Ruby\n",
"# List all known RVM installable rubies\n", "!rvm get stable\n",
"!rvm list known\n", "\n",
"\n", "# Reload Ruby (or open a new terminal)\n",
"# List all installed Ruby versions\n", "!rvm reload\n",
"!rvm rubies\n", "\n",
"\n", "# List all known RVM installable rubies\n",
"# Install a specific Ruby version\n", "!rvm list known\n",
"!rvm install 2.1.5\n", "\n",
"\n", "# List all installed Ruby versions\n",
"# Set Ruby version\n", "!rvm rubies\n",
"!rvm --default ruby-2.1.5\n", "\n",
"\n", "# Install a specific Ruby version\n",
"# Check Ruby version\n", "!rvm install 2.1.5\n",
"!ruby -v" "\n",
], "# Set Ruby version\n",
"language": "python", "!rvm --default ruby-2.1.5\n",
"metadata": {}, "\n",
"outputs": [] "# Check Ruby version\n",
}, "!ruby -v"
{ ]
"cell_type": "markdown", },
"metadata": {}, {
"source": [ "cell_type": "markdown",
"<h2 id=\"jekyll\">Jekyll</h2>" "metadata": {},
] "source": [
}, "<h2 id=\"jekyll\">Jekyll</h2>"
{ ]
"cell_type": "markdown", },
"metadata": {}, {
"source": [ "cell_type": "markdown",
"[Jekyll](http://jekyllrb.com/) is a blog framework that can be hosted on GitHub Pages.\n", "metadata": {},
"\n", "source": [
"In addition to donnemartin.com, I\u2019ve started to build up its mirror site donnemartin.github.io to try out Jekyll. So far I love that I can use my existing developer tools to generate content (SublimeText, Terminal, and GitHub).\n", "[Jekyll](http://jekyllrb.com/) is a blog framework that can be hosted on GitHub Pages.\n",
"\n", "\n",
"Here are other features I like about Jekyll:\n", "In addition to donnemartin.com, Ive started to build up its mirror site donnemartin.github.io to try out Jekyll. So far I love that I can use my existing developer tools to generate content (SublimeText, Terminal, and GitHub).\n",
"\n", "\n",
"* Converts Markdown to produce fast, static pages\n", "Here are other features I like about Jekyll:\n",
"* Simple to get started, no backend or manual updates\n", "\n",
"* Hosted on GitHub Pages\n", "* Converts Markdown to produce fast, static pages\n",
"* Open source on GitHub" "* Simple to get started, no backend or manual updates\n",
] "* Hosted on GitHub Pages\n",
}, "* Open source on GitHub"
{ ]
"cell_type": "markdown", },
"metadata": {}, {
"source": [ "cell_type": "markdown",
"Many Jekyll themes require a Ruby version of 2 and above. However, the AWS CLI requires Ruby 1.8.7. Run the proper version of Ruby for Jekyll:" "metadata": {},
] "source": [
}, "Many Jekyll themes require a Ruby version of 2 and above. However, the AWS CLI requires Ruby 1.8.7. Run the proper version of Ruby for Jekyll:"
{ ]
"cell_type": "code", },
"collapsed": false, {
"input": [ "cell_type": "code",
"!rvm --default ruby-2.1.5" "execution_count": null,
], "metadata": {
"language": "python", "collapsed": false
"metadata": {}, },
"outputs": [] "outputs": [],
}, "source": [
{ "!rvm --default ruby-2.1.5"
"cell_type": "markdown", ]
"metadata": {}, },
"source": [ {
"Build and run the localy Jekyll server:" "cell_type": "markdown",
] "metadata": {},
}, "source": [
{ "Build and run the localy Jekyll server:"
"cell_type": "code", ]
"collapsed": false, },
"input": [ {
"# => The current folder will be generated into ./_site\n", "cell_type": "code",
"!bundle exec jekyll build\n", "execution_count": null,
"\n", "metadata": {
"# => A development server will run at http://localhost:4000/\n", "collapsed": false
"# Auto-regeneration: enabled. Use `--no-watch` to disable.\n", },
"!bundle exec jekyll serve" "outputs": [],
], "source": [
"language": "python", "# => The current folder will be generated into ./_site\n",
"metadata": {}, "!bundle exec jekyll build\n",
"outputs": [] "\n",
} "# => A development server will run at http://localhost:4000/\n",
], "# Auto-regeneration: enabled. Use `--no-watch` to disable.\n",
"metadata": {} "!bundle exec jekyll serve"
]
} }
] ],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 0
} }