permalinks for sage cell computations

66 views
Skip to first unread message

Jason Grout

unread,
Feb 11, 2012, 11:56:10 PM2/11/12
to sage-notebook
Just FYI, we now have permalinks for Sage Cell computations. If you go
to aleph.sagemath.org and type in some code, then evaluate the code, a
"Permalink" link appears. That link encodes your code as a URL. If you
send that URL to anyone, it will load your code into the sage cell
server for them.

As an example, try going to this link:

http://aleph.sagemath.org/?z=eJx1kEFuwyAQRfc-BYoSmXHGlmM7m0oj9R5VFVGbxKjEIEBtnNOXmjTNomUDM7z_NPAhHM_DKIPIIXtWU5BO9CEb5JEduaNd2RS98XwhAAN5rQbpeF3tsCmsqiYOAE8Zi8uSNVq4g9UmcIcshZDVyEKMjqp_n6T31ML2T7BejIBC21FQXe0habek1ST5C6-xhkh3aSLArvBqigd4_Ycs72j5y-I348OsJeVlmd-j1sTXc-7SNBTgJ8seWjdJ7J3eeqONo9zJIccl7NVVUrPHq3Hxj6hL6jGcNV-tHW38erV58EO696P55BYvZzVR2cZdXKjF-VbOqRTeyj4cnAjK0A6-AMdVgy8=

(yeah, I know it's kind of long. I didn't want the permalink to depend
on the server, so all of the code is zipped and base64 encoded into the
URL).

Thanks,

Jason

Juan Luis Cano Rodríguez

unread,
Feb 12, 2012, 1:06:47 PM2/12/12
to sage-n...@googlegroups.com
Oh my! This is **the** way now to share interacts! Maybe we could even replace some nasty gifs from the wiki with real interacts, and easily show to the world the potential of Sage, and...

Thank you very much, we have lots of possibilities now.

Bruce Cohen

unread,
Feb 12, 2012, 2:05:54 PM2/12/12
to sage-notebook
Wow! Permalinks will really help. Thanks.

-Bruce

http://aleph.sagemath.org/?z=eJytkj9vwjAQxXd_ihMMxMoFBSK1k9eOFSN_WpBJriQijS3bISFVv3udlAJDR7z4zta935Ofx1AqdQTp4Cxo-xV12_k3NEZqTRlIo-oqA5cTdJFsC8vGYPCAe0hVqYwFm6sGWjxjB7Ily07SBJOhxxpPE85cXqTHiqwVT8yJhGkxY6RtUapKTOOELYQulUuygLZBFLTbeegNcI6bFiOH7h033aUAaTWlbmekK5QI_BkmHJWWaeHOYvrM2VJIY1TjxTZ-JMbYT1_2X79iYiibYFNkLhdXZ5iTzLxsVtRWxNMZwhuD-zXcl-QNzxGuwDlnqxsw7l32wBjdPfBgiKoHItf3yB46IOPhgS7IfVnTA4mMvQ4ZDQn5gDi2CLdYrxVni5nQ0shPcqZId5dcg9q7o1YHUT0EO_SO_7kdKSOrA43wX8X-ewXLcBWuw8UsXCB89PLiRZaW-A-TmNoO

On Feb 11, 8:56 pm, Jason Grout <jason-s...@creativetrax.com> wrote:
> Just FYI, we now have permalinks for Sage Cell computations.  If you go
> to aleph.sagemath.org and type in some code, then evaluate the code, a
> "Permalink" link appears.  That link encodes your code as a URL.  If you
> send that URL to anyone, it will load your code into the sage cell
> server for them.
>
> As an example, try going to this link:
>
> http://aleph.sagemath.org/?z=eJx1kEFuwyAQRfc-BYoSmXHGlmM7m0oj9R5VFVGb...

Harald Schilly

unread,
Feb 12, 2012, 2:11:10 PM2/12/12
to sage-n...@googlegroups.com
On Sun, Feb 12, 2012 at 05:56, Jason Grout <jason...@creativetrax.com> wrote:
> Just FYI, we now have permalinks for Sage Cell computations.

hi, that's fantastic! have you thought about adding an optional url
shortener? your long url could look just like http://goo.gl/J4NcC for
example :-)
i think it's not allowed to let this replacement happen automatically,
but there is an api to make this rather painless
http://code.google.com/apis/urlshortener/

h

Keshav Kini

unread,
Feb 12, 2012, 2:37:26 PM2/12/12
to sage-n...@googlegroups.com

