Skip to content
William Stein edited this page Apr 3, 2016 · 170 revisions

Question: May I use SageMathCloud for commercial purposes?

(Updated May 13, 2015).

YES. You may use all SMC projects for commercial purposes (e.g., "for personal or company gain"). SMC runs entirely on Google Compute Engine Virtual Machines that are paid for by a private company (SageMath, Inc.). Also, all data is stored and offsite backups are done on hardware owned by SageMath, Inc. Please see our privacy policy.

Question: May I use SageMathCloud for Sage development?

YES. You may use SMC projects for Sage development. Instructions on how to go about doing this can be at the page SageMath Development on SageMathCloud.

Question: How can I sync my files with Dropbox or Google Drive?

It is currently not possible to sync files in a SageMathCloud project with either Dropbox or Google Drive.

Question: I want to start long-running numerically intensive computations on SageMathCloud. What are the current limitations?

Open your project and click on Settings. The default limitations are listed under "Quotas" in the lower left. These can be raised, as mentioned there. Notes:

  1. Projects on free non-members only Virtual Machines will get restarted regularly (these are hosted on Google preemtible instances). You can check if a VM rebooted by typing "uptime". crontab files are persistent.

  2. If a project isn't used (via the web-based UI) for the idle timeout (as listed in quotas), then all processes in that project are terminated and the user is removed (so ssh into the project also is not possible). You can pay to raise the idle timeout.

Question: I want to see all processes running in my project

Type exactly the following in a full terminal (+New--> Terminal) to see all processing running in a project (note the back ticks!):

htop -u `whoami`

You can kill things, etc. See http://linux.die.net/man/1/top

Question: I want to know how much memory I am using

Type exactly the following in a full terminal (+New--> Terminal):

smem -tk

It lists all processes and the bottom line shows the total sum. The last RSS column is probably the most interesting one, for more consult man smem. The total used memory is also listed under 'Project usage and quotas" in project settings.

Question: I want some scratch space

Use /tmp. Files in /tmp may be deleted at any time, and aren't backed up.

Question: What can I store in a project?

The available webspace is a courtesy to be able to run your computational projects online. It's not for downloading arbitrary stuff from the internet. For more details about our policies, please read https://cloud.sagemath.com/policies/terms.html

Question: How can I create public projects on SageMathCloud?

You can make individual files and folders public. Pull up information for a file (click the info icon), and click on "Share Publicly". Once you do this, simply share the URL that is displayed in the top of your browser when you look at the file (or directory). Anybody else who views that link will see the file, and can create an account and copy it to their own project.

You can also publish Jupyter notebooks via a Publish button -- see this video.

Question: I would like to use SageMathCloud with my 300+ Calculus Students

Go for it! We have substantial excess capacity. For example, UCLA used SMC in their 400+ Calculus class, and dozens of other 100+ courses are using SMC. See https://github.com/sagemathinc/smc/wiki/Teaching

Question: What tools are available for course management?

This blog post describes some new SMC features for course management - e.g. setting up student projects, adding assignments, etc. There is also a video tutorial at the end of the post.

Question: I would like to use hashtags

You can put #foo in the title or description of any project. When you view your list of projects a button will appear for each hashtag, which you can click to show only projects with that tag. There is also excellent support for hashtags in task lists (SageMathCloud's todo list functionality).

Question: How can I download a whole directory?

There is currently no provision to download an entire directory. To accomplish this, you can easily create a .zip-archive. Above the files view, on the right, there is a command-box. For a directory called "My Homework", type in:

zip download-homework.zip "My Homework"

The directory name needs to be exactly the same, including upper and lowercase letters, and any space characters need to be protected by quoting the entire name.

If successful, a new file download-homework.zip should appear.

Question: If I "share" a file, does it become public to everyone and/or searchable? Or is the only way to get to it via a link and a SageMath account?

When you click "Share Publicly" in the info dialog for a file or directory, then yes, it does become public to everyone (as the name "publicly" suggests). It is NOT searchable (via Google, say) right now, but may become searchable later, when I implement something to encourage that. The only way to get it today is via a link, after you share it publicly. But that is temporary. The person getting the link does not need a SageMath account -- try opening the link in private browsing mode to see.

