title: Custom IPython magic command for multiple cells
body: <p>How to build a custom IPython magic command that:</p>
  <ol>
  <li>run a block of code before running a cell;</li>
  <li>only needs to be called once to be applied on every cell of notebook.</li>
  </ol>
  <p><strong>Similar cases</strong><br>
  <code>%matplotlib</code>,
  <code>%pdb</code>,
  <code>%doctest_mode</code></p>
  <p><strong>Example</strong></p>
  <pre><code>In [1]: %myMagic 1
  Out[1]: myMagic is: ON
  
  In [2]: x = 1
  Out[2]: 'Hello World'
  
  In [3]: x
  Out[3]: 'Hello World'
     ...:  1
  
  In [4]: %myMagic 0
  Out[4]: myMagic is: OFF
  
  In [5]: y=x+1
     ...: y
  Out[5]: 2
  </code></pre>