Colab tips
Prevent Colab from disconnecting
On Chrome, open console via More tools
-> Developer Tools
function keepAwake(){
console.log("Awake");
document.querySelector("#comments > span").click();
}
setInterval(keepAwake, 5000);
Hide code cell
Simply add a title to the Code cell (e.g. #@title cell title
) or
- Right-click on the area on the left of the cell (below the “Play” button) and choose “Add a form”
- Enter a title for the cell like
#@title cell title
- Right-click again in the same place and choose “Form > Hide code”
Collapsible markdown
CLICK
#### hidden code block in a text cell! ```python print("hello world!") ```
Useful magic commands
Command | Description |
---|---|
%%bash |
Make the accept shell commands instead of python code |
%%clear |
Clear cell output |
%debug |
Debug last execution that failed with an Exception |
%%writefile [-a] filename |
Write the cell content of into file (e.g. %%writefile main.py ). If -a /--append is provided then the content of the cell will be appended to the file. |
%%file filename |
alias for %%writefile . |