Question: What's my sudo/root password?

  1. You cannot have sudo/root access, because you are on a shared machine and such a global privilege only for administrators. To install a python package locally, do pip install --user ...
  2. To get internet access, please subscribe to one of the memberships. This page tells you more about this. https://cloud.sagemath.com/policies/pricing.html
  3. If you tell us which package you need, we might be able to install it system wide for you.

HELP: The SageMathCloud website doesn't work!!!

There are numerous reasons why you could experience a problem with accessing https://cloud.sagemath.com . Below are some ideas what you can try to triage the problem or do on your side to fix it:

  1. Check if you are online, and the site is up an running. This page should show you a bit of technical information about the running servers: https://cloud.sagemath.com/stats If this times out, there is nothing to see, or your browser tells you about any issues, there is either a problem with your internet connection or the SMC website.
  2. If you can load the page but it keeps timing out or doesn't load up properly, you might have received outdated code, cached in a server between you and the SMC servers, or cached locally. Try to reload the website with the Shift-key held down (that tells the browser to ignore your local cache), or clean your browser's cache directly via its interface.
  3. Additionally to the above, you can try to connect to SMC by opening up a "private browsing" or "incognito mode" window. That way, you avoid using existing cookies, etc.
  4. Another source of problems are installed browser extensions. They might also inject JavaScript code to the website, which does not play along well with the JavaScript code of SMC. With Chrome, you can go to the Settings and disable some ... or run Chrome with the command-line switch --disable-extensions. (Usually, extensions are disabled in "incognito mode", so, the point above should have taken care of this). Similarly, you can disable add-ons on Firefox.
  5. If you experience issues like frequent reloads, see strange advertising banners across the page, additional odd banners around the page, you might be a victim of some tool or virus injecting additional html code on your page (for tracking you, showing ads, etc.). For Google Chrome browser, there is the Chrome Cleanup Tool might help you to fix this.
  6. Related to the above, you might be a victim of some malicious software changing your DNS server and re-routing you through a bad proxy. Check your DNS settings and try setting 8.8.8.8 as your only DNS server to see if this helps.

Question: How do I raise the limit on the number of output messages per cell in a Sage worksheet?

import sage_server
sage_server.MAX_OUTPUT_MESSAGES=100000

See this published worksheet for more details.

Also, type sage_server.[tab key] to see information about other limitations.

Question: I would like to edit files (with sync) or manipulate data files that are on some remote server that I have ssh access to

WARNING: The following will only work if your project has outgoing network access, i.e., it says "Network access: true" under project settings. (Outgoing network access is blocked by default due to people using SageMathCloud as a platform to attack other computers. Please sign up for a membership in order to get network access.)

Suppose you have an account on some computer that you can ssh to, e.g, so this works for you:

To temporarily make the files at [email protected] available in a cloud project, open a Terminal and type

mkdir foo   # make any directory you want
sshfs [email protected]:path/to/files/ foo/

and type your password to login to [email protected]. You'll find that you can now use the files at path/to/files in [email protected] as if they were in the directory foo in your project. You can edit files (with sync), open and output data files, etc. When you're done, type

fusermount -u foo

to unmount foo. Whenever the project server is restarted, foo/ will also be unmounted. So you'll have to type sshfs [email protected]: foo/ to mount foo every once in a while.

(Alternatively, you can type crontab -e in a terminal, and add a line like this */2 * * * * sshfs [email protected]: foo/, but that would require setting up ssh keys for passwordless connections to [email protected], which you may or may not want to do.)

NOTE: The files in foo/ will not be included in snapshots, because they are part of another filesystem, and the snapshot system is configured to not cross filesystem boundaries.

Question: I would like to use Octave

I've put an example IPython octave notebook and a Sage octave worksheet here:

https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/cloud-examples/octave/