Dan Drake

unread,
Feb 12, 2012, 8:28:36 PM2/12/12
to sage-n...@googlegroups.com
On Sat, 11 Feb 2012 at 10:56PM -0600, Jason Grout wrote:
> Just FYI, we now have permalinks for Sage Cell computations. If you
> go to aleph.sagemath.org and type in some code, then evaluate the
> code, a "Permalink" link appears. That link encodes your code as a
> URL. If you send that URL to anyone, it will load your code into
> the sage cell server for them.

That's very cool! Huge possibilities there; you could include URLs in
emails, papers and random web pages. Very interesting.

It looks like you ran something through HugeURL:
http://hugeurl.geeks.org/

Also, that's a nice @interact. I'll just bookmark that and save it for
later...

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

Jason Grout

unread,
Feb 13, 2012, 6:52:41 AM2/13/12
to sage-n...@googlegroups.com
On 2/12/12 7:28 PM, Dan Drake wrote:
> That's very cool! Huge possibilities there; you could include URLs in
> emails, papers and random web pages. Very interesting.

The itch I was scratching was that a colleague of mine was using links
to Wolfram Alpha in a multivariable calculus textbook that I am using
and revising, and I really wanted to put in corresponding links to Sage
interacts and Sage computations. Now I can.

Jason

William Stein

unread,
Feb 13, 2012, 7:23:24 AM2/13/12
to sage-n...@googlegroups.com

The "shortened" permalink implementation doesn't work for me in Chrome, in that
if I do something and put my cursor over "(shortened)" the link in the
hint at the bottom
of the screen shoes the shortened URL, but when I click, that vanishes
and the link
at the top (in the address bar) is *not* shortened, and moreover the
shortened link
is displayed nowhere else on the page.

-- William

Dan Drake

unread,
Feb 13, 2012, 7:38:43 AM2/13/12
to sage-n...@googlegroups.com

It did occur to me that it should be pretty easy to do something in
SageTeX so that you could make links. Hopefully something like this
would work:

\setsinglecellbaseurl{aleph.sagemath.org}

"You can view this computation at
\href{\makesinglecelllink{code here...}}{this link}."

(Not sure about } inside the code, but I'm just brainstorming here.) Or,
you could give labels to environments to somehow reuse the code:

\begin[cool-code]{sageblock}
some cool code
\end{sageblock}

and then later, use some macro with that label to automatically pull in
that code so you don't have to retype it, and can guarantee that what is
in the text corresponds to what is in the URL.

signature.asc

Jason Grout

unread,
Feb 13, 2012, 7:51:37 AM2/13/12
to sage-n...@googlegroups.com

That's working as expected. You click on a tinyURL link, and it goes to
tinyURL, then forwards you on to the original, non-shortened URL, which
is basically all of your code zipped and base64-encoded in the URL. It
loads your code and waits for you to evaluate it.

Typically you'll copy the short url link and send that along. I suppose
we should explicitly display it to make it easy to copy.

Jason


William Stein

unread,
Feb 13, 2012, 8:03:27 AM2/13/12
to sage-n...@googlegroups.com
On Mon, Feb 13, 2012 at 4:51 AM, Jason Grout

<jason...@creativetrax.com> wrote:
> On 2/13/12 6:23 AM, William Stein wrote:
>>
>> On Mon, Feb 13, 2012 at 3:52 AM, Jason Grout
>> <jason...@creativetrax.com>  wrote:
>>>
>>> On 2/12/12 7:28 PM, Dan Drake wrote:
>>>>
>>>>
>>>> That's very cool! Huge possibilities there; you could include URLs in
>>>> emails, papers and random web pages. Very interesting.
>>>
>>>
>>>
>>> The itch I was scratching was that a colleague of mine was using links to
>>> Wolfram Alpha in a multivariable calculus textbook that I am using and
>>> revising, and I really wanted to put in corresponding links to Sage
>>> interacts and Sage computations.  Now I can.
>>
>>
>> The "shortened" permalink implementation doesn't work for me in Chrome, in
>> that
>> if I do something and put my cursor over "(shortened)" the link in the
>> hint at the bottom
>> of the screen shoes the shortened URL, but when I click, that vanishes
>> and the link
>> at the top (in the address bar) is *not* shortened, and moreover the
>> shortened link
>> is displayed nowhere else on the page.
>
>
> That's working as expected.

