19

Lately I came across this question with a huge amount of data which I put on pastebin here under my account.

One can see that I've already put quite a few mathematica.stackexchange.com-related set of data on my Pastebin with various lengths to ease the reading of some questions.

So I was wondering if it was possible to have a mma.se account for the community? Or maybe something like the imgur-palette?

Of course, it would be possible to upload them as guests, without an account, but at least with an account it's possible to edit/delete more easily.

6
  • 3
    I have a solution in the works (been working on it for sometime) but it isn't ready yet... I will release it here.
    – rm -rf Mod
    Jul 25, 2014 at 10:23
  • @rm-rf Any idea on when it could be released? Any details on the language used? Any help needed?
    – Öskå
    Jul 25, 2014 at 10:27
  • Hopefully within a month (depends on my free time)... python + sql + javascript.
    – rm -rf Mod
    Jul 25, 2014 at 10:49
  • @rm-rf We all look forward to it. :-)
    – Mr.Wizard
    Jul 25, 2014 at 11:10
  • I started experimenting on this some time ago. I don't remember why it went down on my pile ... Jul 28, 2014 at 2:56
  • Now in v10 you can include unlimited data as Metadata in images, unfortunately imgur seems to strip images from the EXIF metadata. I wander if that's an option.
    – rhermans
    Oct 6, 2014 at 23:31

6 Answers 6

18

Lest we forget, there is also a built-in way in V10 to share expressions with other users, namely CloudPut with Permissions -> "Public" and CloudGet:

Sharing with the cloud

4
  • Great idea in principle; I worry about the cost in WC credits. Jul 28, 2014 at 20:07
  • 4
    @bobthechemist I'm not sure it uses any credits. Look at this page; it only charges you for computation, not bandwidth. Storing/retrieving expressions does not require computation.
    – C. E.
    Jul 30, 2014 at 10:23
  • 1
    @bobthechemist I think this method won't cost any credit: my test.
    – Silvia
    Aug 5, 2014 at 9:06
  • @Silvia We mean this cloud object is used by others.
    – yode
    May 3, 2017 at 6:08
16

This is a proof-of-concept using Pastebin. It's a utility function that you can put in your init.m to always have available in case you need to upload a list (or another string).

How to install it

  1. Create a user account at Pastebin.com.
  2. Log in and copy your dev key from this page.
  3. Go to this page and generate a user key.
  4. Modify the function below with your own dev key and user key, and put the function where you want it (init.m for example.)

Function

Pastebin[expr_, OptionsPattern[{
    DevKey -> "<your dev key here>",
    UserKey -> "<your user key here>",
    PastePrivate -> "0",
    PasteName -> "",
    PasteExpireDate -> "N",
    }]] := With[{url = URLFetch[
     "http://pastebin.com/api/api_post.php",
     "Method" -> "POST",
     "Parameters" -> {
       "api_option" -> "paste",
       "api_dev_key" -> OptionValue[DevKey],
       "api_user_key" -> OptionValue[UserKey],
       "api_paste_private" -> OptionValue[PastePrivate],
       "api_paste_name" -> OptionValue[PasteName],
       "api_paste_expire_date" -> OptionValue[PasteExpireDate],
       "api_paste_code" -> expr
       }
     ]},
    CopyToClipboard[
     StandardForm[
      Defer[Import][
      "http://pastebin.com/raw.php?i=" <> StringReplace[url, "http://pastebin.com/" -> ""]]
      ]
   ];
  Hyperlink[url]
  ]

How to use it

The only required argument is the string you want to upload. If the upload is successful a link is returned to the frontend and the corresponding Import statement is copied to the clipboard.

Pastebin[ToString@Range[10], PasteName -> "Test", PasteExpireDate -> "1W"]
(* Out: http://pastebin.com/postID *)

The clipboard now holds Import["http://pastebin.com/raw.php?i=postID"].

There are are three options:

  • PastePrivate 0 = public, 1 = unlisted and 2 = private
  • PasteExpireDate N = Never, 10M = 10 Minutes, 1H = 1 Hour, 1D = 1 Day, 1W = 1 Week, 2W = 2 Weeks, 1M = 1 Month
  • PasteName Each post can have a name.

Screencast

screencast

11
  • Unfortunatly URLFetch was introduced in v9. But, did you have that before? Or did you just make it?
    – Öskå
    Jul 25, 2014 at 18:14
  • @Öskå I just made it. At least I didn't use anything introduced in V10 :)
    – C. E.
    Jul 25, 2014 at 18:23
  • I was more or less thinking about doing the same (or that's how I would have imagined it) but since rm said that he had something in the works I gave up.. :)
    – Öskå
    Jul 25, 2014 at 18:39
  • 2
    Nice :) Could you perhaps set the default expiration to "Never" so that if someone just calls Pastebin[code], we don't lose it in 10 mins?
    – rm -rf Mod
    Jul 25, 2014 at 19:56
  • @rm-rf Yep, done.
    – C. E.
    Jul 25, 2014 at 20:02
  • @rm-rf Do you think that it would be possible to have a common account for mma.se? Name could be something like mma.se and password Compress@"mma.se". Then DevKey and UserKey would be common for everyone.
    – Öskå
    Jul 26, 2014 at 9:28
  • @Pickett Then one person can know the password only. The point would be to have all the data under one account, and the keys for this account would be given in your answer here. Nobody needs to know the password after then *Key are given (or just one person).
    – Öskå
    Jul 26, 2014 at 9:54
  • @Öskå Sorry, I removed my comment because I didn't think it was well phrased. If you have the keys you can do anything you can do with the API, including deleting all posts on the account. You don't need the password.
    – C. E.
    Jul 26, 2014 at 10:02
  • @Pickett Ah. Then I don't know. Having all the pastes spread over multiple accounts is silly IMO, but maybe that's the only way.. :)
    – Öskå
    Jul 26, 2014 at 10:05
  • @Öskå On a closer look I think that if people use their own user keys we can share a developer key, because you can only delete posts associated with a user key. So would you prefer this? Also, do you have any other ideas for improvement?
    – C. E.
    Jul 26, 2014 at 12:53
  • @Pickett It's not about what I personally prefer or not.. :) It's just that there are currently several questions with pastebin links under different accounts or guests. And the problem is that I can't text your code because of URLFetch but it looks good from the Screencast.
    – Öskå
    Jul 26, 2014 at 13:01
