Can I use Databins to share packages and notebooks?
If yes. How?
bin = CreateDatabin
DatabinAdd[bin, <|"myPack" -> "???"|>]
How can I load a Package stored in a Databin?
Same question in SE: here
I thought that it would make more elegant to exchange Wolfram code in this way. So users could interact directly with the repository, without need to use DropBox or it own server, and all could be done directly in Mathematica.
If I could just do something like:
and then, to load it, do:
Would be cool!
But I believe that it's not the main pourpose of Databin (now). And that neither Get or Needs were overload to do this.
Pity. It would be nice for quick code exchange in forums and in the community.
Here is an overloading sugestion:
So, to add you package into a Databin, just do:
Now, to load it, let's work with Get:
Export[path, packContent, "Text"];
Now, to load you package, just do:
Some problem with my post. I can't edit it, and my name is missing.
This code part is useless:
Can be removed
Create a bin
mybin = CreateDatabin
a simple package read from disk with escapes
myFunc::usage=\"a function from the data drop\"
myFunc[x_]:= x + 1
Drop it in a bin
DatabinAdd[mybin, <| "myPack" -> packstring |>]
Ask for the values in your bin
if there is a lot of stuff in your bin you need to be more specific
x = mybin["Data"]["myPack"]["Values"][]
The "Values" parameter is used because the datadrops representation is in "EventSeries" and I don't want the "Times" part of the coordinates. The part [] is just the third selection.
You package tekst is now back from the data drop. Next challenge is the Get function to load it. My solution is to first export it to disk.
f = Export["e:\\folder\\tst2.wl", x, "Text"]
If you write to tst2.txt it works fine. For convention I write to .wl in plain text.
the context droptest is on the context path and myFunc results in 3. Nice
So yes it is possible but why do you need such a solution? Wouldn't is be much easier if your package was loaded from your own web-server somewhere.