"as expected" by you. That is definitely *not* "as expected" by my.
Tons of sites (like google maps) have options to obtain a shortened
URL for a permalink, and they always make the link clearly displayed
when you click on "short url".

>  You click on a tinyURL link, and it goes to
> tinyURL, then forwards you on to the original, non-shortened URL, which is
> basically all of your code zipped and base64-encoded in the URL.  It loads
> your code and waits for you to evaluate it.
>
> Typically you'll copy the short url link and send that along.  I suppose we
> should explicitly display it to make it easy to copy.

That's definitely not a good solution either, IMHO.

Please go to http://maps.google.com, click on the link icon, and see
how it works there. That is an example of doing permalinks right.

I'm planning to demo this permalinks thing in my (rather huge) Sage
class today since I think it is so cool.

-- William

>
> Jason
>
>

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Harald Schilly

unread,
Feb 13, 2012, 8:09:21 AM2/13/12
to sage-n...@googlegroups.com


On Mon, Feb 13, 2012 at 13:51, Jason Grout <jason...@creativetrax.com> wrote:
That's working as expected.

I think the difference is, that in usual url shortening implementations, the shortening only happens explicitly when you click on it. as far as i can see now, it happens automatically, even when you don't need the url. I haven't read the terms of use, but i guess that's not a nice behavior and might be considered as some kind of spam, because it creates many unused shortened urls.

William Stein

unread,
Feb 13, 2012, 8:26:52 AM2/13/12
to sage-n...@googlegroups.com

According to the discussion we had yesterday at the notebook sprint,
you are in fact definitely violating the terms of usage. You cannot
automatically create shortened URL's unless the user explicitly asks
for them.

William

>
> H

Jason Grout

unread,
Feb 13, 2012, 8:54:02 AM2/13/12
to sage-n...@googlegroups.com
On 2/13/12 7:26 AM, William Stein wrote:
> On Mon, Feb 13, 2012 at 5:09 AM, Harald Schilly
> <harald....@gmail.com> wrote:
>>
>>
>> On Mon, Feb 13, 2012 at 13:51, Jason Grout<jason...@creativetrax.com>
>> wrote:
>>>
>>> That's working as expected.
>>
>>
>> I think the difference is, that in usual url shortening implementations, the
>> shortening only happens explicitly when you click on it. as far as i can see
>> now, it happens automatically, even when you don't need the url. I haven't
>> read the terms of use, but i guess that's not a nice behavior and might be
>> considered as some kind of spam, because it creates many unused shortened
>> urls.
>
> According to the discussion we had yesterday at the notebook sprint,
> you are in fact definitely violating the terms of usage. You cannot
> automatically create shortened URL's unless the user explicitly asks
> for them.

Thanks for pointing this out. I'll change it as soon as I can.

Jason


Jason Grout

unread,
Feb 13, 2012, 8:58:35 AM2/13/12
to sage-n...@googlegroups.com

I've commented out the code that makes the short url. Like William
pointed out, there are definitely design issues to work out as well as
making sure we don't violate terms of usage.

Thanks,

Jason


Jason

unread,
Feb 13, 2012, 4:22:50 PM2/13/12
to sage-notebook
I wonder if you could do better on the compression by having some pre-
defined dictionaries already created in sage. While I'm no expert, I
believe that when you compress the code to shorten it, you have to use
some of the bytes to define the dictionary. For short code, this is
probably a significant portion of the total number of bytes.

You could take hundreds of code snippets and create maybe 15 different
dictionaries. Then the first part of the code specifies which
dictionary the code uses, from 0 - 14. If including it's own
dictionary results in the smallest size, then it could be type 15.
You'd probably also want a version number if you were to go down that
path. Maybe it turns out 128 dictionaries is better, same principle.

Here's some related info, they talk about fixed tables:
http://stackoverflow.com/questions/732578/what-is-the-best-compression-algorithm-for-small-4-kb-files

Robert Bradshaw

unread,
Feb 13, 2012, 6:21:44 PM2/13/12
to sage-n...@googlegroups.com
This is really cool, though I've heard that some browsers don't handle
2K+ URLs very well.

Interesting idea, though there is an advantage to being able to say
"this is base-64 gzipped code" so that anyone can easily make/decode
such URLs. If the code is short enough (and, say, all ascii), it'd be
nice to forgo the obfuscation of the compression altogether.

- Robert

Dan Drake