Unfortunately, neither IPython nor Sage worksheets in Octave mode are "rock solid". For something that is rock solid, type "+New", click terminal, and type "octave" on the command line, and this should work well. You can type "+New", enter a filename that ends with .m, and edit it, then load it into the command line (by typing the filename without the extension).

You might also find this useful: https://github.com/sagemath/cloud/issues/97

Question: I would like to develop a webserver in Python

Here's a simple example of an HTTP server written using the Python SimpleHTTPServer class. Open a project and click "+New" then paste in this link, then click the "From Web" button:

https://gist.github.com/certik/7031075/raw/fe9eb600946e8b3a94b752a50f0ace9d5641354f/browser

Then in a terminal type

chmod +x browser
./browser

Here's a simple example of the above with Flask

You'll see a URL in a box that looks something like this

 https://cloud.sagemath.com/4a5f0542-5873-4eed-a85c-a18c706e8bcd/port/22273/

Just paste it into your browser.

IMPORTANT: This web server is visible exactly to collaborators on your project and nobody else, and all communication is SSL encrypted. Thus you can't use this method to create a general purpose webserver available to the world. On the other hand, this is a good way to collaborate with a controlled group of people on development, without having to worry about security.

If you just want an http view of your files, use the raw servers, which is already available by default at https://cloud.sagemath.com/project_id/raw/. The point of the above script is that you could modify it to provide all sorts of interesting functionality.

Question: How can I install Python packages from https://pypi.python.org/pypi using pip?

WARNING: Due to people launching attacks from SMC, using pip install --user will not work unless you pay to enable network access for your project.

Let's suppose the package is called ggplot. Create a new Terminal in a project (+New-->Terminal) and type

sage -sh
pip install --user ggplot

Open the project's settings (the gear icon) and click "Restart Sage Worksheet Server" in the Restart section. If you're using Juoyter Notebook you may also have to click "Restart Project Server". Now ggplot should be available in any (restarted) worksheet (click the red restart icon in a worksheet to restart it). The restart is necessary, since the worksheet server uses forking to reduce startup time of worksheets from 5 seconds to 0.1 seconds.

To directly install your Python dependencies for your local user account, you can place your packages here: $HOME/.local/lib/python2.7/site-packages/. The $HOME/.local/ path is the "canonical" root for some overlay directories of linux's standard directory layout (For more information, type $ man hier in a terminal).

To use binaries installed by pip add export PATH=~/.local/bin:$PATH to ~/.bashrc and run source ~/.bashrc

Question: Can you tell me how to insert HTML, LaTeX or simple text between two cells in a Sage worksheet?

Put

%md

at the top of a cell to use markdown formatting (which fully supports LaTeX formulas). See http://daringfireball.net/projects/markdown/ about markdown. When you press shift-enter, the output is displayed. Double click to edit.

You can also use %html in a similar way to the above, which also supports LaTeX.

No graphical editor is available yet to edit %html cells, but I hope to change that soon.

Question: I want to use my own copy of Jupyter, which is part of my own Python stack

You can install any version of Python you want into your own project -- just download and build it locally, and install Jupyter (and whatever you want) into it. Then, make a directory "bin" in the home directory of your project and put a symlink to your ipython there, e.g.,

cd ~/bin/
ln -s /path/to/your/ipython .

In project settings, restart your project server (just to be sure), then make sure that when you type "ipython" on the command line, you get your Jupyter. Then clicking on existing Jupyter notebooks or creating new ones (through the gui) should use your copy of Jupyter. It just uses the "Jupyter" that is in the path, since ipython-notebook just sets up some options and runs "ipython notebook" (look at ~/.smc/ipython-notebook).

Question: I want to install the cite2c Jupyter extension, so I can use Zotero

(WARNING: Due to people launching attacks from SMC, you must pay to enable network access for your project in order to use github.)

Do the following in a terminal:

git clone https://github.com/takluyver/cite2c.git && cd cite2c && sage install.py

Now when you open a Jupyter notebook, there will be two new buttons at the end of the button bar, which will let you insert citations.

Question: How can I add my own Jupyter Kernel?

Jupyter Kernels are small JSON files, telling the Jupyter Notebook what program to start to communicate with the actual kernel that holds your working session and executes your code. To install your own, they need to go into the directory:

