data-science-ipython-notebooks/commands/misc.ipynb
2015-03-01 06:01:30 -05:00

256 lines
7.0 KiB
Plaintext

{
"metadata": {
"name": "",
"signature": "sha256:228c15dc58e640c2fa954f5b43981c8cc8538f70b7a16e96adf81cbda15c8bbe"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Misc Commands\n",
"\n",
"* Anaconda\n",
"* Git\n",
"* Ruby\n",
"* Jekyll\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Anaconda\n",
"\n",
"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",
"collapsed": false,
"input": [
"# See Anaconda installed packages\n",
"conda list\n",
"\n",
"# Create Python 3 environment\n",
"conda create -n py3k python=3 anaconda\n",
"\n",
"# Activate Python 3 environment\n",
"source activate py3k\n",
"\n",
"# Deactivate Python 3 environment\n",
"source deactivate\n",
"\n",
"# Update Anaconda\n",
"conda update conda\n",
"\n",
"# Update a package with Anaconda\n",
"conda update ipython"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Git\n",
"\n",
"Git is a distributed revision control system."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Configure git\n",
"git config --global user.name 'First Last'\n",
"git config --global user.email 'name@domain.com'\n",
"git init\n",
"\n",
"# View status and log\n",
"git status\n",
"git log\n",
"\n",
"# Add or remove from staging area\n",
"git add [target]\n",
"git reset [target]\n",
"\n",
"# Automatically stage tracked files, including deleting the previously tracked files\n",
"git add -u\n",
"\n",
"# Delete files and stage them\n",
"git rm [target]\n",
"\n",
"# Commit\n",
"git commit -m \u201cAdd commit message here\u201d\n",
"\n",
"# Add new origin\n",
"git remote add origin https://github.com/donnemartin/ipython-data-notebooks.git\n",
"\n",
"# Set to new origin\n",
"git remote set-url origin https://github.com/donnemartin/pydatasnippets.git\n",
" \n",
"# Push to master, -u saves config so you can just do \"git push\" afterwards\n",
"git push -u origin master\n",
"git push\n",
"\n",
"# Pull down from master\n",
"git pull origin master\n",
"\n",
"# Diff files\n",
"git diff HEAD\n",
"git diff --staged\n",
"git diff --cached\n",
"\n",
"# Undo a file that has not been added\n",
"git checkout \u2014 [target]\n",
"\n",
"# Create a branch\n",
"git branch [branch]\n",
"\n",
"# Check branches\n",
"git branch\n",
"\n",
"# Switch branches\n",
"git checkout [branch]\n",
"\n",
"# Merge branch to master\n",
"git merge [branch]\n",
"\n",
"# Delete branch\n",
"git branch -d [branch]\n",
"\n",
"# Clone\n",
"git clone git@github.com:repo folder-name\n",
"git clone https://donnemartin@bitbucket.org/donnemartin/tutorial.git\n",
"\n",
"# 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",
"git format-patch origin/master\n",
"\n",
"# GitHub tutorial:\n",
"http://try.github.io/levels/1/challenges/9\n",
"\n",
"# BitBucket Setup\n",
"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",
"\n",
"# Open Hatch missions\n",
"git clone https://openhatch.org/git-mission-data/git/dmartin git_missions"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Ruby\n",
"\n",
"Ruby is used to interact with the AWS command line and for Jekyll, a blog framework hosted on GitHub Pages."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"# Update Ruby\n",
"rvm get stable\n",
"\n",
"# Reload Ruby (or open a new terminal)\n",
"rvm reload\n",
"\n",
"# List all known RVM installable rubies\n",
"rvm list known\n",
"\n",
"# List all installed Ruby versions\n",
"rvm rubies\n",
"\n",
"# Install a specific Ruby version\n",
"rvm install 2.1.5\n",
"\n",
"# Set Ruby version\n",
"rvm --default ruby-2.1.5\n",
"\n",
"# Check Ruby version\n",
"ruby -v\n",
"\n",
"# MRI Rubies\n",
"[ruby-]1.9.2[-p320]"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Jekyll\n",
"\n",
"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",
"\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": [
"rvm --default ruby-2.1.5"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"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",
"bundle exec jekyll build\n",
"\n",
"# => A development server will run at http://localhost:4000/\n",
"# Auto-regeneration: enabled. Use `--no-watch` to disable.\n",
"bundle exec jekyll serve"
],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}