unread,
Feb 13, 2012, 7:36:12 PM2/13/12
to sage-n...@googlegroups.com
On Mon, 13 Feb 2012 at 03:21PM -0800, Robert Bradshaw wrote:
> Interesting idea, though there is an advantage to being able to say
> "this is base-64 gzipped code" so that anyone can easily make/decode
> such URLs.

I agree -- my thoughts about doing such things in SageTeX depend on it
being super easy to make the URL. You just make sure it's encoded in
UTF-8, zip, and base64-encode.

What, really, would be the advantage of shorter URLs -- especially since
you have a tinyurl button? I'm not skeptical, just curious.

signature.asc

Jason

unread,
Feb 13, 2012, 7:37:46 PM2/13/12
to sage-notebook


On Feb 13, 3:21 pm, Robert Bradshaw <rober...@math.washington.edu>
wrote:
> Interesting idea, though there is an advantage to being able to say
> "this is base-64 gzipped code" so that anyone can easily make/decode
> such URLs. If the code is short enough (and, say, all ascii), it'd be
> nice to forgo the obfuscation of the compression altogether.
>
> - Robert
I agree, I can't say it's necessarily worth the additional complexity.
We're just talking a % reduction, not short links.

Jason Grout

unread,
Feb 13, 2012, 8:58:55 PM2/13/12
to sage-n...@googlegroups.com
On 2/13/12 6:36 PM, Dan Drake wrote:
> I agree -- my thoughts about doing such things in SageTeX depend on it
> being super easy to make the URL. You just make sure it's encoded in
> UTF-8, zip, and base64-encode.

The server doesn't care if the zipped base64 data comes in the URL or in
form fields. SageTeX presumably would submit the data in a POST
request, which avoids problems with URLs that are too long.

The 'c' argument specifies raw code. If that field is empty, then it
looks in the 'z' argument for zipped base64 code.

Jason

Jason Grout

unread,
Feb 13, 2012, 9:00:12 PM2/13/12
to sage-n...@googlegroups.com

Right now, if the url-escaped code is less than 50 characters, the raw
code is returned rather than the zipped/base64 version. Maybe that
threshold should be higher.

Jason


Robert Bradshaw

unread,
Feb 14, 2012, 2:50:05 AM2/14/12
to sage-n...@googlegroups.com

I love it when feature requests are already implemented :). Yeah, I
might bump it up to 100 characters or more.

- Robert

Jason Grout

unread,
Feb 14, 2012, 5:17:39 AM2/14/12
to sage-n...@googlegroups.com
On 2/14/12 1:50 AM, Robert Bradshaw wrote:

> I love it when feature requests are already implemented :). Yeah, I
> might bump it up to 100 characters or more.

It's now 100 characters.

Jason

Jason Grout

unread,
Feb 14, 2012, 3:23:05 AM2/14/12
to sage-n...@googlegroups.com
On 2/13/12 7:26 AM, William Stein wrote:
> On Mon, Feb 13, 2012 at 5:09 AM, Harald Schilly
> <harald....@gmail.com> wrote:
>>
>>
>> On Mon, Feb 13, 2012 at 13:51, Jason Grout<jason...@creativetrax.com>
>> wrote:
>>>
>>> That's working as expected.
>>
>>
>> I think the difference is, that in usual url shortening implementations, the
>> shortening only happens explicitly when you click on it. as far as i can see
>> now, it happens automatically, even when you don't need the url. I haven't
>> read the terms of use, but i guess that's not a nice behavior and might be
>> considered as some kind of spam, because it creates many unused shortened
>> urls.
>
> According to the discussion we had yesterday at the notebook sprint,
> you are in fact definitely violating the terms of usage. You cannot
> automatically create shortened URL's unless the user explicitly asks
> for them.

Now I'm curious what the basis of your conclusion is. For example,
TinyURL's terms of use on their front page (http://tinyurl.com/#terms) is:

--
Terms of use:

TinyURL was created as a free service to make posting long URLs easier,
and may only be used for actual URLs. Using it for spamming or illegal
purposes is forbidden and any such use will result in the TinyURL being
disabled and you may be reported to all ISPs involved and to the proper
governmental agencies. This service is provided without warranty of any
kind.

--

I don't see anything in there about not automatically generating tiny
urls. I agree that it may not be very nice, of course. Was that the
basis for the conclusion?

Jason


William Stein

unread,
Feb 14, 2012, 2:09:49 PM2/14/12
to sage-n...@googlegroups.com

I just heard several people in the room say it. I don't know what
they based their conclusion on.

-- William

Reply all
Reply to author
Forward
0 new messages