Skip to content

Commit b100e3f

Browse files
committed
Created using Colaboratory
1 parent 3cf5ee6 commit b100e3f

1 file changed

Lines changed: 152 additions & 0 deletions

File tree

notebooks/colab-github-demo.ipynb

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
{
2+
"nbformat": 4,
3+
"nbformat_minor": 0,
4+
"metadata": {
5+
"colab": {
6+
"name": "colab-github-demo.ipynb",
7+
"provenance": [],
8+
"collapsed_sections": [],
9+
"include_colab_link": true
10+
},
11+
"kernelspec": {
12+
"display_name": "Python 3",
13+
"name": "python3"
14+
}
15+
},
16+
"cells": [
17+
{
18+
"cell_type": "markdown",
19+
"metadata": {
20+
"id": "view-in-github",
21+
"colab_type": "text"
22+
},
23+
"source": [
24+
"<a href=\"https://colab.research.google.com/github/jplotts/OnlinePythonTutor/blob/master/notebooks/colab-github-demo.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
25+
]
26+
},
27+
{
28+
"cell_type": "markdown",
29+
"metadata": {
30+
"id": "-pVhOfzLx9us"
31+
},
32+
"source": [
33+
"# Using Google Colab with GitHub\n",
34+
"\n"
35+
]
36+
},
37+
{
38+
"cell_type": "markdown",
39+
"metadata": {
40+
"id": "wKJ4bd5rt1wy"
41+
},
42+
"source": [
43+
"\n",
44+
"[Google Colaboratory](http://colab.research.google.com) is designed to integrate cleanly with GitHub, allowing both loading notebooks from github and saving notebooks to github."
45+
]
46+
},
47+
{
48+
"cell_type": "markdown",
49+
"metadata": {
50+
"id": "K-NVg7RjyeTk"
51+
},
52+
"source": [
53+
"## Loading Public Notebooks Directly from GitHub\n",
54+
"\n",
55+
"Colab can load public github notebooks directly, with no required authorization step.\n",
56+
"\n",
57+
"For example, consider the notebook at this address: https://github.com/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb.\n",
58+
"\n",
59+
"The direct colab link to this notebook is: https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb.\n",
60+
"\n",
61+
"To generate such links in one click, you can use the [Open in Colab](https://chrome.google.com/webstore/detail/open-in-colab/iogfkhleblhcpcekbiedikdehleodpjo) Chrome extension."
62+
]
63+
},
64+
{
65+
"cell_type": "markdown",
66+
"metadata": {
67+
"id": "WzIRIt9d2huC"
68+
},
69+
"source": [
70+
"## Browsing GitHub Repositories from Colab\n",
71+
"\n",
72+
"Colab also supports special URLs that link directly to a GitHub browser for any user/organization, repository, or branch. For example:\n",
73+
"\n",
74+
"- http://colab.research.google.com/github will give you a general github browser, where you can search for any github organization or username.\n",
75+
"- http://colab.research.google.com/github/googlecolab/ will open the repository browser for the ``googlecolab`` organization. Replace ``googlecolab`` with any other github org or user to see their repositories.\n",
76+
"- http://colab.research.google.com/github/googlecolab/colabtools/ will let you browse the main branch of the ``colabtools`` repository within the ``googlecolab`` organization. Substitute any user/org and repository to see its contents.\n",
77+
"- http://colab.research.google.com/github/googlecolab/colabtools/blob/master will let you browse ``master`` branch of the ``colabtools`` repository within the ``googlecolab`` organization. (don't forget the ``blob`` here!) You can specify any valid branch for any valid repository."
78+
]
79+
},
80+
{
81+
"cell_type": "markdown",
82+
"metadata": {
83+
"id": "Rmai0dD30XzL"
84+
},
85+
"source": [
86+
"## Loading Private Notebooks\n",
87+
"\n",
88+
"Loading a notebook from a private GitHub repository is possible, but requires an additional step to allow Colab to access your files.\n",
89+
"Do the following:\n",
90+
"\n",
91+
"1. Navigate to http://colab.research.google.com/github.\n",
92+
"2. Click the \"Include Private Repos\" checkbox.\n",
93+
"3. In the popup window, sign-in to your Github account and authorize Colab to read the private files.\n",
94+
"4. Your private repositories and notebooks will now be available via the github navigation pane."
95+
]
96+
},
97+
{
98+
"cell_type": "markdown",
99+
"metadata": {
100+
"id": "8J3NBxtZpPcK"
101+
},
102+
"source": [
103+
"## Saving Notebooks To GitHub or Drive\n",
104+
"\n",
105+
"Any time you open a GitHub hosted notebook in Colab, it opens a new editable view of the notebook. You can run and modify the notebook without worrying about overwriting the source.\n",
106+
"\n",
107+
"If you would like to save your changes from within Colab, you can use the File menu to save the modified notebook either to Google Drive or back to GitHub. Choose **File→Save a copy in Drive** or **File→Save a copy to GitHub** and follow the resulting prompts. To save a Colab notebook to GitHub requires giving Colab permission to push the commit to your repository."
108+
]
109+
},
110+
{
111+
"cell_type": "markdown",
112+
"metadata": {
113+
"id": "8QAWNjizy_3O"
114+
},
115+
"source": [
116+
"## Open In Colab Badge\n",
117+
"\n",
118+
"Anybody can open a copy of any github-hosted notebook within Colab. To make it easier to give people access to live views of GitHub-hosted notebooks,\n",
119+
"colab provides a [shields.io](http://shields.io/)-style badge, which appears as follows:\n",
120+
"\n",
121+
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb)\n",
122+
"\n",
123+
"The markdown for the above badge is the following:\n",
124+
"\n",
125+
"```markdown\n",
126+
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb)\n",
127+
"```\n",
128+
"\n",
129+
"The HTML equivalent is:\n",
130+
"\n",
131+
"```HTML\n",
132+
"<a href=\"https://colab.research.google.com/github/googlecolab/colabtools/blob/master/notebooks/colab-github-demo.ipynb\">\n",
133+
" <img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/>\n",
134+
"</a>\n",
135+
"```\n",
136+
"\n",
137+
"Remember to replace the notebook URL in this template with the notebook you want to link to."
138+
]
139+
},
140+
{
141+
"cell_type": "code",
142+
"metadata": {
143+
"id": "3VQqVi-3ScBC"
144+
},
145+
"source": [
146+
""
147+
],
148+
"execution_count": null,
149+
"outputs": []
150+
}
151+
]
152+
}

0 commit comments

Comments
 (0)