13

Not-so-large data can be QR-encoded in an image and uploaded to SE easily

dat = RandomInteger[9, {500, 3}];
BarcodeImage[Compress[dat], "QR"]

Mathematica graphics

dat===Uncompress@BarcodeRecognize@Import["https://i.stack.imgur.com/aulnt.png"]
> True

Not very efficient, I would agree, but simple enough.

3

One needs to address two main issues first, before entertaining an answer

Permanence

The main issue is find a method that will remain available permanently.

Unfortunately, we've had a lot of users share files on dropbox and then delete them at their end when they got the answer :(rm -rf

Minimalist policy

One should, in most cases, avoid large data or code, by providing a minimum working example, with code that generates simple synthetic data, if necessary. So try not to do this.

See also Q2145

Solutions

HTML imbedded

This Q&A takes advantage of the fact that Mathematica Stack Exchange accepts HTML in the questions, invalid HTML is ignored when formatting the question for display, but still be available when editing the question.

You can format your data and paste at the end of your question.

EncodeForQuestion[expr_List] := 
 CopyToClipboard[
  StringJoin["<data payload=\"", 
    URLEncode[ExportString[expr, "CSV"]], "\"/>"]]

enter image description here

and get the data back with the API

GetQuestionPlain[SEQuestionId_Integer] := Import[
   URLBuild[
    {"https://api.stackexchange.com", "2.2", "posts", ToString[SEQuestionId]}
    , {"site" -> "mathematica", "filter" -> "!SWK9z)LGKmEEgF5)yL"}]
   , "RawJSON"][["items", 1, "body_markdown"]]

Be aware of these safety considerations

Data on imgur image

QR answer before.

As described in this other answer.

0

Using DropBox

data = RandomInteger[9, {1000, 3}];

dropbox = ServiceConnect["Dropbox", "New"];
ServiceExecute[dropbox
  ,"DataUpload"
  , {
    "Path" -> "/MmaSE/datatest.txt"
  , "Data" ->Compress[data]
   }
 ];

Now share manually in the DropBox page get the URL and change the option "?dl=0" to "?dl=1"

data == Uncompress[
 Import["https://www.dropbox.com/s/tofsut7k90m90pi/datatest.txt?dl=1", "Text"]
 ]
(* True *)

Unfortunately dropbox["FileData", "Path" ->file] does not provide the sharing link.

3
  • 1
    Unfortunately, we've had a lot of users share files on dropbox and then delete them at their end when they got the answer :(
    – rm -rf Mod
    Oct 17, 2015 at 17:18
  • 1
    @R.M. well things can be done wrongly on any platform. Pastebin.com could have expiration date, and data in Wolfram Could could be deleted too.
    – rhermans
    Oct 17, 2015 at 17:21
  • 3
    Fully agree, which is why I voted for your QR code approach :) May not be optimal, but at least it stays with the question.
    – rm -rf Mod
    Oct 17, 2015 at 19:19
0

paste.ee

https://paste.ee also offers permanent (never expire) paste with raw download.

pasteee[expr_, OptionsPattern[
   {
    "key" -> pasteekey (* Put your key string *)
    , "expire" -> "0"
    , "description" -> "Mma.SE"
    }]
  ] := Module[{
   import,
   id = URLFetch["https://paste.ee/api"
     , "Method" -> "POST"
     , "Parameters" ->
      {"key" -> OptionValue["key"]
       , "expire" -> OptionValue["expire"]
       , "description" -> OptionValue["description"]
       , "format" -> "simple"
       , "return" -> "id"
       , "paste" -> expr
       }]},
  import = StringJoin["Import[\"https://paste.ee/r/", id, "\"]"];
  CopyToClipboard@import;
  Echo[import, "Copied Clipboard: "];
  SystemOpen@StringJoin["https://paste.ee/p/", id];
  Row[{"Download file: ", URL[StringJoin["https://paste.ee/d/", id]]}]
  ]

Use

pasteee[
 "https://mathematica.meta.stackexchange.com/q/1351/10397"
 , "description" -> "Mma.meta.SE Q1351"
 ]

Mathematica graphics

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .