By default we are in COMMAND mode
Notebook control:
Cells control:
Editing cells:
Executing cells:
More shortcuts listed under "Help" => "Keyboard shortcuts"
Cells have a type, which can be changed using shortcuts or the dedicated dropdown menu.
This is an example of text cell, where you can use Markdown tags to format your text.
You can also highlight chunks of code in almost any langauge
Example of Bash script:
#!/bin/bash
# A useless script
for i in $(seq 10); do
echo Hello World
done
Example of C fragment:
29 /*
28 * System energy normalization
27 * Returns the normalized value, in the range [0..SCHED_LOAD_SCALE],
26 * corresponding to the specified energy variation.
25 */
24 static inline int
23 normalize_energy(int energy_diff)
22 {
21 u32 normalized_nrg;
20 int max_delta;
19
18 #ifdef CONFIG_SCHED_DEBUG
17 /* Check for boundaries */
16 max_delta = schedtune_target_nrg.max_power;
15 max_delta -= schedtune_target_nrg.min_power;
14 WARN_ON(abs(energy_diff) >= max_delta);
13 #endif
12
11 /* Do scaling using positive numbers to increase the range */
10 normalized_nrg = (energy_diff < 0) ? -energy_diff : energy_diff;
9
8 /* Scale by energy magnitude */
7 normalized_nrg <<= SCHED_LOAD_SHIFT;
6
5 /* Normalize on max energy for target platform */
4 normalized_nrg = reciprocal_divide(
3 normalized_nrg, schedtune_target_nrg.rdiv);
2
1 return (energy_diff < 0) ? -normalized_nrg : normalized_nrg;
5292 }
Normally cells contains code, which is executed when Shift+Return is pressed
In [28]:
a = 1
b = 2
In [29]:
def my_simple_sum(a, b):
"""Simple addition
:param a: fist number
:param b: second number
"""
print "Sum is:", a+b
In [33]:
my_simple_sum(a,b)
In [32]:
# Further down in the code we do some changes
a = 100
# than we can go back and re-execute just the previous cell
In [24]:
# Use TAB to complete the function name
# Use SHIFT+Tab after the '(' to access
my_simple_sum(2,3)
We can use a "!" at the beginning of a line to execute that command in a local shell
In [34]:
!pwd
In [36]:
!date
We can also use variables as parameters by passing them wrapped in "{}"
In [57]:
folder = "../"
!ls -la {folder} | wc -l
Output of a local shell command can also be captured, for example to be post-processed in python
In [68]:
output = !find ../../ipynb/ -name "*.ipynb"
print "Available notebooks:"
for line in output:
print line.replace('../../ipynb/', ' ')
A notebook can be exported as a standalone script by via the "File" => "Download as" menu
By mixing code and markdown formatted comments it's quite easy to generate an HTML report which can be exported via the "File" => "Download As" menu. PDF format is also supported but it requires some configuration of the backend.