$HOME/.local/share/jupyter/kernels/[name_of_your_kernel]/kernel.json

For example, this is the content of kernel.json file is running Anaconda Python 3:

{
 "display_name": "My Anaconda (Python 3)",
 "argv": [
  "/projects/anaconda3/bin/python3",
  "-E",
  "-m",
  "ipykernel",
  "--matplotlib=inline",
  "-f",
  "{connection_file}"
 ],
 "language": "python",
 "env":{
    "LD_LIBRARY_PATH" : "/projects/anaconda3/lib",
    "PYTHONPATH" : "/projects/anaconda3/lib/python3.5:/projects/anaconda3/lib/python3.5/site-packages",
    "PYTHONHOME" : "/projects/anaconda3/lib/python3.5"
 }
}

Once that file is there, click the reload button (top right of the jupyter notebook) to let it search for kernels and find your configuration.

Question: I need to spell check my LaTeX documents

Whenever you save the LaTeX document, it will run a spell checker and underling the words that are not spelled correctly. By default, it uses the language you've set in your web browser.

You can change the autosave interval to be very short in account settings (under editor) if you need the spell checking to update frequently.

Seeing a list of alternative words (correct spellings) isn't supported directly in the editor yet https://github.com/sagemath/cloud/issues/50. For now, a workaround is to run LaTeX-aware aspell, e.g.

1. open a terminal
2. aspell -t -c <filename.tex>

Question: How can I properly work with multi-document LaTeX projects?

Suppose, your LaTeX project is composed of one master.tex file and several chapter-1.tex, chapter-2.tex, etc. SageMathCloud's LaTeX editor only knows about the currently opened file, and using \import{} doesn't work, because the chapter-*.tex parts are not proper documents.

To solve this, use the subfiles package instead. It does not only collect the partial documents into one, but also extracts the preamble of the master.tex file for each chapter-*.tex in order to create valid subdocuments.

Following the documentation, do this:

  1. \usepackage{subfiles} in master.tex

  2. \subfile{⟨subfile name ⟩} for each subfile in master.tex's document environment (i.e. instead of \include or \import).

  3. For each chapter-*.tex subfile:

      \documentclass[⟨master.tex file-name⟩]{subfiles}
      \begin{document}
      ⟨text, graphics, etc.⟩
      \end{document}
    

After that, all *.tex files can be compiled and all other features like forward/inverse search work, too.

Question: I would like that all of my worksheets know where to find a given module that I write or install.

Put an executable file with this content in $HOME/bin/sage:

#!/usr/bin/env bash
SAGE_PATH=$HOME/NEW_MODULE /usr/local/bin/sage "$@"

You could do this by making a new directory called bin, then a new file in there called "sage". Then in the terminal type the following to make "sage" executable.

  cd; cd bin; chmod +x sage

This is also the file "sage" attached to this message.

Then restart the worksheet server by going project settings and clicking "Restart --> Worksheet server".

Now any newly (re-)started worksheet will run with the above modified SAGE_PATH. Since SAGE_PATH is added to PYTHONPATH when Sage starts, this does what you want.

Obviously, I plan to add a simple way to do something equivalent to the above, by filling in some settings box in the UI. I'll update this FAQ entry once I do that.

(From Nathan Dunfield) Another approach, which also works now and doesn't require the custom "$HOME/bin/sage", is to use http://docs.python.org/2/install/#alternate-installation-the-user-scheme

That is, one installs a module with "sage -python setup.py install --user" and it's dumped into

   $HOME/.local/lib/python2.7/site-packages

This is location is searched automatically by Sage's Python without any intervention on the part of the user. (However, I did have to restart the worksheet server to access newly installed modules from a worksheet.) One can also put modules into the user's site-packages by hand and Sage will find them.

I created an HTML form in a .sagews file using HTML, CSS and JS. How can I connect my form with my Python code?

To create a connection between your HTML form in a .sagews file created using HTML, CSS and JS, you need to use the worksheet.execute_code() function in your JS code.

