2015-02-22 06:57:55 +08:00
{
"metadata": {
"name": "",
2015-04-13 06:30:00 +08:00
"signature": "sha256:c39bbf32494020a300d424ed24cb9891d891ab8e67fe4c3162296bad4385c933"
2015-02-22 06:57:55 +08:00
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 18:57:09 +08:00
"# Misc Commands\n",
"\n",
2015-03-01 19:01:30 +08:00
"* Anaconda\n",
2015-03-01 19:19:18 +08:00
"* IPython Notebook\n",
2015-03-01 18:57:09 +08:00
"* Git\n",
"* Ruby\n",
"* Jekyll\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 20:00:42 +08:00
"<h2 id=\"anaconda\">Anaconda</h2>"
2015-03-01 19:56:15 +08:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 19:25:57 +08:00
"[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."
2015-03-01 19:01:30 +08:00
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# See Anaconda installed packages\n",
2015-03-13 20:05:56 +08:00
"!conda list\n",
2015-03-01 19:01:30 +08:00
"\n",
"# Create Python 3 environment\n",
2015-03-13 20:05:56 +08:00
"!conda create -n py3k python=3 anaconda\n",
2015-03-01 19:01:30 +08:00
"\n",
"# Activate Python 3 environment\n",
2015-03-13 20:05:56 +08:00
"!source activate py3k\n",
2015-03-01 19:01:30 +08:00
"\n",
"# Deactivate Python 3 environment\n",
2015-03-13 20:05:56 +08:00
"!source deactivate\n",
2015-03-01 19:01:30 +08:00
"\n",
"# Update Anaconda\n",
2015-03-13 20:05:56 +08:00
"!conda update conda\n",
2015-03-01 19:01:30 +08:00
"\n",
"# Update a package with Anaconda\n",
2015-03-13 20:05:56 +08:00
"!conda update ipython"
2015-03-01 19:01:30 +08:00
],
"language": "python",
"metadata": {},
"outputs": []
},
2015-03-01 19:19:18 +08:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 20:00:42 +08:00
"<h2 id=\"ipython-notebook\">IPython Notebook</h2>"
2015-03-01 19:56:15 +08:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 19:19:18 +08:00
"[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",
"collapsed": false,
"input": [
"# Start IPython Notebook\n",
"ipython notebook\n",
"\n",
"# Start IPython Notebook with built-in mode to work cleanly \n",
"# with matplotlib figures\n",
"ipython notebook --pylab inline\n",
"\n",
"# Start IPython Notebook with a profile\n",
"ipython notebook --profile=dark-bg\n",
"\n",
2015-04-13 06:30:00 +08:00
"# Load the contents of a file\n",
"%load dir/file.py\n",
"\n",
2015-03-01 19:19:18 +08:00
"# Time execution of a Python statement or expression\n",
"%timeit\n",
2015-04-13 06:30:00 +08:00
"%%time\n",
2015-03-01 19:19:18 +08:00
"\n",
"# Activate the interactive debugger\n",
"%debug\n",
"\n",
"# Write the contents of the cell to a file\n",
"%writefile\n",
"\n",
"# Run a cell via a shell command\n",
"%%script\n",
"\n",
"# Run cells with bash in a subprocess\n",
"# This is a shortcut for %%script bash\n",
"%%bash\n",
"\n",
"# Run cells with python2 in a subprocess\n",
"%%python2\n",
"\n",
"# Run cells with python3 in a subprocess\n",
"%%python3"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"| Command | Description |\n",
"|-----------|------------------------------------------|\n",
"| ? | Intro and overview of IPython's features |\n",
"| %quickref | Quick reference |\n",
"| help | Python help |\n",
"| object? | Object details, also use object?? |"
]
},
2015-03-01 19:01:30 +08:00
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 20:00:42 +08:00
"<h2 id=\"git\">Git</h2>"
2015-03-01 19:56:15 +08:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 19:25:57 +08:00
"[Git](http://git-scm.com/) is a distributed revision control system."
2015-03-01 18:57:09 +08:00
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Configure git\n",
2015-03-13 20:05:56 +08:00
"!git config --global user.name 'First Last'\n",
"!git config --global user.email 'name@domain.com'\n",
"!git init\n",
2015-03-01 18:57:09 +08:00
"\n",
"# View status and log\n",
2015-03-13 20:05:56 +08:00
"!git status\n",
"!git log\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Add or remove from staging area\n",
2015-03-13 20:05:56 +08:00
"!git add [target]\n",
"!git reset [target file or commit]\n",
"!git reset --hard origin/master\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Automatically stage tracked files, including deleting the previously tracked files\n",
2015-03-13 20:05:56 +08:00
"!git add -u\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Delete files and stage them\n",
2015-03-13 20:05:56 +08:00
"!git rm [target]\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Commit\n",
2015-03-13 20:05:56 +08:00
"!git commit -m \u201cAdd commit message here\u201d\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Add new origin\n",
2015-03-13 20:05:56 +08:00
"!git remote add origin https://github.com/donnemartin/ipython-data-notebooks.git\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Set to new origin\n",
2015-03-13 20:05:56 +08:00
"!git remote set-url origin https://github.com/donnemartin/pydatasnippets.git\n",
2015-03-01 18:57:09 +08:00
" \n",
"# Push to master, -u saves config so you can just do \"git push\" afterwards\n",
2015-03-13 20:05:56 +08:00
"!git push -u origin master\n",
"!git push\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Diff files\n",
2015-03-13 20:05:56 +08:00
"!git diff HEAD\n",
"!git diff --staged\n",
"!git diff --cached\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Undo a file that has not been added\n",
2015-03-13 20:05:56 +08:00
"!git checkout \u2014 [target]\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Create a branch\n",
2015-03-13 20:05:56 +08:00
"!git branch [branch]\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Check branches\n",
2015-03-13 20:05:56 +08:00
"!git branch\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Switch branches\n",
2015-03-13 20:05:56 +08:00
"!git checkout [branch]\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Merge branch to master\n",
2015-03-13 20:05:56 +08:00
"!git merge [branch]\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Delete branch\n",
2015-03-13 20:05:56 +08:00
"!git branch -d [branch]\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Clone\n",
2015-03-13 20:05:56 +08:00
"!git clone git@github.com:repo folder-name\n",
"!git clone https://donnemartin@bitbucket.org/donnemartin/tutorial.git\n",
2015-03-13 20:03:01 +08:00
" \n",
"# Update a local repository with changes from a remote repository\n",
2015-04-08 20:04:09 +08:00
"# (pull down from master)\n",
2015-03-13 20:05:56 +08:00
"!git pull origin master\n",
2015-03-01 18:57:09 +08:00
"\n",
2015-04-08 20:04:09 +08:00
"# Configuring a remote for a fork\n",
"!git remote -v\n",
"!git remote add upstream [target]\n",
"!git remote -v\n",
"\n",
"# Syncing a fork\n",
"!git fetch upstream\n",
"!git checkout master\n",
"!git merge upstream/master\n",
"\n",
2015-03-01 18:57:09 +08:00
"# Create a file containing a patch\n",
"# git format-patch are like normal patch files, but they also carry information \n",
"# about the git commit that created the patch: the author, the date, and the \n",
"# commit log message are all there at the top of the patch.\n",
2015-03-13 20:05:56 +08:00
"!git format-patch origin/master\n",
2015-03-01 18:57:09 +08:00
"\n",
"# GitHub tutorial:\n",
2015-03-13 20:05:56 +08:00
"!http://try.github.io/levels/1/challenges/9\n",
2015-03-01 18:57:09 +08:00
"\n",
"# BitBucket Setup\n",
2015-03-13 20:05:56 +08:00
"!cd /path/to/my/repo\n",
"!git init\n",
"!git remote add origin https://donnemartin@bitbucket.org/donnemartin/repo.git\n",
"!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",
2015-03-01 18:57:09 +08:00
"\n",
"# Open Hatch missions\n",
2015-03-13 20:05:56 +08:00
"!git clone https://openhatch.org/git-mission-data/git/dmartin git_missions"
2015-03-01 18:57:09 +08:00
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 20:00:42 +08:00
"<h2 id=\"ruby\">Ruby</h2>"
2015-03-01 19:56:15 +08:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 19:25:57 +08:00
"[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."
2015-03-01 18:57:09 +08:00
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Update Ruby\n",
2015-03-13 20:05:56 +08:00
"!rvm get stable\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Reload Ruby (or open a new terminal)\n",
2015-03-13 20:05:56 +08:00
"!rvm reload\n",
2015-03-01 18:57:09 +08:00
"\n",
"# List all known RVM installable rubies\n",
2015-03-13 20:05:56 +08:00
"!rvm list known\n",
2015-03-01 18:57:09 +08:00
"\n",
"# List all installed Ruby versions\n",
2015-03-13 20:05:56 +08:00
"!rvm rubies\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Install a specific Ruby version\n",
2015-03-13 20:05:56 +08:00
"!rvm install 2.1.5\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Set Ruby version\n",
2015-03-13 20:05:56 +08:00
"!rvm --default ruby-2.1.5\n",
2015-03-01 18:57:09 +08:00
"\n",
"# Check Ruby version\n",
2015-03-13 20:05:56 +08:00
"!ruby -v"
2015-03-01 18:57:09 +08:00
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 20:00:42 +08:00
"<h2 id=\"jekyll\">Jekyll</h2>"
2015-03-01 19:56:15 +08:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2015-03-01 19:25:57 +08:00
"[Jekyll](http://jekyllrb.com/) is a blog framework that can be hosted on GitHub Pages.\n",
"\n",
2015-02-28 22:17:43 +08:00
"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",
2015-02-22 06:57:55 +08:00
"\n",
"Here are other features I like about Jekyll:\n",
"\n",
"* Converts Markdown to produce fast, static pages\n",
"* Simple to get started, no backend or manual updates\n",
"* Hosted on GitHub Pages\n",
"* Open source on GitHub"
]
},
{
"cell_type": "markdown",
"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": [
2015-03-13 20:05:56 +08:00
"!rvm --default ruby-2.1.5"
2015-02-22 06:57:55 +08:00
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Build and run the localy Jekyll server:"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
2015-02-28 22:15:38 +08:00
"# => The current folder will be generated into ./_site\n",
2015-03-13 20:05:56 +08:00
"!bundle exec jekyll build\n",
2015-02-28 22:15:38 +08:00
"\n",
"# => A development server will run at http://localhost:4000/\n",
"# Auto-regeneration: enabled. Use `--no-watch` to disable.\n",
2015-03-13 20:05:56 +08:00
"!bundle exec jekyll serve"
2015-02-22 06:57:55 +08:00
],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}