{ "cells": [ { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" }, "toc": "true" }, "source": [ "# Table of Contents\n", "
" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Demo of RISE for slides with Jupyter notebooks (Python)\n", "\n", "- This document is an example of a slideshow, written in a [Jupyter notebook](https://www.jupyter.org/) with the [RISE extension](https://github.com/damianavila/RISE).\n", "\n", "> By [Lilian Besson](http://perso.crans.org/besson/), Sept.2017." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "---\n", "## Title 2\n", "### Title 3\n", "#### Title 4\n", "##### Title 5\n", "##### Title 6" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Text\n", "With text, *emphasis*, **bold**, ~~striked~~, `inline code` and\n", "\n", "> *Quote.*\n", ">\n", "> -- By a guy." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Maths\n", "With inline math $\\sin(x)^2 + \\cos(x)^2 = 1$ and equations:\n", "$$\\sin(x)^2 + \\cos(x)^2 = \\left(\\frac{\\mathrm{e}^{ix} - \\mathrm{e}^{-ix}}{2i}\\right)^2 + \\left(\\frac{\\mathrm{e}^{ix} + \\mathrm{e}^{-ix}}{2}\\right)^2 = \\frac{-\\mathrm{e}^{2ix}-\\mathrm{e}^{-2ix}+2 \\; ++\\mathrm{e}^{2ix}+\\mathrm{e}^{-2ix}+2}{4} = 1.$$" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## And code\n", "In Markdown:\n", "```python\n", "from sys import version\n", "print(version)\n", "```\n", "\n", "And in a executable cell (with Python 3 kernel) :" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "slideshow": { "slide_type": "-" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.6.3 (default, Oct 3 2017, 21:45:48) \n", "[GCC 7.2.0]\n" ] } ], "source": [ "from sys import version\n", "print(version)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# More demo of Markdown code" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "## Lists\n", "\n", "- Unordered\n", "- lists\n", "- are easy.\n", "\n", "And\n", "\n", "1. and ordered also ! Just\n", "2. start lines by `1.`, `2.` etc\n", "3. or simply `1.`, `1.`, ..." ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### Images\n", "With a HTML `` tag or the `![alt](url)` Markdown code:\n", "\n", "\n", "![agreg/images/dooku.jpg](agreg/images/dooku.jpg)" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "## Some code" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [ { "data": { "text/plain": [ "'Embed a YouTube video via its embed url into a notebook.'" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# https://gist.github.com/dm-wyncode/55823165c104717ca49863fc526d1354\n", "\"\"\"Embed a YouTube video via its embed url into a notebook.\"\"\"\n", "from functools import partial\n", "\n", "from IPython.display import display, IFrame\n", "\n", "width, height = (560, 315, )" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def _iframe_attrs(embed_url):\n", " \"\"\"Get IFrame args.\"\"\"\n", " return (\n", " ('src', 'width', 'height'), \n", " (embed_url, width, height, ),\n", " )" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def _get_args(embed_url):\n", " \"\"\"Get args for type to create a class.\"\"\"\n", " iframe = dict(zip(*_iframe_attrs(embed_url)))\n", " attrs = {\n", " 'display': partial(display, IFrame(**iframe)),\n", " }\n", " return ('YouTubeVideo', (object, ), attrs, )" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "slideshow": { "slide_type": "subslide" } }, "outputs": [], "source": [ "def youtube_video(embed_url):\n", " \"\"\"Embed YouTube video into a notebook.\n", "\n", " Place this module into the same directory as the notebook.\n", "\n", " >>> from embed import youtube_video\n", " >>> youtube_video(url).display()\n", " \"\"\"\n", " YouTubeVideo = type(*_get_args(embed_url)) # make a class\n", " return YouTubeVideo() # return an object" ] }, { "cell_type": "markdown", "metadata": { "slideshow": { "slide_type": "subslide" } }, "source": [ "#### And Markdown can include raw HTML\n", "\n", "