Because worksheet.execute_code isn't a standard JS function, but special SageMathCloud function, you need to load your JS code with worksheet.execute_code(). In particular do NOT use

load('path/to/js/code.js')

but instead use

salvus.javascript(open('path/to/js/code.js').read())

For example in .sagews file suppose you created a div with id='myApp' as follows:

%html
<div id='myApp'>
....
    <div id="msgLog"></div>
    <div id="msgErr"></div>
</div>

Let's say your Python function will double x:

def myfunc(x):
    print(x*2)

In your JS code type:

worksheet.execute_code({
    code: 'myfunc(n)',
    data: {n: 2},
    preparse: true,
    cb: function(msg){
            if(msg.stdout){$('#myApp #msgLog').html(msg.stdout);}
            if(msg.stderr){$('#myApp #msgErr').html(msg.stderr);}
    }
});

Please note that myfunc() doesn't return anything. On the contrary, it uses print() to send output. This is because JS and python are different languages, and you can't just use return in your Python function to return some answer. stdout in JS code means standard output stream. That is, the print function in your Python code places the result of myfunc() in the output stream. That's why you need to use print() but not return() in your Python code.

Also, if your Python code will raise some exception, then it will result in output to stderr -- the standard error stream. If you JS code (as in the example above) catches stderr, you can get any error message from your Python code.

Question: In the standard Sage notebook there is a checkbox to switch on the typesetting of math. How do I turn on typesetting of math output in SageMathCloud?

Turn it on with

typeset_mode(True)

and off with

typeset_mode(False)

Putting

%auto
typeset_mode(True)

at the top of a worksheet will make this automatic.

Question: I'm using the vim pentadactyl plugin, and the editor isn't working.

The Pentadactyl plugin is not compatible with the Codemirror editor in SageMathCloud. You can disable Pentadactyl for a particular page, perhaps by pressing Control+Z. SagemMathCloud has it's own Vim bindings for worksheets and editing files; to enable it, go to setting (click the gear by your name in the upper right), then select Vim next to Editor --> Bindings.

Question: I want to browse and view (or edit) files outside of my project's home directory.

You can make a symbolic link to the root of the filesystem by typing

 ln -s / root

Now you can explore the complete filesystem. Note that there many files that you can only read and not write.

Question: I would like to use Emacs in a Terminal on Chrome. Help!

Chrome absolutely doesn't allow normal web applications to intercept certain keystrokes, which makes Emacs-in-a-terminal painful on some operating systems (esp. Linux/Windows). E.g., Ctrl-N brings up a new window, instead of going to the next line! (It is possible to eventually get around this by creating a Chrome extension, but I haven't done this yet.) In the meantime, you can install the SageMathCloud chrome app from the app store or on Linux, type google-chrome --app=https://cloud.sagemath.com to local the website as an app (if you use chromium instead, type chromium-browser --app=https://cloud.sagemath.com).

This is not a completely solution since in some cases, control-shift-minus and control-shift-plus still zoom in and out (on ChromeOS they zoom the entire desktop -- every window, all icons, the time, etc., in and out!). This is a major problem, because control-shift-minus is "undo" in emacs. The workaround I currently use is to put this in my .emacs file, and instead type "alt-u" for undo:

