text: {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {
      "collapsed": true
     },
     "source": [
      "# Demo of Notebook Magic...\n",
      "\n",
      "## cell magic denoted by %\n",
      "## line magic denoted by %%"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {
      "collapsed": false
     },
     "source": [
      "<style type=\"text/css\">\n",
      ".reveal section h1 {\n",
      "  color: blue;\n",
      "}\n",
      "</style> "
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Operating System Commands..."
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 1,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "text": [
        " Volume in drive C is OS\n",
        " Volume Serial Number is D49A-CC4A\n",
        "\n",
        " Directory of C:\\Users\\BryanCafferky\\Documents\\Python\\notebook\n",
        "\n",
        "10/02/2016  11:11 AM    <DIR>          .\n",
        "10/02/2016  11:11 AM    <DIR>          ..\n",
        "10/01/2016  01:26 PM    <DIR>          .ipynb_checkpoints\n",
        "10/01/2016  12:56 PM            13,676 demo1_boxplot.ipynb\n",
        "09/23/2016  09:31 AM                64 departments.csv\n",
        "09/23/2016  09:31 AM                99 employees.csv\n",
        "09/23/2016  09:31 AM            22,180 eu_revolving_loans.csv\n",
        "09/23/2016  09:31 AM            15,802 eu_trade_sums.csv\n",
        "10/02/2016  11:11 AM            42,218 nb_walkthrough.ipynb\n",
        "10/01/2016  01:06 AM            30,826 R_Notebook_1.ipynb\n",
        "09/23/2016  12:36 PM             1,036 Test1.ipynb\n",
        "               8 File(s)        125,901 bytes\n",
        "               3 Dir(s)  546,018,377,728 bytes free\n"
       ]
      }
     ],
     "source": [
      "%ls"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "# present working directory..."
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 2,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "data": {
        "text/plain": [
         "'C:\\\\Users\\\\BryanCafferky\\\\Documents\\\\Python\\\\notebook'"
        ]
       },
       "execution_count": 2,
       "metadata": {},
       "output_type": "execute_result"
      }
     ],
     "source": [
      "%pwd"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 1,
     "metadata": {
      "collapsed": true
     },
     "outputs": [],
     "source": [
      "%alias list_files dir"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 3,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "text": [
        " Volume in drive C is OS\n",
        " Volume Serial Number is D49A-CC4A\n",
        "\n",
        " Directory of C:\\Users\\BryanCafferky\\Documents\\Python\\notebook\n",
        "\n",
        "10/02/2016  11:13 AM    <DIR>          .\n",
        "10/02/2016  11:13 AM    <DIR>          ..\n",
        "10/02/2016  11:13 AM    <DIR>          .ipynb_checkpoints\n",
        "10/01/2016  12:56 PM            13,676 demo1_boxplot.ipynb\n",
        "09/23/2016  09:31 AM                64 departments.csv\n",
        "09/23/2016  09:31 AM                99 employees.csv\n",
        "09/23/2016  09:31 AM            22,180 eu_revolving_loans.csv\n",
        "09/23/2016  09:31 AM            15,802 eu_trade_sums.csv\n",
        "10/02/2016  11:11 AM            42,218 nb_walkthrough.ipynb\n",
        "10/02/2016  11:12 AM             2,542 Notebook_magic.ipynb\n",
        "10/01/2016  01:06 AM            30,826 R_Notebook_1.ipynb\n",
        "10/02/2016  11:12 AM             2,542 Test1.ipynb\n",
        "               9 File(s)        129,949 bytes\n",
        "               3 Dir(s)  546,018,021,376 bytes free\n"
       ]
      }
     ],
     "source": [
      "list_files"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### Running shell commands..."
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 4,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "text": [
        "Microsoft Windows [Version 10.0.10586]\r\n",
        "(c) 2015 Microsoft Corporation. All rights reserved.\r\n",
        "\r\n",
        "C:\\Users\\BryanCafferky\\Documents\\Python\\notebook>echo This is the command window\n",
        "This is the command window\r\n",
        "\r\n",
        "C:\\Users\\BryanCafferky\\Documents\\Python\\notebook>dir *.bat\n",
        " Volume in drive C is OS\r\n",
        " Volume Serial Number is D49A-CC4A\r\n",
        "\r\n",
        " Directory of C:\\Users\\BryanCafferky\\Documents\\Python\\notebook\r\n",
        "\r\n",
        "10/03/2016  10:55 PM                61 convert.bat\r\n",
        "               1 File(s)             61 bytes\r\n",
        "               0 Dir(s)  538,368,708,608 bytes free\r\n",
        "\r\n",
        "C:\\Users\\BryanCafferky\\Documents\\Python\\notebook>"
       ]
      }
     ],
     "source": [
      "%%cmd \n",
      "echo This is the command window\n",
      "dir *.bat"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### Indirectly call PowerShell..."
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 2,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "text": [
        "Microsoft Windows [Version 10.0.10586]\r\n",
        "(c) 2015 Microsoft Corporation. All rights reserved.\r\n",
        "\r\n",
        "C:\\Users\\BryanCafferky\\Documents\\Python\\notebook>PowerShell Get-ChildItem\n",
        "The AllUsersAllHosts profile has started...\n",
        "The CurrentUserAllHosts profile has started...\n",
        "The CurrentUserCurrentHost profile has started...\n",
        "Welcome BryanCafferky.\n",
        "\r\n",
        "\r\n",
        "    Directory: \r\n",
        "    C:\\Users\\BryanCafferky\\Documents\\GitHub\\Professional\\PowerShell\\Function\r\n",
        "\r\n",
        "\r\n",
        "Mode                LastWriteTime         Length Name                          \r\n",
        "----                -------------         ------ ----                          \r\n",
        "-a----       12/18/2015   6:20 PM             10 20                            \r\n",
        "-a----        6/28/2016  10:48 PM           2657 Download_Scripts_SQL_Walkthrou\r\n",
        "                                                 gh.ps1                        \r\n",
        "-a----        8/28/2014   6:35 PM            397 InvokeExcel.ps1               \r\n",
        "-a----         1/2/2014   3:40 PM          10278 ufn_Add-SqlTable.ps1          \r\n",
        "-a----        8/29/2014  12:08 PM            192 ufn_automate_access.ps1       \r\n",
        "-a----        8/29/2014  10:17 AM            104 ufn_check_for_32bit_or_64bit.p\r\n",
        "                                                 s1                            \r\n",
        "-a----       12/17/2013  11:48 AM           1442 ufn_combine_files.ps1         \r\n",
        "-a----        2/13/2014   4:17 PM           1696 ufn_ConvertFrom_XLx.ps1       \r\n",
        "-a----       12/10/2013   2:38 PM           1806 ufn_copy_files.ps1            \r\n",
        "-a----       12/10/2013   2:41 PM           1874 ufn_copy_newest_file.ps1      \r\n",
        "-a----         1/8/2014   3:21 PM            846 ufn_csharp_functions.ps1      \r\n",
        "-a----         1/9/2014   2:57 PM          13254 ufn_database_functions.ps1    \r\n",
        "-a----        2/13/2014  10:52 PM           4016 ufn_export_excel_xls.ps1      \r\n",
        "-a----         1/3/2014   2:37 PM           1210 ufn_file_rows_append_text.ps1 \r\n",
        "-a----        7/13/2014   8:18 AM          17484 ufn_FormMain_show.ps1         \r\n",
        "-a----        8/17/2014   5:14 PM           4044 ufn_Get_Winform_FileName.ps1  \r\n",
        "-a----        2/13/2014   3:57 PM          17386 ufn_Import_Excel.ps1          \r\n",
        "-a----        2/13/2014   4:08 PM           4312 ufn_import_excel_basic.ps1    \r\n",
        "-a----         1/2/2014   4:29 PM           7658 ufn_Invoke-Sqlcmd2.ps1        \r\n",
        "-a----         1/6/2014   9:33 AM          19466 ufn_invoke_CSharp.ps1         \r\n",
        "-a----        8/31/2014  10:06 AM            898 ufn_load_excel_table.ps1      \r\n",
        "-a----        1/27/2014   8:35 AM           9640 ufn_message_box.ps1           \r\n",
        "-a----         1/2/2014   3:26 PM           6168 ufn_Out-DataTable.ps1         \r\n",
        "-a----         1/5/2014   1:55 PM           1020 ufn_Out_SqlGrid.ps1           \r\n",
        "-a----       12/18/2013   3:26 PM            797 ufn_register_file_create_event\r\n",
        "                                                 .ps1                          \r\n",
        "-a----        1/15/2014   4:08 PM            794 ufn_say_it.ps1                \r\n",
        "-a----       12/18/2013   2:50 PM           2056 ufn_say_it_more.ps1           \r\n",
        "-a----        8/17/2014   5:11 PM           1078 ufn_show_file_dialog.ps1      \r\n",
        "-a----       12/18/2013   2:56 PM           1632 ufn_StreamWriter_WriteLine.ps1\r\n",
        "-a----         7/4/2014   7:30 PM            714 ufn_wait_for_file.ps1         \r\n",
        "-a----         1/2/2014   4:26 PM           5374 ufn_Write-DataTable.ps1       \r\n",
        "-a----       12/13/2013   8:59 AM            138 ufn_write_line_to_file.ps1    \r\n",
        "-a----        8/29/2014  12:04 PM            871 ufn_write_to_Access.ps1       \r\n",
        "\r\n",
        "\r\n",
        "\r\n",
        "C:\\Users\\BryanCafferky\\Documents\\Python\\notebook>"
       ]
      }
     ],
     "source": [
      "%%cmd\n",
      "PowerShell Get-ChildItem"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "### Run R commands or scripts..."
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 16,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "text": [
        "\r\n",
        "R version 3.3.1 (2016-06-21) -- \"Bug in Your Hair\"\r\n",
        "Copyright (C) 2016 The R Foundation for Statistical Computing\r\n",
        "Platform: x86_64-w64-mingw32/x64 (64-bit)\r\n",
        "\r\n",
        "R is free software and comes with ABSOLUTELY NO WARRANTY.\r\n",
        "You are welcome to redistribute it under certain conditions.\r\n",
        "Type 'license()' or 'licence()' for distribution details.\r\n",
        "\r\n",
        "  Natural language support but running in an English locale\r\n",
        "\r\n",
        "R is a collaborative project with many contributors.\r\n",
        "Type 'contributors()' for more information and\r\n",
        "'citation()' on how to cite R or R packages in publications.\r\n",
        "\r\n",
        "Type 'demo()' for some demos, 'help()' for on-line help, or\r\n",
        "'help.start()' for an HTML browser interface to help.\r\n",
        "Type 'q()' to quit R.\r\n",
        "\r\n",
        "> 5 + 5\r\n",
        "[1] 10\r\n",
        "> \r\n"
       ]
      }
     ],
     "source": [
      "%%script r --no-save\n",
      "5 + 5"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "## Shell commands can be issued too!"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 1,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "text": [
        " Volume in drive C is OS\n",
        " Volume Serial Number is D49A-CC4A\n",
        "\n",
        " Directory of C:\\Users\\BryanCafferky\\Documents\\Python\\notebook\n",
        "\n",
        "10/04/2016  09:23 AM    <DIR>          .\n",
        "10/04/2016  09:23 AM    <DIR>          ..\n",
        "10/04/2016  09:23 AM    <DIR>          .ipynb_checkpoints\n",
        "10/03/2016  10:55 PM                61 convert.bat\n",
        "10/03/2016  10:06 PM           959,889 Demo_1_github_04.14-Visualization-With-Seaborn.ipynb\n",
        "10/03/2016  11:13 PM           182,221 Demo_2_B_R.ipynb\n",
        "10/02/2016  12:02 PM            41,771 Demo_2_rnb_walkthrough.ipynb\n",
        "10/03/2016  10:55 PM           305,041 Demo_2_rnb_walkthrough.slides.html\n",
        "10/03/2016  11:02 PM             6,600 Demo_3_Notebook_magic.ipynb\n",
        "10/03/2016  11:04 PM             1,051 Demo_4_widgets.ipynb\n",
        "10/03/2016  11:06 PM            18,411 demo_5_widgets.ipynb\n",
        "09/23/2016  09:31 AM                64 departments.csv\n",
        "09/23/2016  09:31 AM                99 employees.csv\n",
        "09/23/2016  09:31 AM            22,180 eu_revolving_loans.csv\n",
        "09/23/2016  09:31 AM            15,802 eu_trade_sums.csv\n",
        "10/03/2016  10:12 PM           792,253 nb_pres_slides.html\n",
        "10/03/2016  10:48 PM           301,122 nb_slides.html\n",
        "10/02/2016  12:23 PM            42,161 nb_slides.ipynb\n",
        "10/03/2016  10:51 PM           304,948 nb_slides.slides.html\n",
        "10/03/2016  10:58 PM            13,700 R_boxplot.ipynb\n",
        "09/29/2016  04:37 PM             8,706 r_button.jpg\n",
        "10/03/2016  10:46 PM           280,307 R_Notebook_1.html\n",
        "10/01/2016  01:06 AM            30,826 R_Notebook_1.ipynb\n",
        "10/01/2016  11:33 AM           183,558 r_with_python.png\n",
        "10/03/2016  11:24 PM                72 Untitled.ipynb\n",
        "09/30/2016  03:35 PM             3,599 Welcome to Python.ipynb\n",
        "10/04/2016  09:23 AM            15,383 Welcome to Spark with Python.ipynb\n",
        "10/02/2016  03:36 PM            50,746 x_jupyter__test_demo.ipynb\n",
        "              25 File(s)      3,580,571 bytes\n",
        "               3 Dir(s)  534,232,023,040 bytes free\n"
       ]
      }
     ],
     "source": [
      "!dir"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": 1,
     "metadata": {
      "collapsed": false
     },
     "outputs": [
      {
       "name": "stdout",
       "output_type": "stream",
       "text": [
        "[' Volume in drive C is OS', ' Volume Serial Number is D49A-CC4A', '', ' Directory of C:\\\\Users\\\\BryanCafferky\\\\Documents\\\\Python\\\\notebook', '', '10/04/2016  07:35 PM    <DIR>          .', '10/04/2016  07:35 PM    <DIR>          ..', '10/04/2016  07:28 PM    <DIR>          .ipynb_checkpoints', '10/03/2016  10:55 PM                61 convert.bat', '10/04/2016  07:31 PM             6,244 demofortesst.ipynb', '10/03/2016  10:06 PM           959,889 Demo_1_github_04.14-Visualization-With-Seaborn.ipynb', '10/03/2016  11:13 PM           182,221 Demo_2_B_R.ipynb', '10/04/2016  07:35 PM            41,795 Demo_2_rnb_walkthrough.ipynb', '10/03/2016  10:55 PM           305,041 Demo_2_rnb_walkthrough.slides.html', '10/04/2016  12:51 PM            48,004 demo_3_nb_slides.ipynb', '10/04/2016  12:55 PM            16,638 Demo_4_Notebook_magic.ipynb', '10/04/2016  12:58 PM            22,806 demo_5_widgets.ipynb', '10/04/2016  01:46 PM            26,683 demo_7_TestingRpy2.ipynb', '10/04/2016  01:46 PM            67,436 demo_8_TestingRpy2_2.ipynb', '10/04/2016  09:23 AM            15,383 demo_9_Welcome to Spark with Python.ipynb', '10/04/2016  11:52 AM            24,668 demo_slides1.ipynb', '09/23/2016  09:31 AM                64 departments.csv', '09/23/2016  09:31 AM                99 employees.csv', '09/23/2016  09:31 AM            22,180 eu_revolving_loans.csv', '09/23/2016  09:31 AM            15,802 eu_trade_sums.csv', '10/04/2016  12:19 PM           291,393 nbconvert.pdf', '10/03/2016  10:12 PM           792,253 nb_pres_slides.html', '10/03/2016  10:48 PM           301,122 nb_slides.html', '10/03/2016  10:51 PM           304,948 nb_slides.slides.html', '10/04/2016  01:46 PM    <DIR>          rpy2_sample_notebooks-master', '10/04/2016  01:11 PM            67,983 rpy2_sample_notebooks-master.zip', '10/03/2016  10:58 PM            13,700 R_boxplot.ipynb', '09/29/2016  04:37 PM             8,706 r_button.jpg', '10/03/2016  10:46 PM           280,307 R_Notebook_1.html', '10/01/2016  01:06 AM            30,826 R_Notebook_1.ipynb', '10/01/2016  11:33 AM           183,558 r_with_python.png', '07/18/2016  11:22 AM           158,336 superhero.css', '09/30/2016  03:33 PM           182,221 Welcome R  - demo.ipynb', '09/30/2016  03:35 PM             3,599 Welcome to Python.ipynb', '10/03/2016  11:04 PM             1,051 x_Demo_4_widgets.ipynb', '10/02/2016  03:36 PM            50,746 x_jupyter__test_demo.ipynb', '              32 File(s)      4,425,763 bytes', '               4 Dir(s)  537,427,226,624 bytes free']\n"
       ]
      }
     ],
     "source": [
      "mylist = !dir\n",
      "print(mylist)"
     ]
    },
    {
     "cell_type": "code",
     "execution_count": null,
     "metadata": {
      "collapsed": true
     },
     "outputs": [],
     "source": []
    }
   ],
   "metadata": {
    "anaconda-cloud": {},
    "kernelspec": {
     "display_name": "Python [Root]",
     "language": "python",
     "name": "Python [Root]"
    },
    "language_info": {
     "codemirror_mode": {
      "name": "ipython",
      "version": 3
     },
     "file_extension": ".py",
     "mimetype": "text/x-python",
     "name": "python",
     "nbconvert_exporter": "python",
     "pygments_lexer": "ipython3",
     "version": "3.5.2"
    }
   },
   "nbformat": 4,
   "nbformat_minor": 0
  }
  