(define-key esc-map "u" 'undo)

Note that undo is also available by default through other key bindings, like C-x u and C-/. (Execute "M-x where-is undo".) So there are other options available.

Question: Is .bashrc or .bash_profile called on startup?

~/.bashrc is run on startup and ~/.bash_profile is not! Hence, use ~/.bashrc to customize your setup, and you can also use ~/.bash_aliases for your aliases (see ~/.bashrc).a

Make sure you have at least 6GB disk space (look at quotas in project settings -- if you don't, don't want to upgrade, and are just playing around, cd to /tmp instead), then type

 install-latest-sage-release   

Then type this, assuming the name of the install you just got is sage-6.7:

cd; mkdir -p bin; cd bin; ln -sf ~/sage-6.7/sage .

See the discussion about worksheet servers in the next FAQ question below. Also, now that you have your own copy of Sage, you can change anything in Sage! Do so, send us patches, etc. See http://www.sagemath.org/doc/developer/ for step-by-step instructions.

Question: I want to use my own custom built-from-source copy of Sage (takes hours)

Open a Terminal. Grab the source tarball (requires network access). You can browse http://sage.math.washington.edu/home/release/ to find recent releases and testing versions. To build, do the following in your terminal (no need to worry about screen or tmux, of course, since sessions are persistent even if your browser leaves), and check back in a few hours:

tar xvf sage-6.10.tar.gz && cd sage-6.10 && make

WARNING: In fact, building can easily take more than 2 hours. By default SageMathCloud projects have an idle timeout that is smaller. If you aren't editing files in the project, your build will get killed part of the way through. If you're doing legit Sage development, email THE LINK TO YOUR PROJECT to [email protected] and we will increase the idle timeout, disk space, RAM, etc, so you can contribute to Sage.

After doing that, do something like this in the terminal:

cd; mkdir -p bin; cd bin; ln -s ~/sage-6.10/sage .

Then restart your worksheet server (in project settings). Then for that project, you'll have your own 100% customizable copy of Sage; and moreover, when I upgrade the system-wide Sage, your project isn't impacted at all -- that sort of stability is a major win for some people. This also uses little extra disk space in my backups/snapshots, because of de-duplication. You can of course also install any custom packages you want into this copy of Sage. You can also help improve Sage: http://www.sagemath.org/doc/developer/

If you want to do Sage development see http://mathandhats.blogspot.com/2014/06/how-to-develop-for-sage-using-sage-math.html.

Important: Whenever you change Python code installed in that copy of Sage, you may have to restart the worksheet server and any running worksheets. This is inconvenient, but is necessary because the worksheet server starts one copy of Sage, then forks off additional copies each time you open a new worksheet, which greatly reduces the time from when you open a worksheet until it actually starts computing things.

Also Important: If your copy of Sage is messed up in some way, then the worksheet server can't start, hence worksheets won't open. To debug this, open a terminal and do this:

~$ cd .smc
~/.smc$ sage sage_server.py
you should see an error here, e.g., 

and fix whatever error you see. Also look at log files in ~/.smc/sage_server/

Question: How to turn off the character accent selector and re-enable key repetition on Mac OS X ?

launch a Terminal and run the command

 defaults write -g ApplePressAndHoldEnabled -bool false

Question: I want to use a Jupyter Notebook (with Sage support)

Click "+New", then enter a filename and click Jupyter Notebook. This is Jupyter, but enhanced with realtime synchronization. You can also just run a standard Jupyter notebook server (no sync, not integrated into cloud) by (1) finding your project's id in project settings, then (2) visiting https://cloud.sagemath.com/[project_id]/port/jupyter (you will possibly have to refresh your browser if this takes too long the first time). Any collaborator on your project can securely use the Jupyter notebook server by visiting this link, but nobody else can.

If you want to make Jupyter Sage-friendly, so the Sage preparser and library are available, type

 %load_ext sage

Note: nobody has added support for displaying plots yet to this mode (but Volker Braun just did a lot of work on this and it is coming soon!). As a temporary workaround, this function will display a Sage plot:

def showplot(g):
    import IPython.display
    save(g, 'a.png')
    display(IPython.display.Image('a.png'))

For example, this will now work:

g = plot(sin,(0,5)) + plot(cos, (0,5), color='red')
showplot(g)

Question: How can I tell if my code is running in a SageMathCloud Worksheet (a sagews file)?

The global variable __SAGEWS__ will be defined.

Question: How do I access functionality specific to SageMathCloud worksheets (sagews files)?

Type salvus.[tab key].

Question: I created an ssh key in my project; how do I easily copy it?

If you type ssh-keygen in a terminal, then you'll generate an ssh key, which you might use with github (say) or sage's trac to easily push and pull to repositories. To copy this ssh key, you could type cat .ssh/id_rsa.pub and copy in the terminal, but you'll have to manually delete a bunch of newlines. Alternatively, do the following:

  1. In the project file list, click on the icon that looks like an eye in the middle on the right side of the screen to reveal hidden files (those that start with a dot).

  2. Click on the .ssh directory -- you can easily find it by typing "ssh" in the search box labeled "choose files..." on the left.

  3. Click on id_rsa.pub, then highlight everything and copy as usual.

  4. Click the eye again to turn off viewing hidden files.

Alternatively, type this into the small "terminal command" box in "files": cat ~/.ssh/*.pub. Below the box, you can conveniently copy/paste it!

You can also type the following into a full terminal: open ~/.ssh/id_rsa.pub

Question: How to fix an exception related to Sage's Integer(...) vs. Python ints?

By default, Sage parses the input commands and replaces some elements with its own parts and also adds some syntactic sugar. For example, an integer like 234 is translated to Integer(234) in order to be more powerful and live as a part of Sage. To avoid this behaviour, either append an r to the number, like 234r or change the mode of the cell to Python by adding %python at the top. You can also switch to pure Python mode by default via %default_mode python. Alternatively, you can type Integer=int and possibly also RealNumber=float.

Question: I would like to ssh into my project.

Under "Status" in project settings, you'll find a section labeled "SSH into your project", with the ssh command line that you can type (on any computer anywhere) to ssh to your project.

For this to work, you MUST add an ssh public key to your project. There is a link "add a public key to ~/.ssh/authorized_keys" right there, so click on it, and paste an ssh public key into that file, then save it. Now you can ssh to your project.

Question: I would like to install new R packages.

Open a terminal windows and type

    `sage -R`

Then you can install packages as usual

    `install.packages('packagename')`

Note that you must also upgrade your project to have network access (requires a subscription).

Question: I would like to push and pull from github using ssh.

First, despite the fact that you are accessing SageMathCloud through the internet, you are actually working in a highly restricted environment. Processes running inside a free project are not allowed to directly access the internet. (We do not allow such access for free users, since when we did, malicious users launched attacks on other computers from SageMathCloud.) Enable internet access by adding the "internet access" quota. See https://cloud.sagemath.com/policies/pricing.html

Once you have enabled network access for your project, to use ssh from SMC to connect to github you need to create an ssh key and explicitly allow that account/key access to github.

  1. Make a terminal: "+New --> Terminal"

  2. Create an ssh key public/private key pair by typing the command ssh-keygen.

  3. Copy .ssh/id_rsa.pub to github.

Question: I would like to use R in a Sage Worksheet.

Video

  1. Click +New, type a filename, then click the "Sage Worksheet" button.

  2. To evaluate code using R, begin the cell with %r, type the code, then press shift+enter.

  3. Type %default_mode r in a cell and press shift+enter; now all cells will be evaluated using R by default. If you need to switch back, use %default_mode sage.

Question: I would like to override the default width and height for R svg figures in a Sage Worksheet.

To set width to 10 inches and height to 4 inches, use the sage command:

r.set_plot_options(width=10, height=4)

If you have set default_mode to r, then enter the command in a sage mode cell:

%sage r.set_plot_options(width=10, height=4)

You can change it by typing it again.

Question: I would like to use Julia in a Sage Worksheet.

  1. Click +New, type a filename, then click the "Sage Worksheet" button.

  2. To evaluate code using Julia, begin the cell with %julia, type the code, then press shift+enter.

  3. Type %default_mode julia in a cell and press shift+enter; now all cells will be evaluated using Julia by default. If you need to switch back, use %default_mode sage (or %sage to just switch back for one cell).

Question: I would like to create, compile and run a C program.

Video

  1. Click +New, type a filename ending in ".c", e.g., foo.c, and click "Create File" (or just press return).

  2. Paste this code into the file:

#include<stdio.h>
int main(void) {
    printf("Hello World\n");
    printf("this is SageMathCloud!\n");
}
  1. Open a terminal by clicking +New, clicking "Command Line Terminal" (or typing a filename ending in .term), and type gcc foo.c. Finally, run the program by typing ./a.out.

Question: I would like to create, compile and run a Fortran F90 program.

Video

  1. Create a file sum.f90 by clicking +New, which I copy and paste from http://en.wikibooks.org/wiki/Fortran/Fortran_examples#Area_Of_a_Triangle_program

  2. Create a terminal and type gfortran sum.f90

  3. Run the program by typing ./a.out

Question: I would like to create, compile and run a Java program.

Video

  1. Create a file HelloWorld.java containing
public class HelloWorld {
    public static void main (String[] args) {
	System.out.println ("Hello World!");
    }
}
  1. Create a terminal and run javac HelloWorld.java to compile your program.

  2. Run java HelloWorld to see the output.

Question: I want to install Python3 and use it as my default.

With full network access enabled, you can download and compile Python 3 this way. Last line sets a symlink to make it your default!

apt-get source python3.4-dev
cd python3.4-3.4.0/
./configure --prefix=$HOME
make
make install
cd ..
pip3 install numpy
pip3 install scipy
pip3 install matplotlib
pip3 install ipython
pip3 install pyzmq
pip3 install jinja2
pip3 install tornado
ln -s ~/bin/python3 ~/bin/python

Question: Is Scilab broken?

No, the Java stacktrace only happens because there is no graphical interface available due to the fact that there is no graphical interface ;-)

Type

scilab-adv-cli

or

scilab-cli

or

scilab -nw

The following Sage/Python command modifies the PATH variable to include $HOME/bin. Sage looks for the fricas executable in this PATH:

os.environ['PATH'] = '%s/bin:%s'%(os.environ['HOME'],os.environ['PATH'])

Restart the worksheet to make sure the new version of FriCAS is started.

A mode xxx specified by %xxx in the first line of a cell in SageMathCloud is just a Python function xxx that takes the cell input as a string and does something visible with it. For example, the following function takes whatever the cell input is, executes the code in Fricas, performs some simple substitutions on the FriCAS output and then displays it using Markdown:

%sage
def fricas_tex(s):
    import re
    t = fricas.eval(s)
    t=re.compile(r'\r').sub('',t)
    # mathml overbar
    t=re.compile(r'&#x000AF;').sub('&#x203E;',t,count=0)
    # cleanup FriCAS LaTeX
    t=re.compile(r'\\leqno\(.*\)\n').sub('',t)
    t=re.compile(r'\\sb ').sub('_',t,count=0)
    t=re.compile(r'\\sp ').sub('^',t,count=0)
    md(t, hide=False)

FriCAS can generate output that is (almost) compatible with Markdown format.

For example you can use this new mode in a cell with the following contents:

%fricas_tex
)set output algebra off
)set output mathml on
)set output tex on
sqrt(2)/2+1

This will evaluate 'sqrt(2)/2+1' and display the result in both LaTeX format and MathML formats (in a MathML capable browser).

Note: The current version of Sage (6.6 and earlier) requires a patch to correct a bug in the fricas/axiom interface.

Question: How do I keep code blocks from being hidden?

Use %html(hide=False) if HTML code block or %md(hide=False) if not.

Here's the current (as of May 2015) backup system:

  1. The files in your project sit on a VM at google, whose filesystem is snapshotted twice per day, with snapshots saved for about 10 days.

  2. The files are rsync'd to another server whenever your project is saved (so every 5 minutes when actively used).

  3. The files and the second server are snapshotted using ZFS with snapshots saved for several months (but trimmed over time).

  4. Every few hours a bup (=git) archive is made of modified projects and saved in a Google cloud storage nearline bucket.

  5. At least once per week (and usually once per day), I rsync the new bup archives to an encrypted USB drive, which is usually not connected to the internet (and with my personally in most cases).

  6. I periodically rsync that usb drive to another encrypted USB drive.

  7. I periodically swap that usb drive from above out with another encrypted USB drive that is kept in a locked office elsewhere.

Question: I want to XXX, but I don't see XXX above.

Do not hesitate to email THE LINK TO YOUR PROJECT TO [email protected] or https://groups.google.com/forum/?fromgroups#!forum/sage-cloud

Clone this wiki locally